public inbox for linux-kselftest@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Vincenzo Frascino <vincenzo.frascino@arm.com>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Shuah Khan <shuah@kernel.org>, Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Cristian Marussi <cristian.marussi@arm.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] kselftest: Fix vdso_test_abi return status
Date: Thu, 27 Jan 2022 16:18:09 -0700	[thread overview]
Message-ID: <5ea69341-73af-e741-7b5d-c161845583c9@linuxfoundation.org> (raw)
In-Reply-To: <20220126122608.54061-1-vincenzo.frascino@arm.com>

On 1/26/22 5:26 AM, Vincenzo Frascino wrote:
> vdso_test_abi contains a batch of tests that verify the validity of the
> vDSO ABI.
> 
> When a vDSO symbol is not found the relevant test is skipped reporting
> KSFT_SKIP. All the tests return values are then added in a single
> variable which is checked to verify failures. This approach can have
> side effects which result in reporting the wrong kselftest exit status.
> 
> Fix vdso_test_abi verifying the return code of each test separately.
> 
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Reported-by: Cristian Marussi <cristian.marussi@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>   tools/testing/selftests/vDSO/vdso_test_abi.c | 27 +++++++++++---------
>   1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c
> index 3d603f1394af..3a4efb91b9b2 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_abi.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
> @@ -184,10 +184,12 @@ static inline int vdso_test_clock(clockid_t clock_id)
>   	return ret0;
>   }
>   
> +#define VDSO_TESTS_MAX	9
> +
>   int main(int argc, char **argv)
>   {
>   	unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
> -	int ret;
> +	int ret[VDSO_TESTS_MAX] = {0};
>   
>   	if (!sysinfo_ehdr) {
>   		printf("AT_SYSINFO_EHDR is not present!\n");
> @@ -201,44 +203,45 @@ int main(int argc, char **argv)
>   
>   	vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
>   
> -	ret = vdso_test_gettimeofday();
> +	ret[0] = vdso_test_gettimeofday();
>   
>   #if _POSIX_TIMERS > 0
>   
>   #ifdef CLOCK_REALTIME
> -	ret += vdso_test_clock(CLOCK_REALTIME);
> +	ret[1] = vdso_test_clock(CLOCK_REALTIME);
>   #endif
>   
>   #ifdef CLOCK_BOOTTIME
> -	ret += vdso_test_clock(CLOCK_BOOTTIME);
> +	ret[2] = vdso_test_clock(CLOCK_BOOTTIME);
>   #endif
>   
>   #ifdef CLOCK_TAI
> -	ret += vdso_test_clock(CLOCK_TAI);
> +	ret[3] = vdso_test_clock(CLOCK_TAI);
>   #endif
>   
>   #ifdef CLOCK_REALTIME_COARSE
> -	ret += vdso_test_clock(CLOCK_REALTIME_COARSE);
> +	ret[4] = vdso_test_clock(CLOCK_REALTIME_COARSE);
>   #endif
>   
>   #ifdef CLOCK_MONOTONIC
> -	ret += vdso_test_clock(CLOCK_MONOTONIC);
> +	ret[5] = vdso_test_clock(CLOCK_MONOTONIC);
>   #endif
>   
>   #ifdef CLOCK_MONOTONIC_RAW
> -	ret += vdso_test_clock(CLOCK_MONOTONIC_RAW);
> +	ret[6] = vdso_test_clock(CLOCK_MONOTONIC_RAW);
>   #endif
>   
>   #ifdef CLOCK_MONOTONIC_COARSE
> -	ret += vdso_test_clock(CLOCK_MONOTONIC_COARSE);
> +	ret[7] = vdso_test_clock(CLOCK_MONOTONIC_COARSE);
>   #endif
>   
>   #endif
>   
> -	ret += vdso_test_time();
> +	ret[8] = vdso_test_time();
>   
> -	if (ret > 0)
> -		return KSFT_FAIL;
> +	for (int i = 0; i < VDSO_TESTS_MAX; i++)
> +		if (ret[i] == KSFT_FAIL)
> +			return KSFT_FAIL;
>   
>   	return KSFT_PASS;
>   }
> 

You can use the ksft_* counts interfaces for this instead of adding
counts here. ksft_test_result_*() can be used to increment the right
result counters and then print counts at the end.

Either if there is a failure in any of the tests it will be fail with
clear indication on which tests failed. vdso_test_clock() test for
example is reporting false positives by overriding the Skip return
with a pass.

thanks,
-- Shuah




  reply	other threads:[~2022-01-27 23:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26 10:27 [PATCH 0/5] Miscellaneous trivial fixes Cristian Marussi
2022-01-26 10:27 ` [PATCH 1/5] selftests: skip mincore.check_file_mmap when fs lacks needed support Cristian Marussi
2022-01-27 23:23   ` Shuah Khan
2022-01-26 10:27 ` [PATCH 2/5] kselftest: Fix vdso_test_time to pass on skips Cristian Marussi
2022-01-26 12:22   ` Vincenzo Frascino
2022-01-26 12:34     ` Cristian Marussi
2022-01-26 15:26       ` Vincenzo Frascino
2022-01-26 12:26   ` [PATCH] kselftest: Fix vdso_test_abi return status Vincenzo Frascino
2022-01-27 23:18     ` Shuah Khan [this message]
2022-01-28 11:09       ` Vincenzo Frascino
2022-01-27 23:02   ` [PATCH 2/5] kselftest: Fix vdso_test_time to pass on skips Shuah Khan
2022-01-26 10:27 ` [PATCH 3/5] selftests: openat2: Print also errno in failure messages Cristian Marussi
2022-01-27 23:11   ` Shuah Khan
2022-01-26 10:27 ` [PATCH 4/5] selftests: openat2: Add missing dependency in Makefile Cristian Marussi
2022-01-27 23:12   ` Shuah Khan
2022-01-26 10:27 ` [PATCH 5/5] selftests: openat2: Skip testcases that fail with EOPNOTSUPP Cristian Marussi
2022-01-27 23:13   ` Shuah Khan
2022-01-27 23:05 ` [PATCH 0/5] Miscellaneous trivial fixes Shuah Khan

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=5ea69341-73af-e741-7b5d-c161845583c9@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vincenzo.frascino@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox