From patchwork Mon Jun 10 05:41:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13691498 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05B4C1755C; Mon, 10 Jun 2024 05:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998063; cv=none; b=kpJd/HcR0Rwb0tTm9vfBqw5xZomg2csyjiCxdthezozq6sg2Ror+umucEvQQ6CuueZmCNH8gbfB5uvL+ln2xOUf8f5Yyw9jODz5ZLYHRxAGtuz1ZJQFbMpO2Hoh33A8Ya3I6/PZ5S2Fv67hQeQnMxOhiGigQzD8RR+d8it/z+Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998063; c=relaxed/simple; bh=DcQaDcNXN78UOD3DTHZRmfQSWi58vR/vSZYiDdiNKpE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W32Pb/KWkvzQ+JVz9m1aed1CmKw8+fbrz2WRA1POFO8jULheITMV2chqAEkonJ3MwRLIcntSxhcUnmfGxZ8jTYu2Cy/f57IlyqjqV8Ii1RTgodtBcJdXAJEXPO5CE0XpQbQltE7QfIwvFLgwhIQHrFNffNv9A+x1CsTHqNcPoMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=qCrunUUA; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="qCrunUUA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717998059; bh=DcQaDcNXN78UOD3DTHZRmfQSWi58vR/vSZYiDdiNKpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCrunUUA0kPOHFlokcKejxRdqoraW+HpDyjUM9gTLcBycZ9WXrLuF44Ufeugyed4n rPXILKVL2HFAHaGZ5/6LKBKcUKzl0h6IUK0ier2z0MOHm8yevmhF5KMlf91msNN5N+ xHwmypRgYRJCLLxdi5jmzELIgonWuu72uvD0kDrnufDK7Yu2Tteg35EqJD/1ubvMzY juM9eHF4vXxQ6PPivB+DIdhsjuIVHGXbIVQ7kn7f5+IYyyJJkwfmle7uHIrj4R9VEQ 2JMxpB4kY+u1bg5o0dWwspKRGq4SvqXcW2JGpRRayPVmzGBuu8vIsyFEbG1uDZM0Je eim9s275yG8Gg== Received: from deb.www.tendawifi.com (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 2957E3782159; Mon, 10 Jun 2024 05:40:56 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Vincenzo Frascino , Muhammad Usama Anjum , Tiezhu Yang , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel@collabora.com Subject: [PATCH v2 1/4] kselftests: vdso: vdso_test_clock_getres: conform test to TAP output Date: Mon, 10 Jun 2024 10:41:26 +0500 Message-Id: <20240610054129.1527389-2-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610054129.1527389-1-usama.anjum@collabora.com> References: <20240610054129.1527389-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Use kselftest_harness.h to conform to TAP as the number of tests depend on the available options at build time. The kselftest_harness makes the test easy to convert and presents better maintainability. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - Update commit message to include that kselftest_harness has been used to conform to TAP and why --- .../selftests/vDSO/vdso_test_clock_getres.c | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c index 38d46a8bf7cba..c1ede40521f05 100644 --- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c +++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c @@ -25,7 +25,7 @@ #include #include -#include "../kselftest.h" +#include "../kselftest_harness.h" static long syscall_clock_getres(clockid_t _clkid, struct timespec *_ts) { @@ -54,18 +54,8 @@ const char *vdso_clock_name[12] = { /* * This function calls clock_getres in vdso and by system call * with different values for clock_id. - * - * Example of output: - * - * clock_id: CLOCK_REALTIME [PASS] - * clock_id: CLOCK_BOOTTIME [PASS] - * clock_id: CLOCK_TAI [PASS] - * clock_id: CLOCK_REALTIME_COARSE [PASS] - * clock_id: CLOCK_MONOTONIC [PASS] - * clock_id: CLOCK_MONOTONIC_RAW [PASS] - * clock_id: CLOCK_MONOTONIC_COARSE [PASS] */ -static inline int vdso_test_clock(unsigned int clock_id) +static inline void vdso_test_clock(struct __test_metadata *_metadata, unsigned int clock_id) { struct timespec x, y; @@ -73,52 +63,60 @@ static inline int vdso_test_clock(unsigned int clock_id) clock_getres(clock_id, &x); syscall_clock_getres(clock_id, &y); - if ((x.tv_sec != y.tv_sec) || (x.tv_nsec != y.tv_nsec)) { - printf(" [FAIL]\n"); - return KSFT_FAIL; - } - - printf(" [PASS]\n"); - return KSFT_PASS; + ASSERT_EQ(0, ((x.tv_sec != y.tv_sec) || (x.tv_nsec != y.tv_nsec))); } -int main(int argc, char **argv) -{ - int ret = 0; - #if _POSIX_TIMERS > 0 #ifdef CLOCK_REALTIME - ret += vdso_test_clock(CLOCK_REALTIME); +TEST(clock_realtime) +{ + vdso_test_clock(_metadata, CLOCK_REALTIME); +} #endif #ifdef CLOCK_BOOTTIME - ret += vdso_test_clock(CLOCK_BOOTTIME); +TEST(clock_boottime) +{ + vdso_test_clock(_metadata, CLOCK_BOOTTIME); +} #endif #ifdef CLOCK_TAI - ret += vdso_test_clock(CLOCK_TAI); +TEST(clock_tai) +{ + vdso_test_clock(_metadata, CLOCK_TAI); +} #endif #ifdef CLOCK_REALTIME_COARSE - ret += vdso_test_clock(CLOCK_REALTIME_COARSE); +TEST(clock_realtime_coarse) +{ + vdso_test_clock(_metadata, CLOCK_REALTIME_COARSE); +} #endif #ifdef CLOCK_MONOTONIC - ret += vdso_test_clock(CLOCK_MONOTONIC); +TEST(clock_monotonic) +{ + vdso_test_clock(_metadata, CLOCK_MONOTONIC); +} #endif #ifdef CLOCK_MONOTONIC_RAW - ret += vdso_test_clock(CLOCK_MONOTONIC_RAW); +TEST(clock_monotonic_raw) +{ + vdso_test_clock(_metadata, CLOCK_MONOTONIC_RAW); +} #endif #ifdef CLOCK_MONOTONIC_COARSE - ret += vdso_test_clock(CLOCK_MONOTONIC_COARSE); +TEST(clock_monotonic_coarse) +{ + vdso_test_clock(_metadata, CLOCK_MONOTONIC_COARSE); +} #endif -#endif - if (ret > 0) - return KSFT_FAIL; +#endif /* _POSIX_TIMERS > 0 */ - return KSFT_PASS; -} +TEST_HARNESS_MAIN From patchwork Mon Jun 10 05:41:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13691499 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C51141865B; Mon, 10 Jun 2024 05:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998065; cv=none; b=laHeT6zxIwyKYLUWLp6JhdPpAoodnoScQA4K84K0REsIocSlxKC/oSUlh/8xI2ch0mV/Q4xrs8+jSOMXX6z0fdI3tZwvK68GrCbjnGvxhcU0PTAGsjFfkqAoKG63YQuMZChkk7+7WIalJiLGSDgO13yWZJS4qJtgMDKPY27Tcoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998065; c=relaxed/simple; bh=BDc4NM9WwjjXQJ0PTvdEt7g6tkleuvV0tTM1gFIYrc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TU5o6PIBzq9O6nlkFHlO99WN75RjnmuMiX7j/EmeaQSd2ARxXRqI7Fl2aHYOPpvXUrvEUpHQyXlT558/hIWZKHnjE+84VtPidn8dy61e/PHJiC7kfX5LTIxXFFtu/iR+cy57zcN4C5hkfCZ8UmqggNJfFsyXS+fudB9+UAcLM5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=LpY6lnli; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="LpY6lnli" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717998062; bh=BDc4NM9WwjjXQJ0PTvdEt7g6tkleuvV0tTM1gFIYrc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LpY6lnliBoAh8hxpZtpGhJP52VPeIo+8RJxR8qMFdLMCgMi9E4vebg7J4u2mopjS+ qw0tCy3T1D0sjjmJkgeQh4QgJB7xGm7LsGdG13sjqRFQrLhbzVOT/NwAFPjVTY/cNl LAmdF3a2TBl1VkxF5fheWIvyFfxiItGtf2b3ij9OrLs9N4GETYhbuAsr7nKJGqpjQX RDHB/GRU0gTEagupsOYWoxJJfyquUrQJ1j2jZX0q7O+wQwfuA5B8bXJHg9wVE4zcrA V1M6NoMrgG/25dbRjD0prttjs1nVsj2D9hoYNeIrunnGHJ3eRAleVTYHRReUX/5Ntw VBXWsSNocOXPw== Received: from deb.www.tendawifi.com (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 090723782172; Mon, 10 Jun 2024 05:40:59 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Vincenzo Frascino , Muhammad Usama Anjum , Tiezhu Yang , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel@collabora.com Subject: [PATCH v2 2/4] kselftests: vdso: vdso_test_correctness: conform test to TAP output Date: Mon, 10 Jun 2024 10:41:27 +0500 Message-Id: <20240610054129.1527389-3-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610054129.1527389-1-usama.anjum@collabora.com> References: <20240610054129.1527389-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum --- .../selftests/vDSO/vdso_test_correctness.c | 146 +++++++++--------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c index e691a3cf14911..688f83abb28eb 100644 --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c @@ -46,8 +46,6 @@ struct __kernel_timespec { /* max length of lines in /proc/self/maps - anything longer is skipped here */ #define MAPS_LINE_LEN 128 -int nerrs = 0; - typedef int (*vgettime_t)(clockid_t, struct timespec *); vgettime_t vdso_clock_gettime; @@ -97,7 +95,7 @@ static void *vsyscall_getcpu(void) fclose(maps); if (!found) { - printf("Warning: failed to find vsyscall getcpu\n"); + ksft_print_msg("Warning: failed to find vsyscall getcpu\n"); return NULL; } return (void *) (0xffffffffff600800); @@ -115,30 +113,29 @@ static void fill_function_pointers() vdso = dlopen("linux-gate.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); if (!vdso) { - printf("[WARN]\tfailed to find vDSO\n"); - return; + ksft_print_msg("failed to find vDSO\n"); + ksft_finished(); } vdso_getcpu = (getcpu_t)dlsym(vdso, name[4]); if (!vdso_getcpu) - printf("Warning: failed to find getcpu in vDSO\n"); + ksft_print_msg("Warning: failed to find getcpu in vDSO\n"); vgetcpu = (getcpu_t) vsyscall_getcpu(); vdso_clock_gettime = (vgettime_t)dlsym(vdso, name[1]); if (!vdso_clock_gettime) - printf("Warning: failed to find clock_gettime in vDSO\n"); + ksft_print_msg("Warning: failed to find clock_gettime in vDSO\n"); #if defined(VDSO_32BIT) vdso_clock_gettime64 = (vgettime64_t)dlsym(vdso, name[5]); if (!vdso_clock_gettime64) - printf("Warning: failed to find clock_gettime64 in vDSO\n"); + ksft_print_msg("Warning: failed to find clock_gettime64 in vDSO\n"); #endif vdso_gettimeofday = (vgtod_t)dlsym(vdso, name[0]); if (!vdso_gettimeofday) - printf("Warning: failed to find gettimeofday in vDSO\n"); - + ksft_print_msg("Warning: failed to find gettimeofday in vDSO\n"); } static long sys_getcpu(unsigned * cpu, unsigned * node, @@ -164,7 +161,7 @@ static inline int sys_gettimeofday(struct timeval *tv, struct timezone *tz) static void test_getcpu(void) { - printf("[RUN]\tTesting getcpu...\n"); + ksft_print_msg("Testing getcpu...\n"); for (int cpu = 0; ; cpu++) { cpu_set_t cpuset; @@ -199,18 +196,16 @@ static void test_getcpu(void) if (!ret_vsys && (cpu_vsys != cpu || node_vsys != node)) ok = false; - printf("[%s]\tCPU %u:", ok ? "OK" : "FAIL", cpu); + ksft_print_msg("CPU %u:", ok ? "OK" : "FAIL", cpu); if (!ret_sys) - printf(" syscall: cpu %u, node %u", cpu_sys, node_sys); + ksft_print_msg(" syscall: cpu %u, node %u", cpu_sys, node_sys); if (!ret_vdso) - printf(" vdso: cpu %u, node %u", cpu_vdso, node_vdso); + ksft_print_msg(" vdso: cpu %u, node %u", cpu_vdso, node_vdso); if (!ret_vsys) - printf(" vsyscall: cpu %u, node %u", cpu_vsys, - node_vsys); - printf("\n"); + ksft_print_msg(" vsyscall: cpu %u, node %u", cpu_vsys, node_vsys); + ksft_print_msg("\n"); - if (!ok) - nerrs++; + ksft_test_result(ok, "Succeeded\n"); } } @@ -259,19 +254,20 @@ static void test_one_clock_gettime(int clock, const char *name) struct timespec start, vdso, end; int vdso_ret, end_ret; - printf("[RUN]\tTesting clock_gettime for clock %s (%d)...\n", name, clock); + ksft_print_msg("Testing clock_gettime for clock %s (%d)...\n", name, clock); if (sys_clock_gettime(clock, &start) < 0) { if (errno == EINVAL) { vdso_ret = vdso_clock_gettime(clock, &vdso); if (vdso_ret == -EINVAL) { - printf("[OK]\tNo such clock.\n"); + ksft_test_result_skip("No such clock.\n"); } else { - printf("[FAIL]\tNo such clock, but __vdso_clock_gettime returned %d\n", vdso_ret); - nerrs++; + ksft_test_result_fail("No such clock, but __vdso_clock_gettime returned %d\n", + vdso_ret); } } else { - printf("[WARN]\t clock_gettime(%d) syscall returned error %d\n", clock, errno); + ksft_test_result_skip("clock_gettime(%d) syscall returned error %d\n", + clock, errno); } return; } @@ -280,30 +276,32 @@ static void test_one_clock_gettime(int clock, const char *name) end_ret = sys_clock_gettime(clock, &end); if (vdso_ret != 0 || end_ret != 0) { - printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n", - vdso_ret, errno); - nerrs++; + ksft_test_result_fail("vDSO returned %d, syscall errno=%d\n", vdso_ret, errno); return; } - printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n", - (unsigned long long)start.tv_sec, start.tv_nsec, - (unsigned long long)vdso.tv_sec, vdso.tv_nsec, - (unsigned long long)end.tv_sec, end.tv_nsec); + ksft_print_msg("\t%llu.%09ld %llu.%09ld %llu.%09ld\n", + (unsigned long long)start.tv_sec, start.tv_nsec, + (unsigned long long)vdso.tv_sec, vdso.tv_nsec, + (unsigned long long)end.tv_sec, end.tv_nsec); if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) { - printf("[FAIL]\tTimes are out of sequence\n"); - nerrs++; + ksft_test_result_fail("Times are out of sequence\n"); return; } - printf("[OK]\tTest Passed.\n"); + ksft_test_result_pass("Test Passed.\n"); } static void test_clock_gettime(void) { if (!vdso_clock_gettime) { - printf("[SKIP]\tNo vDSO, so skipping clock_gettime() tests\n"); + for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++) + ksft_test_result_skip("No vDSO, so skipping %s\n", clocknames[clock]); + + ksft_test_result_skip("No vDSO, so skipping clock_gettime() tests -1\n"); + ksft_test_result_skip("No vDSO, so skipping clock_gettime() tests min\n"); + ksft_test_result_skip("No vDSO, so skipping clock_gettime() tests max\n"); return; } @@ -321,19 +319,20 @@ static void test_one_clock_gettime64(int clock, const char *name) struct __kernel_timespec start, vdso, end; int vdso_ret, end_ret; - printf("[RUN]\tTesting clock_gettime64 for clock %s (%d)...\n", name, clock); + ksft_print_msg("Testing clock_gettime64 for clock %s (%d)...\n", name, clock); if (sys_clock_gettime64(clock, &start) < 0) { if (errno == EINVAL) { vdso_ret = vdso_clock_gettime64(clock, &vdso); if (vdso_ret == -EINVAL) { - printf("[OK]\tNo such clock.\n"); + ksft_test_result_skip("No such clock.\n"); } else { - printf("[FAIL]\tNo such clock, but __vdso_clock_gettime64 returned %d\n", vdso_ret); - nerrs++; + ksft_test_result_fail("No such clock, but __vdso_clock_gettime64 returned %d\n", + vdso_ret); } } else { - printf("[WARN]\t clock_gettime64(%d) syscall returned error %d\n", clock, errno); + ksft_test_result_skip("clock_gettime64(%d) syscall returned error %d\n", + clock, errno); } return; } @@ -342,30 +341,32 @@ static void test_one_clock_gettime64(int clock, const char *name) end_ret = sys_clock_gettime64(clock, &end); if (vdso_ret != 0 || end_ret != 0) { - printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n", - vdso_ret, errno); - nerrs++; + ksft_test_result_fail("vDSO returned %d, syscall errno=%d\n", vdso_ret, errno); return; } - printf("\t%llu.%09lld %llu.%09lld %llu.%09lld\n", - (unsigned long long)start.tv_sec, start.tv_nsec, - (unsigned long long)vdso.tv_sec, vdso.tv_nsec, - (unsigned long long)end.tv_sec, end.tv_nsec); + ksft_print_msg("\t%llu.%09lld %llu.%09lld %llu.%09lld\n", + (unsigned long long)start.tv_sec, start.tv_nsec, + (unsigned long long)vdso.tv_sec, vdso.tv_nsec, + (unsigned long long)end.tv_sec, end.tv_nsec); if (!ts64_leq(&start, &vdso) || !ts64_leq(&vdso, &end)) { - printf("[FAIL]\tTimes are out of sequence\n"); - nerrs++; + ksft_test_result_fail("Times are out of sequence\n"); return; } - printf("[OK]\tTest Passed.\n"); + ksft_test_result_pass("Test Passed.\n"); } static void test_clock_gettime64(void) { if (!vdso_clock_gettime64) { - printf("[SKIP]\tNo vDSO, so skipping clock_gettime64() tests\n"); + for (int clock = 0; clock < ARRAY_SIZE(clocknames); clock++) + ksft_test_result_skip("No vDSO, so skipping %s\n", clocknames[clock]); + + ksft_test_result_skip("No vDSO, so skipping clock_gettime() tests -1\n"); + ksft_test_result_skip("No vDSO, so skipping clock_gettime() tests min\n"); + ksft_test_result_skip("No vDSO, so skipping clock_gettime() tests max\n"); return; } @@ -384,14 +385,18 @@ static void test_gettimeofday(void) struct timezone sys_tz, vdso_tz; int vdso_ret, end_ret; - if (!vdso_gettimeofday) + if (!vdso_gettimeofday) { + ksft_test_result_skip("No vDSO, so skipping clock_gettime64() tests\n"); return; + } - printf("[RUN]\tTesting gettimeofday...\n"); + ksft_print_msg("Testing gettimeofday...\n"); + + /* Make sure that passing NULL for tz doesn't crash. */ + vdso_gettimeofday(&vdso, NULL); if (sys_gettimeofday(&start, &sys_tz) < 0) { - printf("[FAIL]\tsys_gettimeofday failed (%d)\n", errno); - nerrs++; + ksft_test_result_fail("sys_gettimeofday failed (%d)\n", errno); return; } @@ -399,39 +404,36 @@ static void test_gettimeofday(void) end_ret = sys_gettimeofday(&end, NULL); if (vdso_ret != 0 || end_ret != 0) { - printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n", - vdso_ret, errno); - nerrs++; + ksft_test_result_fail("vDSO returned %d, syscall errno=%d\n", vdso_ret, errno); return; } - printf("\t%llu.%06ld %llu.%06ld %llu.%06ld\n", - (unsigned long long)start.tv_sec, start.tv_usec, - (unsigned long long)vdso.tv_sec, vdso.tv_usec, - (unsigned long long)end.tv_sec, end.tv_usec); + ksft_print_msg("\t%llu.%06ld %llu.%06ld %llu.%06ld\n", + (unsigned long long)start.tv_sec, start.tv_usec, + (unsigned long long)vdso.tv_sec, vdso.tv_usec, + (unsigned long long)end.tv_sec, end.tv_usec); if (!tv_leq(&start, &vdso) || !tv_leq(&vdso, &end)) { - printf("[FAIL]\tTimes are out of sequence\n"); - nerrs++; + ksft_test_result_fail("Times are out of sequence\n"); + return; } if (sys_tz.tz_minuteswest == vdso_tz.tz_minuteswest && sys_tz.tz_dsttime == vdso_tz.tz_dsttime) { - printf("[OK]\ttimezones match: minuteswest=%d, dsttime=%d\n", - sys_tz.tz_minuteswest, sys_tz.tz_dsttime); + ksft_test_result_pass("timezones match: minuteswest=%d, dsttime=%d\n", + sys_tz.tz_minuteswest, sys_tz.tz_dsttime); } else { - printf("[FAIL]\ttimezones do not match\n"); - nerrs++; + ksft_test_result_fail("timezones do not match\n"); } - - /* And make sure that passing NULL for tz doesn't crash. */ - vdso_gettimeofday(&vdso, NULL); } int main(int argc, char **argv) { name = (const char **)&names[VDSO_NAMES]; + ksft_print_header(); + ksft_set_plan(7 + ARRAY_SIZE(clocknames) * 2 + sysconf(_SC_NPROCESSORS_ONLN)); + fill_function_pointers(); test_clock_gettime(); @@ -444,5 +446,5 @@ int main(int argc, char **argv) */ test_getcpu(); - return nerrs ? 1 : 0; + ksft_finished(); } From patchwork Mon Jun 10 05:41:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13691500 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F97A1CD15; Mon, 10 Jun 2024 05:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998067; cv=none; b=XpQuk42dmsM9fPIDPOXdw07fwSuNO98SR8VgFG5mjQZJn3hgBXxQ0DDoXZr0OAdI/sJ0bgZV2UYNN6STWdQyQ8f1NFtaA5S5pCn7yEyogmh4NkOiBFxy51DepIUk5hQhTZZtsiYwtGzbgiHKXcl6LUH6wz4hKSVLJmhlrAnroII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998067; c=relaxed/simple; bh=Vry0QvqeeNdr1PQL4qhBb23PCn3qOnl455a/3LEzC80=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OI44NQtSLmB3vqw5nXYKy+zx4tkPbovladG9Tz2ZCZt/FWJwp+5VsTSohii9NNZNjNFHrf5tBjyASw+dQ9tA6U13X2bAORKafx1yeGWwUXbn5ei5cvDX/1ivfgZJ1+JJw5UG/ojss0qGG62pgehzHglFpMcPrYyqtRzY9bv0Wqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=q76RmGfK; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="q76RmGfK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717998065; bh=Vry0QvqeeNdr1PQL4qhBb23PCn3qOnl455a/3LEzC80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q76RmGfK4nUxZqenLYS+bbg2mdYx6ByMcvR4NvhdTniTg4zilfNXkVAuUld/3j+SC dMNrC1v+nHOu56GpwE7v8GFgATKElKeKr4+GJzMLyAZfEhzpMQfDJd835z5cfHY+/8 8ceAYvn8CNynavxfikix3agiFWpeisSxCp/IYAwo8Hol/HZvBCM0FYzZxt2qbTr5k3 ZHNT5EL9iWvFaMwBkhgP/aqybMUH80kNpXCvlFzQkVZlWs1t2xP24M/LE8yW1N9uMV CHIsuS+edyTtQrGDgExKJRmh8x45Wunf0qHTxwNoPpKjBEzMUI8HE6lwGyiOghbPPf Z31JLNt/oblRA== Received: from deb.www.tendawifi.com (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id DE0783782009; Mon, 10 Jun 2024 05:41:02 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Vincenzo Frascino , Muhammad Usama Anjum , Tiezhu Yang , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel@collabora.com Subject: [PATCH v2 3/4] kselftests: vdso: vdso_test_getcpu: conform test to TAP output Date: Mon, 10 Jun 2024 10:41:28 +0500 Message-Id: <20240610054129.1527389-4-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610054129.1527389-1-usama.anjum@collabora.com> References: <20240610054129.1527389-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_getcpu.c b/tools/testing/selftests/vDSO/vdso_test_getcpu.c index b758f68c6c9c2..d8e247783057a 100644 --- a/tools/testing/selftests/vDSO/vdso_test_getcpu.c +++ b/tools/testing/selftests/vDSO/vdso_test_getcpu.c @@ -28,9 +28,12 @@ int main(int argc, char **argv) getcpu_t get_cpu; long ret; + ksft_print_header(); + ksft_set_plan(1); + sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); if (!sysinfo_ehdr) { - printf("AT_SYSINFO_EHDR is not present!\n"); + ksft_print_msg("AT_SYSINFO_EHDR is not present!\n"); return KSFT_SKIP; } @@ -38,17 +41,12 @@ int main(int argc, char **argv) get_cpu = (getcpu_t)vdso_sym(version, name[4]); if (!get_cpu) { - printf("Could not find %s\n", name[4]); + ksft_print_msg("Could not find %s\n", name[4]); return KSFT_SKIP; } ret = get_cpu(&cpu, &node, 0); - if (ret == 0) { - printf("Running on CPU %u node %u\n", cpu, node); - } else { - printf("%s failed\n", name[4]); - return KSFT_FAIL; - } + ksft_test_result(ret == 0, "Running on CPU %u node %u\n", cpu, node); - return 0; + ksft_finished(); } From patchwork Mon Jun 10 05:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13691501 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61E7C20B34; Mon, 10 Jun 2024 05:41:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998070; cv=none; b=qwAq1b+kQk5eVWQXqHZ/ttvnY6s3Q1gRTs1Twnpx7eTKH+/rZeJle9EZycUszg5gtLZsJmgoB3Prxss8iw6CMChL3StVvWMWylyUv4LRMx/DI//sM6JgTyoz8U6Ym+Jd+63V+VLOHn2U6zvLXhc1ICs1vT83K9SMl6ELnf+8wio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717998070; c=relaxed/simple; bh=ipCczr7QYa5QI1mKS580Ngx2AkBjsXEeRuQtWBoAi+0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qiQ/BJMAOGPMixLP5hH/gc+q23vyc6hT2pvntEgSM7TNW/CuittQNNCDoobPijCYyGOP+ojQaApQcxrzLBrbkT1oH/NXQBZwJrZpoLibCBABUV9rD1JeiRI8m7vWmeENGRF7b5koPnNlKbDFpulOJlRmv/Jl86DtLlsJ5WTaiWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=FfTpgH48; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="FfTpgH48" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717998067; bh=ipCczr7QYa5QI1mKS580Ngx2AkBjsXEeRuQtWBoAi+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FfTpgH48OTFMQWvJPP210pCXJj/fkW3rvBBFELUBcJntVuuHcLHDNM8huW5HjhDSN J5ENl9mSdRNzTKqsBkZnLuoJPs/xYFncLucQRdQr2+6kOi5n99OiBh/8m2M/PfIzNY 4H434f15+WSGpytIIIbAB5HALnfiY6X46HeJFFGKi+EK2jlPxJH9m83uyhVR3SSTpq y9nKR08fMYdB3tgsiJyS/Z8OrFStlKxgh9YW1A2PHaN6A/P75N3/q++Y8ewzREGYUR GD+Jpkp/AKlfQbZxyipJFOfNc3XUciaeTxPKFM9rOLr95fMrjvcIPZ1acPEN5ZFk2P SEMqGEZM1jRng== Received: from deb.www.tendawifi.com (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 8D296378217A; Mon, 10 Jun 2024 05:41:05 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Vincenzo Frascino , Muhammad Usama Anjum , Tiezhu Yang , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: kernel@collabora.com Subject: [PATCH v2 4/4] kselftests: vdso: vdso_test_gettimeofday: conform test to TAP output Date: Mon, 10 Jun 2024 10:41:29 +0500 Message-Id: <20240610054129.1527389-5-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610054129.1527389-1-usama.anjum@collabora.com> References: <20240610054129.1527389-1-usama.anjum@collabora.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum --- .../selftests/vDSO/vdso_test_gettimeofday.c | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c index ee4f1ca56a71a..2f42277b29ffe 100644 --- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c @@ -24,10 +24,13 @@ int main(int argc, char **argv) { const char *version = versions[VDSO_VERSION]; const char **name = (const char **)&names[VDSO_NAMES]; - unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); + + ksft_print_header(); + ksft_set_plan(1); + if (!sysinfo_ehdr) { - printf("AT_SYSINFO_EHDR is not present!\n"); + ksft_print_msg("AT_SYSINFO_EHDR is not present!\n"); return KSFT_SKIP; } @@ -38,20 +41,18 @@ int main(int argc, char **argv) gtod_t gtod = (gtod_t)vdso_sym(version, name[0]); if (!gtod) { - printf("Could not find %s\n", name[0]); + ksft_print_msg("Could not find %s\n", name[0]); return KSFT_SKIP; } struct timeval tv; long ret = gtod(&tv, 0); - if (ret == 0) { - printf("The time is %lld.%06lld\n", - (long long)tv.tv_sec, (long long)tv.tv_usec); - } else { - printf("%s failed\n", name[0]); - return KSFT_FAIL; - } + if (ret == 0) + ksft_test_result_pass("The time is %lld.%06lld\n", + (long long)tv.tv_sec, (long long)tv.tv_usec); + else + ksft_test_result_fail("%s failed\n", name[0]); - return 0; + ksft_finished(); }