All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 5/5] y2038: testsuite/smokey/y2038: testcase for settime64 and gettime64
@ 2021-04-20  6:23 Song Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Song Chen @ 2021-04-20  6:23 UTC (permalink / raw)
  To: xenomai, florian.bezdeka; +Cc: chensong

From: chensong <chensong@tj.kylinos.cn>

new test case for clock_settime64 and clock_gettime64 and reorganize
run_2038.

If you want to trigger and verify y2038 problem, please be careful and
make sure it has no impact to your test device.

Signed-off-by: chensong <chensong@tj.kylinos.cn>

---
v3:
1, rename structs, variables
2, reorganize registration in run_y2038
3, remove unnecessary definitions

v4:
1, return run_y2038 to its original approach

v5:
1, smokey warning when clock_getime failed
---
 testsuite/smokey/y2038/syscall-tests.c | 77 +++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 2 deletions(-)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 1d61bbd..990e05c 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -114,10 +114,10 @@ static int test_sc_cobalt_sem_timedwait64(void)
 
 	/*
 	 * The semaphore is already exhausted, so calling again will validate
-	 * the provided timeout now. Providing an invalid adress has to deliver
+	 * the provided timeout now. Providing an invalid address has to deliver
 	 * EFAULT
 	 */
-	ret = syscall(code, &sem, (void*) 0xdeadbeefUL);
+	ret = syscall(code, &sem, (void *)0xdeadbeefUL);
 	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
 		return errno;
 
@@ -163,6 +163,71 @@ static int test_sc_cobalt_sem_timedwait64(void)
 	return 0;
 }
 
+static int test_sc_cobalt_clock_gettime64(void)
+{
+	long ret;
+	int code = __xn_syscode(sc_cobalt_clock_gettime64);
+	struct xn_timespec64 ts64;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = syscall(code, NULL, NULL);
+	if (ret == -1 && errno == ENOSYS) {
+		smokey_note("clock_gettime64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = syscall(code, CLOCK_REALTIME, (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Provide a valid 64bit timespec*/
+	ret = syscall(code, CLOCK_REALTIME, &ts64);
+	if (!smokey_assert(!ret))
+		return errno;
+
+	return 0;
+}
+
+static int test_sc_cobalt_clock_settime64(void)
+{
+	long ret;
+	int code = __xn_syscode(sc_cobalt_clock_settime64);
+	struct xn_timespec64 ts64;
+	struct timespec now;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = syscall(code, NULL, NULL);
+	if (ret == -1 && errno == ENOSYS) {
+		smokey_note("clock_settime64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = syscall(code, CLOCK_REALTIME, (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Provide a valid 64bit timespec*/
+	ret = clock_gettime(CLOCK_REALTIME, &now);
+	if (ret) {
+		smokey_warning("clock_gettime failed in cloc_settime64.");
+		return errno;
+	}
+
+	ts64.tv_sec  = now.tv_sec;
+	ts64.tv_nsec = now.tv_nsec;
+	ret = syscall(code, CLOCK_REALTIME, &ts64);
+	if (!smokey_assert(!ret))
+		return errno;
+
+	return 0;
+}
+
 static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 {
 	int ret;
@@ -171,5 +236,13 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_clock_gettime64();
+	if (ret)
+		return ret;
+
+	ret = test_sc_cobalt_clock_settime64();
+	if (ret)
+		return ret;
+
 	return 0;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v5 5/5] y2038: testsuite/smokey/y2038: testcase for settime64 and gettime64
@ 2021-04-21  8:36 Song Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Song Chen @ 2021-04-21  8:36 UTC (permalink / raw)
  To: xenomai, florian.bezdeka; +Cc: chensong

From: chensong <chensong@tj.kylinos.cn>

new test case for clock_settime64 and clock_gettime64 and reorganize
run_2038.

If you want to trigger and verify y2038 problem, please be careful and
make sure it has no impact to your test device.

Signed-off-by: chensong <chensong@tj.kylinos.cn>

---
v3:
1, rename structs, variables
2, reorganize registration in run_y2038
3, remove unnecessary definitions

v4:
1, return run_y2038 to its original approach

v5:
1, smokey warning when clock_getime failed
2, REALTIME --> MONOTONIC
---
 testsuite/smokey/y2038/syscall-tests.c | 77 +++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 2 deletions(-)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 1d61bbd..6ca841d 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -114,10 +114,10 @@ static int test_sc_cobalt_sem_timedwait64(void)
 
 	/*
 	 * The semaphore is already exhausted, so calling again will validate
-	 * the provided timeout now. Providing an invalid adress has to deliver
+	 * the provided timeout now. Providing an invalid address has to deliver
 	 * EFAULT
 	 */
-	ret = syscall(code, &sem, (void*) 0xdeadbeefUL);
+	ret = syscall(code, &sem, (void *)0xdeadbeefUL);
 	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
 		return errno;
 
@@ -163,6 +163,71 @@ static int test_sc_cobalt_sem_timedwait64(void)
 	return 0;
 }
 
+static int test_sc_cobalt_clock_gettime64(void)
+{
+	long ret;
+	int code = __xn_syscode(sc_cobalt_clock_gettime64);
+	struct xn_timespec64 ts64;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = syscall(code, NULL, NULL);
+	if (ret == -1 && errno == ENOSYS) {
+		smokey_note("clock_gettime64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = syscall(code, CLOCK_MONOTONIC, (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Provide a valid 64bit timespec*/
+	ret = syscall(code, CLOCK_MONOTONIC, &ts64);
+	if (!smokey_assert(!ret))
+		return errno;
+
+	return 0;
+}
+
+static int test_sc_cobalt_clock_settime64(void)
+{
+	long ret;
+	int code = __xn_syscode(sc_cobalt_clock_settime64);
+	struct xn_timespec64 ts64;
+	struct timespec now;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = syscall(code, NULL, NULL);
+	if (ret == -1 && errno == ENOSYS) {
+		smokey_note("clock_settime64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = syscall(code, CLOCK_MONOTONIC, (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Provide a valid 64bit timespec*/
+	ret = clock_gettime(CLOCK_MONOTONIC, &now);
+	if (ret) {
+		smokey_warning("clock_gettime failed in cloc_settime64.");
+		return errno;
+	}
+
+	ts64.tv_sec  = now.tv_sec;
+	ts64.tv_nsec = now.tv_nsec;
+	ret = syscall(code, CLOCK_MONOTONIC, &ts64);
+	if (!smokey_assert(!ret))
+		return errno;
+
+	return 0;
+}
+
 static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 {
 	int ret;
@@ -171,5 +236,13 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_clock_gettime64();
+	if (ret)
+		return ret;
+
+	ret = test_sc_cobalt_clock_settime64();
+	if (ret)
+		return ret;
+
 	return 0;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-21  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  6:23 [PATCH v5 5/5] y2038: testsuite/smokey/y2038: testcase for settime64 and gettime64 Song Chen
2021-04-21  8:36 Song Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.