| |
Radiant
Registered: Sep 2004 Posts: 639 |
Unit testing 6502 code
Hi,
I figured TDD could be a good approach for math code and other hardware agnostic routines, so I set out to find if there are any tools available. I stumbled upon unit-sim: http://unit-sim.cvs.sourceforge.net/viewvc/unit-sim/
Has anyone used it, and if so, is it any good? My own approach would otherwise be to write a small detachable unit testing framework in native assembler using the ca65 toolchain (which seems quite ideal for the purpose), but if unit-sim or some other existing solution is good then I guess it would just be a waste of time. :-)
What are your experiences and opinions? |
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
i have knocked up this for testing cc65 itself, the simulator may or may not be useful for what you want to do :) |
| |
Radiant
Registered: Sep 2004 Posts: 639 |
Groepaz: Talked to Mathman/HT about this at work today and he independently tipped me about the cc65 test suite. :-) Thanks, will check it out! |
| |
tlr
Registered: Sep 2003 Posts: 1790 |
Cool, does it count cycles as well? |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
<Post edited by chatGPZ on 24/9-2014 20:17>
out of coincidence oliver asked me to test the recent git version of cc65, and i ended up putting everything up on github myself here
tlr: no such thing as cycle counting (there is no use for that at the moment)... the simulator has an idea of the cycles used though, so something like that could be added if needed. at some point i will also make a similar script for use with the VICE tests (whatever it takes to make you fix that damned sprite stretch bug.... =D) |
| |
tlr
Registered: Sep 2003 Posts: 1790 |
Point taken. :)
Automatic regression suite script with automatic pixel output compare, yeah! I was having utopic dreams of that when we coded the thing. Regression hell! |
| |
Martin Piper
Registered: Nov 2007 Posts: 722 |
There is also BDD testing: https://github.com/martinpiper/BDD6502
I use it to unit and system test various bits of code.
It allows tests to be written in plain English so that the tests describe expected behaviour given known inputs.
For example:
Feature: Assemble 6502 code test
This assembles simple code and checks the expected results after executing it
Scenario: Simple code test
Given I have a simple 6502 system
And I create file "test.a" with
"""
!sal
*=$400
start
lda #0
sta $400
ldx #$20
.l1
inc $400
dex
bne .l1
rts
"""
And I run the command line: ..\C64\acme.exe -o test.prg --labeldump test.lbl -f cbm test.a
And I load prg "test.prg"
And I load labels "test.lbl"
Then I expect to see $400 contain $a9
# The above code is actually 100 instructions long when executing
When I execute the procedure at start for no more than 100 instructions
# Note how the label "start" is used below and correctly resolves to be $400 when checking memory
Then I expect to see start contain 32
And I expect to see $402 contain $8d
|
| |
Martin Piper
Registered: Nov 2007 Posts: 722 |
Here is an example of performance and functional testing sprite animation code.
https://github.com/martinpiper/C64Public/blob/master/Scroller/f.. |