public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/4] lib: add tst_set_timeout for reset entire timeout
Date: Thu,  9 Jan 2025 12:55:30 +0800	[thread overview]
Message-ID: <20250109045532.43017-3-liwang@redhat.com> (raw)
In-Reply-To: <20250109045532.43017-1-liwang@redhat.com>

Signed-off-by: Li Wang <liwang@redhat.com>
---
 doc/old/C-Test-API.asciidoc |  9 +++++++++
 include/tst_test.h          |  5 +++++
 lib/tst_test.c              | 13 +++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/doc/old/C-Test-API.asciidoc b/doc/old/C-Test-API.asciidoc
index d4e0276e4..fe9904439 100644
--- a/doc/old/C-Test-API.asciidoc
+++ b/doc/old/C-Test-API.asciidoc
@@ -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);
diff --git a/include/tst_test.h b/include/tst_test.h
index 8df05b9bb..2ddfde5b4 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -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);
 
 /*
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 486df6cd7..43583e2f9 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -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);
-- 
2.47.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2025-01-09  4:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09  4:55 [LTP] [PATCH v2 0/3] Refine overall timeout and runtime management in LTP Li Wang
2025-01-09  4:55 ` [LTP] [PATCH v2 1/4] lib: redefine the overall timeout logic of test Li Wang
2025-01-09  9:53   ` Cyril Hrubis
2025-01-09  4:55 ` Li Wang [this message]
2025-01-09 10:26   ` [LTP] [PATCH v2 2/4] lib: add tst_set_timeout for reset entire timeout Cyril Hrubis
2025-01-09  4:55 ` [LTP] [PATCH v2 3/4] set_mempolicy01: make use of tst_set_timeout Li Wang
2025-01-09 10:26   ` Cyril Hrubis
2025-01-09 10:33     ` Li Wang
2025-01-09  4:55 ` [LTP] [PATCH v2 4/4] readahead02: reset timeout based the IO test elapsed Li Wang
2025-01-09  9:03   ` Li Wang
2025-01-09  5:02 ` [LTP] [PATCH v2 0/3] Refine overall timeout and runtime management in LTP Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250109045532.43017-3-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox