xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Florian Bezdeka <florian.bezdeka@siemens.com>
To: xenomai@lists.linux.dev, jan.kiszka@siemens.com
Cc: Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: [PATCH v2 11/14] y2038: testsuite/smokey/y2038: Adding tests for timerfd_settime
Date: Mon, 15 May 2023 16:50:11 +0200	[thread overview]
Message-ID: <20230508-florian-y2038-part-two-v2-11-a12f69d870d7@siemens.com> (raw)
In-Reply-To: <20230508-florian-y2038-part-two-v2-0-a12f69d870d7@siemens.com>

Extending the smokey testsuite to do some tests for the recently added
timerfd_settime syscall.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 testsuite/smokey/y2038/syscall-tests.c | 62 ++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 069553f37..87d85b9df 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -11,6 +11,7 @@
  */
 #include <asm/xenomai/syscall.h>
 #include <smokey/smokey.h>
+#include <sys/timerfd.h>
 #include <sys/utsname.h>
 #include <mqueue.h>
 #include <rtdm/ipc.h>
@@ -1339,6 +1340,63 @@ out:
 	return ret;
 }
 
+static int test_sc_cobalt_timerfd_settime64(void)
+{
+	long sc_nr = sc_cobalt_timerfd_settime64;
+	struct xn_itimerspec64 its = { 0 };
+	uint64_t buf = 0;
+	ssize_t sz;
+	int ret;
+	int fd;
+
+	fd = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0));
+	if (fd < 0)
+		return fd;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = XENOMAI_SYSCALL4(sc_nr, fd, 0, NULL, NULL);
+	if (ret == -ENOSYS) {
+		smokey_note(
+			"cobalt_timerfd_settime64: skipped. (no kernel support)");
+		ret = 0;
+		goto out; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -EFAULT)) {
+		ret = ret ?: -EINVAL;
+		goto out;
+	}
+
+	its.value.tv_sec = -1;
+	its.value.tv_nsec = 100000;
+
+	/* Provide an invalid expiration time, should deliver -EINVAL */
+	ret = XENOMAI_SYSCALL4(sc_nr, fd, 0, &its, NULL);
+	if (!smokey_assert(ret == -EINVAL)) {
+		ret = ret ?: -EINVAL;
+		goto out;
+	}
+
+	/* Provide a valid expiration time, should succeed */
+	its.value.tv_sec = 0;
+	ret = XENOMAI_SYSCALL4(sc_nr, fd, 0, &its, NULL);
+	if (!smokey_assert(!ret))
+		goto out;
+
+	ret = XENOMAI_SYSCALL4(sc_nr, fd, 0, &its, NULL);
+	if (!smokey_assert(!ret))
+		goto out;
+
+	sz = smokey_check_errno(read(fd, &buf, sizeof(buf)));
+	if (sz != sizeof(buf))
+		goto out;
+
+	smokey_assert(buf == 1);
+out:
+	smokey_check_errno(close(fd));
+
+	return ret;
+}
+
 static int check_kernel_version(void)
 {
 	int ret, major, minor;
@@ -1436,5 +1494,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_timerfd_settime64();
+	if (ret)
+		return ret;
+
 	return 0;
 }

-- 
2.39.2


  parent reply	other threads:[~2023-05-15 15:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 14:50 [PATCH v2 00/14] y2038: Part two - timer and timerfd support Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 01/14] y2038: cobalt: Introduce some itimerspec64 related helpers Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 02/14] y2038: cobalt/posix/timer: Adding timer_settime64 Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 03/14] y2038: cobalt/posix/timer: Use timespec64_valid() for validation Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 04/14] y2038: lib/cobalt: Dispatch timer_settime Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 05/14] y2038: testsuite/smokey/y2038: Adding tests for timer_settime Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 06/14] y2038: cobalt/posix/timer: Adding timer_gettime64 Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 07/14] y2038: lib/cobalt: Dispatch timer_gettime Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 08/14] y2038: testsuite/smokey/y2038: Adding tests for timer_gettime Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 09/14] y2038: cobalt/posix/timerfd: Adding timerfd_settime64 Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 10/14] y2038: lib/cobalt: Dispatch timerfd_settime Florian Bezdeka
2023-05-15 14:50 ` Florian Bezdeka [this message]
2023-05-15 14:50 ` [PATCH v2 12/14] y2038: cobalt/posix/timerfd: Adding timerfd_gettime64 Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 13/14] y2038: lib/cobalt: Dispatch timerfd_gettime Florian Bezdeka
2023-05-15 14:50 ` [PATCH v2 14/14] y2038: testsuite/smokey/y2038: Adding tests for timerfd_gettime Florian Bezdeka
2023-05-16  6:43 ` [PATCH v2 00/14] y2038: Part two - timer and timerfd support Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230508-florian-y2038-part-two-v2-11-a12f69d870d7@siemens.com \
    --to=florian.bezdeka@siemens.com \
    --cc=jan.kiszka@siemens.com \
    --cc=xenomai@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).