From: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
Date: Mon, 18 Nov 2019 10:34:55 +0800 [thread overview]
Message-ID: <1574044495-2813-2-git-send-email-xuyang2018.jy@cn.fujitsu.com> (raw)
In-Reply-To: <1574044495-2813-1-git-send-email-xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/prctl/.gitignore | 1 +
testcases/kernel/syscalls/prctl/Makefile | 2 +-
testcases/kernel/syscalls/prctl/prctl09.c | 47 ++++++++++++++++++++++
4 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 testcases/kernel/syscalls/prctl/prctl09.c
diff --git a/runtest/syscalls b/runtest/syscalls
index fee91f909..e4e162b23 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -880,6 +880,7 @@ prctl05 prctl05
prctl06 prctl06
prctl07 prctl07
prctl08 prctl08
+prctl09 prctl09
pread01 pread01
pread01_64 pread01_64
diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
index fe36a8e0f..0f2c9b194 100644
--- a/testcases/kernel/syscalls/prctl/.gitignore
+++ b/testcases/kernel/syscalls/prctl/.gitignore
@@ -7,3 +7,4 @@
/prctl06_execve
/prctl07
/prctl08
+/prctl09
diff --git a/testcases/kernel/syscalls/prctl/Makefile b/testcases/kernel/syscalls/prctl/Makefile
index cf19507c0..c02b6d1de 100644
--- a/testcases/kernel/syscalls/prctl/Makefile
+++ b/testcases/kernel/syscalls/prctl/Makefile
@@ -21,5 +21,5 @@ top_srcdir ?= ../../../..
include $(top_srcdir)/include/mk/testcases.mk
prctl07: LDLIBS += $(CAP_LIBS)
-
+prctl09: LDLIBS += -lrt
include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/prctl/prctl09.c b/testcases/kernel/syscalls/prctl/prctl09.c
new file mode 100644
index 000000000..0d94df7b5
--- /dev/null
+++ b/testcases/kernel/syscalls/prctl/prctl09.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ */
+
+/*
+ * Test Description:
+ * This is a timer sample test that timer slack is 200us.
+ */
+
+#include <errno.h>
+#include <sys/prctl.h>
+#include "lapi/prctl.h"
+#include "tst_timer_test.h"
+
+int sample_fn(int clk_id, long long usec)
+{
+ struct timespec t = tst_us_to_timespec(usec);
+
+ tst_timer_start(clk_id);
+ TEST(nanosleep(&t, NULL));
+ tst_timer_stop();
+ tst_timer_sample();
+
+ if (TST_RET != 0) {
+ tst_res(TFAIL | TTERRNO,
+ "nanosleep() returned %li", TST_RET);
+ return 1;
+ }
+
+ return 0;
+}
+
+static void setup(void)
+{
+ TEST(prctl(PR_SET_TIMERSLACK, 200000));
+ if (TST_RET != 0)
+ tst_brk(TBROK | TTERRNO,
+ "prctl set timerslack 200us failed");
+}
+
+static struct tst_test test = {
+ .setup = setup,
+ .scall = "prctl()",
+ .sample = sample_fn,
+};
--
2.18.0
next prev parent reply other threads:[~2019-11-18 2:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 10:51 [LTP] [PATCH v3] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK Yang Xu
2019-10-09 12:19 ` Cyril Hrubis
2019-10-11 4:23 ` [LTP] [PATCH v4 1/2] " Yang Xu
2019-10-11 4:23 ` [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
2019-11-07 13:23 ` Cyril Hrubis
2019-11-08 11:21 ` Yang Xu
2019-10-21 13:00 ` [LTP] [PATCH v4 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK Yang Xu
2019-11-07 13:05 ` Cyril Hrubis
2019-11-08 11:03 ` Yang Xu
2019-11-08 12:00 ` [LTP] [PATCH v5 " Yang Xu
2019-11-08 12:00 ` [LTP] [PATCH v5 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
2019-11-15 16:35 ` Cyril Hrubis
2019-11-18 1:21 ` Yang Xu
2019-11-18 2:34 ` [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK Yang Xu
2019-11-18 2:34 ` Yang Xu [this message]
2019-11-25 11:07 ` [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Cyril Hrubis
2019-11-20 6:54 ` [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK Yang Xu
2019-11-25 10:18 ` Yang Xu
2019-11-15 9:01 ` [LTP] [PATCH v5 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK Yang Xu
2019-11-15 16:34 ` Cyril Hrubis
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=1574044495-2813-2-git-send-email-xuyang2018.jy@cn.fujitsu.com \
--to=xuyang2018.jy@cn.fujitsu.com \
--cc=ltp@lists.linux.it \
/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 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.