Thinking about finer-grained unit tests

2 views
Skip to first unread message

Blake

unread,
Sep 15, 2007, 2:18:00 AM9/15/07
to a2c-discuss
I've uploaded a file to the files section called bcr-unittest.tar.gz.
This is a fairly simple skeleton for doing finer-grained unit tests
that may or may not be useful.

bcr-unittest/clean -- a script for cleaning up built files

bcr-unittest/printable-string-encoded/driver.c -- the main driver for
the test case

bcr-unittest/printable-string-encoded/expected.bin -- the expected
output (from stdout)

bcr-unittest/printable-string-encoded/input.asn -- the input ASN.1

bcr-unittest/runtests -- a script for running all the tests

bcr-unittest/test-util.c -- helper code for the tests

bcr-unittest/test-util.h -- header for the helper code for the tests

The basic operation is pretty simple, and the core of the "runtests"
script is as follows:

for each directory
Compile input.asn to input.[ch]
Compile *.c plus ../test-util.c into testprog
Run testprog with input.bin (if present) as stdin, saving output to
actual.bin
Diff expected.bin and actual.bin, if there's any differences, the
process has failed

This still needs some work -- it doesn't catch compile errors for
instance.

I'll write some more tests and see how I feel about this tomorrow. Let
me know if this is interesting.

Blake

Reply all
Reply to author
Forward
0 new messages