[openssl-dev] Test framework improvements
paul.dale at oracle.com
Wed Mar 29 03:41:33 UTC 2017
A number of improvements to the output of the C portion of the test framework have been made.
Specifically, a number of functions have been added to provide uniform reporting of test case failures.
You access this functionality by including "testutil.h"
There are two unconditional functions: TEST_info and TEST_error which print informative and error messages respectively. They have no return value and accept a printf format string plus arguments.
All of the remaining functions are conditional tests. They return 1 if the condition is true and 0 if false. They output a uniform diagnostic message in the latter case and nothing in the former. The majority of these are of the form TEST_type_cond, where _type_ is the type being tested and _cond_ is the relation being tested. The currently available types are:
type C type
uint unsigned int
uchar unsigned char
ulong unsigned long
ptr void *
str char *
mem void *, size_t
For the integral types, cond can be:
cond C comparison
For the pointer types, cond can only be _eq_ or _ne_. In the case of _str_ and _mem_, the memory pointed to is compared. For _ptr_ just the pointer themselves are compared. The _mem_ comparisons take a pair of pointers + sizes as arguments (i.e. ptr1, size1, ptr2, size2).
There are two additional short hand calls for ptr:
TEST_ptr ptr != NULL
TEST_ptr_null ptr == NULL
Finally, there are two calls to check Boolean values:
TEST_true checks for != 0
TEST_false checks for == 0
In all cases, it is up to the test executable to process the return codes and to indicate success or failure to the PERL test framework. This would usually be done using:
See the brief notes at the end of test/README and look at some of the test cases that have been converted already:
To see some examples output of failing tests, test the test_test case:
make test TESTS=test_test VERBOSE=1
To see examples of all of the new test functions have a look in test/test_test.c This features both passing and failing calls. However, the actual error handling is not normal for a test executable because it treats desired failures as passes.
Dr Paul Dale | Cryptographer | Network Security & Encryption
Phone +61 7 3031 7217
More information about the openssl-dev