commit | 5c36ae3e302a64d6581c625899dc7813af4df291 | [log] [tgz] |
---|---|---|
author | Petr Vorel <pvorel@suse.cz> | Thu Dec 17 14:55:32 2020 +0100 |
committer | Petr Vorel <pvorel@suse.cz> | Thu Jan 07 11:59:18 2021 +0100 |
tree | f16045382474d01d78d477964d4f7cbb784d8353 | |
parent | 84d1927ece47f01527b55ae1b9967cc0aa85b7e3 [diff] |
tst_test.sh: Call cleanup function only after test start When shell API was introduced, cleanup function was run only if 1) setup function was defined 2) and also run. That was inconsistent from C API, thus e7dc14caa run it always. But shell API is different from C API: tst_brk can be called from tst_test.sh (or other library which is run before tst_run, e.g. tst_net.sh). That leads to confusing error because library was executed via '. tst_test.sh' before loading cleanup function: $ ./icmp-uni-basic.sh -s 10:100:1000:10000:65507 icmp-uni-basic 1 TCONF: Must be super/root for this test! /opt/ltp/testcases/bin/tst_test.sh: line 32: tst_ipsec_cleanup: command not found That was probably the reason, why detection via $TST_SETUP_STARTED was introduced in the initial version of shell API. And does not make sense to run the shell test cleanup function if the setup function hasn't been run. At least some network tests expect setup has been run before running cleanup (e.g. tcp_fastopen_run.sh). Fixes: e7dc14caa ("tst_test.sh: Run cleanup even setup is not defined") Reviewed-by: Cyril Hrubis <chrubis@suse.cz> [ Cyril: rename variable to $TST_DO_CLEANUP and define it also before running setup to cover cases when test call tst_brk() in the middle of setup and expect the cleanup() to be executed. ] Signed-off-by: Petr Vorel <pvorel@suse.cz> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Linux Test Project is a joint project started by SGI, OSDL and Bull developed and maintained by IBM, Cisco, Fujitsu, SUSE, Red Hat, Oracle and others. The project goal is to deliver tests to the open source community that validate the reliability, robustness, and stability of Linux.
The LTP testsuite contains a collection of tools for testing the Linux kernel and related features. Our goal is to improve the Linux kernel and system libraries by bringing test automation to the testing effort. Interested open source contributors are encouraged to join.
Project pages are located at: http://linux-test-project.github.io/
The latest image is always available at: https://github.com/linux-test-project/ltp/releases
The discussion about the project happens at ltp mailing list: http://lists.linux.it/listinfo/ltp
The git repository is located at GitHub at: https://github.com/linux-test-project/ltp
The patchwork instance is at: https://patchwork.ozlabs.org/project/ltp/list/
Be careful with these tests!
Don't run them on production systems. Growfiles, doio, and iogen in particular stress the I/O capabilities of systems and while they should not cause problems on properly functioning systems, they are intended to find (or cause) problems.
If you have git, autoconf, automake, m4, pkgconf / pkg-config, libc headers, linux kernel headers and other common development packages installed (see INSTALL and travis/*.sh), the chances are the following will work:
$ git clone https://github.com/linux-test-project/ltp.git $ cd ltp $ make autotools $ ./configure
Now you can continue either with compiling and running a single test or with compiling and installing the whole testsuite.
For optional library dependencies look into scripts for major distros in travis/
directory. You can also build whole LTP with ./build.sh
script.
If you need to execute a single test you actually do not need to compile the whole LTP, if you want to run a syscall testcase following should work.
$ cd testcases/kernel/syscalls/foo $ make $ PATH=$PATH:$PWD ./foo01
Shell testcases are a bit more complicated since these need a path to a shell library as well as to compiled binary helpers, but generally following should work.
$ cd testcases/lib $ make $ cd ../commands/foo $ PATH=$PATH:$PWD:$PWD/../../lib/ ./foo01.sh
Open Posix Testsuite has it's own build system which needs Makefiles to be generated first, then compilation should work in subdirectories as well.
$ cd testcases/open_posix_testsuite/ $ make generate-makefiles $ cd conformance/interfaces/foo $ make $ ./foo_1-1.run-test
$ make $ make install
This will install LTP to /opt/ltp
.
doc/mini-howto-building-ltp-from-git.txt
.INSTALL
and ./configure --help
.Some tests will be disabled if the configure script can not find their build dependencies.
TCONF
due to a missing component, check the ./configure
output.INSTALL
.To run all the test suites
$ cd /opt/ltp $ ./runltp
Note that many test cases have to be executed as root.
To run a particular test suite
$ ./runltp -f syscalls
To run all tests with madvise
in the name
$ ./runltp -f syscalls -s madvise
Also see
$ ./runltp --help
Test suites (e.g. syscalls) are defined in the runtest directory. Each file contains a list of test cases in a simple format, see doc/ltp-run-files.txt.
Each test case has its own executable or script, these can be executed directly
$ testcases/bin/abort01
Some have arguments
$ testcases/bin/fork13 -i 37
The vast majority of test cases accept the -h (help) switch
$ testcases/bin/ioctl01 -h
Many require certain environment variables to be set
$ LTPROOT=/opt/ltp PATH="$PATH:$LTPROOT/testcases/bin" testcases/bin/wc01.sh
Most commonly, the path variable needs to be set and also LTPROOT
, but there are a number of other variables, runltp
usually sets these for you.
Note that all shell scripts need the PATH
to be set. However this is not limited to shell scripts, many C based tests need environment variables as well.
For more info see doc/user-guide.txt
or online at https://github.com/linux-test-project/ltp/wiki/User-Guidelines.
Network tests require certain setup, described in testcases/network/README.md
(online at https://github.com/linux-test-project/ltp/tree/master/testcases/network) and INSTALL
.
Before you start you should read following documents:
doc/test-writing-guidelines.txt
doc/build-system-guide.txt
doc/library-api-writing-guidelines.txt
There is also a step-by-step tutorial:
doc/c-test-tutorial-simple.txt
If something is not covered there don't hesitate to ask on the LTP mailing list. Also note that these documents are available online at:
Although we accept GitHub pull requests, the preferred way is sending patches to our mailing list.
It's a good idea to test patches on Travis CI before posting to mailing list. Our travis setup covers various architectures and distributions in order to make sure LTP compiles cleanly on most common configurations. For testing you need to sign up to Travis CI, enable running builds on your LTP fork on https://travis-ci.org/account/repositories and push your branch.