6 Sparse has a number of test cases in its validation directory. The test-suite
7 script aims at making automated checking of these tests possible. It works by
8 embedding tags in C comments in the test cases.
10 check-name: (mandatory)
13 check-description: (optional)
14 A description of what the test checks.
16 check-command: (optional)
17 There are different kinds of tests. Some can validate the sparse
18 preprocessor, while others will use sparse, cgcc, or even other backends
19 of the library. check-command allows you to give a custom command to
21 The '$file' string is special. It will be expanded to the file name at
23 It defaults to "sparse $file".
25 check-exit-value: (optional)
26 The expected exit value of check-command. It defaults to 0.
28 check-output-start / check-output-end (optional)
29 The expected output (stdout and stderr) of check-command lies between
30 those two tags. It defaults to no output.
32 check-known-to-fail (optional)
33 Mark the test as being known to fail.
39 The test-suite script is called through the check target of the Makefile. It
40 will try to check every test case it finds (find validation -name '*.c').
42 It can be called to check a single test with:
44 $ ./test-suite single preprocessor/preprocessor1.c
45 TEST Preprocessor #1 (preprocessor/preprocessor1.c)
46 preprocessor/preprocessor1.c passed !
52 test-suite comes with a format command to make a test easier to write:
54 test-suite format file [name [cmd]]
57 check-name value. If no name is provided, it defaults to the file name.
59 check-command value. If no cmd is provided, it defaults to
62 The output of the test-suite format command can be redirected into the
63 test case to create a test-suite formated file.
65 $ ./test-suite format bad-assignment.c Assignment >> bad-assignment.c
69 * check-name: bad assignment
71 * check-command: sparse $file
75 bad-assignment.c:3:6: error: Expected ; at end of statement
76 bad-assignment.c:3:6: error: got \
80 You can define the check-command you want to use for the test. $file will be
81 extended to the file name at run time.
83 $ ./test-suite format validation/preprocessor2.c "Preprocessor #2" \
84 "sparse -E \$file" >> validation/preprocessor2.c
86 cat validation/preprocessor2.c
88 * This one we happen to get right.
90 * It should result in a simple
94 * for a proper preprocessor.
98 #define UNARY(x) BINARY(x)
99 #define BINARY(x, y) x + y
103 * check-name: Preprocessor #2
105 * check-command: sparse -E $file
106 * check-exit-value: 0