From patchwork Wed Jan 26 12:26:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 537032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB688C28CF5 for ; Wed, 26 Jan 2022 12:26:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241246AbiAZM0V (ORCPT ); Wed, 26 Jan 2022 07:26:21 -0500 Received: from foss.arm.com ([217.140.110.172]:36326 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241247AbiAZM0U (ORCPT ); Wed, 26 Jan 2022 07:26:20 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C76E0D6E; Wed, 26 Jan 2022 04:26:19 -0800 (PST) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C6AA23F793; Wed, 26 Jan 2022 04:26:18 -0800 (PST) From: Vincenzo Frascino To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vincenzo.frascino@arm.com, Shuah Khan , Andy Lutomirski , Thomas Gleixner , Cristian Marussi Subject: [PATCH] kselftest: Fix vdso_test_abi return status Date: Wed, 26 Jan 2022 12:26:08 +0000 Message-Id: <20220126122608.54061-1-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220126102723.23300-3-cristian.marussi@arm.com> References: <20220126102723.23300-3-cristian.marussi@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 Cc: Andy Lutomirski Cc: Thomas Gleixner Reported-by: Cristian Marussi Signed-off-by: Vincenzo Frascino --- 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; } From patchwork Wed Jan 26 10:27:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 537033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AA42C636C8 for ; Wed, 26 Jan 2022 10:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239913AbiAZK1t (ORCPT ); Wed, 26 Jan 2022 05:27:49 -0500 Received: from foss.arm.com ([217.140.110.172]:57884 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232519AbiAZK1k (ORCPT ); Wed, 26 Jan 2022 05:27:40 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EAE1C11D4; Wed, 26 Jan 2022 02:27:39 -0800 (PST) Received: from e120937-lin.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 23E173F766; Wed, 26 Jan 2022 02:27:38 -0800 (PST) From: Cristian Marussi To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: shuah@kernel.org, Cristian Marussi , Vincenzo Frascino Subject: [PATCH 2/5] kselftest: Fix vdso_test_time to pass on skips Date: Wed, 26 Jan 2022 10:27:20 +0000 Message-Id: <20220126102723.23300-3-cristian.marussi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220126102723.23300-1-cristian.marussi@arm.com> References: <20220126102723.23300-1-cristian.marussi@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When a vDSO symbol is not found, all the testcases in vdso_test_abi usually report a SKIP, which, in turn, is reported back to Kselftest as a PASS. Testcase vdso_test_time, instead, reporting a SKIP, causes the whole set of tests within vdso_test_abi to be considered FAIL when symbol is not found. Fix it reporting a PASS when vdso_test_time cannot find the vdso symbol. Cc: Vincenzo Frascino Signed-off-by: Cristian Marussi --- Seen as a failure on both a JUNO and a Dragonboard on both recent and old kernels/testruns: root@deb-buster-arm64:~# /opt/ksft/vDSO/vdso_test_abi [vDSO kselftest] VDSO_VERSION: LINUX_2.6.39 The time is 1637922136.675304 The time is 1637922136.675361000 The resolution is 0 1 clock_id: CLOCK_REALTIME [PASS] The time is 1927.760604900 The resolution is 0 1 clock_id: CLOCK_BOOTTIME [PASS] The time is 1637922136.675649700 The resolution is 0 1 clock_id: CLOCK_TAI [PASS] The time is 1637922136.672000000 The resolution is 0 4000000 clock_id: CLOCK_REALTIME_COARSE [PASS] The time is 1927.761005600 The resolution is 0 1 clock_id: CLOCK_MONOTONIC [PASS] The time is 1927.761132780 The resolution is 0 1 clock_id: CLOCK_MONOTONIC_RAW [PASS] The time is 1927.757093740 The resolution is 0 4000000 clock_id: CLOCK_MONOTONIC_COARSE [PASS] Could not find __kernel_time <<< This caused a FAIL as a whole root@deb-buster-arm64:~# echo $? 1 e.g.: https://lkft.validation.linaro.org/scheduler/job/2192570#L27778 --- tools/testing/selftests/vDSO/vdso_test_abi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c index 3d603f1394af..7dcc66d1cecf 100644 --- a/tools/testing/selftests/vDSO/vdso_test_abi.c +++ b/tools/testing/selftests/vDSO/vdso_test_abi.c @@ -90,8 +90,9 @@ static int vdso_test_time(void) (vdso_time_t)vdso_sym(version, name[2]); if (!vdso_time) { + /* Skip if symbol not found: consider skipped tests as passed */ printf("Could not find %s\n", name[2]); - return KSFT_SKIP; + return KSFT_PASS; } long ret = vdso_time(NULL);