[LTP] [PATCH] lib: ensure multiply_runtime() returns at least 1 second

Li Wang liwang@redhat.com
Fri Jun 20 09:30:00 CEST 2025


This patch introduces support for fractional `LTP_RUNTIME_MUL` values
in the range (0, 1], allowing fine-grained control over test runtimes.
For example, setting `LTP_RUNTIME_MUL=0.1` can reduce a 300s test
to just 30s, which helps fit CI execution within 40 minutes.

To avoid skipping tests with low `.runtime` (e.g. nice05 with `.runtime=3`),
this patch also modifies `multiply_runtime()` to always return at least 1.
This ensures that even after floating-point multiplication, a test is never
silently skipped due to runtime being rounded to zero.

Follow-up: a6a369c5ee ("lib: redefine the overall timeout logic of test")
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Ian Wienand <iwienand@redhat.com>
---
 lib/tst_test.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 495e022f7..467299e37 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -626,11 +626,14 @@ static void parse_mul(float *mul, const char *env_name, float min, float max)
 
 static int multiply_runtime(unsigned int runtime)
 {
+	int adj;
 	static float runtime_mul = -1;
 
 	parse_mul(&runtime_mul, "LTP_RUNTIME_MUL", 0.0099, 100);
 
-	return runtime * runtime_mul;
+	adj = runtime * runtime_mul;
+
+	return adj > 0 ? adj : 1;
 }
 
 static struct option {
@@ -662,7 +665,7 @@ static void print_help(void)
 	fprintf(stderr, "LTP_SINGLE_FS_TYPE       Specifies filesystem instead all supported (for .all_filesystems)\n");
 	fprintf(stderr, "LTP_FORCE_SINGLE_FS_TYPE Testing only. The same as LTP_SINGLE_FS_TYPE but ignores test skiplist.\n");
 	fprintf(stderr, "LTP_TIMEOUT_MUL          Timeout multiplier (must be a number >=1)\n");
-	fprintf(stderr, "LTP_RUNTIME_MUL          Runtime multiplier (must be a number >=1)\n");
+	fprintf(stderr, "LTP_RUNTIME_MUL          Runtime multiplier (must be a number > 0)\n");
 	fprintf(stderr, "LTP_VIRT_OVERRIDE        Overrides virtual machine detection (values: \"\"|kvm|microsoft|xen|zvm)\n");
 	fprintf(stderr, "TMPDIR                   Base directory for template directory (for .needs_tmpdir, default: %s)\n", TEMPDIR);
 	fprintf(stderr, "\n");
-- 
2.49.0



More information about the ltp mailing list