blob: 037ca23ff314df8f34bcfe7c3e2ffcdd96b6e1ad [file] [log] [blame]
Lucas De Marchi23e354b2012-02-06 16:50:54 -02001testsuite
2
3OVERVIEW
4========
5
6Kmod's testsuite was designed to automate the process of running tests with
7different scenarios, configurations and architectures. The idea is that once we
8received a bug report, we reproduce it using the testsuite so we avoid
9recurring on the same bug in future.
10
11
12FEATURES
13========
14
15- Isolate each test by running them in separate processes;
16- Exec a binary, so we can test the tools and not only the lib API
17- Fake accesses to filesystem so we can provide a test rootfs with all the
18 configuration, indexes, etc that test needs to be executed.
19- Fake calls to init_module(), delete_module() and uname(), so we don't have to
20 run tests as root and figure out how to deal with different architectures.
21
22HOW TO ADD A TEST
23=================
24
25The simplest way to add a test is to copy and paste one already there. Most of
26the options you can have are covered by another tests. This is what you need to
27pay attention when writing a test:
28
291 - Look at testsuite.h, struct test, to see all the options available.
30
312 - Fill in the name and description. Convention is to have the name equal to
32 the function used to test and the struct name as s<function-name>
33
343 - If you want testsuite to compare the stdout/stderr of your tests in order
35to check if it worked or not, fill in output.{stderr,stdout} the file with the
36expected output. Bare in mind the same file is used for all architectures, so
37don't print arch-dependent content if you are comparing the output.
38
394 - Fill in the config vector. Setting any of these configuration will make
40testsuite to export LD_PRELOAD with the necessary override libs before
41executing the test. If you are not exec'ing an external binary, you need to
42pass "need_spawn = true" below, otherwise it will not work (LD_PRELOAD is only
43applied when exec'ing a binary). See each config description in testsuite.h
44
455 - need_spawn: if testsuite will exec itself before running a test
46
476 - expected_fail: if that test is expected to fail, i.e. the return code is
48expected not to be 0.
49
507 - If you added files to the rootfs, be sure to compact it back to
51rootfs.tar.xz before sending patches.
52
538 - Tests can be run individually, outside of 'make check'. strace and gdb work
54too, as long as you tell them to operate on child process.
Lucas De Marchi54c43df2012-02-06 19:50:17 -020055
569 - Make sure test passes when using "default" build flags, i.e. by running
57bootstrap-configure instead of simpler bootstrap/autogen.sh