* [PATCH 3/3] y2038: testsuite/smokey/y2038: testcase for event_wait64
@ 2021-07-27 6:55 Song Chen
0 siblings, 0 replies; only message in thread
From: Song Chen @ 2021-07-27 6:55 UTC (permalink / raw)
To: florian.bezdeka, xenomai
add test case for event_wait64 in testsuite
Signed-off-by: Song Chen <chensong_2000@189.cn>
---
testsuite/smokey/y2038/syscall-tests.c | 76 ++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 3913938..34658ff 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -20,6 +20,7 @@
#include <mqueue.h>
#include <signal.h>
#include <cobalt/uapi/monitor.h>
+#include <cobalt/uapi/event.h>
#include <sys/cobalt.h>
smokey_test_plugin(y2038, SMOKEY_NOARGS, "Validate correct y2038 support");
@@ -837,6 +838,77 @@ static int test_sc_cobalt_monitor_wait64(void)
return 0;
}
+static int test_sc_cobalt_event_wait64(void)
+{
+ int ret;
+ int sc_nr = sc_cobalt_event_wait64;
+ struct xn_timespec64 ts64, ts_wu;
+ struct timespec ts_nat;
+ struct cobalt_event_shadow evt;
+ unsigned int flags;
+
+ ret = cobalt_event_init(&evt, 0, 1);
+ if (ret)
+ return -errno;
+
+ /* Make sure we don't crash because of NULL pointers */
+ ret = XENOMAI_SYSCALL5(sc_nr, NULL, NULL, NULL, NULL, NULL);
+ if (ret == -ENOSYS) {
+ smokey_note("event_wait64: skipped. (no kernel support)");
+ return 0; // Not implemented, nothing to test, success
+ }
+ if (!smokey_assert(ret == -EINVAL))
+ return ret ? ret : -EINVAL;
+
+ /* Providing an invalid address has to deliver EFAULT */
+ ret = XENOMAI_SYSCALL5(sc_nr, &evt, 0x1, &flags,
+ 0, (void *)0xdeadbeefUL);
+ if (!smokey_assert(ret == -EFAULT))
+ return ret ? ret : -EINVAL;
+
+ /*
+ * providing an invalid timeout has to deliver EINVAL
+ */
+ ts64.tv_sec = -1;
+ ret = XENOMAI_SYSCALL5(sc_nr, &evt, 0x1, &flags, 0, &ts64);
+ if (!smokey_assert(ret == -EINVAL))
+ return ret ? ret : -EINVAL;
+
+ /*
+ * Providing a valid timeout, waiting for it to time out and check
+ * that we didn't come back to early.
+ */
+ ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
+ if (ret)
+ return -errno;
+
+ ts64.tv_sec = 0;
+ ts64.tv_nsec = 500000;
+
+ ret = XENOMAI_SYSCALL5(sc_nr, &evt, 0x1, &flags, 0, &ts64);
+ if (!smokey_assert(ret == -ETIMEDOUT))
+ return ret;
+
+ ts64.tv_sec = ts_nat.tv_sec;
+ ts64.tv_nsec = ts_nat.tv_nsec;
+
+ ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
+ if (ret)
+ return -errno;
+
+ ts_wu.tv_sec = ts_nat.tv_sec;
+ ts_wu.tv_nsec = ts_nat.tv_nsec;
+
+ if (ts_less(&ts_wu, &ts64))
+ smokey_warning("event_wait64 returned to early!\n"
+ "Expected wakeup at: %lld sec %lld nsec\n"
+ "Back at : %lld sec %lld nsec\n",
+ ts64.tv_sec, ts64.tv_nsec, ts_wu.tv_sec,
+ ts_wu.tv_nsec);
+
+ return 0;
+}
+
static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
{
@@ -886,5 +958,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
if (ret)
return ret;
+ ret = test_sc_cobalt_event_wait64();
+ if (ret)
+ return ret;
+
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-27 6:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 6:55 [PATCH 3/3] y2038: testsuite/smokey/y2038: testcase for event_wait64 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.