document for writing a test case
Masatake YAMATO
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"
from "mytest.c".
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<tab>[+TEST-DRIVER] [STRACE-OPT...]
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.
Files
========================================================================
tests/mytest
the test target
tests/mytest.c
the source of the test target
tests/mytest.gen.test
the script running the test target
tests/mytest.gen.dir/log
the file where the strace's output goes
tests/mytest.gen.dir/exp
the file where the test target's stdout goes
Masatake YAMATO
More information about the Strace-devel
mailing list