[LTP] [RFC PATCH] tst_test: Add flags to control runtime scaling in timing sensitive tests
Li Wang
liwang@redhat.com
Mon Jun 23 11:12:23 CEST 2025
Some tests, such as those using fuzzy synchronization or probabilistic triggers
(e.g. preadv203), require sufficient runtime to collect meaningful results.
These tests often rely on thresholds like `fzsync_pair.min_samples`, which must
be met during the runtime window.
When LTP_RUNTIME_MUL is set to a value < 1.0 (commonly in CI environments),
tests may run for too short a time, failing to gather enough samples and
silently producing false negatives or unstable results.
This patch introduces the following test flags in `enum tst_flag` to provide
fine-grained control over runtime and timeout scaling:
- TST_NO_RUNTIME_MUL:
Ignore LTP_RUNTIME_MUL and use the original .runtime value.
- TST_NO_TIMEOUT_MUL:
Ignore LTP_TIMEOUT_MUL and use the original .timeout value.
- TST_NO_FRACTIONAL_RUNTIME_MUL:
If LTP_RUNTIME_MUL is less than 1.0, round it up to 1.0 to preserve
intended test duration.
This helps ensure that timing sensitive tests are not impacted by externally
applied runtime reductions in CI or developer environments.
Example usage:
.flags = TST_NO_RUNTIME_MUL | TST_NO_TIMEOUT_MUL,
Follow-up: https://lists.linux.it/pipermail/ltp/2025-June/043960.html
Signed-off-by: Li Wang <liwang@redhat.com>
---
Notes:
This patch also introduces two additional flags:
- TST_NO_RUNTIME_MUL
- TST_NO_TIMEOUT_MUL
These two flags are not currently used by any tests, but are included as
examples of how the flags mechanism can be extended in the future to support
more control scenarios.
Or, maybe we can drop them. I want to get suggestions here.
include/tst_test.h | 24 +++++++++++++++++++
lib/newlib_tests/tst_fuzzy_sync01.c | 1 +
lib/newlib_tests/tst_fuzzy_sync02.c | 1 +
lib/tst_test.c | 10 ++++++++
testcases/cve/cve-2016-7117.c | 1 +
testcases/kernel/syscalls/preadv2/preadv203.c | 1 +
6 files changed, 38 insertions(+)
diff --git a/include/tst_test.h b/include/tst_test.h
index 6fd8cbae3..72470d40b 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -291,6 +291,26 @@ struct tst_fs {
const char *min_kver;
};
+/**
+ * enum tst_flag - Optional flags to control test behavior.
+ * These flags can be set in the .flags field of struct tst_test.
+ *
+ * @TST_NO_RUNTIME_MUL:
+ * Ignore the value of LTP_RUNTIME_MUL and use the unscaled runtime.
+ *
+ * @TST_NO_TIMEOUT_MUL:
+ * Ignore the value of LTP_TIMEOUT_MUL and use the unscaled timeout.
+ *
+ * @TST_NO_FRACTIONAL_RUNTIME_MUL:
+ * If LTP_RUNTIME_MUL is less than 1.0, ignore it (treat as 1.0).
+ * This prevents runtimes from being scaled down too low.
+ */
+enum tst_flag {
+ TST_NO_RUNTIME_MUL = 1 << 0,
+ TST_NO_TIMEOUT_MUL = 1 << 1,
+ TST_NO_FRACTIONAL_RUNTIME_MUL = 1 << 2,
+};
+
/**
* struct tst_test - A test description.
*
@@ -516,6 +536,8 @@ struct tst_fs {
*
* @tags: A {} terminated array of test tags. See struct tst_tag for details.
*
+ * @flags: Bitmask of enum tst_flag values to control runtime behavior.
+ *
* @needs_cmds: A NULL terminated array of commands required for the test to run.
*
* @needs_cgroup_ver: If set the test will run only if the specified cgroup
@@ -608,6 +630,8 @@ struct tst_fs {
const struct tst_tag *tags;
+ unsigned int flags;
+
const char *const *needs_cmds;
const enum tst_cg_ver needs_cgroup_ver;
diff --git a/lib/newlib_tests/tst_fuzzy_sync01.c b/lib/newlib_tests/tst_fuzzy_sync01.c
index b1390f460..a527ba5eb 100644
--- a/lib/newlib_tests/tst_fuzzy_sync01.c
+++ b/lib/newlib_tests/tst_fuzzy_sync01.c
@@ -247,4 +247,5 @@ static struct tst_test test = {
.setup = setup,
.cleanup = cleanup,
.runtime = 150,
+ .flags = TST_NO_FRACTIONAL_RUNTIME_MUL,
};
diff --git a/lib/newlib_tests/tst_fuzzy_sync02.c b/lib/newlib_tests/tst_fuzzy_sync02.c
index bc079f6ff..689a0b090 100644
--- a/lib/newlib_tests/tst_fuzzy_sync02.c
+++ b/lib/newlib_tests/tst_fuzzy_sync02.c
@@ -224,4 +224,5 @@ static struct tst_test test = {
.setup = setup,
.cleanup = cleanup,
.runtime = 150,
+ .flags = TST_NO_FRACTIONAL_RUNTIME_MUL,
};
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 467299e37..b2c2d8d64 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -631,6 +631,13 @@ static int multiply_runtime(unsigned int runtime)
parse_mul(&runtime_mul, "LTP_RUNTIME_MUL", 0.0099, 100);
+ if ((tst_test->flags & TST_NO_RUNTIME_MUL))
+ runtime_mul = 1;
+
+ if ((tst_test->flags & TST_NO_FRACTIONAL_RUNTIME_MUL) &&
+ (runtime_mul < 1.0))
+ runtime_mul = 1;
+
adj = runtime * runtime_mul;
return adj > 0 ? adj : 1;
@@ -1801,6 +1808,9 @@ unsigned int tst_multiply_timeout(unsigned int timeout)
if (tst_has_slow_kconfig())
timeout *= 4;
+ if ((tst_test->flags & TST_NO_TIMEOUT_MUL))
+ timeout_mul = 1;
+
return timeout * timeout_mul;
}
diff --git a/testcases/cve/cve-2016-7117.c b/testcases/cve/cve-2016-7117.c
index dbec2b28b..4000b9bc1 100644
--- a/testcases/cve/cve-2016-7117.c
+++ b/testcases/cve/cve-2016-7117.c
@@ -152,6 +152,7 @@ static struct tst_test test = {
.setup = setup,
.cleanup = cleanup,
.runtime = 60,
+ .flags = TST_NO_FRACTIONAL_RUNTIME_MUL,
.tags = (const struct tst_tag[]) {
{"linux-git", "34b88a68f26a"},
{"CVE", "2016-7117"},
diff --git a/testcases/kernel/syscalls/preadv2/preadv203.c b/testcases/kernel/syscalls/preadv2/preadv203.c
index 128e7ae34..c5f7edda1 100644
--- a/testcases/kernel/syscalls/preadv2/preadv203.c
+++ b/testcases/kernel/syscalls/preadv2/preadv203.c
@@ -284,5 +284,6 @@ static struct tst_test test = {
.mount_device = 1,
.all_filesystems = 1,
.runtime = 60,
+ .flags = TST_NO_FRACTIONAL_RUNTIME_MUL,
.needs_root = 1,
};
--
2.49.0
More information about the ltp
mailing list