* [LTP] [PATCH 0/3] LTP_TIMEOUT for shell API
@ 2019-09-12 20:13 Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 1/3] shell: Add tst_is_num() Petr Vorel
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Petr Vorel @ 2019-09-12 20:13 UTC (permalink / raw)
To: ltp
Hi,
patchset replaces LTP_TIMEOUT_MUL for shell and C [1]
and memcg_stress_test.sh timeout fix [2].
It's also related to Clements fix for TST_RETRY_FN() and tst_adjust_timeout().
Kind regards,
Petr
[1] https://patchwork.ozlabs.org/project/ltp/list/?series=120151&state=*
[2] https://patchwork.ozlabs.org/patch/1155460/
[3] https://patchwork.ozlabs.org/project/ltp/list/?submitter=74899
Petr Vorel (3):
shell: Add tst_is_num()
shell: Introduce LTP_TIMEOUT variable
net/if-mtu-change.sh: set LTP_TIMEOUT
doc/test-writing-guidelines.txt | 89 ++++++++++++-------
.../memcg/stress/memcg_stress_test.sh | 2 +-
testcases/lib/tst_test.sh | 31 ++++++-
.../network/stress/interface/if-mtu-change.sh | 4 +-
4 files changed, 90 insertions(+), 36 deletions(-)
--
2.22.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/3] shell: Add tst_is_num()
2019-09-12 20:13 [LTP] [PATCH 0/3] LTP_TIMEOUT for shell API Petr Vorel
@ 2019-09-12 20:13 ` Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT Petr Vorel
2 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2019-09-12 20:13 UTC (permalink / raw)
To: ltp
Using grep -E, which more portable than using awk or anything else.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/test-writing-guidelines.txt | 6 ++++++
testcases/lib/tst_test.sh | 7 ++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index a735b43bb..2d118578f 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -2259,6 +2259,12 @@ Checking for integers
tst_is_int "$FOO"
-------------------------------------------------------------------------------
+Checking for integers and floating point numbers
+++++++++++++++++++++++++++++++++++++++++++++++++
+# returns zero if passed an integer or floating point number parameter, non-zero otherwise
+tst_is_num "$FOO"
+-------------------------------------------------------------------------------
+
Obtaining random numbers
++++++++++++++++++++++++
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index e0b24c6b9..ca63745fd 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) Linux Test Project, 2014-2018
+# Copyright (c) Linux Test Project, 2014-2019
# Author: Cyril Hrubis <chrubis@suse.cz>
#
# LTP test library for shell.
@@ -344,6 +344,11 @@ tst_is_int()
return $?
}
+tst_is_num()
+{
+ echo "$1" | grep -Eq '^[-+]?[0-9]+\.?[0-9]*$'
+}
+
tst_usage()
{
if [ -n "$TST_USAGE" ]; then
--
2.22.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable
2019-09-12 20:13 [LTP] [PATCH 0/3] LTP_TIMEOUT for shell API Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 1/3] shell: Add tst_is_num() Petr Vorel
@ 2019-09-12 20:13 ` Petr Vorel
2019-09-13 10:26 ` Cristian Marussi
2019-09-12 20:13 ` [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT Petr Vorel
2 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2019-09-12 20:13 UTC (permalink / raw)
To: ltp
to unify shell API with C API.
LTP_TIMEOUT should be set in tests only, it's equivalent of
tst_test->timeout in C API.
+ add checks requiring both LTP_TIMEOUT and LTP_TIMEOUT_MUL >= 1,
that allow to set LTP_TIMEOUT lower than the default 300 sec
(might be useful for some case).
LTP_TIMEOUT_MUL can be float, but that adds awk as a dependency.
+ replace LTP_TIMEOUT_MUL in memcg_stress_test.sh with LTP_TIMEOUT.
+ document both variables.
Suggested-by: Clemens Famulla-Conrad <cfamullaconrad@suse.de>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/test-writing-guidelines.txt | 83 ++++++++++++-------
.../memcg/stress/memcg_stress_test.sh | 2 +-
testcases/lib/tst_test.sh | 24 +++++-
3 files changed, 75 insertions(+), 34 deletions(-)
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 2d118578f..d6e1a6940 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -488,7 +488,18 @@ before calling 'fork()' or 'clone()'. Note that the 'SAFE_FORK()' calls this
function automatically. See 3.4 FILE buffers and fork() for explanation why is
this needed.
-2.2.3 Test temporary directory
+2.2.3 Library environment variables for C
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[options="header"]
+|=============================================================================
+| Variable name | Action done
+| 'LTP_TIMEOUT_MUL' | Multiply timeout, must be number >= 1 (> 1 is useful for
+ slow machines to avoid unexpected timeout).
+ Variable is also used in shell tests.
+|=============================================================================
+
+2.2.4 Test temporary directory
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If '.needs_tmpdir' is set to '1' in the 'struct tst_test' unique test
@@ -500,7 +511,7 @@ IMPORTANT: Close all file descriptors (that point to files in test temporary
or in the test 'cleanup()' otherwise the test may break temporary
directory removal on NFS (look for "NFS silly rename").
-2.2.4 Safe macros
+2.2.5 Safe macros
^^^^^^^^^^^^^^^^^
Safe macros aim to simplify error checking in test preparation. Instead of
@@ -539,7 +550,7 @@ example, do:
See 'include/tst_safe_macros.h', 'include/tst_safe_stdio.h' and
'include/tst_safe_file_ops.h' and 'include/tst_safe_net.h' for a complete list.
-2.2.5 Test specific command line options
+2.2.6 Test specific command line options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[source,c]
@@ -617,7 +628,7 @@ static struct tst_test test = {
-------------------------------------------------------------------------------
-2.2.6 Runtime kernel version detection
+2.2.7 Runtime kernel version detection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Testcases for newly added kernel functionality require kernel newer than a
@@ -655,7 +666,7 @@ test may be relevant even if the kernel version does not suggests so. See
WARNING: The shell 'tst_kvercmp' maps the result into unsigned integer - the
process exit value.
-2.2.7 Fork()-ing
+2.2.8 Fork()-ing
^^^^^^^^^^^^^^^^
Be wary that if the test forks and there were messages printed by the
@@ -671,7 +682,7 @@ To avoid that you should use 'SAFE_FORK()'.
IMPORTANT: You have to set the '.forks_child' flag in the test structure
if your testcase forks.
-2.2.8 Doing the test in the child process
+2.2.9 Doing the test in the child process
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Results reported by 'tst_res()' are propagated to the parent test process via
@@ -747,7 +758,7 @@ library prepares for it and has to make sure the 'LTP_IPC_PATH' environment
variable is passed down, then the very fist thing the program has to call in
'main()' is 'tst_reinit()' that sets up the IPC.
-2.2.9 Fork() and Parent-child synchronization
+2.2.10 Fork() and Parent-child synchronization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
As LTP tests are written for Linux, most of the tests involve fork()-ing and
@@ -826,7 +837,7 @@ The 'TST_PROCESS_STATE_WAIT()' waits until process 'pid' is in requested
It's mostly used with state 'S' which means that process is sleeping in kernel
for example in 'pause()' or any other blocking syscall.
-2.2.10 Signals and signal handlers
+2.2.11 Signals and signal handlers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you need to use signal handlers, keep the code short and simple. Don't
@@ -867,14 +878,14 @@ they subsequently modify RLIMIT_CORE.
Note that LTP library will reap any processes that test didn't reap itself,
and report any non-zero exit code as failure.
-2.2.11 Kernel Modules
+2.2.12 Kernel Modules
^^^^^^^^^^^^^^^^^^^^^
There are certain cases where the test needs a kernel part and userspace part,
happily, LTP can build a kernel module and then insert it to the kernel on test
start for you. See 'testcases/kernel/device-drivers/block' for details.
-2.2.12 Useful macros
+2.2.13 Useful macros
^^^^^^^^^^^^^^^^^^^^^
[source,c]
@@ -892,7 +903,7 @@ LTP_ALIGN(x, a)
Aligns the x to be next multiple of a. The a must be power of 2.
-2.2.13 Filesystem type detection
+2.2.14 Filesystem type detection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests are known to fail on certain filesystems (you cannot swap on TMPFS,
@@ -927,7 +938,7 @@ below:
}
-------------------------------------------------------------------------------
-2.2.14 Thread-safety in the LTP library
+2.2.15 Thread-safety in the LTP library
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is safe to use library 'tst_res()' function in multi-threaded tests.
@@ -979,7 +990,7 @@ static void cleanup(void)
-------------------------------------------------------------------------------
-2.2.15 Testing with a block device
+2.2.16 Testing with a block device
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests needs a block device (inotify tests, syscall 'EROFS' failures,
@@ -1071,7 +1082,7 @@ unsigned long tst_dev_bytes_written(const char *dev);
This function reads test block device stat file (/sys/block/<device>/stat) and
returns the bytes written since the last invocation of this function.
-2.2.16 Formatting a device with a filesystem
+2.2.17 Formatting a device with a filesystem
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[source,c]
@@ -1098,7 +1109,7 @@ The extra options 'extra_opts' should either be 'NULL' if there are none, or a
will be passed after device name. e.g: +mkfs -t ext4 -b 1024 /dev/sda1 102400+
in this case.
-2.2.17 Verifying a filesystem's free space
+2.2.18 Verifying a filesystem's free space
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests have size requirements for the filesystem's free space. If these
@@ -1123,7 +1134,7 @@ The required free space is calculated by 'size * mult', e.g.
filesystem, which '"/tmp/testfile"' is in, has 64MB free space at least, and 0
if not.
-2.2.18 Files, directories and fs limits
+2.2.19 Files, directories and fs limits
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests need to know the maximum count of links to a regular file or
@@ -1198,7 +1209,7 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
Creates/overwrites a file with specified pattern using file path.
-2.2.19 Getting an unused PID number
+2.2.20 Getting an unused PID number
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests require a 'PID', which is not used by the OS (does not belong to
@@ -1224,7 +1235,7 @@ int tst_get_free_pids(void);
Returns number of unused pids in the system. Note that this number may be
different once the call returns and should be used only for rough estimates.
-2.2.20 Running executables
+2.2.21 Running executables
^^^^^^^^^^^^^^^^^^^^^^^^^^
[source,c]
@@ -1266,7 +1277,7 @@ const char *const cmd[] = { "ls", "-l", NULL };
...
-------------------------------------------------------------------------------
-2.2.21 Measuring elapsed time and helper functions
+2.2.22 Measuring elapsed time and helper functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[source,c]
@@ -1380,7 +1391,7 @@ between two times.
NOTE: All conversions to ms and us rounds the value.
-2.2.22 Datafiles
+2.2.23 Datafiles
^^^^^^^^^^^^^^^^
[source,c]
@@ -1418,7 +1429,7 @@ was installed.
The file(s) are copied to the newly created test temporary directory which is
set as the test working directory when the 'test()' functions is executed.
-2.2.23 Code path tracing
+2.2.24 Code path tracing
^^^^^^^^^^^^^^^^^^^^^^^^
'tst_res' is a macro, so on when you define a function in one file:
@@ -1465,7 +1476,7 @@ common.h:9: FAIL: check failed
test.c:8: INFO: do_action(arg) failed
-------------------------------------------------------------------------------
-2.2.24 Tainted kernels
+2.2.25 Tainted kernels
^^^^^^^^^^^^^^^^^^^^^^
If you need to detect, if a testcase triggers a kernel warning, bug or oops,
@@ -1507,13 +1518,13 @@ For reference to tainted kernels, see kernel documentation:
Documentation/admin-guide/tainted-kernels.rst or
https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html
-2.2.25 Checksums
+2.2.26 Checksums
^^^^^^^^^^^^^^^^
CRC32c checksum generation is supported by LTP. In order to use it, the
test should include "tst_checksum.h" header, then can call tst_crc32c().
-2.2.26 Checking kernel for the driver support
+2.2.27 Checking kernel for the driver support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests may need specific kernel drivers, either compiled in, or built
@@ -1524,7 +1535,7 @@ first missing driver.
Since it relies on modprobe command, the check will be skipped if the command
itself is not available on the system.
-2.2.27 Saving & restoring /proc|sys values
+2.2.28 Saving & restoring /proc|sys values
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LTP library can be instructed to save and restore value of specified
@@ -1563,7 +1574,7 @@ static struct tst_test test = {
};
-------------------------------------------------------------------------------
-2.2.28 Parsing kernel .config
+2.2.29 Parsing kernel .config
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Generally testcases should attempt to autodetect as much kernel features as
@@ -1598,7 +1609,7 @@ static struct tst_test test = {
};
-------------------------------------------------------------------------------
-2.2.29 Changing the Wall Clock Time during test execution
+2.2.30 Changing the Wall Clock Time during test execution
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are some tests that, for different reasons, might need to change the
@@ -1634,7 +1645,7 @@ struct tst_test test = {
};
-------------------------------------------------------------------------------
-2.2.30 Testing similar syscalls in one test
+2.2.31 Testing similar syscalls in one test
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In some cases kernel has several very similar syscalls that do either the same
@@ -1699,7 +1710,7 @@ struct tst_test test = {
};
-------------------------------------------------------------------------------
-2.2.31 Guarded buffers
+2.2.32 Guarded buffers
^^^^^^^^^^^^^^^^^^^^^^
The test library supports guarded buffers, which are buffers allocated so
@@ -1769,7 +1780,7 @@ setting up the size or struct iovec, which is allocated recursively including
the individual buffers as described by an '-1' terminated array of buffer
sizes.
-2.2.32 Adding and removing capabilities
+2.2.33 Adding and removing capabilities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some tests may require the presence or absence of particular
@@ -2030,8 +2041,8 @@ tst_run
'$TST_TEST_DATA' can be used with '$TST_CNT'. If '$TST_TEST_DATA_IFS' not specified,
space as default value is used. Of course, it's possible to use separate functions.
-2.3.2 Library variables
-^^^^^^^^^^^^^^^^^^^^^^^
+2.3.2 Library environment variables for shell
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Similarily to the C library various checks and preparations can be requested
simply by setting right '$TST_NEEDS_FOO'.
@@ -2047,6 +2058,14 @@ simply by setting right '$TST_NEEDS_FOO'.
the test (see below).
| 'TST_NEEDS_MODULE' | Test module name needed for the test (see below).
| 'TST_NEEDS_DRIVERS'| Checks kernel drivers support for the test.
+| 'LTP_TIMEOUT' | Maximum timeout set for the test in sec. Must be float
+ >= 1 for C, int >=1 for shell. Default value is 300 sec,
+ timeout can be disabled by setting it to -1.
+ Variable should be set in tests, not by user.
+| 'LTP_TIMEOUT_MUL' | Multiply timeout, must be number >= 1 (> 1 is useful for
+ slow machines to avoid unexpected timeout).
+ Variable is also used in C tests,
+ it should be set by user, not in tests.
|=============================================================================
NOTE: Network tests (see testcases/network/README.md) use additional variables
diff --git a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
index 5b19cc292..ddcdbd5f1 100755
--- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
+++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
@@ -17,7 +17,7 @@ TST_NEEDS_CMDS="mount umount cat kill mkdir rmdir grep awk cut"
# Each test case runs for 900 secs when everything fine
# therefore the default 5 mins timeout is not enough.
-LTP_TIMEOUT_MUL=7
+LTP_TIMEOUT=2100
. cgroup_lib.sh
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index ca63745fd..f427cd459 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -379,9 +379,31 @@ _tst_rescmp()
_tst_setup_timer()
{
+ TST_TIMEOUT=${TST_TIMEOUT:-300}
LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1}
- local sec=$((300 * LTP_TIMEOUT_MUL))
+ if [ "$LTP_TIMEOUT_MUL" = -1 ]; then
+ tst_res TINFO "Timeout per run is disabled"
+ return
+ fi
+
+ local err
+ tst_is_num || err=1
+ if tst_is_int; then
+ [ "$LTP_TIMEOUT_MUL" -ge 1 ] || err=1
+ else
+ tst_test_cmds awk
+ echo | awk '{if ('"$LTP_TIMEOUT_MUL"' < 1) {exit 1;}}' || err=1
+ fi
+ if [ "$err" ]; then
+ tst_brk TCONF "LTP_TIMEOUT_MUL must be number >= 1! ($LTP_TIMEOUT_MUL)"
+ fi
+
+ if ! tst_is_int || [ "$LTP_TIMEOUT" -lt 1 ]; then
+ tst_brk TCONF "LTP_TIMEOUT must be int >= 1! ($LTP_TIMEOUT)"
+ fi
+
+ local sec=$((TST_TIMEOUT * LTP_TIMEOUT_MUL))
local h=$((sec / 3600))
local m=$((sec / 60 % 60))
local s=$((sec % 60))
--
2.22.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT
2019-09-12 20:13 [LTP] [PATCH 0/3] LTP_TIMEOUT for shell API Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 1/3] shell: Add tst_is_num() Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable Petr Vorel
@ 2019-09-12 20:13 ` Petr Vorel
2019-09-13 10:00 ` Clemens Famulla-Conrad
2 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2019-09-12 20:13 UTC (permalink / raw)
To: ltp
The default setup (100 * 5 seconds just for sleep) is longer than default timeout.
30 sec for each iteration should be more than enough as a default.
Fixes: fbea02ab5 ("lib/tst_test.sh: setup timeout per test run for the shell tests")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/network/stress/interface/if-mtu-change.sh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/testcases/network/stress/interface/if-mtu-change.sh b/testcases/network/stress/interface/if-mtu-change.sh
index 30c013214..a1113f714 100755
--- a/testcases/network/stress/interface/if-mtu-change.sh
+++ b/testcases/network/stress/interface/if-mtu-change.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) 2017-2018 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
# Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
# Copyright (c) International Business Machines Corp., 2005
# Author: Mitsuru Chinen <mitch@jp.ibm.com>
@@ -13,6 +13,8 @@ TST_CLEANUP="do_cleanup"
# The interval of the mtu change [second]
CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
+LTP_TIMEOUT=$(((CHANGE_INTERVAL + 30) * MTU_CHANGE_TIMES))
+
# The array of the value which MTU is changed into sequentially
# 552 - net.ipv4.route.min_pmtu
CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
--
2.22.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT
2019-09-12 20:13 ` [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT Petr Vorel
@ 2019-09-13 10:00 ` Clemens Famulla-Conrad
2019-09-13 10:41 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Clemens Famulla-Conrad @ 2019-09-13 10:00 UTC (permalink / raw)
To: ltp
On Thu, 2019-09-12 at 22:13 +0200, Petr Vorel wrote:
> The default setup (100 * 5 seconds just for sleep) is longer than
> default timeout.
> 30 sec for each iteration should be more than enough as a default.
>
> Fixes: fbea02ab5 ("lib/tst_test.sh: setup timeout per test run for
> the shell tests")
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> testcases/network/stress/interface/if-mtu-change.sh | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/network/stress/interface/if-mtu-change.sh
> b/testcases/network/stress/interface/if-mtu-change.sh
> index 30c013214..a1113f714 100755
> --- a/testcases/network/stress/interface/if-mtu-change.sh
> +++ b/testcases/network/stress/interface/if-mtu-change.sh
> @@ -1,6 +1,6 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0-or-later
> -# Copyright (c) 2017-2018 Petr Vorel <pvorel@suse.cz>
> +# Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
> # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights
> Reserved.
> # Copyright (c) International Business Machines Corp., 2005
> # Author: Mitsuru Chinen <mitch@jp.ibm.com>
> @@ -13,6 +13,8 @@ TST_CLEANUP="do_cleanup"
> # The interval of the mtu change [second]
> CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
>
> +LTP_TIMEOUT=$(((CHANGE_INTERVAL + 30) * MTU_CHANGE_TIMES))
^
TST_TIMEOUT
At least I would go with TST_ instead of LTP_ as the prefix TST_ means
for me Libray and LTP_ user. This apply to some other places of this
patchset.
> +
> # The array of the value which MTU is changed into sequentially
> # 552 - net.ipv4.route.min_pmtu
> CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable
2019-09-12 20:13 ` [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable Petr Vorel
@ 2019-09-13 10:26 ` Cristian Marussi
2019-09-13 10:46 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Cristian Marussi @ 2019-09-13 10:26 UTC (permalink / raw)
To: ltp
Hi
On 12/09/2019 21:13, Petr Vorel wrote:
> to unify shell API with C API.
>
> LTP_TIMEOUT should be set in tests only, it's equivalent of
> tst_test->timeout in C API.
>
> + add checks requiring both LTP_TIMEOUT and LTP_TIMEOUT_MUL >= 1,
> that allow to set LTP_TIMEOUT lower than the default 300 sec
> (might be useful for some case).
> LTP_TIMEOUT_MUL can be float, but that adds awk as a dependency.
>
> + replace LTP_TIMEOUT_MUL in memcg_stress_test.sh with LTP_TIMEOUT.
>
> + document both variables.
>
> Suggested-by: Clemens Famulla-Conrad <cfamullaconrad@suse.de>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> doc/test-writing-guidelines.txt | 83 ++++++++++++-------
> .../memcg/stress/memcg_stress_test.sh | 2 +-
> testcases/lib/tst_test.sh | 24 +++++-
> 3 files changed, 75 insertions(+), 34 deletions(-)
>
> diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
> index 2d118578f..d6e1a6940 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -488,7 +488,18 @@ before calling 'fork()' or 'clone()'. Note that the 'SAFE_FORK()' calls this
> function automatically. See 3.4 FILE buffers and fork() for explanation why is
> this needed.
>
> -2.2.3 Test temporary directory
> +2.2.3 Library environment variables for C
> +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +[options="header"]
> +|=============================================================================
> +| Variable name | Action done
> +| 'LTP_TIMEOUT_MUL' | Multiply timeout, must be number >= 1 (> 1 is useful for
> + slow machines to avoid unexpected timeout).
> + Variable is also used in shell tests.
> +|=============================================================================
> +
> +2.2.4 Test temporary directory
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> If '.needs_tmpdir' is set to '1' in the 'struct tst_test' unique test
> @@ -500,7 +511,7 @@ IMPORTANT: Close all file descriptors (that point to files in test temporary
> or in the test 'cleanup()' otherwise the test may break temporary
> directory removal on NFS (look for "NFS silly rename").
>
> -2.2.4 Safe macros
> +2.2.5 Safe macros
> ^^^^^^^^^^^^^^^^^
>
> Safe macros aim to simplify error checking in test preparation. Instead of
> @@ -539,7 +550,7 @@ example, do:
> See 'include/tst_safe_macros.h', 'include/tst_safe_stdio.h' and
> 'include/tst_safe_file_ops.h' and 'include/tst_safe_net.h' for a complete list.
>
> -2.2.5 Test specific command line options
> +2.2.6 Test specific command line options
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> [source,c]
> @@ -617,7 +628,7 @@ static struct tst_test test = {
> -------------------------------------------------------------------------------
>
>
> -2.2.6 Runtime kernel version detection
> +2.2.7 Runtime kernel version detection
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Testcases for newly added kernel functionality require kernel newer than a
> @@ -655,7 +666,7 @@ test may be relevant even if the kernel version does not suggests so. See
> WARNING: The shell 'tst_kvercmp' maps the result into unsigned integer - the
> process exit value.
>
> -2.2.7 Fork()-ing
> +2.2.8 Fork()-ing
> ^^^^^^^^^^^^^^^^
>
> Be wary that if the test forks and there were messages printed by the
> @@ -671,7 +682,7 @@ To avoid that you should use 'SAFE_FORK()'.
> IMPORTANT: You have to set the '.forks_child' flag in the test structure
> if your testcase forks.
>
> -2.2.8 Doing the test in the child process
> +2.2.9 Doing the test in the child process
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Results reported by 'tst_res()' are propagated to the parent test process via
> @@ -747,7 +758,7 @@ library prepares for it and has to make sure the 'LTP_IPC_PATH' environment
> variable is passed down, then the very fist thing the program has to call in
> 'main()' is 'tst_reinit()' that sets up the IPC.
>
> -2.2.9 Fork() and Parent-child synchronization
> +2.2.10 Fork() and Parent-child synchronization
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> As LTP tests are written for Linux, most of the tests involve fork()-ing and
> @@ -826,7 +837,7 @@ The 'TST_PROCESS_STATE_WAIT()' waits until process 'pid' is in requested
> It's mostly used with state 'S' which means that process is sleeping in kernel
> for example in 'pause()' or any other blocking syscall.
>
> -2.2.10 Signals and signal handlers
> +2.2.11 Signals and signal handlers
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> If you need to use signal handlers, keep the code short and simple. Don't
> @@ -867,14 +878,14 @@ they subsequently modify RLIMIT_CORE.
> Note that LTP library will reap any processes that test didn't reap itself,
> and report any non-zero exit code as failure.
>
> -2.2.11 Kernel Modules
> +2.2.12 Kernel Modules
> ^^^^^^^^^^^^^^^^^^^^^
>
> There are certain cases where the test needs a kernel part and userspace part,
> happily, LTP can build a kernel module and then insert it to the kernel on test
> start for you. See 'testcases/kernel/device-drivers/block' for details.
>
> -2.2.12 Useful macros
> +2.2.13 Useful macros
> ^^^^^^^^^^^^^^^^^^^^^
>
> [source,c]
> @@ -892,7 +903,7 @@ LTP_ALIGN(x, a)
>
> Aligns the x to be next multiple of a. The a must be power of 2.
>
> -2.2.13 Filesystem type detection
> +2.2.14 Filesystem type detection
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests are known to fail on certain filesystems (you cannot swap on TMPFS,
> @@ -927,7 +938,7 @@ below:
> }
> -------------------------------------------------------------------------------
>
> -2.2.14 Thread-safety in the LTP library
> +2.2.15 Thread-safety in the LTP library
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> It is safe to use library 'tst_res()' function in multi-threaded tests.
> @@ -979,7 +990,7 @@ static void cleanup(void)
> -------------------------------------------------------------------------------
>
>
> -2.2.15 Testing with a block device
> +2.2.16 Testing with a block device
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests needs a block device (inotify tests, syscall 'EROFS' failures,
> @@ -1071,7 +1082,7 @@ unsigned long tst_dev_bytes_written(const char *dev);
> This function reads test block device stat file (/sys/block/<device>/stat) and
> returns the bytes written since the last invocation of this function.
>
> -2.2.16 Formatting a device with a filesystem
> +2.2.17 Formatting a device with a filesystem
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> [source,c]
> @@ -1098,7 +1109,7 @@ The extra options 'extra_opts' should either be 'NULL' if there are none, or a
> will be passed after device name. e.g: +mkfs -t ext4 -b 1024 /dev/sda1 102400+
> in this case.
>
> -2.2.17 Verifying a filesystem's free space
> +2.2.18 Verifying a filesystem's free space
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests have size requirements for the filesystem's free space. If these
> @@ -1123,7 +1134,7 @@ The required free space is calculated by 'size * mult', e.g.
> filesystem, which '"/tmp/testfile"' is in, has 64MB free space at least, and 0
> if not.
>
> -2.2.18 Files, directories and fs limits
> +2.2.19 Files, directories and fs limits
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests need to know the maximum count of links to a regular file or
> @@ -1198,7 +1209,7 @@ int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount);
>
> Creates/overwrites a file with specified pattern using file path.
>
> -2.2.19 Getting an unused PID number
> +2.2.20 Getting an unused PID number
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests require a 'PID', which is not used by the OS (does not belong to
> @@ -1224,7 +1235,7 @@ int tst_get_free_pids(void);
> Returns number of unused pids in the system. Note that this number may be
> different once the call returns and should be used only for rough estimates.
>
> -2.2.20 Running executables
> +2.2.21 Running executables
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> [source,c]
> @@ -1266,7 +1277,7 @@ const char *const cmd[] = { "ls", "-l", NULL };
> ...
> -------------------------------------------------------------------------------
>
> -2.2.21 Measuring elapsed time and helper functions
> +2.2.22 Measuring elapsed time and helper functions
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> [source,c]
> @@ -1380,7 +1391,7 @@ between two times.
>
> NOTE: All conversions to ms and us rounds the value.
>
> -2.2.22 Datafiles
> +2.2.23 Datafiles
> ^^^^^^^^^^^^^^^^
>
> [source,c]
> @@ -1418,7 +1429,7 @@ was installed.
> The file(s) are copied to the newly created test temporary directory which is
> set as the test working directory when the 'test()' functions is executed.
>
> -2.2.23 Code path tracing
> +2.2.24 Code path tracing
> ^^^^^^^^^^^^^^^^^^^^^^^^
>
> 'tst_res' is a macro, so on when you define a function in one file:
> @@ -1465,7 +1476,7 @@ common.h:9: FAIL: check failed
> test.c:8: INFO: do_action(arg) failed
> -------------------------------------------------------------------------------
>
> -2.2.24 Tainted kernels
> +2.2.25 Tainted kernels
> ^^^^^^^^^^^^^^^^^^^^^^
>
> If you need to detect, if a testcase triggers a kernel warning, bug or oops,
> @@ -1507,13 +1518,13 @@ For reference to tainted kernels, see kernel documentation:
> Documentation/admin-guide/tainted-kernels.rst or
> https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html
>
> -2.2.25 Checksums
> +2.2.26 Checksums
> ^^^^^^^^^^^^^^^^
>
> CRC32c checksum generation is supported by LTP. In order to use it, the
> test should include "tst_checksum.h" header, then can call tst_crc32c().
>
> -2.2.26 Checking kernel for the driver support
> +2.2.27 Checking kernel for the driver support
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests may need specific kernel drivers, either compiled in, or built
> @@ -1524,7 +1535,7 @@ first missing driver.
> Since it relies on modprobe command, the check will be skipped if the command
> itself is not available on the system.
>
> -2.2.27 Saving & restoring /proc|sys values
> +2.2.28 Saving & restoring /proc|sys values
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> LTP library can be instructed to save and restore value of specified
> @@ -1563,7 +1574,7 @@ static struct tst_test test = {
> };
> -------------------------------------------------------------------------------
>
> -2.2.28 Parsing kernel .config
> +2.2.29 Parsing kernel .config
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Generally testcases should attempt to autodetect as much kernel features as
> @@ -1598,7 +1609,7 @@ static struct tst_test test = {
> };
> -------------------------------------------------------------------------------
>
> -2.2.29 Changing the Wall Clock Time during test execution
> +2.2.30 Changing the Wall Clock Time during test execution
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> There are some tests that, for different reasons, might need to change the
> @@ -1634,7 +1645,7 @@ struct tst_test test = {
> };
> -------------------------------------------------------------------------------
>
> -2.2.30 Testing similar syscalls in one test
> +2.2.31 Testing similar syscalls in one test
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> In some cases kernel has several very similar syscalls that do either the same
> @@ -1699,7 +1710,7 @@ struct tst_test test = {
> };
> -------------------------------------------------------------------------------
>
> -2.2.31 Guarded buffers
> +2.2.32 Guarded buffers
> ^^^^^^^^^^^^^^^^^^^^^^
>
> The test library supports guarded buffers, which are buffers allocated so
> @@ -1769,7 +1780,7 @@ setting up the size or struct iovec, which is allocated recursively including
> the individual buffers as described by an '-1' terminated array of buffer
> sizes.
>
> -2.2.32 Adding and removing capabilities
> +2.2.33 Adding and removing capabilities
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Some tests may require the presence or absence of particular
> @@ -2030,8 +2041,8 @@ tst_run
> '$TST_TEST_DATA' can be used with '$TST_CNT'. If '$TST_TEST_DATA_IFS' not specified,
> space as default value is used. Of course, it's possible to use separate functions.
>
> -2.3.2 Library variables
> -^^^^^^^^^^^^^^^^^^^^^^^
> +2.3.2 Library environment variables for shell
> +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Similarily to the C library various checks and preparations can be requested
> simply by setting right '$TST_NEEDS_FOO'.
> @@ -2047,6 +2058,14 @@ simply by setting right '$TST_NEEDS_FOO'.
> the test (see below).
> | 'TST_NEEDS_MODULE' | Test module name needed for the test (see below).
> | 'TST_NEEDS_DRIVERS'| Checks kernel drivers support for the test.
> +| 'LTP_TIMEOUT' | Maximum timeout set for the test in sec. Must be float
> + >= 1 for C, int >=1 for shell. Default value is 300 sec,
> + timeout can be disabled by setting it to -1.
> + Variable should be set in tests, not by user.
> +| 'LTP_TIMEOUT_MUL' | Multiply timeout, must be number >= 1 (> 1 is useful for
> + slow machines to avoid unexpected timeout).
> + Variable is also used in C tests,
> + it should be set by user, not in tests.
> |=============================================================================
>
> NOTE: Network tests (see testcases/network/README.md) use additional variables
> diff --git a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
> index 5b19cc292..ddcdbd5f1 100755
> --- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
> +++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
> @@ -17,7 +17,7 @@ TST_NEEDS_CMDS="mount umount cat kill mkdir rmdir grep awk cut"
>
> # Each test case runs for 900 secs when everything fine
> # therefore the default 5 mins timeout is not enough.
> -LTP_TIMEOUT_MUL=7
> +LTP_TIMEOUT=2100
>
> . cgroup_lib.sh
>
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index ca63745fd..f427cd459 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -379,9 +379,31 @@ _tst_rescmp()
>
> _tst_setup_timer()
> {
> + TST_TIMEOUT=${TST_TIMEOUT:-300}
> LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1}
>
> - local sec=$((300 * LTP_TIMEOUT_MUL))
> + if [ "$LTP_TIMEOUT_MUL" = -1 ]; then
> + tst_res TINFO "Timeout per run is disabled"
> + return
> + fi
> +
> + local err
> + tst_is_num || err=1
Not sure to understand what's going on here ....tst_is_num needs at least an arg right ?
> + if tst_is_int; then
> + [ "$LTP_TIMEOUT_MUL" -ge 1 ] || err=1
....same for tst_is_int .... and I can see no trace of code handling the new LTP_TIMEOUT
around this patch...am I missing something ?
Cheers
Cristian
> + else
> + tst_test_cmds awk
> + echo | awk '{if ('"$LTP_TIMEOUT_MUL"' < 1) {exit 1;}}' || err=1
> + fi
> + if [ "$err" ]; then
> + tst_brk TCONF "LTP_TIMEOUT_MUL must be number >= 1! ($LTP_TIMEOUT_MUL)"
> + fi
> +
> + if ! tst_is_int || [ "$LTP_TIMEOUT" -lt 1 ]; then
> + tst_brk TCONF "LTP_TIMEOUT must be int >= 1! ($LTP_TIMEOUT)"
> + fi
> +
> + local sec=$((TST_TIMEOUT * LTP_TIMEOUT_MUL))
> local h=$((sec / 3600))
> local m=$((sec / 60 % 60))
> local s=$((sec % 60))
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT
2019-09-13 10:00 ` Clemens Famulla-Conrad
@ 2019-09-13 10:41 ` Petr Vorel
0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2019-09-13 10:41 UTC (permalink / raw)
To: ltp
Hi Clements,
> > +LTP_TIMEOUT=$(((CHANGE_INTERVAL + 30) * MTU_CHANGE_TIMES))
> ^
> TST_TIMEOUT
> At least I would go with TST_ instead of LTP_ as the prefix TST_ means
> for me Libray and LTP_ user. This apply to some other places of this
> patchset.
Good point. Metan, do we want TST_TIMEOUT for library and LTP_TIMEOUT_MUL for
user? That's a bit strange, but I'd be for it.
LTP_* is for user to define (that's actually not true for tst_net.sh)
and TST_* for test definitions in script.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable
2019-09-13 10:26 ` Cristian Marussi
@ 2019-09-13 10:46 ` Petr Vorel
0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2019-09-13 10:46 UTC (permalink / raw)
To: ltp
Hi
<snip>
> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> > index ca63745fd..f427cd459 100644
> > --- a/testcases/lib/tst_test.sh
> > +++ b/testcases/lib/tst_test.sh
> > @@ -379,9 +379,31 @@ _tst_rescmp()
> > _tst_setup_timer()
> > {
> > + TST_TIMEOUT=${TST_TIMEOUT:-300}
> > LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1}
> > - local sec=$((300 * LTP_TIMEOUT_MUL))
> > + if [ "$LTP_TIMEOUT_MUL" = -1 ]; then
> > + tst_res TINFO "Timeout per run is disabled"
> > + return
> > + fi
> > +
> > + local err
> > + tst_is_num || err=1
> Not sure to understand what's going on here ....tst_is_num needs at least an arg right ?
Good point, it should have been
tst_is_num "$TST_TIMEOUT" || err=1
And I omit to grep TIMEOUT" in tst_run() in tst_test.s.
> > + if tst_is_int; then
> > + [ "$LTP_TIMEOUT_MUL" -ge 1 ] || err=1
> ....same for tst_is_int .... and I can see no trace of code handling the new LTP_TIMEOUT
> around this patch...am I missing something ?
Sorry, s/LTP_TIMEOUT/TST_TIMEOUT in docs and tests. Will be in v2.
> Cheers
> Cristian
Kind regards,
Petr
PS: please snip the unrelated content in long patches like this one
(easier to read in both mail and patchwork).
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-09-13 10:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-12 20:13 [LTP] [PATCH 0/3] LTP_TIMEOUT for shell API Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 1/3] shell: Add tst_is_num() Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 2/3] shell: Introduce LTP_TIMEOUT variable Petr Vorel
2019-09-13 10:26 ` Cristian Marussi
2019-09-13 10:46 ` Petr Vorel
2019-09-12 20:13 ` [LTP] [PATCH 3/3] net/if-mtu-change.sh: set LTP_TIMEOUT Petr Vorel
2019-09-13 10:00 ` Clemens Famulla-Conrad
2019-09-13 10:41 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox