-
Notifications
You must be signed in to change notification settings - Fork 8
Writing Tests
Generally we use check for testing. Take a look at the source code inside the tests/ folder to get a hang for this.
These are special: As this is the heart of the library, there is a lot of testing to be done. Thus, tests are split up. All files match the pattern test_message_*.c
where there is one for each message type. Inside each file there are tests for cases corresponding to each message type.
Additionally, there are special files:
test_message.c
: There are no tests here, instead it contains the main
function and creates the test suite and runner.
test_message_common.c
: Tests that need to be run for all types. Check below for special notes on this.
test_message_helper.c
: Contains helper functions available to all message tests.
This file must be included in all specific tests, i.e. there must be a line #include test_message_common.c
in the actual test file. It only contains static variables and functions that are local to each test file. It also has some requirements on setup and teardown that must be followed for the tests to run:
- The variable
p7
must be filled with a valid pkiMessage of the type you are testing, e.g. the result ofscep_pkcsreq
when testing PKCSReq. - The variable
p7_nosigcert
must be created so that no signature cert is included in the resulting pkiMessage.
A generic_setup
and generic_teardown
function exist in test_message_common.c
. They can be used as unchecked fixtures. This is recommended as it saves the work of multiple loading and freeing of memory seldomly used and never changed, e.g. the keys and certificates global to all tests. It is recommended that your setup methods call these and are unchecked, too.