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: 11386
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: 1790
Cool, does it count cycles as well?
2014-09-24 17:52
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)
2014-09-24 17:59
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!
2014-10-05 11:42
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
2014-10-18 13:59
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..
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
Xiny6581/Dees Produc..
Genius/Xenon
El Jefe/Slackers^sidD
Metal Maniac/Dual Crew
MWR/Visdom
Dan
csabanw
Jazzcat/Onslaught
Operator Teleksu
algorithm
Guests online: 96
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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