[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0dbe701a-99c1-4606-915e-1f1c67802f64@linuxfoundation.org>
Date: Tue, 26 Mar 2024 13:28:41 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Shengyu Li <shengyu.li.evgeny@...il.com>, shuah@...nel.org
Cc: luto@...capital.net, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org, wad@...omium.org,
Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests/harness: Prevent infinite loop due to Assert in
FIXTURE_TEARDOWN
On 3/14/24 16:43, Shengyu Li wrote:
> This patch addresses an issue in the selftests/harness where an assertion within FIXTURE_TEARDOWN could trigger an infinite loop. The problem arises because the teardown procedure is meant to execute once, but the presence of failing assertions (ASSERT_EQ(0, 1)) leads to repeated attempts to execute teardown due to the long jump mechanism used by the harness for handling assertions.
>
> To resolve this, the patch ensures that the teardown process runs only once, regardless of assertion outcomes, preventing the infinite loop and allowing tests to fail.
>
Please make sure change log is formatted with 70-75 character
long lines.
Please include information on how you found this problem.
Send v2 with that change.
> Signed-off-by: Shengyu Li <shengyu.li.evgeny@...il.com>
> ---
> tools/testing/selftests/kselftest_harness.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index 4fd735e48ee7..230d62884885 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -383,6 +383,7 @@
> FIXTURE_DATA(fixture_name) self; \
> pid_t child = 1; \
> int status = 0; \
> + bool jmp = false; \
> memset(&self, 0, sizeof(FIXTURE_DATA(fixture_name))); \
> if (setjmp(_metadata->env) == 0) { \
> /* Use the same _metadata. */ \
> @@ -399,8 +400,10 @@
> _metadata->exit_code = KSFT_FAIL; \
> } \
> } \
> + else \
> + jmp = true; \
> if (child == 0) { \
> - if (_metadata->setup_completed && !_metadata->teardown_parent) \
> + if (_metadata->setup_completed && !_metadata->teardown_parent && !jmp) \
> fixture_name##_teardown(_metadata, &self, variant->data); \
> _exit(0); \
> } \
thanks,
-- Shuah
Powered by blists - more mailing lists