[LTP] [RFC] [PATCH] syscalls/timer_tests: Hardcode runtime
Cyril Hrubis
chrubis@suse.cz
Tue Jun 14 13:57:10 CEST 2022
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.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
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(-)
diff --git a/include/tst_timer_test.h b/include/tst_timer_test.h
index b825a4d1a..689e2eea7 100644
--- a/include/tst_timer_test.h
+++ b/include/tst_timer_test.h
@@ -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 */
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index ef9b24d11..593917f40 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -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)
diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c
index feb3e4791..544884e9a 100644
--- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c
+++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep02.c
@@ -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,
};
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
index 2ad1a6abc..064231d9d 100644
--- a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c
@@ -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,
};
diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c
index d2c0b6ef4..7bd45498e 100644
--- a/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c
+++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait02.c
@@ -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,
};
diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait04.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait04.c
index dc62e9202..44b957ee0 100644
--- a/testcases/kernel/syscalls/epoll_wait/epoll_wait04.c
+++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait04.c
@@ -68,4 +68,5 @@ static struct tst_test test = {
.test_all = run,
.setup = setup,
.cleanup = cleanup,
+ .max_runtime = TST_TIMER_TEST_RUNTIME,
};
diff --git a/testcases/kernel/syscalls/futex/futex_wait05.c b/testcases/kernel/syscalls/futex/futex_wait05.c
index 8fad5d858..b80832054 100644
--- a/testcases/kernel/syscalls/futex/futex_wait05.c
+++ b/testcases/kernel/syscalls/futex/futex_wait05.c
@@ -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,
};
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep01.c b/testcases/kernel/syscalls/nanosleep/nanosleep01.c
index eaacb89fa..e0045662c 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep01.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep01.c
@@ -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,
};
diff --git a/testcases/kernel/syscalls/poll/poll02.c b/testcases/kernel/syscalls/poll/poll02.c
index c0665927b..30026e7d0 100644
--- a/testcases/kernel/syscalls/poll/poll02.c
+++ b/testcases/kernel/syscalls/poll/poll02.c
@@ -55,4 +55,5 @@ static struct tst_test test = {
.sample = sample_fn,
.setup = setup,
.cleanup = cleanup,
+ .max_runtime = TST_TIMER_TEST_RUNTIME,
};
diff --git a/testcases/kernel/syscalls/prctl/prctl09.c b/testcases/kernel/syscalls/prctl/prctl09.c
index 07ce57063..8c22d95dd 100644
--- a/testcases/kernel/syscalls/prctl/prctl09.c
+++ b/testcases/kernel/syscalls/prctl/prctl09.c
@@ -44,4 +44,5 @@ static struct tst_test test = {
.setup = setup,
.scall = "prctl()",
.sample = sample_fn,
+ .max_runtime = TST_TIMER_TEST_RUNTIME,
};
diff --git a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
index 5b2b8b3ba..e2381bc61 100644
--- a/testcases/kernel/syscalls/pselect/pselect01.c
+++ b/testcases/kernel/syscalls/pselect/pselect01.c
@@ -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,
};
diff --git a/testcases/kernel/syscalls/select/select02.c b/testcases/kernel/syscalls/select/select02.c
index 784ec9211..5e51951e6 100644
--- a/testcases/kernel/syscalls/select/select02.c
+++ b/testcases/kernel/syscalls/select/select02.c
@@ -62,4 +62,5 @@ static struct tst_test test = {
.setup = setup,
.test_variants = TEST_VARIANTS,
.cleanup = cleanup,
+ .max_runtime = TST_TIMER_TEST_RUNTIME,
};
--
2.35.1
More information about the ltp
mailing list