syscalls/timer_tests: Hardcode runtime
RFC PATCH 1/1 syscalls/timer_tests: Hardcode runtime
This commit changes how default runtime is set for the timer testcases.
The main motivation behind this is to make sure that runtime is propagated to the metadata. The downside is that we have to add the runtime explicitly into each tst_test structure, but I still think that it's better this way.
--- include/tst_timer_test.h | 5 +++++ lib/tst_timer_test.c | 12 ++++++------ .../syscalls/clock_nanosleep/clock_nanosleep02.c | 1 + .../kernel/syscalls/epoll_pwait/epoll_pwait03.c | 1 + testcases/kernel/syscalls/epoll_wait/epoll_wait02.c | 1 + testcases/kernel/syscalls/epoll_wait/epoll_wait04.c | 1 + testcases/kernel/syscalls/futex/futex_wait05.c | 1 + testcases/kernel/syscalls/nanosleep/nanosleep01.c | 1 + testcases/kernel/syscalls/poll/poll02.c | 1 + testcases/kernel/syscalls/prctl/prctl09.c | 1 + testcases/kernel/syscalls/pselect/pselect01.c | 1 + testcases/kernel/syscalls/select/select02.c | 1 + 12 files changed, 21 insertions(+), 6 deletions(-)
include/tst_timer_test.h +5 -0
@@ -39,6 +39,11 @@void tst_timer_sample (void ); +/* +* By default the timer tests run for bit less than 9 seconds. +*/ +#define TST_TIMER_TEST_RUNTIME 10 +# ifdef TST_NO_DEFAULT_MAIN struct tst_test *tst_timer_test_setup (struct tst_test *test);# endif /* TST_NO_DEFAULT_MAIN */
lib/tst_timer_test.c +6 -6
@@ -387,6 +387,10 @@ static void timer_cleanup(void)cleanup (); } +/* +* If you change this table do not forget to update the TST_TIMER_TEST_RUNTIME +* in the corresponding header to be slightly larger than a sum of this table. +*/ static struct tst_timer_tcase { long long usec; unsigned int samples;
@@ -420,7 +424,6 @@ static struct tst_option options[] = {static void parse_timer_opts (void ) { -size_t i;long long runtime_us =0 ;if (str_sleep_time) {
@@ -449,12 +452,9 @@ static void parse_timer_opts(void) test->test_all = single_timer_test; test->test =NULL ; test->tcnt =0 ; - }else { -for (i =0 ; i <ARRAY_SIZE (tcases); i++) - runtime_us += tcases[i].usec * tcases[i].samples; - } -tst_set_max_runtime ((runtime_us + runtime_us/10 )/1000000 ); +tst_set_max_runtime ((runtime_us + runtime_us/10 )/1000000 ); + } }struct tst_test *tst_timer_test_setup (struct tst_test *timer_test)
testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c +1 -0
@@ -32,5 +32,6 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="clock_nanosleep()" , + .max_runtime =TST_TIMER_TEST_RUNTIME , .sample = sample_fn, };
testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c +1 -0
@@ -70,5 +70,6 @@ static struct tst_test test = { .sample = sample_fn, .setup = setup, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, .test_variants = TEST_VARIANTS, };
testcases/kernel/syscalls/epoll_wait/epoll_wait02.c +1 -0
@@ -68,6 +68,7 @@ static void cleanup(void)static struct tst_test test = { .scall ="epoll_wait()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , .setup = setup, .cleanup = cleanup, };
testcases/kernel/syscalls/epoll_wait/epoll_wait04.c +1 -0
@@ -68,4 +68,5 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, };
testcases/kernel/syscalls/futex/futex_wait05.c +1 -0
@@ -41,4 +41,5 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="futex_wait()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , };
testcases/kernel/syscalls/nanosleep/nanosleep01.c +1 -0
@@ -35,4 +35,5 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="nanosleep()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , };
testcases/kernel/syscalls/poll/poll02.c +1 -0
@@ -55,4 +55,5 @@ static struct tst_test test = { .sample = sample_fn, .setup = setup, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, };
testcases/kernel/syscalls/prctl/prctl09.c +1 -0
@@ -44,4 +44,5 @@ static struct tst_test test = { .setup = setup, .scall = "prctl()", .sample = sample_fn, + .max_runtime = TST_TIMER_TEST_RUNTIME, };
testcases/kernel/syscalls/pselect/pselect01.c +1 -0
@@ -34,4 +34,5 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="pselect()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , };
testcases/kernel/syscalls/select/select02.c +1 -0
@@ -62,4 +62,5 @@ static struct tst_test test = { .setup = setup, .test_variants = TEST_VARIANTS, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, };
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril, all,
[ sorry for duplicity in the reply ]
Quoted 6 lines
This commit changes how default runtime is set for the timer testcases.
The main motivation behind this is to make sure that runtime is propagated to the metadata. The downside is that we have to add the runtime explicitly into each
tst_teststructure, but I still think that it's better this way.
I'm not happy having to put .max_runtime = TST_TIMER_TEST_RUNTIME, into each tst_test structure, but as C does not allow to have a default value and assign it in runtime does not help to have it in docs, I agree. Others, WDYT?
Kind regards,
Petr
Quoted 174 lines
Signed-off-by Cyril Hrubis <[email protected]>--- include/tst_timer_test.h | 5 +++++ lib/tst_timer_test.c | 12 ++++++------ .../syscalls/clock_nanosleep/clock_nanosleep02.c | 1 + .../kernel/syscalls/epoll_pwait/epoll_pwait03.c | 1 + testcases/kernel/syscalls/epoll_wait/epoll_wait02.c | 1 + testcases/kernel/syscalls/epoll_wait/epoll_wait04.c | 1 + testcases/kernel/syscalls/futex/futex_wait05.c | 1 + testcases/kernel/syscalls/nanosleep/nanosleep01.c | 1 + testcases/kernel/syscalls/poll/poll02.c | 1 + testcases/kernel/syscalls/prctl/prctl09.c | 1 + testcases/kernel/syscalls/pselect/pselect01.c | 1 + testcases/kernel/syscalls/select/select02.c | 1 + 12 files changed, 21 insertions(+), 6 deletions(-)include/tst_timer_test.h +5
-0@@ -39,6 +39,11 @@void tst_timer_sample (void ); +/* +* By default the timer tests run for bit less than 9 seconds. +*/ +#define TST_TIMER_TEST_RUNTIME 10 +# ifdef TST_NO_DEFAULT_MAIN struct tst_test *tst_timer_test_setup (struct tst_test *test);# endif /* TST_NO_DEFAULT_MAIN */ lib/tst_timer_test.c +6
-6@@ -387,6 +387,10 @@ static void timer_cleanup(void)cleanup (); } +/* +* If you change this table do not forget to update the TST_TIMER_TEST_RUNTIME +* in the corresponding header to be slightly larger than a sum of this table. +*/ static struct tst_timer_tcase { long long usec; unsigned int samples;@@ -420,7 +424,6 @@ static struct tst_option options[] = {static void parse_timer_opts (void ) { -size_t i;long long runtime_us =0 ;if (str_sleep_time) {@@ -449,12 +452,9 @@ static void parse_timer_opts(void) test->test_all = single_timer_test; test->test =NULL ; test->tcnt =0 ; - }else { -for (i =0 ; i <ARRAY_SIZE (tcases); i++) - runtime_us += tcases[i].usec * tcases[i].samples; - } -tst_set_max_runtime ((runtime_us + runtime_us/10 )/1000000 ); +tst_set_max_runtime ((runtime_us + runtime_us/10 )/1000000 ); + } }struct tst_test *tst_timer_test_setup (struct tst_test *timer_test)testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c +1
-0@@ -32,5 +32,6 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="clock_nanosleep()" , + .max_runtime =TST_TIMER_TEST_RUNTIME , .sample = sample_fn, };testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c +1
-0@@ -70,5 +70,6 @@ static struct tst_test test = { .sample = sample_fn, .setup = setup, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, .test_variants = TEST_VARIANTS, };testcases/kernel/syscalls/epoll_wait/epoll_wait02.c +1
-0@@ -68,6 +68,7 @@ static void cleanup(void)static struct tst_test test = { .scall ="epoll_wait()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , .setup = setup, .cleanup = cleanup, };testcases/kernel/syscalls/epoll_wait/epoll_wait04.c +1
-0@@ -68,4 +68,5 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, };testcases/kernel/syscalls/futex/futex_wait05.c +1
-0@@ -41,4 +41,5 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="futex_wait()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , };testcases/kernel/syscalls/nanosleep/nanosleep01.c +1
-0@@ -35,4 +35,5 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="nanosleep()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , };testcases/kernel/syscalls/poll/poll02.c +1
-0@@ -55,4 +55,5 @@ static struct tst_test test = { .sample = sample_fn, .setup = setup, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, };testcases/kernel/syscalls/prctl/prctl09.c +1
-0@@ -44,4 +44,5 @@ static struct tst_test test = { .setup = setup, .scall = "prctl()", .sample = sample_fn, + .max_runtime = TST_TIMER_TEST_RUNTIME, };testcases/kernel/syscalls/pselect/pselect01.c +1
-0@@ -34,4 +34,5 @@ int sample_fn(int clk_id, long long usec)static struct tst_test test = { .scall ="pselect()" , .sample = sample_fn, + .max_runtime =TST_TIMER_TEST_RUNTIME , };testcases/kernel/syscalls/select/select02.c +1
-0@@ -62,4 +62,5 @@ static struct tst_test test = { .setup = setup, .test_variants = TEST_VARIANTS, .cleanup = cleanup, + .max_runtime = TST_TIMER_TEST_RUNTIME, };
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp