All of lore.kernel.org
 help / color / mirror / Atom feed
From: keescook at chromium.org (Kees Cook)
Subject: [PATCH 1/2] selftests/harness: Allow test to configure timeout
Date: Thu, 23 May 2019 15:49:37 -0700	[thread overview]
Message-ID: <201905231549.0952C6CE@keescook> (raw)
In-Reply-To: <20190523224223.11054-2-alexandre.belloni@bootlin.com>

On Fri, May 24, 2019 at 12:42:22AM +0200, Alexandre Belloni wrote:
> Commit a745f7af3cbd ("selftests/harness: Add 30 second timeout per test")
> adds an hardcoded 30s timeout to all tests. Unfortunately, rtctest has two
> tests taking up to 60s. Allow for individual tests to define their own
> timeout.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni at bootlin.com>

Ah yes. Very nice; thanks!

Reviewed-by: Kees Cook <keescook at chromium.org>

> ---
>  tools/testing/selftests/kselftest_harness.h | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 941d9391377f..2067c6b0e8a1 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -62,6 +62,7 @@
>  #include <sys/wait.h>
>  #include <unistd.h>
>  
> +#define TEST_TIMEOUT_DEFAULT 30
>  
>  /* Utilities exposed to the test definitions */
>  #ifndef TH_LOG_STREAM
> @@ -169,7 +170,8 @@
>  	static void test_name(struct __test_metadata *_metadata); \
>  	static struct __test_metadata _##test_name##_object = \
>  		{ .name = "global." #test_name, \
> -		  .fn = &test_name, .termsig = _signal }; \
> +		  .fn = &test_name, .termsig = _signal, \
> +		  .timeout = TEST_TIMEOUT_DEFAULT, }; \
>  	static void __attribute__((constructor)) _register_##test_name(void) \
>  	{ \
>  		__register_test(&_##test_name##_object); \
> @@ -280,12 +282,15 @@
>   */
>  /* TODO(wad) register fixtures on dedicated test lists. */
>  #define TEST_F(fixture_name, test_name) \
> -	__TEST_F_IMPL(fixture_name, test_name, -1)
> +	__TEST_F_IMPL(fixture_name, test_name, -1, TEST_TIMEOUT_DEFAULT)
>  
>  #define TEST_F_SIGNAL(fixture_name, test_name, signal) \
> -	__TEST_F_IMPL(fixture_name, test_name, signal)
> +	__TEST_F_IMPL(fixture_name, test_name, signal, TEST_TIMEOUT_DEFAULT)
>  
> -#define __TEST_F_IMPL(fixture_name, test_name, signal) \
> +#define TEST_F_TIMEOUT(fixture_name, test_name, timeout) \
> +	__TEST_F_IMPL(fixture_name, test_name, -1, timeout)
> +
> +#define __TEST_F_IMPL(fixture_name, test_name, signal, tmout) \
>  	static void fixture_name##_##test_name( \
>  		struct __test_metadata *_metadata, \
>  		FIXTURE_DATA(fixture_name) *self); \
> @@ -307,6 +312,7 @@
>  		.name = #fixture_name "." #test_name, \
>  		.fn = &wrapper_##fixture_name##_##test_name, \
>  		.termsig = signal, \
> +		.timeout = tmout, \
>  	 }; \
>  	static void __attribute__((constructor)) \
>  			_register_##fixture_name##_##test_name(void) \
> @@ -632,6 +638,7 @@ struct __test_metadata {
>  	int termsig;
>  	int passed;
>  	int trigger; /* extra handler after the evaluation */
> +	int timeout;
>  	__u8 step;
>  	bool no_print; /* manual trigger when TH_LOG_STREAM is not available */
>  	struct __test_metadata *prev, *next;
> @@ -696,7 +703,7 @@ void __run_test(struct __test_metadata *t)
>  	t->passed = 1;
>  	t->trigger = 0;
>  	printf("[ RUN      ] %s\n", t->name);
> -	alarm(30);
> +	alarm(t->timeout);
>  	child_pid = fork();
>  	if (child_pid < 0) {
>  		printf("ERROR SPAWNING TEST CHILD\n");
> -- 
> 2.21.0
> 

-- 
Kees Cook

WARNING: multiple messages have this Message-ID (diff)
From: keescook@chromium.org (Kees Cook)
Subject: [PATCH 1/2] selftests/harness: Allow test to configure timeout
Date: Thu, 23 May 2019 15:49:37 -0700	[thread overview]
Message-ID: <201905231549.0952C6CE@keescook> (raw)
Message-ID: <20190523224937.qyTL2-8xkqlP3jU1PySRP3WNJA1zJTyZWIOJ07yTGBQ@z> (raw)
In-Reply-To: <20190523224223.11054-2-alexandre.belloni@bootlin.com>

On Fri, May 24, 2019@12:42:22AM +0200, Alexandre Belloni wrote:
> Commit a745f7af3cbd ("selftests/harness: Add 30 second timeout per test")
> adds an hardcoded 30s timeout to all tests. Unfortunately, rtctest has two
> tests taking up to 60s. Allow for individual tests to define their own
> timeout.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni at bootlin.com>

Ah yes. Very nice; thanks!

Reviewed-by: Kees Cook <keescook at chromium.org>

> ---
>  tools/testing/selftests/kselftest_harness.h | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 941d9391377f..2067c6b0e8a1 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -62,6 +62,7 @@
>  #include <sys/wait.h>
>  #include <unistd.h>
>  
> +#define TEST_TIMEOUT_DEFAULT 30
>  
>  /* Utilities exposed to the test definitions */
>  #ifndef TH_LOG_STREAM
> @@ -169,7 +170,8 @@
>  	static void test_name(struct __test_metadata *_metadata); \
>  	static struct __test_metadata _##test_name##_object = \
>  		{ .name = "global." #test_name, \
> -		  .fn = &test_name, .termsig = _signal }; \
> +		  .fn = &test_name, .termsig = _signal, \
> +		  .timeout = TEST_TIMEOUT_DEFAULT, }; \
>  	static void __attribute__((constructor)) _register_##test_name(void) \
>  	{ \
>  		__register_test(&_##test_name##_object); \
> @@ -280,12 +282,15 @@
>   */
>  /* TODO(wad) register fixtures on dedicated test lists. */
>  #define TEST_F(fixture_name, test_name) \
> -	__TEST_F_IMPL(fixture_name, test_name, -1)
> +	__TEST_F_IMPL(fixture_name, test_name, -1, TEST_TIMEOUT_DEFAULT)
>  
>  #define TEST_F_SIGNAL(fixture_name, test_name, signal) \
> -	__TEST_F_IMPL(fixture_name, test_name, signal)
> +	__TEST_F_IMPL(fixture_name, test_name, signal, TEST_TIMEOUT_DEFAULT)
>  
> -#define __TEST_F_IMPL(fixture_name, test_name, signal) \
> +#define TEST_F_TIMEOUT(fixture_name, test_name, timeout) \
> +	__TEST_F_IMPL(fixture_name, test_name, -1, timeout)
> +
> +#define __TEST_F_IMPL(fixture_name, test_name, signal, tmout) \
>  	static void fixture_name##_##test_name( \
>  		struct __test_metadata *_metadata, \
>  		FIXTURE_DATA(fixture_name) *self); \
> @@ -307,6 +312,7 @@
>  		.name = #fixture_name "." #test_name, \
>  		.fn = &wrapper_##fixture_name##_##test_name, \
>  		.termsig = signal, \
> +		.timeout = tmout, \
>  	 }; \
>  	static void __attribute__((constructor)) \
>  			_register_##fixture_name##_##test_name(void) \
> @@ -632,6 +638,7 @@ struct __test_metadata {
>  	int termsig;
>  	int passed;
>  	int trigger; /* extra handler after the evaluation */
> +	int timeout;
>  	__u8 step;
>  	bool no_print; /* manual trigger when TH_LOG_STREAM is not available */
>  	struct __test_metadata *prev, *next;
> @@ -696,7 +703,7 @@ void __run_test(struct __test_metadata *t)
>  	t->passed = 1;
>  	t->trigger = 0;
>  	printf("[ RUN      ] %s\n", t->name);
> -	alarm(30);
> +	alarm(t->timeout);
>  	child_pid = fork();
>  	if (child_pid < 0) {
>  		printf("ERROR SPAWNING TEST CHILD\n");
> -- 
> 2.21.0
> 

-- 
Kees Cook

WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Shuah Khan <shuah@kernel.org>,
	Jeffrin Thalakkottoor <jeffrin@rajagiritech.edu.in>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH 1/2] selftests/harness: Allow test to configure timeout
Date: Thu, 23 May 2019 15:49:37 -0700	[thread overview]
Message-ID: <201905231549.0952C6CE@keescook> (raw)
In-Reply-To: <20190523224223.11054-2-alexandre.belloni@bootlin.com>

On Fri, May 24, 2019 at 12:42:22AM +0200, Alexandre Belloni wrote:
> Commit a745f7af3cbd ("selftests/harness: Add 30 second timeout per test")
> adds an hardcoded 30s timeout to all tests. Unfortunately, rtctest has two
> tests taking up to 60s. Allow for individual tests to define their own
> timeout.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

Ah yes. Very nice; thanks!

Reviewed-by: Kees Cook <keescook@chromium.org>

> ---
>  tools/testing/selftests/kselftest_harness.h | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 941d9391377f..2067c6b0e8a1 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -62,6 +62,7 @@
>  #include <sys/wait.h>
>  #include <unistd.h>
>  
> +#define TEST_TIMEOUT_DEFAULT 30
>  
>  /* Utilities exposed to the test definitions */
>  #ifndef TH_LOG_STREAM
> @@ -169,7 +170,8 @@
>  	static void test_name(struct __test_metadata *_metadata); \
>  	static struct __test_metadata _##test_name##_object = \
>  		{ .name = "global." #test_name, \
> -		  .fn = &test_name, .termsig = _signal }; \
> +		  .fn = &test_name, .termsig = _signal, \
> +		  .timeout = TEST_TIMEOUT_DEFAULT, }; \
>  	static void __attribute__((constructor)) _register_##test_name(void) \
>  	{ \
>  		__register_test(&_##test_name##_object); \
> @@ -280,12 +282,15 @@
>   */
>  /* TODO(wad) register fixtures on dedicated test lists. */
>  #define TEST_F(fixture_name, test_name) \
> -	__TEST_F_IMPL(fixture_name, test_name, -1)
> +	__TEST_F_IMPL(fixture_name, test_name, -1, TEST_TIMEOUT_DEFAULT)
>  
>  #define TEST_F_SIGNAL(fixture_name, test_name, signal) \
> -	__TEST_F_IMPL(fixture_name, test_name, signal)
> +	__TEST_F_IMPL(fixture_name, test_name, signal, TEST_TIMEOUT_DEFAULT)
>  
> -#define __TEST_F_IMPL(fixture_name, test_name, signal) \
> +#define TEST_F_TIMEOUT(fixture_name, test_name, timeout) \
> +	__TEST_F_IMPL(fixture_name, test_name, -1, timeout)
> +
> +#define __TEST_F_IMPL(fixture_name, test_name, signal, tmout) \
>  	static void fixture_name##_##test_name( \
>  		struct __test_metadata *_metadata, \
>  		FIXTURE_DATA(fixture_name) *self); \
> @@ -307,6 +312,7 @@
>  		.name = #fixture_name "." #test_name, \
>  		.fn = &wrapper_##fixture_name##_##test_name, \
>  		.termsig = signal, \
> +		.timeout = tmout, \
>  	 }; \
>  	static void __attribute__((constructor)) \
>  			_register_##fixture_name##_##test_name(void) \
> @@ -632,6 +638,7 @@ struct __test_metadata {
>  	int termsig;
>  	int passed;
>  	int trigger; /* extra handler after the evaluation */
> +	int timeout;
>  	__u8 step;
>  	bool no_print; /* manual trigger when TH_LOG_STREAM is not available */
>  	struct __test_metadata *prev, *next;
> @@ -696,7 +703,7 @@ void __run_test(struct __test_metadata *t)
>  	t->passed = 1;
>  	t->trigger = 0;
>  	printf("[ RUN      ] %s\n", t->name);
> -	alarm(30);
> +	alarm(t->timeout);
>  	child_pid = fork();
>  	if (child_pid < 0) {
>  		printf("ERROR SPAWNING TEST CHILD\n");
> -- 
> 2.21.0
> 

-- 
Kees Cook

  reply	other threads:[~2019-05-23 22:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 22:42 [PATCH 0/2] kselftest: fix rtctest timeout alexandre.belloni
2019-05-23 22:42 ` Alexandre Belloni
2019-05-23 22:42 ` Alexandre Belloni
2019-05-23 22:42 ` [PATCH 1/2] selftests/harness: Allow test to configure timeout alexandre.belloni
2019-05-23 22:42   ` Alexandre Belloni
2019-05-23 22:42   ` Alexandre Belloni
2019-05-23 22:49   ` keescook [this message]
2019-05-23 22:49     ` Kees Cook
2019-05-23 22:49     ` Kees Cook
2019-05-23 22:42 ` [PATCH 2/2] selftests: rtc: rtctest: specify timeouts alexandre.belloni
2019-05-23 22:42   ` Alexandre Belloni
2019-05-23 22:42   ` Alexandre Belloni
2019-05-23 22:50   ` keescook
2019-05-23 22:50     ` Kees Cook
2019-05-23 22:50     ` Kees Cook
2019-05-23 22:57 ` [PATCH 0/2] kselftest: fix rtctest timeout shuah
2019-05-23 22:57   ` shuah
2019-05-23 22:57   ` shuah
2019-05-23 23:32   ` shuah
2019-05-23 23:32     ` shuah
2019-05-23 23:32     ` shuah

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=201905231549.0952C6CE@keescook \
    --to=unknown@example.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.