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 13/13] y2038: testsuite/smokey/y2038: Adding tests for timerfd_gettime
Date: Mon, 08 May 2023 10:13:35 +0200	[thread overview]
Message-ID: <20230508-florian-y2038-part-two-v1-13-a417812fba85@siemens.com> (raw)
In-Reply-To: <20230508-florian-y2038-part-two-v1-0-a417812fba85@siemens.com>

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

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

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 87d85b9df..2e3b81e0c 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -1397,6 +1397,52 @@ out:
 	return ret;
 }
 
+static int test_sc_cobalt_timerfd_gettime64(void)
+{
+	long sc_nr = sc_cobalt_timerfd_gettime64;
+	struct xn_itimerspec64 its = { 0 };
+	uint64_t buf = 0;
+	int ret;
+	int fd;
+
+	fd = timerfd_create(CLOCK_REALTIME, 0);
+	if (fd == -1)
+		return -errno;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = XENOMAI_SYSCALL2(sc_nr, fd, NULL);
+	if (ret == -ENOSYS) {
+		smokey_note(
+			"cobalt_timerfd_gettime64: skipped. (no kernel support)");
+		ret = 0;
+		goto out; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -EFAULT)) {
+		ret = ret ?: -EINVAL;
+		goto out;
+	}
+
+	/*
+	 * Set some random values, allows us to detect that the kernel has
+	 * written the time
+	 */
+	its.value.tv_sec = 123;
+	its.value.tv_nsec = 456;
+
+	/* Fetch the time from the timer, should succeed */
+	ret = XENOMAI_SYSCALL2(sc_nr, fd, &its);
+	if (!smokey_assert(!ret))
+		goto out;
+
+	smokey_assert(buf == 0);
+	smokey_assert(its.value.tv_sec == 0);
+	smokey_assert(its.value.tv_nsec == 0);
+out:
+	smokey_check_errno(close(fd));
+
+	return ret;
+}
+
 static int check_kernel_version(void)
 {
 	int ret, major, minor;
@@ -1498,5 +1544,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_timerfd_gettime64();
+	if (ret)
+		return ret;
+
 	return 0;
 }

-- 
2.39.2


  parent reply	other threads:[~2023-05-08  8:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08  8:13 [PATCH 00/13] y2038: Part two - timer and timerfd support Florian Bezdeka
2023-05-08  8:13 ` [PATCH 01/13] y2038: cobalt: Introduce some itimerspec64 related helpers Florian Bezdeka
2023-05-12 15:59   ` Jan Kiszka
2023-05-15  9:31     ` Florian Bezdeka
2023-05-15  9:36       ` Jan Kiszka
2023-05-08  8:13 ` [PATCH 02/13] y2038: cobalt/posix/timer: Adding timer_settime64 Florian Bezdeka
2023-05-12 16:02   ` Jan Kiszka
2023-05-15  9:33     ` Florian Bezdeka
2023-05-08  8:13 ` [PATCH 03/13] y2038: lib/cobalt: Dispatch timer_settime Florian Bezdeka
2023-05-08  8:13 ` [PATCH 04/13] y2038: testsuite/smokey/y2038: Adding tests for timer_settime Florian Bezdeka
2023-05-08  8:13 ` [PATCH 05/13] y2038: cobalt/posix/timer: Adding timer_gettime64 Florian Bezdeka
2023-05-08  8:13 ` [PATCH 06/13] y2038: lib/cobalt: Dispatch timer_gettime Florian Bezdeka
2023-05-08  8:13 ` [PATCH 07/13] y2038: testsuite/smokey/y2038: Adding tests for timer_gettime Florian Bezdeka
2023-05-08  8:13 ` [PATCH 08/13] y2038: cobalt/posix/timerfd: Adding timerfd_settime64 Florian Bezdeka
2023-05-08  8:13 ` [PATCH 09/13] y2038: lib/cobalt: Dispatch timerfd_settime Florian Bezdeka
2023-05-08  8:13 ` [PATCH 10/13] y2038: testsuite/smokey/y2038: Adding tests for timerfd_settime Florian Bezdeka
2023-05-08  8:13 ` [PATCH 11/13] y2038: cobalt/posix/timerfd: Adding timerfd_gettime64 Florian Bezdeka
2023-05-08  8:13 ` [PATCH 12/13] y2038: lib/cobalt: Dispatch timerfd_gettime Florian Bezdeka
2023-05-08  8:13 ` Florian Bezdeka [this message]
2023-05-08 10:50   ` [PATCH 13/13] y2038: testsuite/smokey/y2038: Adding tests for timerfd_gettime Lukasz Majewski
2023-05-08 11:45     ` Florian Bezdeka
2023-05-12 16:09 ` [PATCH 00/13] 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-v1-13-a417812fba85@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).