aboutsummaryrefslogtreecommitdiff
path: root/testcases/lib
AgeCommit message (Collapse)Author
2019-04-04shell: Fix handling default parameters in tst_mkfs()Petr Vorel
fixes regression when testing df01.sh Dash does not like shifting more than possible: /opt/ltp/testcases/bin/df01.sh: 291: shift: can't shift that many Fixes: 465faf47f ("shell: Use $TST_FS_TYPE and $TST_DEVICE in tst_mkfs()") Reported-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Petr Vorel <pvorel@suse.cz>
2019-03-27shell: Remove tst_suPetr Vorel
tst_su() was added only into legacy (but at the time the only) shell API. Last user of it was removed in 0fc9b8624, thus remove it. Fixes: 0fc9b8624 Remove admin_tools test Acked-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Petr Vorel <pvorel@suse.cz>
2019-03-14shell: Use $TST_FS_TYPE and $TST_DEVICE in tst_mkfs()Petr Vorel
as default parameters. Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2019-03-14shell: Move mkfs.foo into tst_mkfs()Petr Vorel
+ remove unused local ret variable. Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2019-03-14shell: Add tst_mount() helperPetr Vorel
and TST_FS_TYPE, TST_MNTPOINT, TST_MNT_PARAMS variables. TST_FS_TYPE is going to replace FS_TYPE in next commits. + document changes. Signed-off-by: Petr Vorel <pvorel@suse.cz> [pvorel: Thanks Cyril to point out correct variable names + doc fixes] Acked-by: Cyril Hrubis <chrubis@suse.cz>
2019-02-28lib/tst_net.sh: don't treat TWARN/TCONF as failure in tst_netload()Alexey Kodanev
Report TWARN and don't stop the test in that case. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Acked-by: Petr Vorel <pvorel@suse.cz>
2019-02-21network: use TST_NET_MAX_PKTAlexey Kodanev
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <pvorel@suse.cz>
2019-02-21lib/tst_net.sh: add new TST_NET_MAX_PKT env variableAlexey Kodanev
This is critical for performance tests, which compare virtual devices with the real ones. Trigger the fragmentation but keep the number of fragments at the minimum for those cases. Also improve the test timing if MTU is not large. The previous numbers can be restored with TST_NET_MAX_PKT environment variable. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <pvorel@suse.cz>
2019-01-29shell: Add tst_security.sh helperPetr Vorel
and load it in tst_test.sh. In case of TBROK/TFAIL/TWARN it prints warning if AppArmor and/or SELinux is running and has profiles loaded for anything in TST_NEEDS_CMDS environment variable. This is due some false positives because improper usage or bugs in AppArmor profiles (e.g. traceroute, dnsmasq). It's also possible trying to disable these LSM via TST_DISABLE_APPARMOR and TST_DISABLE_SELINUX environment variables. Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2019-01-10lib/tst_net.sh: fix tst_set_sysctl() for non-netns setupAlexey Kodanev
When we don't use netns setup, $rparam is empty in tst_set_sysctl(), and tst_net_run() mistakenly set sysctl command to $rparam. This results to the following error, $cmd is empty: bbr01 1 TINFO: timeout per run is 0h 20m 0s bbr01 1 TINFO: emulate congestion with packet loss 0.5% bbr01 1 TINFO: compare 'cubic' and 'bbr' congestion alg. results bbr01 1 TINFO: setting cubic bbr01 1 TBROK: tst_net_run: command not defined Fixes: 372d9201c ("net: Add tst_net_run helper") Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> [pvorel: quote -e to make obvious it's parameter for -r, not another parameter] Acked-by: Petr Vorel <pvorel@suse.cz>
2018-12-21lib/tst_net.sh: fix checking ping6 command availabilityAlexey Kodanev
* Fix the previous patch with tst_ping(), move setting $cmd before tst_test_cmds(). * Avoid misleading 'iface' in the info messages, rename 'iface' to 'iface/saddr' since we can pass a source address instead of an interface name. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-12-20lib/tst_net.sh: determine ping command based on dst addrAlexey Kodanev
tst_ping() can be used with the empty TST_IPV6, for example in the virtual tunnel tests, with IPv6 over IPv4 scenario. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-12-18net: Add tst_net_run helperPetr Vorel
and use it in tst_set_sysctl + improve doc of tst_rhost_run() Signed-off-by: Petr Vorel <pvorel@suse.cz> Reviewed-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-12-17tst_test.sh: Add info about LTP_TIMEOUT_MUL into TBROK messagePetr Vorel
Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-11-30tst_test.sh: Suppress wait outputPetr Vorel
Not only kill command in _tst_do_exit(), also wait has some output is needed to redirect to /dev/null: /opt/ltp/testcases/bin/tst_test.sh: line 65: 5337 Terminated \ sleep $sec && tst_res TBROK "test killed, timeout!" && kill -9 -$pid (wd: /opt/ltp/testcases/bin) Fixes: fbea02ab5 ("lib/tst_test.sh: setup timeout per test run for the shell tests") Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-11-30lib/tst_test.sh: don't call _tst_do_exit() recursively with tst_brk()Alexey Kodanev
With this patch, "safe" functions such as "ROD" and "tst_rhost_run -s" can be used in a test cleanup function. In case of an error, "safe" command won't recursively call cleanup function but will only print the warning message about the failure. This behavior is consistent with the LTP C library. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <pvorel@suse.cz>
2018-11-30lib/tst_test.sh: setup timeout per test run for the shell testsAlexey Kodanev
Use LTP_TIMEOUT_MUL environment variable, similar to what we have in the C library. Basically, the patch puts the child process with kill command to the background to signal the test process group processes after the certain timeout, which is controlled by LTP_TIMEOUT_MUL. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <pvorel@suse.cz>
2018-10-29lib/tst_test.sh: fix 'reserved variable TST_TMPDIR used' TWARNAlexey Kodanev
For example, nfs06 produces the warning: <<<test_output>>> nfs06 1 TWARN: Reserved variable TST_TMPDIR used! nfs06 1 TINFO: timeout per run is 0h 20m 0s nfs06 1 TINFO: setup NFSv3, socket type udp ... Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-10-26network/virt_lib: bind to virtual device with tst_netload()Alexey Kodanev
There is no yet any parameter that can switch on/off this. So by default it is on for all virt tests using tst_netload. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-10-22tst_net.sh: Fix ping detectionPetr Vorel
tst_cmd_available() is not available in legacy API, keep test just for new tests. Fixes: d57ac0b7a net: Fix missing ping6 Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-10-19net: Fix missing ping6Petr Vorel
ping6 is needed for some tst_net.sh based tests (and for netns_helper.sh, but it handles the dependency itself). iputils commit ebad35f ("ping: merge `ping6` command into `ping`") [1], released in s20150815 stopped providing ping6 and left it on distributions (see also [2]). Some distros don't create it (or didn't create it in the past [3]), use workaround and warn once about it (as it's also a bug which should be fixed). NOTE: Unfortunately we cannot use 'ping -${TST_IPVER}' as ping got '-6' switch (as a part of support for IPv6) was in commit 25aaaf4 ("Allow ping to use IPv6 addresses") [4], released in s20150815 (previous versions supported only ping6). [1] https://github.com/iputils/iputils/commit/ebad35fee3de851b809c7b72ccc654a72b6af61d [2] https://bugzilla.redhat.com/show_bug.cgi?id=617934#c22 [3] https://bugzilla.opensuse.org/show_bug.cgi?id=1017616 [4] https://github.com/iputils/iputils/commit/25aaaf4c58b485a5d9ec758a1f170cc5ec4073c4 Signed-off-by: Petr Vorel <pvorel@suse.cz> Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-09-20lib/tst_test.sh: add TST_NEEDS_DRIVERS parameterAlexey Kodanev
The drivers are checked with 'tst_check_drivers' command. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <petr.vorel@gmail.com> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
2018-09-20lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmdAlexey Kodanev
The drivers are checked with modprobe. If modprobe is not available on the system, the checks are silently skipped. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Reviewed-by: Petr Vorel <petr.vorel@gmail.com> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
2018-09-13TST_RTNL_CHK: Add RTNETLINK error "Protocol not supported"Petr Vorel
Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-09-13lib/tst_test.sh: add TST_RTNL_CHK() helper functionAlexey Kodanev
It should parse iproute commands output and exit the test with TCONF if there are certain messages returned from iproute/RTNETLINK. Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Acked-by: Petr Vorel <pvorel@suse.cz>
2018-07-26tst_test.sh: Add default trap to INTPetr Vorel
+ remove it's definition from network stress tests already converted to the new API. Trap function can be overwritten in tests, if needed. Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-07-26tst_test.sh: Silence getoptsPetr Vorel
We handle the error already there, so there is no point printing one more redundant message that doesn't have LTP format. Signed-off-by: Petr Vorel <pvorel@suse.cz> Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-24tst_test.sh: Add test cmd helper tst_check_cmds()Petr Vorel
+ tst_cmd_available() tst_check_cmds() is meant to be a check just for a particular test. Works like tst_test_cmd(), but instead of tst_brk() calls tst_res(). tst_test_cmds() helper can handle cases when command shell builtin is not available (e.g. Busybox). Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-24shell: Rename s/tst_check_cmds/tst_test_cmds/Petr Vorel
This has been discussed on ML [1] [2] as tst_check_cmds() will be used for different function. [1] http://lists.linux.it/pipermail/ltp/2018-July/008801.html [2] http://lists.linux.it/pipermail/ltp/2018-July/008808.html Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-24add testcases/lib/tst_supported_fs to .gititnoreMichael Moese
The binary tst_supported_fs was missing in the .gitinore file in testcases/lib, so it should be added. Signed-off-by: Michael Moese <mmoese@suse.de> Reviewed-by: Xiao Yang <yangx.jy@cn.fujitsu.com> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-23lib: Factor out is_supported() && Add tst_supported_fsXiao Yang
1) Factor out is_supported() and rename it as tst_fs_is_supported(), so that some tests can check a specified filesystem by it. 2) Add tst_supported_fs binary for shell tests to check a specified filesystem or all supported fielsystems. PS: hint messages from tst_supported_fs binary is targeted as stderr, so we can filter them by "2> /dev/null". Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-19testcases: Replace "getconf" by "tst_getconf"Mylène Josserand
Now that tst_getconf is available to use "sysconf()" function instead of relying on the application "getconf", let's convert all the tests to it. Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com> Reviewed-by: Li Wang <liwang@redhat.com> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-19testcase: lib: Create tst_getconf to replace "getconf"Mylène Josserand
In some system, "getconf" application may not be installed. Some tests are using it to retrieve some variables such as the page size (PAGESIZE). Create a tst_getconf binary that use sysconf() function to retrieve these variables instead of relying on "getconf" application that may not be available. Add also this new helper in the documentation. Example: pagesize=`tst_getconf PAGESIZE` Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com> Reviewed-by: Li Wang <liwang@redhat.com> Acked-by: Cyril Hrubis <chrubis@suse.cz>
2018-07-04net/{stress,virt}: Use SPDX-License-Identifier GPL-2.0-or-laterPetr Vorel
to save space + add author in few cases. Signed-off-by: Petr Vorel <pvorel@suse.cz> Reviewed-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-07-04tst_net.sh: Harden library against deadlocksPetr Vorel
Signed-off-by: Petr Vorel <pvorel@suse.cz> Reviewed-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-07-04tst_net.sh: Introduce TST_LIB_NET_LOADEDPetr Vorel
to load it only once. Some tests (macsec0{1,2}.sh) load tst_net.sh twice via loading from ipsec_lib.sh and virt_lib.sh. That brings duplicity in some variables (TST_OPTS) and create infinite loop, as tst_net_setup calls itself. Signed-off-by: Petr Vorel <pvorel@suse.cz> Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-07-04tst_test.sh: Introduce TST_LIB_LOADEDPetr Vorel
to load the library only once. Signed-off-by: Petr Vorel <pvorel@suse.cz> Suggested-by: Cyril Hrubis <chrubis@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz> Reviewed-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-06-29tst_device: Print help into stderrPetr Vorel
so it does not confuse with output of `tst_device acquire' call. Signed-off-by: Petr Vorel <pvorel@suse.cz> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
2018-06-29tst_test.sh: Fix check for $TST_DEVICEPetr Vorel
When tst_device acquire call fails, it outputs into stdout, therefore the content is actually help message. => Check for file presence or error exit code rather than variable not being empty. Fixes: c5ac5d712 tst_test.sh: Make use of tst_device helper Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Jan Stancek <jstancek@redhat.com>
2018-06-28test.sh: Fix assign to local variable in dashPetr Vorel
tst_rod call in ROD_SILENT must be quoted as it can have multiline output. This has been already fixed for tst_test.sh in 5c4a9839d Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-06-12tst_test.sh: Quote function parameterPetr Vorel
As following patches shows the need to use function with parameter [1], quotes are needed. [1] http://lists.linux.it/pipermail/ltp/2018-May/008147.html Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-06-12tst_test.sh: achieve TST_RETRY_FUNC function in shellLi Wang
The commit c2ce4df67d(include: add an exponential backoff macro for function retry) involves a new MACRO for function retry in C code, here achieve it in shell lib and gives a introduction in LTP documents. Signed-off-by: Li Wang <liwang@redhat.com> Acked-by: Petr Vorel <pvorel@suse.cz>
2018-06-06net: Remove $ipver setups and replace the usage with $TST_IPVERPetr Vorel
Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-06-06net: Introduce new TST_IPVER library variablePetr Vorel
Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-06-06tst_test.sh: Add TST_TEST_DATA and TST_TEST_DATA_IFSPetr Vorel
This is specific only for shell. Each run of tst_run gets passed sequence number of a test being run as '$1' and corresponding part of data from TST_TEST_DATA as '$2'. Also create internal functions _tst_run_tests() and _tst_run_test() to reduce duplicity. Introduced dependencies: cut tr wc. Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-06-06tst_test.sh: s/resm/res/Petr Vorel
resm is for legacy API. Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-06-06tst_test.sh: Warn about using "private" variable or functionPetr Vorel
Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-06-06tst_test.sh: Hide "private" variables with "_tst_" prefixPetr Vorel
Variables in tst_run and out of functions are visible to the test. Adding prefix "_tst_" manifest they're private. NOTE: kept $res from tst_run() as it's going to be moved into separate function in new commit. Signed-off-by: Petr Vorel <pvorel@suse.cz> Acked-by: Cyril Hrubis <chrubis@suse.cz> Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com>
2018-06-01tst_test.sh: TCONF on basename error when setting TST_IDPetr Vorel
'basename $0' fails when loaded in command line with bash (at least) as $0 is invalid ('-bash'): $ unset TST_ID; export TST_NO_DEFAULT_RUN=1; . tst_test.sh -bash: tst_ansi_color.sh: No such file or directory basename: invalid option -- 'b' Try 'basename --help' for more information. It's better to TCONF than be without TST_ID. NOTE: Sourcing tst_test.sh can be needed for network scripts: users might want to set network variables with tst_net.sh, which itself sources tst_test.sh. Reviewed-by: Li Wang <liwang@redhat.com> Signed-off-by: Petr Vorel <pvorel@suse.cz>
2018-05-25lib/tst_test.sh: Fix test name function detection for TST_CNTPetr Vorel
Reported-by: Cyril Hrubis <chrubis@suse.cz> Signed-off-by: Petr Vorel <pvorel@suse.cz>