Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Unit testing 6502 code
2014-09-23 20:12
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?
2014-09-23 20:25
chatGPZ

Registered: Dec 2001
Posts: 11108
i have knocked up this for testing cc65 itself, the simulator may or may not be useful for what you want to do :)
2014-09-24 17:28
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!
2014-09-24 17:34
tlr

Registered: Sep 2003
Posts: 1714
Cool, does it count cycles as well?
2014-09-24 17:52
chatGPZ

Registered: Dec 2001
Posts: 11108
<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)
2014-09-24 17:59
tlr

Registered: Sep 2003
Posts: 1714
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!
2014-10-05 11:42
Martin Piper

Registered: Nov 2007
Posts: 634
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
2014-10-18 13:59
Martin Piper

Registered: Nov 2007
Posts: 634
Here is an example of performance and functional testing sprite animation code.
https://github.com/martinpiper/C64Public/blob/master/Scroller/f..
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
csabanw
Andy/AEG
Scooby/G★P/Light
Acidchild/Padua
eryngi
psych
Jetboy/Elysium
Jammer
GeirS
Guests online: 131
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 Elwix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.051 sec.