Refine overall timeout and runtime management in LTP
v2 cover Refine overall timeout and runtime management in LTP
This patch series introduces a restructured approach to managing timeouts and runtime limits in the LTP framework. The changes aim to simplify timeout handling, improve clarity, and provide better separation between the phases of a test (setup, execution, and cleanup).
The main updates include refining the description and usage of .timeout, deprecating TST_UNLIMITED_RUNTIME, and introducing the tst_set_timeout() function. Additionally, test cases that previously relied on .max_runtime have been updated to adopt the revised logic, either by moving to .timeout directly or transitioning to .runtime depending on their behavior.
The series ends with an update to the set_mempolicy01 test, demonstrating the use of tst_set_timeout() to determine an upper bound for its execution.
CI job: https://github.com/wangli5665/ltp/actions/runs/12683826906/
Major changes V1 to V2:
* Refined the description of .timeout usage and its relationship with .runtime.
* Moved .max_runtime to .timeout directly for tests where runtime is not explicitly used.
* Transitioned .max_runtime to .runtime for tests that call tst_remaining_runtime() or use the fuzzy_sync library.
* Added the tst_set_timeout() function to allow test cases to set the overall timeout dynamically, particularly useful for tests that aim to determine upper execution bounds.
* Updated set_mempolicy01 to make use of tst_set_timeout().
Li Wang (3):
lib: redefine the overall timeout logic of test
lib: add tst_set_timeout for reset entire timeout
set_mempolicy01: make use of tst_set_timeout
Signature · 5 lines
2.47.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/4 lib: redefine the overall timeout logic of test
This patch revises the logic for managing test timeout and runtime limits, introducing a more structured approach. The key changes include renaming max_runtime to runtime for clarity and adding overall_time to represent the total time limit for a test. This ensures better separation of test phases (setup, execution, and cleanup) and clearer timeout management.
Key Concepts:
timeout: Defines the maximum time allowed for the entire test, including
setup, execution, and cleanup, when no explicit runtime is set. But if a runtime is explicitly defined and tst_remaining_runtime() is used, the timeout applies only to the setup and cleanup phases, as the runtime controls the test execution duration.
runtime: The maximum runtime of the test's main execution loop, used
in tests that call tst_remaining_runtime(). It ensures the main execution runs for a fixed duration, regardless of kernel configuration (e.g., debug kernel).
Overall timeout is structured as follows:
| -- (default_30s + timeout) * timeout_mul -- | -- runtime * runtime_mul -- |
And, the TST_UNLIMITED_RUNTIME constant has been deprecated and replaced by TST_UNLIMITED_TIMEOUT. This change simplifies the handling of unlimited execution scenarios while aligning the terminology with the new timeout model.
--- doc/old/C-Test-API.asciidoc | 36 ++++--- doc/users/setup_tests.rst | 6 +- include/tst_test.h | 33 +++++-- lib/newlib_tests/shell/test_timeout.sh | 10 +- lib/newlib_tests/test_runtime01.c | 2 +- lib/newlib_tests/test_runtime02.c | 2 +- lib/newlib_tests/tst_fuzzy_sync01.c | 2 +- lib/newlib_tests/tst_fuzzy_sync02.c | 2 +- lib/newlib_tests/tst_fuzzy_sync03.c | 2 +- lib/tst_test.c | 95 +++++++++---------- lib/tst_timer_test.c | 2 +- testcases/cve/cve-2014-0196.c | 2 +- testcases/cve/cve-2015-3290.c | 2 +- testcases/cve/cve-2016-7117.c | 2 +- testcases/cve/cve-2017-2671.c | 2 +- .../kernel/controllers/cgroup/cgroup_core03.c | 2 +- testcases/kernel/crypto/af_alg02.c | 2 +- testcases/kernel/crypto/af_alg07.c | 2 +- testcases/kernel/crypto/pcrypt_aead01.c | 2 +- testcases/kernel/fs/fs_fill/fs_fill.c | 2 +- testcases/kernel/fs/fsplough/fsplough.c | 2 +- testcases/kernel/fs/fsx-linux/fsx-linux.c | 2 +- testcases/kernel/fs/read_all/read_all.c | 4 +- testcases/kernel/io/ltp-aiodio/aio-stress.c | 2 +- testcases/kernel/io/ltp-aiodio/aiocp.c | 2 +- .../kernel/io/ltp-aiodio/aiodio_append.c | 2 +- .../kernel/io/ltp-aiodio/aiodio_sparse.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_append.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_read.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_sparse.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_truncate.c | 2 +- testcases/kernel/mem/ksm/ksm02.c | 4 +- testcases/kernel/mem/ksm/ksm04.c | 4 +- .../kernel/mem/mmapstress/mmapstress01.c | 2 +- testcases/kernel/mem/mtest01/mtest01.c | 2 +- testcases/kernel/mem/mtest06/mmap1.c | 2 +- testcases/kernel/mem/mtest06/mmap3.c | 2 +- testcases/kernel/mem/mtest07/mallocstress.c | 2 +- testcases/kernel/mem/oom/oom01.c | 2 +- testcases/kernel/mem/oom/oom02.c | 2 +- testcases/kernel/mem/oom/oom03.c | 2 +- testcases/kernel/mem/oom/oom04.c | 2 +- testcases/kernel/mem/oom/oom05.c | 2 +- testcases/kernel/mem/swapping/swapping01.c | 2 +- testcases/kernel/mem/thp/thp04.c | 2 +- .../kernel/mem/tunable/min_free_kbytes.c | 2 +- testcases/kernel/pty/pty03.c | 2 +- testcases/kernel/pty/pty05.c | 2 +- testcases/kernel/pty/pty06.c | 2 +- testcases/kernel/pty/pty07.c | 2 +- .../sched/cfs-scheduler/cfs_bandwidth01.c | 2 +- .../kernel/sched/cfs-scheduler/starvation.c | 2 +- .../security/dirtyc0w_shmem/dirtyc0w_shmem.c | 2 +- testcases/kernel/security/kallsyms/kallsyms.c | 2 +- testcases/kernel/sound/snd_seq01.c | 2 +- testcases/kernel/sound/snd_timer01.c | 2 +- testcases/kernel/syscalls/bind/bind06.c | 2 +- .../copy_file_range/copy_file_range01.c | 2 +- .../kernel/syscalls/fallocate/fallocate06.c | 2 +- testcases/kernel/syscalls/fork/fork13.c | 2 +- testcases/kernel/syscalls/fsync/fsync02.c | 2 +- .../syscalls/gettimeofday/gettimeofday02.c | 2 +- testcases/kernel/syscalls/inotify/inotify06.c | 2 +- testcases/kernel/syscalls/inotify/inotify09.c | 2 +- testcases/kernel/syscalls/inotify/inotify12.c | 2 +- testcases/kernel/syscalls/ioctl/ioctl_sg01.c | 2 +- .../syscalls/ipc/msgstress/msgstress01.c | 2 +- .../kernel/syscalls/ipc/semget/semget05.c | 2 +- .../kernel/syscalls/ipc/shmctl/shmctl05.c | 2 +- testcases/kernel/syscalls/keyctl/keyctl02.c | 2 +- .../kernel/syscalls/landlock/landlock04.c | 2 +- testcases/kernel/syscalls/madvise/madvise06.c | 2 +- testcases/kernel/syscalls/madvise/madvise11.c | 2 +- .../syscalls/migrate_pages/migrate_pages03.c | 2 +- .../kernel/syscalls/move_pages/move_pages12.c | 2 +- testcases/kernel/syscalls/nice/nice05.c | 2 +- .../perf_event_open/perf_event_open02.c | 2 +- .../perf_event_open/perf_event_open03.c | 2 +- testcases/kernel/syscalls/preadv2/preadv203.c | 2 +- .../kernel/syscalls/readahead/readahead02.c | 8 +- .../syscalls/request_key/request_key03.c | 2 +- .../kernel/syscalls/sendfile/sendfile09.c | 2 +- testcases/kernel/syscalls/sendmsg/sendmsg03.c | 2 +- .../syscalls/set_mempolicy/set_mempolicy01.c | 4 +- .../kernel/syscalls/setsockopt/setsockopt06.c | 2 +- .../kernel/syscalls/setsockopt/setsockopt07.c | 2 +- testcases/kernel/syscalls/swapoff/swapoff01.c | 2 +- testcases/kernel/syscalls/swapon/swapon01.c | 2 +- .../syscalls/timerfd/timerfd_settime02.c | 2 +- testcases/kernel/syscalls/writev/writev03.c | 2 +- testcases/network/can/cve/can_bcm01.c | 2 +- testcases/network/netstress/netstress.c | 2 +- .../network/nfs/nfs_stress/nfs05_make_tree.c | 2 +- testcases/network/packet/fanout01.c | 2 +- testcases/network/sockets/vsock01.c | 2 +- 95 files changed, 196 insertions(+), 178 deletions(-)
doc/old/C-Test-API.asciidoc +21 -15
@@ -95,25 +95,28 @@ in range of [0, '.tcnt' - 1]. IMPORTANT: Only one of '.test' and '.test_all' can be set at a time. Each test has a limit on how long it can run and the limit composes of two -parts max_runtime and timeout. The max_runtime is a limit for how long can the -'.test_all' or a set of '.test' functions take and the timeout is static part -that should cover the duration of test setup and cleanup plus some safety. +parts runtime and timeout. The runtime is a limit for how long can the +'.test_all' or a set of '.test' main functions take and the timeout is static +part that should cover the duration of test setup and cleanup plus some safety. +If test without an explicit runtime, the timeout governs the entire test duration. Any test that runs for more than a second or two has to make sure to: -- set the runtime either by setting the '.max_runtime' in tst_test or by - calling 'tst_set_max_runtime()' in the test setup -- monitor remaning runtime by regular calls to 'tst_remaining_runtime()' and - exit when runtime has been used up +- set the runtime by setting '.runtime' in tst_test and calling 'tst_set_runtime()' + to monitor the remaining runtime and ensure the test exits when the runtime + limit is reached. -Test is free to exit before max_runtime has been used up for example when +- set the timeout by setting '.timeout' in tst_test to limit the whole test + run that does not use 'tst_remaining_runtime()'. + +Test is free to exit before runtime has been used up for example when minimal number of iteration was finished. The limit is applied to a single call of the '.test_all' function that means that for example when '.test_variants' or '.all_filesystems' is set the whole -test will be limited by 'variants * (max_runtime + timeout)' seconds and the -test runtime will be likely close to 'variants * max_runtime' seconds. +test will be limited by 'variants * (runtime + timeout)' seconds and the +test runtime will be likely close to 'variants * runtime' seconds. [source,c] -------------------------------------------------------------------------------
@@ -401,13 +404,16 @@ WARNING: This function is not thread safe. [source,c] ------------------------------------------------------------------------------- -void tst_set_max_runtime(int max_runtime); +void tst_set_runtime(int runtime); ------------------------------------------------------------------------------- -Allows for setting max_runtime per test iteration dynamically in the test 'setup()', -the timeout is specified in seconds. There are a few testcases whose runtime -can vary arbitrarily, these can disable timeouts by setting it to -TST_UNLIMITED_RUNTIME. +Allows for setting the runtime per test iteration dynamically during the test 'setup()'. +The runtime is specified in seconds and represents the duration the test is allowed +to execute its main workload, excluding setup and teardown phases. + +This function is useful for tests where the duration of the main workload can be +controlled or needs to be adjusted dynamically. For example, tests that loop until +the runtime expires can use this function to define how long they should run. [source,c] -------------------------------------------------------------------------------
doc/users/setup_tests.rst +3 -3
@@ -87,14 +87,14 @@ See :master:`testcases/network/README.md`. Test execution time and timeout ------------------------------- -The limit on how long a test can run does compose of two parts: ``max_runtime`` +The limit on how long a test can run does compose of two parts: ``runtime`` and ``timeout``. The limit does apply to a single test variant. That means, for example, that tests which run for all available filesystems will apply this limit for a single filesystem only. -The ``max_runtime`` is a cap on how long the ``run()`` function can take and for +The ``runtime`` is a cap on how long the ``run()`` function can take and for most testcases this part is set to zero. For tests that do run for more than a -second or two the ``max_runtime`` has to be defined and the ``run()`` function +second or two the ``runtime`` has to be defined and the ``run()`` function has to check actively how much runtime is left. Test runtime can be scaled up and down with ``LTP_RUNTIME_MUL`` environment
include/tst_test.h +23 -10
@@ -234,7 +234,7 @@ struct tst_tag {extern unsigned int tst_variant; -#define TST_UNLIMITED_RUNTIME (-1) +#define TST_UNLIMITED_TIMEOUT (-1)/** * struct tst_ulimit_val - An ulimit resource and value.
@@ -435,13 +435,25 @@ struct tst_fs {* The directory is created by the library, the test must not create * it itself. * -* @max_runtime: Maximal test runtime in seconds. Any test that runs for more -* than a second or two should set this and also use -* tst_remaining_runtime() to exit when runtime was used up. -* Tests may finish sooner, for example if requested number of -* iterations was reached before the runtime runs out. If test -* runtime cannot be know in advance it should be set to -* TST_UNLIMITED_RUNTIME. +* @timeout: Maximum allowable time in seconds for the entire duration of a test. +* By default, the timeout limits the total time for setup, execution, +* and cleanup phases. However, if `.runtime` is explicitly set and +* tst_remaining_runtime() is used in the test's main loop, the timeout +* then applies only to the setup and cleanup phases, as the runtime +* separately limits the main test execution. This ensures the test +* does not hang indefinitely, and if the setup or cleanup time cannot +* be accurately determined, it can be set to a sufficiently large value +* or TST_UNLIMITED_TIMEOUT to remove the limit. +* +* @runtime: Maximum runtime in seconds for the test's main execution loop. +* This should be set for tests that are expected to run longer +* than a few seconds and call tst_remaining_runtime() in their +* main loop to exit gracefully when the runtime is exceeded. +* Tests may finish sooner if their task completes (e.g., reaching +* a requested number of iterations) before the runtime runs out. +* The runtime is fixed and does not scale with timeout multipliers +* (e.g., TIMEOUT_MUL), ensuring consistent test duration across +* different environments (e.g., debug vs. stock kernels). * * @setup: Setup callback is called once at the start of the test in order to * prepare the test environment.
@@ -565,7 +577,8 @@ struct tst_fs {const char *mntpoint; -int max_runtime; +int timeout; +int runtime;void (*setup)(void );void (*cleanup)(void );
@@ -676,7 +689,7 @@ unsigned int tst_remaining_runtime(void);/* * Sets maximal test runtime in seconds. */ -void tst_set_max_runtime (int max_runtime); +void tst_set_runtime (int runtime);/* * Create and open a random file inside the given dir path.
lib/newlib_tests/shell/test_timeout.sh +5 -5
@@ -10,7 +10,7 @@ PATH="$(dirname $0):$(dirname $0)/../../../testcases/lib/:$PATH" # file # timeout_mul # use_cat -# max_runtime +# runtime # expected_exit_code # expected passes # expected failed
@@ -114,8 +114,8 @@ for d in $CLEANED_DATA; do file=$(echo $d | cut -d'|' -f1 | xargs) timeout=$(echo $d | cut -d'|' -f2 | xargs) use_cat=$(echo $d | cut -d'|' -f3 | xargs) - max_runtime=$(echo $d | cut -d'|' -f4 | xargs) - max_runtime=${max_runtime:--1} + runtime=$(echo $d | cut -d'|' -f4 | xargs) + runtime=${runtime:--1} exp_exit=$(echo $d | cut -d'|' -f5 | xargs) exp_exit=${exp_exit:--1} exp_passed=$(echo $d | cut -d'|' -f6 | xargs)
@@ -137,8 +137,8 @@ for d in $CLEANED_DATA; do echo "=== $test_nr/$test_max $description ===" run_test "$file" "$timeout" "$use_cat" - if [ $max_runtime -ne -1 ] && [ $test_duration -gt $max_runtime ]; then - echo "FAILED (runtime: $test_duration, expected less than $max_runtime)" + if [ $runtime -ne -1 ] && [ $test_duration -gt $runtime ]; then + echo "FAILED (runtime: $test_duration, expected less than $runtime)" cur_fails=$((cur_fails + 1)) fi
lib/newlib_tests/test_runtime01.c +1 -1
@@ -25,6 +25,6 @@ static void run(void)static struct tst_test test = { .test_all = run, - .max_runtime =4 , + .runtime =4 , .test_variants =2 , };
lib/newlib_tests/test_runtime02.c +1 -1
@@ -24,5 +24,5 @@ static void run(void)static struct tst_test test = { .test_all = run, - .max_runtime =5 , + .runtime =5 , };
lib/newlib_tests/tst_fuzzy_sync01.c +1 -1
@@ -248,5 +248,5 @@ static struct tst_test test = { .test = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 150, + .runtime = 150, };
lib/newlib_tests/tst_fuzzy_sync02.c +1 -1
@@ -225,5 +225,5 @@ static struct tst_test test = { .test = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 150, + .runtime = 150, };
lib/newlib_tests/tst_fuzzy_sync03.c +1 -1
@@ -99,5 +99,5 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .test_all = run, - .max_runtime = 150, + .runtime = 150, };
lib/tst_test.c +47 -48
184 lines not on this page · raw message
lib/tst_timer_test.c +1 -1
@@ -454,7 +454,7 @@ static void parse_timer_opts(void) runtime_us += tcases[i].usec * tcases[i].samples; } -tst_set_max_runtime ((runtime_us + runtime_us/10 )/1000000 ); +tst_set_runtime ((runtime_us + runtime_us/10 )/1000000 ); }struct tst_test *tst_timer_test_setup (struct tst_test *timer_test)
testcases/cve/cve-2014-0196.c +1 -1
@@ -141,7 +141,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .test_all = run, - .max_runtime = 60, + .runtime = 60, .tags = (const struct tst_tag []) { {"linux-git" ,"4291086b1f08" }, {"CVE" ,"2014-0196" },
testcases/cve/cve-2015-3290.c +1 -1
@@ -519,7 +519,7 @@ static struct tst_test test = { .needs_root = 1, .needs_checkpoints = 1, .setup = setup, - .max_runtime = 180, + .runtime = 180, .test_all = run, .tags = (const struct tst_tag []) { {"linux-git" ,"9b6e6a8334d5" },
testcases/cve/cve-2016-7117.c +1 -1
@@ -149,7 +149,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 60, + .runtime = 60, .tags = (const struct tst_tag []) { {"linux-git" ,"a2e2725541fa" }, {"CVE" ,"2016-7117" },
testcases/cve/cve-2017-2671.c +1 -1
@@ -109,7 +109,7 @@ static struct tst_test test = { .test_all = run, .cleanup = cleanup, .needs_root = 1, - .max_runtime = 40, + .runtime = 40, .tags = (const struct tst_tag []) { {"linux-git" ,"43a6684519ab" }, {"CVE" ,"2017-2671" },
testcases/kernel/controllers/cgroup/cgroup_core03.c +1 -1
@@ -124,7 +124,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .forks_child = 1, - .max_runtime = 20, + .timeout = 20, .needs_cgroup_ctrls = (const char *const []){ "base", NULL }, .needs_cgroup_ver = TST_CG_V2, .needs_checkpoints = 1,
testcases/kernel/crypto/af_alg02.c +1 -1
@@ -77,7 +77,7 @@ static void run(void)static struct tst_test test = { .test_all = run, - .max_runtime =20 , + .runtime =20 , .needs_checkpoints =1 , .tags = (const struct tst_tag []) { {"linux-git" ,"ecaaab564978" },
testcases/kernel/crypto/af_alg07.c +1 -1
@@ -125,7 +125,7 @@ static struct tst_test test = { .cleanup = cleanup, .min_kver = "4.10.0", .min_cpus = 2, - .max_runtime = 150, + .runtime = 150, .taint_check = TST_TAINT_W | TST_TAINT_D, .tags = (const struct tst_tag []) { {"linux-git" ,"ff7b11aa481f" },
testcases/kernel/crypto/pcrypt_aead01.c +1 -1
@@ -75,7 +75,7 @@ static struct tst_test test = { .test_all = run, .cleanup = cleanup, .needs_root = 1, - .max_runtime = 300, + .runtime = 300, .tags = (const struct tst_tag []) { {"linux-git" ,"d76c68109f37" }, {"CVE" ,"2017-18075" },
testcases/kernel/fs/fs_fill/fs_fill.c +1 -1
@@ -121,7 +121,7 @@ static void cleanup(void) }static struct tst_test test = { - .max_runtime =300 , + .timeout =300 , .needs_root =1 , .dev_min_size =1024 , .mount_device =1 ,
testcases/kernel/fs/fsplough/fsplough.c +1 -1
@@ -190,7 +190,7 @@ static void setup(void) MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); filedata =SAFE_MALLOC (filesize); -tst_set_max_runtime (bufsize * loop_count / (8 *1024 *1024 )); +tst_set_runtime (bufsize * loop_count / (8 *1024 *1024 )); }static void run (void )
testcases/kernel/fs/fsx-linux/fsx-linux.c +1 -1
@@ -367,7 +367,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .test_all = run, - .max_runtime = 1800, + .timeout = 1800, .options = (struct tst_option []) { {"l:" , &str_file_max_size,"Maximum size in MB of the test file(s) (default 262144)" }, {"o:" , &str_op_max_size,"Maximum size for single operation (default 65536)" },
testcases/kernel/fs/read_all/read_all.c +2 -2
@@ -598,7 +598,7 @@ static void setup(void) worker_timeout); }else { worker_timeout =10 *tst_remaining_runtime (); -tst_res (TINFO ,"Worker timeout set to 10%% of max_runtime: %dms" , +tst_res (TINFO ,"Worker timeout set to 10%% of runtime: %dms" , worker_timeout); } worker_timeout *=1000 ;
@@ -746,5 +746,5 @@ static struct tst_test test = { .cleanup = cleanup, .test_all = run, .forks_child = 1, - .max_runtime = 100, + .runtime = 100, };
testcases/kernel/io/ltp-aiodio/aio-stress.c +1 -1
@@ -1347,7 +1347,7 @@ static struct tst_test test = { .setup = setup, .needs_tmpdir = 1, .needs_root = 1, - .max_runtime = 1800, + .timeout = 1800, .options = (struct tst_option []){ {"a:" , &str_iterations,"Total number of ayncs I/O the program will run (default 500)" }, {"b:" , &str_max_io_submit,"Max number of iocbs to give io_submit at once" },
testcases/kernel/io/ltp-aiodio/aiocp.c +1 -1
@@ -322,7 +322,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1, - .max_runtime = 1800, + .runtime = 1800, .needs_root = 1, .options = (struct tst_option []) { {"b:" , &str_aio_blksize,"Size of writing blocks (default 1K)" },
testcases/kernel/io/ltp-aiodio/aiodio_append.c +1 -1
@@ -190,7 +190,7 @@ static struct tst_test test = { .cleanup = cleanup, .needs_tmpdir = 1, .forks_child = 1, - .max_runtime = 1800, + .runtime = 1800, .options = (struct tst_option []) { {"n:" , &str_numchildren,"Number of threads (default 16)" }, {"s:" , &str_writesize,"Size of the file to write (default 64K)" },
testcases/kernel/io/ltp-aiodio/aiodio_sparse.c +1 -1
@@ -244,7 +244,7 @@ static struct tst_test test = {"tmpfs" ,NULL }, - .max_runtime = 1800, + .runtime = 1800, };#else TST_TEST_TCONF ("test requires libaio and its development packages" );
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
@@ -96,7 +96,7 @@ static struct tst_test test = { .cleanup = cleanup, .needs_tmpdir = 1, .forks_child = 1, - .max_runtime = 1800, + .runtime = 1800, .options = (struct tst_option []) { {"n:" , &str_numchildren,"Number of processes (default 16)" }, {"w:" , &str_writesize,"Write size for each append (default 64K)" },
testcases/kernel/io/ltp-aiodio/dio_read.c +1 -1
@@ -178,7 +178,7 @@ static struct tst_test test = { .cleanup = cleanup, .needs_tmpdir = 1, .forks_child = 1, - .max_runtime = 1800, + .runtime = 1800, .options = (struct tst_option []) { {"n:" , &str_numchildren,"Number of threads (default 8)" }, {"w:" , &str_writesize,"Size of writing blocks (default 32M)" },
testcases/kernel/io/ltp-aiodio/dio_sparse.c +1 -1
@@ -135,5 +135,5 @@ static struct tst_test test = { "tmpfs",NULL }, - .max_runtime = 1800, + .runtime = 1800, };
testcases/kernel/io/ltp-aiodio/dio_truncate.c +1 -1
@@ -170,7 +170,7 @@ static struct tst_test test = { .cleanup = cleanup, .needs_tmpdir = 1, .forks_child = 1, - .max_runtime = 1800, + .runtime = 1800, .options = (struct tst_option []) { {"n:" , &str_numchildren,"Number of threads (default 16)" }, {"s:" , &str_filesize,"Size of file (default 64K)" },
testcases/kernel/mem/ksm/ksm02.c +2 -2
@@ -87,7 +87,7 @@ static void setup(void)parse_ksm_options (opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);if (opt_sizestr && size >DEFAULT_MEMSIZE ) -tst_set_max_runtime (32 * (size /DEFAULT_MEMSIZE )); +tst_set_runtime (32 * (size /DEFAULT_MEMSIZE )); }static struct tst_test test = {
@@ -116,7 +116,7 @@ static struct tst_test test = {NULL }, .test_all = verify_ksm, - .max_runtime = 32, + .runtime = 32, .needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL }, };
testcases/kernel/mem/ksm/ksm04.c +2 -2
@@ -74,7 +74,7 @@ static void setup(void)SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());if (opt_sizestr && size >DEFAULT_MEMSIZE ) -tst_set_max_runtime (32 * (size /DEFAULT_MEMSIZE )); +tst_set_runtime (32 * (size /DEFAULT_MEMSIZE )); }static struct tst_test test = {
@@ -103,7 +103,7 @@ static struct tst_test test = {NULL }, .test_all = verify_ksm, - .max_runtime = 32, + .runtime = 32, .needs_cgroup_ctrls = (const char *const []){"memory" ,"cpuset" ,NULL },
testcases/kernel/mem/mmapstress/mmapstress01.c +1 -1
@@ -362,7 +362,7 @@ static struct tst_test test = { {}, }, .cleanup = cleanup, - .max_runtime = 12, + .runtime = 12, .needs_tmpdir = 1, .forks_child = 1, };
testcases/kernel/mem/mtest01/mtest01.c +1 -1
@@ -235,7 +235,7 @@ static struct tst_test test = { {"v", &verbose, "Verbose"}, {} }, - .max_runtime = 300, + .runtime = 300, .setup = setup, .cleanup = cleanup, .test_all = mem_test,
testcases/kernel/mem/mtest06/mmap1.c +1 -1
@@ -249,6 +249,6 @@ static void run(void)static struct tst_test test = { .test_all = run, .setup = setup, - .max_runtime =180 , + .runtime =180 , .needs_tmpdir =1 , };
testcases/kernel/mem/mtest06/mmap3.c +1 -1
@@ -182,5 +182,5 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .test_all = test_mmap, - .max_runtime = 60, + .runtime = 60, };
testcases/kernel/mem/mtest07/mallocstress.c +1 -1
@@ -194,7 +194,7 @@ static void cleanup(void) }static struct tst_test test = { - .max_runtime =600 , + .runtime =600 , .needs_checkpoints =1 , .setup = setup, .cleanup = cleanup,
testcases/kernel/mem/oom/oom01.c +1 -1
@@ -36,7 +36,7 @@ static void verify_oom(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =TST_UNLIMITED_RUNTIME , + .timeout =TST_UNLIMITED_TIMEOUT , .test_all = verify_oom, .skip_in_compat =1 , .save_restore = (const struct tst_path_val []) {
testcases/kernel/mem/oom/oom02.c +1 -1
@@ -45,7 +45,7 @@ static void setup(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =TST_UNLIMITED_RUNTIME , + .timeout =TST_UNLIMITED_TIMEOUT , .setup = setup, .test_all = verify_oom, .skip_in_compat =1 ,
testcases/kernel/mem/oom/oom03.c +1 -1
@@ -71,7 +71,7 @@ static void setup(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =TST_UNLIMITED_RUNTIME , + .timeout =TST_UNLIMITED_TIMEOUT , .setup = setup, .test_all = verify_oom, .needs_cgroup_ctrls = (const char *const []){"memory" ,NULL },
testcases/kernel/mem/oom/oom04.c +1 -1
@@ -67,7 +67,7 @@ static void setup(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =TST_UNLIMITED_RUNTIME , + .timeout =TST_UNLIMITED_TIMEOUT , .setup = setup, .test_all = verify_oom, .needs_cgroup_ctrls = (const char *const []){"cpuset" ,NULL },
testcases/kernel/mem/oom/oom05.c +1 -1
@@ -88,7 +88,7 @@ void setup(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =TST_UNLIMITED_RUNTIME , + .timeout =TST_UNLIMITED_TIMEOUT , .setup = setup, .test_all = verify_oom, .needs_cgroup_ctrls = (const char *const []){
testcases/kernel/mem/swapping/swapping01.c +1 -1
@@ -174,7 +174,7 @@ static struct tst_test test = { .needs_root = 1, .forks_child = 1, .min_mem_avail = 10, - .max_runtime = 600, + .runtime = 600, .test_all = test_swapping, .skip_in_compat = 1, .needs_kconfigs = (const char *[]) {
testcases/kernel/mem/thp/thp04.c +1 -1
@@ -161,7 +161,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"linux-git" ,"a8f97366452e" }, {"linux-git" ,"8310d48b125d" },
testcases/kernel/mem/tunable/min_free_kbytes.c +1 -1
@@ -221,7 +221,7 @@ static void setup(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =TST_UNLIMITED_RUNTIME , + .timeout =TST_UNLIMITED_TIMEOUT , .setup = setup, .test_all = min_free_kbytes_test, .save_restore = (const struct tst_path_val []) {
testcases/kernel/pty/pty03.c +1 -1
@@ -152,7 +152,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_root = 1, - .max_runtime = 30, + .runtime = 30, .needs_kconfigs = (const char *const []){"CONFIG_SERIO_SERPORT" ,NULL
testcases/kernel/pty/pty05.c +1 -1
@@ -97,7 +97,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"linux-git" ,"82f2341c94d27" }, {"CVE" ,"2017-2636" },
testcases/kernel/pty/pty06.c +1 -1
@@ -97,7 +97,7 @@ static struct tst_test test = { .cleanup = cleanup, .needs_root = 1, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"CVE" ,"2020-36557" }, {"linux-git" ,"ca4463bf8438" },
testcases/kernel/pty/pty07.c +1 -1
@@ -114,7 +114,7 @@ static struct tst_test test = { .cleanup = cleanup, .needs_root = 1, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"linux-git" ,"6cd1ed50efd8" }, {}
testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c +1 -1
@@ -174,7 +174,7 @@ static struct tst_test test = { .cleanup = cleanup, .forks_child = 1, .needs_checkpoints = 1, - .max_runtime = 20, + .timeout = 20, .taint_check = TST_TAINT_W | TST_TAINT_D, .needs_kconfigs = (const char *[]) {"CONFIG_CFS_BANDWIDTH" ,
testcases/kernel/sched/cfs-scheduler/starvation.c +1 -1
@@ -112,7 +112,7 @@ static void setup(void)if (tst_has_slow_kconfig ())tst_brk (TCONF ,"Skip test due to slow kernel configuration" ); -tst_set_max_runtime (timeout); +tst_set_runtime (timeout); } static void handler(int sig LTP_ATTRIBUTE_UNUSED)
testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem.c +1 -1
@@ -108,7 +108,7 @@ static struct tst_test test = { .needs_checkpoints = 1, .forks_child = 1, .needs_root = 1, - .max_runtime = 120, + .runtime = 120, .setup = setup, .cleanup = cleanup, .test_all = dirtyc0w_shmem_test,
testcases/kernel/security/kallsyms/kallsyms.c +1 -1
@@ -203,7 +203,7 @@ static struct tst_test test = { .needs_root = 1, .setup = setup, .cleanup = cleanup, - .max_runtime = 60, + .timeout = 60, .needs_kconfigs = (const char *const []){"CONFIG_KALLSYMS=y" ,NULL
testcases/kernel/sound/snd_seq01.c +1 -1
@@ -123,7 +123,7 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(testfunc_list), .setup = setup, .cleanup = cleanup, - .max_runtime = 60, + .runtime = 60, .taint_check = TST_TAINT_W | TST_TAINT_D, .tags = (const struct tst_tag []) { {"linux-git" ,"d15d662e89fc" },
testcases/kernel/sound/snd_timer01.c +1 -1
@@ -136,7 +136,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"linux-git" ,"d11662f4f798" }, {"linux-git" ,"ba3021b2c79b" },
testcases/kernel/syscalls/bind/bind06.c +1 -1
@@ -92,7 +92,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 300, + .runtime = 300, .taint_check = TST_TAINT_W | TST_TAINT_D, .needs_kconfigs = (const char *[]) {"CONFIG_USER_NS=y" ,
testcases/kernel/syscalls/copy_file_range/copy_file_range01.c +1 -1
@@ -232,5 +232,5 @@ static struct tst_test test = { .all_filesystems = 1, .test = copy_file_range_verify, .test_variants = TEST_VARIANTS, - .max_runtime = 5 + .timeout = 5 };
testcases/kernel/syscalls/fallocate/fallocate06.c +1 -1
@@ -261,7 +261,7 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(testcase_list), .needs_root = 1, .dev_min_size = 1024, - .max_runtime = 120, + .timeout = 120, .mount_device = 1, .mntpoint = MNTPOINT, .all_filesystems = 1,
testcases/kernel/syscalls/fork/fork13.c +1 -1
@@ -110,7 +110,7 @@ static void check(void)static struct tst_test test = { .needs_root =1 , .forks_child =1 , - .max_runtime =600 , + .runtime =600 , .test_all = check, .save_restore = (const struct tst_path_val []) { {"/proc/sys/kernel/pid_max" ,PID_MAX_STR ,TST_SR_TBROK },
testcases/kernel/syscalls/fsync/fsync02.c +1 -1
@@ -115,5 +115,5 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1, - .max_runtime = 300, + .timeout = 300, };
testcases/kernel/syscalls/gettimeofday/gettimeofday02.c +1 -1
@@ -72,6 +72,6 @@ static void setup(void)static struct tst_test test = { .setup = setup, - .max_runtime =10 , + .runtime =10 , .test_all = verify_gettimeofday, };
testcases/kernel/syscalls/inotify/inotify06.c +1 -1
@@ -116,7 +116,7 @@ static void cleanup(void) }static struct tst_test test = { - .max_runtime =600 , + .runtime =600 , .needs_root =1 , .needs_tmpdir =1 , .forks_child =1 ,
testcases/kernel/syscalls/inotify/inotify09.c +1 -1
@@ -97,7 +97,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .test_all = verify_inotify, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"linux-git" ,"d90a10e2444b" }, {}
testcases/kernel/syscalls/inotify/inotify12.c +1 -1
@@ -153,7 +153,7 @@ static void cleanup(void) }static struct tst_test test = { - .max_runtime =10 , + .timeout =10 , .needs_tmpdir =1 , .cleanup = cleanup, .test = verify_inotify,
testcases/kernel/syscalls/ioctl/ioctl_sg01.c +1 -1
@@ -128,7 +128,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 3600, + .timeout = 3600, .tags = (const struct tst_tag []) { {"linux-git" ,"a45b599ad808" }, {"CVE" ,"2018-1000204" },
testcases/kernel/syscalls/ipc/msgstress/msgstress01.c +1 -1
@@ -311,7 +311,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .forks_child = 1, - .max_runtime = 180, + .runtime = 180, .options = (struct tst_option []) { {"n:" , &str_num_messages,"Number of messages to send (default: 1000)" }, {"l:" , &str_num_iterations,"Number iterations per message (default: "
testcases/kernel/syscalls/ipc/semget/semget05.c +1 -1
@@ -43,7 +43,7 @@ static void setup(void)SAFE_FILE_SCANF ("/proc/sys/kernel/sem" ,"%*d %*d %*d %d" , &maxsems);/* Prevent timeout due to high semaphore array limit */ -tst_set_max_runtime (maxsems /200 ); +tst_set_runtime (maxsems /200 ); sem_id_arr =SAFE_MALLOC ((maxsems - used_cnt) *sizeof (int ));for (num =0 ; num < maxsems - used_cnt; num++) {
testcases/kernel/syscalls/ipc/shmctl/shmctl05.c +1 -1
@@ -106,7 +106,7 @@ static void cleanup(void) }static struct tst_test test = { - .max_runtime =10 , + .runtime =10 , .setup = setup, .test_all = do_test, .cleanup = cleanup,
testcases/kernel/syscalls/keyctl/keyctl02.c +1 -1
@@ -160,7 +160,7 @@ static struct tst_test test = { .needs_root = 1, .setup = setup, .cleanup = cleanup, - .max_runtime = 60, + .runtime = 60, .test_all = do_test, .tags = (const struct tst_tag []) { {"linux-git" ,"b4a1b4f5047e" },
testcases/kernel/syscalls/landlock/landlock04.c +1 -1
@@ -204,5 +204,5 @@ static struct tst_test test = { .mount_device = 1, .mntpoint = SANDBOX_FOLDER, .all_filesystems = 1, - .max_runtime = 360, + .timeout = 360, };
testcases/kernel/syscalls/madvise/madvise06.c +1 -1
@@ -242,7 +242,7 @@ static struct tst_test test = { .setup = setup, .needs_tmpdir = 1, .needs_root = 1, - .max_runtime = 60, + .timeout = 60, .taint_check = TST_TAINT_W | TST_TAINT_D, .save_restore = (const struct tst_path_val []) { {"/proc/sys/vm/swappiness" ,NULL ,
testcases/kernel/syscalls/madvise/madvise11.c +1 -1
@@ -432,7 +432,7 @@ static struct tst_test test = {"CONFIG_MEMORY_FAILURE=y" ,NULL }, - .max_runtime = 30, + .runtime = 30, .needs_checkpoints = 1, .setup = setup, .cleanup = cleanup,
testcases/kernel/syscalls/migrate_pages/migrate_pages03.c +1 -1
@@ -139,7 +139,7 @@ static void migrate_test(void) }static struct tst_test test = { - .max_runtime =300 , + .runtime =300 , .needs_root =1 , .setup = setup, .cleanup = cleanup,
testcases/kernel/syscalls/move_pages/move_pages12.c +1 -1
@@ -342,7 +342,7 @@ static struct tst_test test = { .cleanup = cleanup, .test = do_test, .tcnt = ARRAY_SIZE(tcases), - .max_runtime = 240, + .runtime = 240, .tags = (const struct tst_tag []) { {"linux-git" ,"e66f17ff7177" }, {"linux-git" ,"c9d398fa2378" },
testcases/kernel/syscalls/nice/nice05.c +1 -1
@@ -154,5 +154,5 @@ static struct tst_test test = { .setup = setup, .test_all = verify_nice, .needs_root = 1, - .max_runtime = 3, + .runtime = 3, };
testcases/kernel/syscalls/perf_event_open/perf_event_open02.c +1 -1
@@ -334,5 +334,5 @@ static struct tst_test test = { }, .test_all = verify, .needs_root = 1, - .max_runtime = 72 + .timeout = 72 };
testcases/kernel/syscalls/perf_event_open/perf_event_open03.c +1 -1
@@ -127,7 +127,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_root = 1, - .max_runtime = 300, + .runtime = 300, .tags = (const struct tst_tag []) { {"linux-git" ,"7bdb157cdebb" }, {"CVE" ,"2020-25704" },
testcases/kernel/syscalls/preadv2/preadv203.c +1 -1
@@ -278,6 +278,6 @@ static struct tst_test test = { .mntpoint = MNTPOINT, .mount_device = 1, .all_filesystems = 1, - .max_runtime = 60, + .runtime = 60, .needs_root = 1, };
testcases/kernel/syscalls/readahead/readahead02.c +4 -4
@@ -321,7 +321,7 @@ static void test_readahead(unsigned int n)/* * The time consuming of readahead quite depending on the platform IO -* speed, sometime test timeout when the default max_runtime is used up. +* speed, sometime test timeout when the default runtime is used up. * * readahead02.c:221: TINFO: Test #2: POSIX_FADV_WILLNEED on file * readahead02.c:285: TINFO: read_testfile(0) took: 26317623 usec
@@ -330,7 +330,7 @@ static void test_readahead(unsigned int n)* Here raise the maximum runtime dynamically. */ if ((tc+1 )->readahead) -tst_set_max_runtime (test.max_runtime + (usec + usec_ra) /1000000 ); +tst_set_runtime (test.runtime + (usec + usec_ra) /1000000 ); }
@@ -381,7 +381,7 @@ static void setup(void) {if (opt_fsizestr) { testfile_size =SAFE_STRTOL (opt_fsizestr,1 ,INT_MAX ); -tst_set_max_runtime (1 + testfile_size / (DEFAULT_FILESIZE /32 )); +tst_set_runtime (1 + testfile_size / (DEFAULT_FILESIZE /32 )); }if (access (PROC_IO_FNAME ,F_OK ))
@@ -422,7 +422,7 @@ static struct tst_test test = { }, .test = test_readahead, .tcnt = ARRAY_SIZE(tcases), - .max_runtime = 30, + .runtime = 30, .tags = (const struct tst_tag []) { {"linux-git" ,"b833a3660394" }, {"linux-git" ,"5b910bd615ba" },
testcases/kernel/syscalls/request_key/request_key03.c +1 -1
@@ -215,7 +215,7 @@ static struct tst_test test = { .test = do_test, .tcnt = ARRAY_SIZE(testcase_list), .forks_child = 1, - .max_runtime = 20, + .runtime = 20, .options = (struct tst_option []) { {"b:" , &opt_bug,"Bug to test for (cve-2017-15299 or cve-2017-15951; default is both)" }, {}
testcases/kernel/syscalls/sendfile/sendfile09.c +1 -1
@@ -93,7 +93,7 @@ static struct tst_test test = { .setup = setup, .test = run, .tcnt = ARRAY_SIZE(tc), - .max_runtime = 120, + .timeout = 120, .skip_in_compat = 1, .tags = (const struct tst_tag []) { {"linux-git" ,"5d73320a96fcc" },
testcases/kernel/syscalls/sendmsg/sendmsg03.c +1 -1
@@ -105,7 +105,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 150, + .runtime = 150, .needs_kconfigs = (const char *[]) {"CONFIG_USER_NS=y" ,"CONFIG_NET_NS=y" ,
testcases/kernel/syscalls/set_mempolicy/set_mempolicy01.c +2 -2
@@ -43,7 +43,7 @@ static void setup(void)* * Here reset the maximum runtime according to the NUMA nodes. */ -tst_set_max_runtime (test.max_runtime * (1 << nodes->cnt/16 )); +tst_set_runtime (test.runtime * (1 << nodes->cnt/16 )); }static void cleanup (void )
@@ -119,7 +119,7 @@ static struct tst_test test = { .tcnt = 2, .forks_child = 1, .needs_checkpoints = 1, - .max_runtime = 600, + .runtime = 600, };#else
testcases/kernel/syscalls/setsockopt/setsockopt06.c +1 -1
@@ -110,7 +110,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 270, + .runtime = 270, .taint_check = TST_TAINT_W | TST_TAINT_D, .needs_kconfigs = (const char *[]) {"CONFIG_USER_NS=y" ,
testcases/kernel/syscalls/setsockopt/setsockopt07.c +1 -1
@@ -123,7 +123,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 150, + .runtime = 150, .needs_kconfigs = (const char *[]) {"CONFIG_USER_NS=y" ,"CONFIG_NET_NS=y" ,
testcases/kernel/syscalls/swapoff/swapoff01.c +1 -1
@@ -53,6 +53,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_root = 1, .test_all = verify_swapoff, - .max_runtime = 60, + .timeout = 60, .setup = setup };
testcases/kernel/syscalls/swapon/swapon01.c +1 -1
@@ -51,6 +51,6 @@ static struct tst_test test = { .all_filesystems = 1, .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, - .max_runtime = 60, + .timeout = 60, .setup = setup };
testcases/kernel/syscalls/timerfd/timerfd_settime02.c +1 -1
@@ -111,7 +111,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 150, + .runtime = 150, .tags = (const struct tst_tag []) { {"linux-git" ,"1e38da300e1e" }, {"CVE" ,"2017-10661" },
testcases/kernel/syscalls/writev/writev03.c +1 -1
@@ -145,7 +145,7 @@ static struct tst_test test = { .min_cpus = 2, .setup = setup, .cleanup = cleanup, - .max_runtime = 75, + .runtime = 75, .tags = (const struct tst_tag []) { {"linux-git" ,"d4690f1e1cda" }, {}
testcases/network/can/cve/can_bcm01.c +1 -1
@@ -141,7 +141,7 @@ static struct tst_test test = { .taint_check = TST_TAINT_W | TST_TAINT_D, .needs_root = 1, .skip_in_compat = 1, - .max_runtime = 30, + .runtime = 30, .needs_drivers = (const char *const []) {"vcan" ,"can-bcm" ,
testcases/network/netstress/netstress.c +1 -1
@@ -1024,6 +1024,6 @@ static struct tst_test test = { {"B:", &server_bg, "Run in background, arg is the process directory"}, {} }, - .max_runtime = 300, + .timeout = 300, .needs_checkpoints = 1, };
testcases/network/nfs/nfs_stress/nfs05_make_tree.c +1 -1
@@ -214,5 +214,5 @@ static struct tst_test test = { .options = opts, .test_all = do_test, .setup = setup, - .max_runtime = 300, + .timeout = 300, };
testcases/network/packet/fanout01.c +1 -1
@@ -89,7 +89,7 @@ static struct tst_test test = { .test_all = run, .cleanup = cleanup, .needs_root = 1, - .max_runtime = 180, + .runtime = 180, .needs_kconfigs = (const char *[]) {"CONFIG_USER_NS=y" ,"CONFIG_NET_NS=y" ,
testcases/network/sockets/vsock01.c +1 -1
@@ -112,7 +112,7 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .taint_check = TST_TAINT_W | TST_TAINT_D, - .max_runtime = 60, + .runtime = 60, .needs_kconfigs = (const char *[]) {"CONFIG_VSOCKETS_LOOPBACK" ,NULL
Signature · 5 lines
2.47.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/4] lib: redefine the overall timeout logic of test
Hi!
Quoted 137 lines
This patch revises the logic for managing test timeout and runtime limits, introducing a more structured approach. The key changes include renaming
max_runtimeto runtime for clarity and addingoverall_timeto represent the total time limit for a test. This ensures better separation of test phases (setup, execution, and cleanup) and clearer timeout management.Key Concepts:
timeout: Defines the maximum time allowed for the entire test, including
setup, execution, and cleanup, when no explicit runtime is set. But if a runtime is explicitly defined andtst_remaining_runtime()is used, the timeout applies only to the setup and cleanup phases, as the runtime controls the test execution duration.runtime: The maximum runtime of the test's main execution loop, used
in tests that calltst_remaining_runtime(). It ensures the main execution runs for a fixed duration, regardless of kernel configuration (e.g., debug kernel).Overall timeout is structured as follows:
| -- (
default_30s+ timeout) *timeout_mul-- | -- runtime *runtime_mul-- |And, the
TST_UNLIMITED_RUNTIMEconstant has been deprecated and replaced byTST_UNLIMITED_TIMEOUT. This change simplifies the handling of unlimited execution scenarios while aligning the terminology with the new timeout model.Suggested-by Cyril Hrubis <[email protected]>Signed-off-by Li Wang <[email protected]>Cc Petr Vorel <[email protected]>,Cc Martin Doucha <[email protected]>,Cc Jan Stancek <[email protected]>Cc Andrea Cervesato <[email protected]>Cc Avinesh Kumar <[email protected]>,--- doc/old/C-Test-API.asciidoc | 36 ++++--- doc/users/setup_tests.rst | 6 +- include/tst_test.h | 33 +++++-- lib/newlib_tests/shell/test_timeout.sh | 10 +- lib/newlib_tests/test_runtime01.c | 2 +- lib/newlib_tests/test_runtime02.c | 2 +- lib/newlib_tests/tst_fuzzy_sync01.c | 2 +- lib/newlib_tests/tst_fuzzy_sync02.c | 2 +- lib/newlib_tests/tst_fuzzy_sync03.c | 2 +- lib/tst_test.c | 95 +++++++++---------- lib/tst_timer_test.c | 2 +- testcases/cve/cve-2014-0196.c | 2 +- testcases/cve/cve-2015-3290.c | 2 +- testcases/cve/cve-2016-7117.c | 2 +- testcases/cve/cve-2017-2671.c | 2 +- .../kernel/controllers/cgroup/cgroup_core03.c | 2 +- testcases/kernel/crypto/af_alg02.c | 2 +- testcases/kernel/crypto/af_alg07.c | 2 +- testcases/kernel/crypto/pcrypt_aead01.c | 2 +- testcases/kernel/fs/fs_fill/fs_fill.c | 2 +- testcases/kernel/fs/fsplough/fsplough.c | 2 +- testcases/kernel/fs/fsx-linux/fsx-linux.c | 2 +- testcases/kernel/fs/read_all/read_all.c | 4 +- testcases/kernel/io/ltp-aiodio/aio-stress.c | 2 +- testcases/kernel/io/ltp-aiodio/aiocp.c | 2 +- .../kernel/io/ltp-aiodio/aiodio_append.c | 2 +- .../kernel/io/ltp-aiodio/aiodio_sparse.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_append.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_read.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_sparse.c | 2 +- testcases/kernel/io/ltp-aiodio/dio_truncate.c | 2 +- testcases/kernel/mem/ksm/ksm02.c | 4 +- testcases/kernel/mem/ksm/ksm04.c | 4 +- .../kernel/mem/mmapstress/mmapstress01.c | 2 +- testcases/kernel/mem/mtest01/mtest01.c | 2 +- testcases/kernel/mem/mtest06/mmap1.c | 2 +- testcases/kernel/mem/mtest06/mmap3.c | 2 +- testcases/kernel/mem/mtest07/mallocstress.c | 2 +- testcases/kernel/mem/oom/oom01.c | 2 +- testcases/kernel/mem/oom/oom02.c | 2 +- testcases/kernel/mem/oom/oom03.c | 2 +- testcases/kernel/mem/oom/oom04.c | 2 +- testcases/kernel/mem/oom/oom05.c | 2 +- testcases/kernel/mem/swapping/swapping01.c | 2 +- testcases/kernel/mem/thp/thp04.c | 2 +- .../kernel/mem/tunable/min_free_kbytes.c | 2 +- testcases/kernel/pty/pty03.c | 2 +- testcases/kernel/pty/pty05.c | 2 +- testcases/kernel/pty/pty06.c | 2 +- testcases/kernel/pty/pty07.c | 2 +- .../sched/cfs-scheduler/cfs_bandwidth01.c | 2 +- .../kernel/sched/cfs-scheduler/starvation.c | 2 +- .../security/dirtyc0w_shmem/dirtyc0w_shmem.c | 2 +- testcases/kernel/security/kallsyms/kallsyms.c | 2 +- testcases/kernel/sound/snd_seq01.c | 2 +- testcases/kernel/sound/snd_timer01.c | 2 +- testcases/kernel/syscalls/bind/bind06.c | 2 +- .../copy_file_range/copy_file_range01.c | 2 +- .../kernel/syscalls/fallocate/fallocate06.c | 2 +- testcases/kernel/syscalls/fork/fork13.c | 2 +- testcases/kernel/syscalls/fsync/fsync02.c | 2 +- .../syscalls/gettimeofday/gettimeofday02.c | 2 +- testcases/kernel/syscalls/inotify/inotify06.c | 2 +- testcases/kernel/syscalls/inotify/inotify09.c | 2 +- testcases/kernel/syscalls/inotify/inotify12.c | 2 +- testcases/kernel/syscalls/ioctl/ioctl_sg01.c | 2 +- .../syscalls/ipc/msgstress/msgstress01.c | 2 +- .../kernel/syscalls/ipc/semget/semget05.c | 2 +- .../kernel/syscalls/ipc/shmctl/shmctl05.c | 2 +- testcases/kernel/syscalls/keyctl/keyctl02.c | 2 +- .../kernel/syscalls/landlock/landlock04.c | 2 +- testcases/kernel/syscalls/madvise/madvise06.c | 2 +- testcases/kernel/syscalls/madvise/madvise11.c | 2 +- .../syscalls/migrate_pages/migrate_pages03.c | 2 +- .../kernel/syscalls/move_pages/move_pages12.c | 2 +- testcases/kernel/syscalls/nice/nice05.c | 2 +- .../perf_event_open/perf_event_open02.c | 2 +- .../perf_event_open/perf_event_open03.c | 2 +- testcases/kernel/syscalls/preadv2/preadv203.c | 2 +- .../kernel/syscalls/readahead/readahead02.c | 8 +- .../syscalls/request_key/request_key03.c | 2 +- .../kernel/syscalls/sendfile/sendfile09.c | 2 +- testcases/kernel/syscalls/sendmsg/sendmsg03.c | 2 +- .../syscalls/set_mempolicy/set_mempolicy01.c | 4 +- .../kernel/syscalls/setsockopt/setsockopt06.c | 2 +- .../kernel/syscalls/setsockopt/setsockopt07.c | 2 +- testcases/kernel/syscalls/swapoff/swapoff01.c | 2 +- testcases/kernel/syscalls/swapon/swapon01.c | 2 +- .../syscalls/timerfd/timerfd_settime02.c | 2 +- testcases/kernel/syscalls/writev/writev03.c | 2 +- testcases/network/can/cve/can_bcm01.c | 2 +- testcases/network/netstress/netstress.c | 2 +- .../network/nfs/nfs_stress/nfs05_make_tree.c | 2 +- testcases/network/packet/fanout01.c | 2 +- testcases/network/sockets/vsock01.c | 2 +- 95 files changed, 196 insertions(+), 178 deletions(-)doc/old/C-Test-API.asciidoc +0
-0
doc/old/C-Test-API.asciidoc in range of [0, '.tcnt' - 1]. · line 99
Quoted 8 lines
doc/old/C-Test-API.asciidoc +2
-3@@ -95,25 +95,28 @@ in range of [0, '.tcnt' - 1]. IMPORTANT: Only one of '.test' and '.test_all' can be set at a time. Each test has a limit on how long it can run and the limit composes of two -parts max_runtime and timeout. The max_runtime is a limit for how long can the -'.test_all' or a set of '.test' functions take and the timeout is static part -that should cover the duration of test setup and cleanup plus some safety. +parts runtime and timeout. The runtime is a limit for how long can the +'.test_all' or a set of '.test' main functions take and the timeout is static
^
As I pointed out the timeout applies per single invocation of the test function.
We can discuss if it should be revisited but that's how the code was initially written.
The timeout timer is also reset on each subsequent iteration with the test -i parameter, variants or .all_filesystems.
Quoted 90 lines
doc/old/C-Test-API.asciidoc +19
-12+part that should cover the duration of test setup and cleanup plus some safety. +If test without an explicit runtime, the timeout governs the entire test duration. Any test that runs for more than a second or two has to make sure to: -- set the runtime either by setting the '.max_runtime' in tst_test or by - calling 'tst_set_max_runtime()' in the test setup -- monitor remaning runtime by regular calls to 'tst_remaining_runtime()' and - exit when runtime has been used up +- set the runtime by setting '.runtime' in tst_test and calling 'tst_set_runtime()' + to monitor the remaining runtime and ensure the test exits when the runtime + limit is reached. -Test is free to exit before max_runtime has been used up for example when +- set the timeout by setting '.timeout' in tst_test to limit the whole test + run that does not use 'tst_remaining_runtime()'. + +Test is free to exit before runtime has been used up for example when minimal number of iteration was finished. The limit is applied to a single call of the '.test_all' function that means that for example when '.test_variants' or '.all_filesystems' is set the whole -test will be limited by 'variants * (max_runtime + timeout)' seconds and the -test runtime will be likely close to 'variants * max_runtime' seconds. +test will be limited by 'variants * (runtime + timeout)' seconds and the +test runtime will be likely close to 'variants * runtime' seconds. [source,c] -------------------------------------------------------------------------------@@ -401,13 +404,16 @@ WARNING: This function is not thread safe. [source,c] ------------------------------------------------------------------------------- -void tst_set_max_runtime(int max_runtime); +void tst_set_runtime(int runtime); ------------------------------------------------------------------------------- -Allows for setting max_runtime per test iteration dynamically in the test 'setup()', -the timeout is specified in seconds. There are a few testcases whose runtime -can vary arbitrarily, these can disable timeouts by setting it to -TST_UNLIMITED_RUNTIME. +Allows for setting the runtime per test iteration dynamically during the test 'setup()'. +The runtime is specified in seconds and represents the duration the test is allowed +to execute its main workload, excluding setup and teardown phases. + +This function is useful for tests where the duration of the main workload can be +controlled or needs to be adjusted dynamically. For example, tests that loop until +the runtime expires can use this function to define how long they should run. [source,c] -------------------------------------------------------------------------------doc/users/setup_tests.rst +3
-3@@ -87,14 +87,14 @@ See :master:`testcases/network/README.md`. Test execution time and timeout ------------------------------- -The limit on how long a test can run does compose of two parts: ``max_runtime`` +The limit on how long a test can run does compose of two parts: ``runtime`` and ``timeout``. The limit does apply to a single test variant. That means, for example, that tests which run for all available filesystems will apply this limit for a single filesystem only. -The ``max_runtime`` is a cap on how long the ``run()`` function can take and for +The ``runtime`` is a cap on how long the ``run()`` function can take and for most testcases this part is set to zero. For tests that do run for more than a -second or two the ``max_runtime`` has to be defined and the ``run()`` function +second or two the ``runtime`` has to be defined and the ``run()`` function has to check actively how much runtime is left. Test runtime can be scaled up and down with ``LTP_RUNTIME_MUL`` environmentinclude/tst_test.h +1
-1@@ -234,7 +234,7 @@ struct tst_tag {extern unsigned int tst_variant; -#define TST_UNLIMITED_RUNTIME (-1) +#define TST_UNLIMITED_TIMEOUT (-1)/** * struct tst_ulimit_val - An ulimit resource and value. @@ -435,13 +435,25 @@ struct tst_fs {* The directory is created by the library, the test must not create * it itself.
include/tst_test.h struct tst_fs { · line 439
Quoted 10 lines
include/tst_test.h +2
-7* -* @max_runtime: Maximal test runtime in seconds. Any test that runs for more -* than a second or two should set this and also use -* tst_remaining_runtime() to exit when runtime was used up. -* Tests may finish sooner, for example if requested number of -* iterations was reached before the runtime runs out. If test -* runtime cannot be know in advance it should be set to -* TST_UNLIMITED_RUNTIME. +* @timeout: Maximum allowable time in seconds for the entire duration of a test. +* By default, the timeout limits the total time for setup, execution,
^
single test function invocation
We should make sure that it's clear that the timeout is reset in case of the different multipliers (the -i parameter, variants, all_filesytems...)
include/tst_test.h struct tst_fs { · line 444
Quoted 5 lines
include/tst_test.h +5
-0+* and cleanup phases. However, if `.runtime` is explicitly set and +* tst_remaining_runtime() is used in the test's main loop, the timeout +* then applies only to the setup and cleanup phases, as the runtime +* separately limits the main test execution. This ensures the test +* does not hang indefinitely, and if the setup or cleanup time cannot
^
in the rare case that the test timeout cannot be
...
include/tst_test.h struct tst_fs { · line 456
Quoted 12 lines
include/tst_test.h +12
-0+* be accurately determined, it can be set to a sufficiently large value +* or TST_UNLIMITED_TIMEOUT to remove the limit. +* +* @runtime: Maximum runtime in seconds for the test's main execution loop. +* This should be set for tests that are expected to run longer +* than a few seconds and call tst_remaining_runtime() in their +* main loop to exit gracefully when the runtime is exceeded. +* Tests may finish sooner if their task completes (e.g., reaching +* a requested number of iterations) before the runtime runs out. +* The runtime is fixed and does not scale with timeout multipliers +* (e.g., TIMEOUT_MUL), ensuring consistent test duration across +* different environments (e.g., debug vs. stock kernels).
Good description, thanks!
Quoted 46 lines
include/tst_test.h +3
-2* @setup: Setup callback is called once at the start of the test in order to * prepare the test environment. @@ -565,7 +577,8 @@ struct tst_fs {const char *mntpoint; -int max_runtime; +int timeout; +int runtime;void (*setup)(void );void (*cleanup)(void );@@ -676,7 +689,7 @@ unsigned int tst_remaining_runtime(void);/* * Sets maximal test runtime in seconds. */ -void tst_set_max_runtime (int max_runtime); +void tst_set_runtime (int runtime);/* * Create and open a random file inside the given dir path. lib/newlib_tests/shell/test_timeout.sh +3
-3@@ -10,7 +10,7 @@ PATH="$(dirname $0):$(dirname $0)/../../../testcases/lib/:$PATH" # file # timeout_mul # use_cat -# max_runtime +# runtime # expected_exit_code # expected passes # expected failed@@ -114,8 +114,8 @@ for d in $CLEANED_DATA; do file=$(echo $d | cut -d'|' -f1 | xargs) timeout=$(echo $d | cut -d'|' -f2 | xargs) use_cat=$(echo $d | cut -d'|' -f3 | xargs) - max_runtime=$(echo $d | cut -d'|' -f4 | xargs) - max_runtime=${max_runtime:--1} + runtime=$(echo $d | cut -d'|' -f4 | xargs) + runtime=${runtime:--1} exp_exit=$(echo $d | cut -d'|' -f5 | xargs) exp_exit=${exp_exit:--1} exp_passed=$(echo $d | cut -d'|' -f6 | xargs)
lib/newlib_tests/shell/test_timeout.sh for d in $CLEANED_DATA; do · line 143
Quoted 9 lines
lib/newlib_tests/shell/test_timeout.sh +2
-2@@ -137,8 +137,8 @@ for d in $CLEANED_DATA; do echo "=== $test_nr/$test_max $description ===" run_test "$file" "$timeout" "$use_cat" - if [ $max_runtime -ne -1 ] && [ $test_duration -gt $max_runtime ]; then - echo "FAILED (runtime: $test_duration, expected less than $max_runtime)" + if [ $runtime -ne -1 ] && [ $test_duration -gt $runtime ]; then + echo "FAILED (runtime: $test_duration, expected less than $runtime)" cur_fails=$((cur_fails + 1)) fi
This seems to be unrelated, that's just a variable name we parse the test description into. So I would keep the shell script as it is.
Quoted 266 lines
lib/newlib_tests/test_runtime01.c +1
-1@@ -25,6 +25,6 @@ static void run(void)static struct tst_test test = { .test_all = run, - .max_runtime =4 , + .runtime =4 , .test_variants =2 , };lib/newlib_tests/test_runtime02.c +1
-1@@ -24,5 +24,5 @@ static void run(void)static struct tst_test test = { .test_all = run, - .max_runtime =5 , + .runtime =5 , };lib/newlib_tests/tst_fuzzy_sync01.c +1
-1@@ -248,5 +248,5 @@ static struct tst_test test = { .test = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 150, + .runtime = 150, };lib/newlib_tests/tst_fuzzy_sync02.c +1
-1@@ -225,5 +225,5 @@ static struct tst_test test = { .test = run, .setup = setup, .cleanup = cleanup, - .max_runtime = 150, + .runtime = 150, };lib/newlib_tests/tst_fuzzy_sync03.c +1
-1@@ -99,5 +99,5 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .test_all = run, - .max_runtime = 150, + .runtime = 150, };lib/tst_test.c +47
-48@@ -71,8 +71,8 @@ struct results {int failed;int warnings;int broken; -unsigned int timeout; -int max_runtime; +unsigned int runtime; +unsigned int overall_time; };static struct results *results;@@ -546,16 +546,13 @@ static void parse_mul(float *mul, const char *env_name, float min, float max) } } -static int multiply_runtime (int max_runtime) +static int multiply_runtime (unsigned int runtime) {static float runtime_mul =-1 ; -if (max_runtime <=0 ) -return max_runtime; -parse_mul (&runtime_mul,"LTP_RUNTIME_MUL" ,0.0099 ,100 ); -return max_runtime * runtime_mul; +return runtime * runtime_mul; } static struct option {@@ -593,21 +590,21 @@ static void print_help(void)fprintf (stderr,"Timeout and runtime\n" );fprintf (stderr,"-------------------\n" ); -if (tst_test->max_runtime) { - runtime =multiply_runtime (tst_test->max_runtime); +if (tst_test->timeout ==TST_UNLIMITED_TIMEOUT ) { +fprintf (stderr,"Test timeout is not limited\n" ); + }else { + timeout =tst_multiply_timeout (DEFAULT_TIMEOUT + tst_test->timeout); -if (runtime ==TST_UNLIMITED_RUNTIME ) { -fprintf (stderr,"Test iteration runtime is not limited\n" ); - }else { -fprintf (stderr,"Test iteration runtime cap %ih %im %is\n" , - runtime/3600 , (runtime%3600 )/60 , runtime %60 ); - } +fprintf (stderr,"Test timeout (not including runtime) %ih %im %is\n" , + timeout/3600 , (timeout%3600 )/60 , timeout %60 ); } - timeout =tst_multiply_timeout (DEFAULT_TIMEOUT ); +if (tst_test->runtime) { + runtime =multiply_runtime (tst_test->runtime); -fprintf (stderr,"Test timeout (not including runtime) %ih %im %is\n" , - timeout/3600 , (timeout%3600 )/60 , timeout %60 ); +fprintf (stderr,"Test iteration runtime cap %ih %im %is\n" , + runtime/3600 , (runtime%3600 )/60 , runtime %60 ); + }fprintf (stderr,"\n" );@@ -740,8 +737,8 @@ static void parse_opts(int argc, char *argv[]) iterations =SAFE_STRTOL (optarg,0 ,INT_MAX );break ;case 'I' : -if (tst_test->max_runtime >0 ) - tst_test->max_runtime =SAFE_STRTOL (optarg,1 ,INT_MAX ); +if (tst_test->runtime >0 ) + tst_test->runtime =SAFE_STRTOL (optarg,1 ,INT_MAX );else duration =SAFE_STRTOF (optarg,0.1 ,HUGE_VALF );break ;@@ -1265,9 +1262,14 @@ static void do_setup(int argc, char *argv[])if (!tst_test)tst_brk (TBROK ,"No tests to run" ); -if (tst_test->max_runtime <-1 ) { +if (tst_test->timeout <-1 ) { +tst_brk (TBROK ,"Invalid timeout value %i" , + tst_test->timeout); + } + +if (tst_test->runtime <0 ) {tst_brk (TBROK ,"Invalid runtime value %i" , - results->max_runtime); + results->runtime); }if (tst_test->tconf_msg)@@ -1662,7 +1664,7 @@ static void alarm_handler(int sig LTP_ATTRIBUTE_UNUSED) static void heartbeat_handler(int sig LTP_ATTRIBUTE_UNUSED) { -alarm (results->timeout); +alarm (results->overall_time); sigkill_retries =0 ; }@@ -1679,18 +1681,15 @@ unsigned int tst_remaining_runtime(void)static struct timespec now;int elapsed; -if (results->max_runtime ==TST_UNLIMITED_RUNTIME ) -return UINT_MAX ; - -if (results->max_runtime ==0 ) +if (results->runtime ==0 )tst_brk (TBROK ,"Runtime not set!" );if (tst_clock_gettime (CLOCK_MONOTONIC , &now))tst_res (TWARN |TERRNO ,"tst_clock_gettime() failed" ); elapsed =tst_timespec_diff_ms (now, tst_start_time) /1000 ; -if (results->max_runtime > elapsed) -return results->max_runtime - elapsed; +if (results->runtime > elapsed) +return results->runtime - elapsed;return 0 ; }@@ -1709,33 +1708,33 @@ unsigned int tst_multiply_timeout(unsigned int timeout)return timeout * timeout_mul; } -static void set_timeout (void ) +static void set_overall_timeout (void ) { -unsigned int timeout =DEFAULT_TIMEOUT ; +unsigned int timeout =DEFAULT_TIMEOUT + tst_test->timeout; -if (results->max_runtime ==TST_UNLIMITED_RUNTIME ) { +if (tst_test->timeout ==TST_UNLIMITED_TIMEOUT ) {tst_res (TINFO ,"Timeout per run is disabled" );return ; } -if (results->max_runtime <0 ) { -tst_brk (TBROK ,"max_runtime must to be >= -1! (%d)" , - results->max_runtime); +if (results->runtime <0 ) { +tst_brk (TBROK ,"runtime must to be > 0! (%d)" , + results->runtime); } - results->timeout =tst_multiply_timeout (timeout) + results->max_runtime; + results->overall_time =tst_multiply_timeout (timeout) + results->runtime; -tst_res (TINFO ,"Timeout per run is %uh %02um %02us" , - results->timeout/3600 , (results->timeout%3600 )/60 , - results->timeout %60 ); +tst_res (TINFO ,"Overall timeout per run is %uh %02um %02us" , + results->overall_time/3600 , (results->overall_time%3600 )/60 , + results->overall_time %60 ); } -void tst_set_max_runtime (int max_runtime) +void tst_set_runtime (int runtime) { - results->max_runtime =multiply_runtime (max_runtime); -tst_res (TINFO ,"Updating max runtime to %uh %02um %02us" , - max_runtime/3600 , (max_runtime%3600 )/60 , max_runtime %60 ); -set_timeout (); + results->runtime =multiply_runtime (runtime); +tst_res (TINFO ,"Updating runtime to %uh %02um %02us" , + runtime/3600 , (runtime%3600 )/60 , runtime %60 ); +set_overall_timeout ();heartbeat (); }@@ -1746,7 +1745,7 @@ static int fork_testrun(void)SAFE_SIGNAL (SIGINT , sigint_handler);SAFE_SIGNAL (SIGTERM , sigint_handler); -alarm (results->timeout); +alarm (results->overall_time); show_failure_hints =1 ;@@ -1896,10 +1895,10 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)uname (&uval);tst_res (TINFO ,"Tested kernel: %s %s %s" , uval.release, uval.version, uval.machine); -if (tst_test->max_runtime) - results->max_runtime =multiply_runtime (tst_test->max_runtime); +if (tst_test->runtime) + results->runtime =multiply_runtime (tst_test->runtime); -set_timeout (); +set_overall_timeout ();if (tst_test->test_variants) test_variants = tst_test->test_variants;lib/tst_timer_test.c +1
-1@@ -454,7 +454,7 @@ static void parse_timer_opts(void) runtime_us += tcases[i].usec * tcases[i].samples; } -tst_set_max_runtime ((runtime_us + runtime_us/10 )/1000000 ); +tst_set_runtime ((runtime_us + runtime_us/10 )/1000000 ); }
...
testcases/kernel/fs/fsplough/fsplough.c static void setup(void) · line 193
Quoted 10 lines
testcases/kernel/fs/fsplough/fsplough.c +1
-1@@ -190,7 +190,7 @@ static void setup(void) MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); filedata =SAFE_MALLOC (filesize); -tst_set_max_runtime (bufsize * loop_count / (8 *1024 *1024 )); +tst_set_runtime (bufsize * loop_count / (8 *1024 *1024 ));
This should be setting timeout similarily to the set_mempolicy01.c
Quoted 3 lines
testcases/kernel/fs/fsplough/fsplough.c +0
-0}static void run (void )
...
Quoted 14 lines
testcases/kernel/mem/ksm/ksm02.c +1
-1@@ -87,7 +87,7 @@ static void setup(void)parse_ksm_options (opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit);if (opt_sizestr && size >DEFAULT_MEMSIZE ) -tst_set_max_runtime (32 * (size /DEFAULT_MEMSIZE )); +tst_set_runtime (32 * (size /DEFAULT_MEMSIZE )); }static struct tst_test test = {
testcases/kernel/mem/ksm/ksm02.c static struct tst_test test = { · line 121
Quoted 7 lines
testcases/kernel/mem/ksm/ksm02.c +1
-1@@ -116,7 +116,7 @@ static struct tst_test test = {NULL }, .test_all = verify_ksm, - .max_runtime = 32, + .runtime = 32, .needs_cgroup_ctrls = (const char *const []){ "cpuset", NULL }, };
And here as well, this should set timeout and call tst_set_timeout()
Quoted 14 lines
testcases/kernel/mem/ksm/ksm04.c +1
-1@@ -74,7 +74,7 @@ static void setup(void)SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());if (opt_sizestr && size >DEFAULT_MEMSIZE ) -tst_set_max_runtime (32 * (size /DEFAULT_MEMSIZE )); +tst_set_runtime (32 * (size /DEFAULT_MEMSIZE )); }static struct tst_test test = {
testcases/kernel/mem/ksm/ksm04.c static struct tst_test test = { · line 109
Quoted 8 lines
testcases/kernel/mem/ksm/ksm04.c +1
-1@@ -103,7 +103,7 @@ static struct tst_test test = {NULL }, .test_all = verify_ksm, - .max_runtime = 32, + .runtime = 32, .needs_cgroup_ctrls = (const char *const []){"memory" ,"cpuset" ,NULL },
Here as well.
Apart from the few tests that I think need tst_set_timeout() instead of tst_set_runtime() this looks good to me. Thanks a lot for doing this!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/4 lib: add tst_set_timeout for reset entire timeout
In reply to Li Wang--- doc/old/C-Test-API.asciidoc | 9 +++++++++ include/tst_test.h | 5 +++++ lib/tst_test.c | 13 +++++++++++++ 3 files changed, 27 insertions(+)
doc/old/C-Test-API.asciidoc +9 -0
@@ -402,6 +402,15 @@ Returns string describing the status as returned by 'wait()'. WARNING: This function is not thread safe. +[source,c] +------------------------------------------------------------------------------- +void tst_set_timeout(int timeout); +------------------------------------------------------------------------------- + +Allows for setting the entire timeout dynamically during the test setup(). The +timeout is specified in seconds and represents the total time allowed for a single +test iteration, including setup, runtime, and teardown phases. + [source,c] ------------------------------------------------------------------------------- void tst_set_runtime(int runtime);
include/tst_test.h +5 -0
@@ -675,6 +675,11 @@ void tst_reinit(void);*/ int tst_run_script (const char *script_name,char *const params[]); +/* +* Sets entire timeout in seconds. +*/ +void tst_set_timeout (int timeout); +unsigned int tst_multiply_timeout (unsigned int timeout);/*
lib/tst_test.c +13 -0
@@ -1729,6 +1729,19 @@ static void set_overall_timeout(void) results->overall_time % 60); } +void tst_set_timeout (int timeout) +{ +int timeout_adj =DEFAULT_TIMEOUT + timeout; + + results->overall_time =tst_multiply_timeout (timeout_adj) + results->runtime; + +tst_res (TINFO ,"Overall timeout per run is %uh %02um %02us" , + results->overall_time/3600 , (results->overall_time%3600 )/60 , + results->overall_time %60 ); + +heartbeat (); +} +void tst_set_runtime (int runtime) { results->runtime =multiply_runtime (runtime);
Signature · 5 lines
2.47.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/4] lib: add tst_set_timeout for reset entire timeout
Hi!
Looks good, however I would just ammended it to the first commit so that tests that needs to be converted to tst_set_timeout() can be converted correctly from the beginning.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/4 set_mempolicy01: make use of tst_set_timeout
In reply to Li Wang--- testcases/kernel/syscalls/set_mempolicy/set_mempolicy01.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
testcases/kernel/syscalls/set_mempolicy/set_mempolicy01.c +3 -3
@@ -41,9 +41,9 @@ static void setup(void)* has multiple NUMA nodes, the test matrix combination grows exponentially * and bring about test time to increase extremely fast. * -* Here reset the maximum runtime according to the NUMA nodes. +* Here reset the entire timeout according to the NUMA nodes. */ -tst_set_runtime (test.runtime * (1 << nodes->cnt/16 )); +tst_set_timeout (test.timeout * (1 << nodes->cnt/16 )); }static void cleanup (void )
@@ -119,7 +119,7 @@ static struct tst_test test = { .tcnt = 2, .forks_child = 1, .needs_checkpoints = 1, - .runtime = 600, + .timeout = 600, };#else
Signature · 5 lines
2.47.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 3/4] set_mempolicy01: make use of tst_set_timeout
Hi!
Same here, looks good but I would have ammended that to the first commit.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 3/4] set_mempolicy01: make use of tst_set_timeout
Quoted 4 lines · Cyril Hrubis
Hi!
Same here, looks good but I would have ammended that to the first commit.
Sure, I can squash them into the first patch.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/4 readahead02: reset timeout based the IO test elapsed
In reply to Li Wang--- testcases/kernel/syscalls/readahead/readahead02.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/readahead/readahead02.c +4 -4
@@ -321,16 +321,16 @@ static void test_readahead(unsigned int n)/* * The time consuming of readahead quite depending on the platform IO -* speed, sometime test timeout when the default runtime is used up. +* speed, sometime test timed out when the default timeout is used up. * * readahead02.c:221: TINFO: Test #2: POSIX_FADV_WILLNEED on file * readahead02.c:285: TINFO: read_testfile(0) took: 26317623 usec * readahead02.c:286: TINFO: read_testfile(1) took: 26101484 usec * -* Here raise the maximum runtime dynamically. +* Here extend the entire timeout dynamically. */ if ((tc+1 )->readahead) -tst_set_runtime (test.runtime + (usec + usec_ra) /1000000 ); +tst_set_timeout (test.timeout + (usec + usec_ra) /1000000 ); }
@@ -422,7 +422,7 @@ static struct tst_test test = { }, .test = test_readahead, .tcnt = ARRAY_SIZE(tcases), - .runtime = 30, + .timeout = 30, .tags = (const struct tst_tag []) { {"linux-git" ,"b833a3660394" }, {"linux-git" ,"5b910bd615ba" },
Signature · 5 lines
2.47.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 4/4] readahead02: reset timeout based the IO test elapsed
Note: Patch 4/4 need to be rewirten.
If go with Li Wang's .runtime thought, just ignore this patch should be ok.
If go with Cryil's suggestion, need changes to:
testcases/kernel/syscalls/readahead/readahead02.c +0 -3
@@ -318,19 +318,6 @@ static void test_readahead(unsigned int n)tst_res (TCONF ,"Page cache on your system is too small " "to hold whole testfile." ); } - -/* -* The time consuming of readahead quite depending on the platform
IO
- * speed, sometime test timeout when the default runtime is used up. - * - * readahead02.c:221: TINFO: Test #2: POSIX_FADV_WILLNEED on file - * readahead02.c:285: TINFO: read_testfile(0) took: 26317623 usec - * readahead02.c:286: TINFO: read_testfile(1) took: 26101484 usec - * - * Here raise the maximum runtime dynamically. - */
- if ((tc+1)->readahead)
- tst_set_runtime(test.runtime + (usec + usec_ra) / 1000000);
}
@@ -422,7 +409,7 @@ static struct tst_test test = {
},
.test = test_readahead,
.tcnt = ARRAY_SIZE(tcases),
- .runtime = 30,
+ .timeout = 60, // or another value measured on slow HW
.tags = (const struct tst_tag[]) {
{"linux-git", "b833a3660394"},
{"linux-git", "5b910bd615ba"},Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 34 lines · Li Wang
This patch series introduces a restructured approach to managing timeouts and runtime limits in the LTP framework. The changes aim to simplify timeout handling, improve clarity, and provide better separation between the phases of a test (setup, execution, and cleanup).
The main updates include refining the description and usage of .timeout, deprecating
TST_UNLIMITED_RUNTIME, and introducing thetst_set_timeout()function. Additionally, test cases that previously relied on .max_runtime have been updated to adopt the revised logic, either by moving to .timeout directly or transitioning to .runtime depending on their behavior.The series ends with an update to the
set_mempolicy01test, demonstrating the use oftst_set_timeout()to determine an upper bound for its execution.CI job: https://github.com/wangli5665/ltp/actions/runs/12683826906/
Major changes V1 to V2:
* Refined the description of .timeout usage and its relationship with
.runtime.* Moved .max_runtime to .timeout directly for tests where runtime is not
explicitly used.* Transitioned .max_runtime to .runtime for tests that call
tst_remaining_runtime()
or use thefuzzy_synclibrary.* Added the
tst_set_timeout()function to allow test cases to set the
overall
timeout dynamically, particularly useful for tests that aim to
determine
upper execution bounds.
Quoted 8 lines
* Updated
set_mempolicy01to make use oftst_set_timeout().Li Wang (3):
lib: redefine the overall timeout logic of test
lib: addtst_set_timeoutfor reset entire timeout
set_mempolicy01: make use oftst_set_timeout
Note:
Seems I forgot to update the cover-letter title and add the 4/4 patch, but that is not a big deal, it already covers the major changes there.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp