document for writing a test case
yamato at redhat.com
Sun Jul 25 21:26:14 UTC 2021
Do we have a document for writing a test for strace?
It may encourage potential contributors.
I wrote a draft version. However, it is far from perfect.
Could you consider writing a real one?
How to write a test
1. write a test target.
The target is run under strace by a generated shell script.
If using the default test driver, run_strace_match_diff(), the test is
done by comparing the stdout of the target and the output of
strace. run_strace_match_diff() expects they are same.
Let's call the name of the test target "mytest" here.
You must write "mytest.c" for it.
2. put "mytest" to tests/pure_executables.list for building "mytest"
3. write the way to how to run "mytest" under strace tests/gen_tests.in.
The line in the file has the following format:
NAME is the name of the target, "mytest" here.
TEST-DRIVER is the name of a test driver program. run_strace_match_diff()
shell fucntion defined in init.sh is used if +TEST-DRIVER is not given.
STRACE-OPTs are passed to strace.
4. build the test target
Maybe you must run bootstrap and configure as you do for building strace.
Then do (cd tests; make mytest mytest.gen.test).
5. run the test
Do (cd tests; ./mytest.gen.test; echo $?)
"0" means successful.
the test target
the source of the test target
the script running the test target
the file where the strace's output goes
the file where the test target's stdout goes
More information about the Strace-devel