1$FreeBSD$ 2 3This is the test harness for libarchive. 4 5It compiles into a single program "libarchive_test" that is intended 6to exercise as much of the library as possible. It is, of course, 7very much a work in progress. 8 9Each test is a function named test_foo in a file named test_foo.c. 10Note that the file name is the same as the function name. 11Each file must start with this line: 12 13 #include "test.h" 14 15The test function must be declared with a line of this form 16 17 DEFINE_TEST(test_foo) 18 19Nothing else should appear on that line. 20 21When you add a test, please update the top-level Makefile.am and the 22CMakeLists.txt in this directory to add your file to the list of 23tests. The Makefile and main.c use various macro trickery to 24automatically collect a list of test functions to be invoked. 25 26Each test function can rely on the following: 27 28 * The current directory will be a freshly-created empty directory 29 suitable for that test. (The top-level main() creates a 30 directory for each separate test and chdir()s to that directory 31 before running the test.) 32 33 * The test function should use assert(), assertA() and similar macros 34 defined in test.h. If you need to add new macros of this form, feel 35 free to do so. The current macro set includes assertEqualInt() and 36 assertEqualString() that print out additional detail about their 37 arguments if the assertion does fail. 'A' versions also accept 38 a struct archive * and display any error message from there on 39 failure. 40 41 * You are encouraged to document each assertion with a failure() call 42 just before the assert. The failure() function is a printf-like 43 function whose text is displayed only if the assertion fails. It 44 can be used to display additional information relevant to the failure: 45 46 failure("The data read from file %s did not match the data written to that file.", filename); 47 assert(strcmp(buff1, buff2) == 0); 48 49 * Tests are encouraged to be economical with their memory and disk usage, 50 though this is not essential. The test is occasionally run under 51 a memory debugger to try to locate memory leaks in the library; 52 as a result, tests should be careful to release any memory they 53 allocate. 54 55 * Disable tests on specific platforms as necessary. Please avoid 56 using config.h to adjust feature requirements, as I want the tests 57 to also serve as a check on the configure process. The following 58 form is usually more appropriate: 59 60#if !defined(__PLATFORM) && !defined(__Platform2__) 61 assert(xxxx) 62#endif 63 64