lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240610054129.1527389-2-usama.anjum@collabora.com>
Date: Mon, 10 Jun 2024 10:41:26 +0500
From: Muhammad Usama Anjum <usama.anjum@...labora.com>
To: Shuah Khan <shuah@...nel.org>,
	Vincenzo Frascino <vincenzo.frascino@....com>,
	Muhammad Usama Anjum <usama.anjum@...labora.com>,
	Tiezhu Yang <yangtiezhu@...ngson.cn>,
	linux-kselftest@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: kernel@...labora.com
Subject: [PATCH v2 1/4] kselftests: vdso: vdso_test_clock_getres: conform test to TAP output

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 <usama.anjum@...labora.com>
---
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 <unistd.h>
 #include <sys/syscall.h>
 
-#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
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ