All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
@ 2019-10-09 10:51 Yang Xu
  2019-10-09 12:19 ` Cyril Hrubis
  0 siblings, 1 reply; 20+ messages in thread
From: Yang Xu @ 2019-10-09 10:51 UTC (permalink / raw)
  To: ltp

-----
v2->v3:
1.add some check
2.compare time should not expire early before sleep
 I want to take more samples, but .sample and .test have conflict and I
don't konw how to slove it.
-----

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 include/lapi/prctl.h                       |   5 +
 runtest/syscalls                           |   1 +
 testcases/kernel/syscalls/prctl/.gitignore |   1 +
 testcases/kernel/syscalls/prctl/Makefile   |   1 +
 testcases/kernel/syscalls/prctl/prctl08.c  | 129 +++++++++++++++++++++
 5 files changed, 137 insertions(+)
 create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c

diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
index 8ee492259..0b4e196c3 100644
--- a/include/lapi/prctl.h
+++ b/include/lapi/prctl.h
@@ -19,6 +19,11 @@
 # define PR_SET_SECCOMP  22
 #endif
 
+#ifndef PR_SET_TIMERSLACK
+# define PR_SET_TIMERSLACK 29
+# define PR_GET_TIMERSLACK 30
+#endif
+
 #ifndef PR_SET_CHILD_SUBREAPER
 # define PR_SET_CHILD_SUBREAPER	36
 # define PR_GET_CHILD_SUBREAPER	37
diff --git a/runtest/syscalls b/runtest/syscalls
index 4e6310193..76961a684 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -878,6 +878,7 @@ prctl04 prctl04
 prctl05 prctl05
 prctl06 prctl06
 prctl07 prctl07
+prctl08 prctl08
 
 pread01 pread01
 pread01_64 pread01_64
diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
index 2178db366..fe36a8e0f 100644
--- a/testcases/kernel/syscalls/prctl/.gitignore
+++ b/testcases/kernel/syscalls/prctl/.gitignore
@@ -6,3 +6,4 @@
 /prctl06
 /prctl06_execve
 /prctl07
+/prctl08
diff --git a/testcases/kernel/syscalls/prctl/Makefile b/testcases/kernel/syscalls/prctl/Makefile
index cf19507c0..f0adc6fae 100644
--- a/testcases/kernel/syscalls/prctl/Makefile
+++ b/testcases/kernel/syscalls/prctl/Makefile
@@ -21,5 +21,6 @@ top_srcdir		?= ../../../..
 include $(top_srcdir)/include/mk/testcases.mk
 
 prctl07: LDLIBS += $(CAP_LIBS)
+prctl08: LDLIBS += -lrt
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
new file mode 100644
index 000000000..d0384c95c
--- /dev/null
+++ b/testcases/kernel/syscalls/prctl/prctl08.c
@@ -0,0 +1,129 @@
+// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
+ * 1)Each thread has two associated timer slack values: a "default"
+ *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
+ *   timer slack value for the calling thread.
+ * 2)When a new thread is created, the two timer slack values are made
+ *   the same as the "current" value of the creating thread.
+ * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
+ *   is a valid value(about 4s). On 64bit machines, it is about 500 years
+ *   and no person will set this over 4s.  prctl return value is int, so
+ *   we test themaximum value is INT_MAX.
+ * 4)we also check current value via /proc/self/timerslack_ns if it is
+ *  supported.
+ */
+
+#include <sys/prctl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/limits.h>
+#include "lapi/syscalls.h"
+#include "lapi/prctl.h"
+#include "tst_timer_test.h"
+#include "tst_test.h"
+
+#define PROC_NS_PATH "/proc/self/timerslack_ns"
+
+static struct tcase {
+	unsigned long setvalue;
+	unsigned long cmptime;
+} tcases[] = {
+	{1, 50000},
+	{70000, 50000},
+	{INT_MAX, 50000},
+};
+
+static int proc_flag = 1;
+
+static void check_proc_ns(char *message, unsigned long value)
+{
+	unsigned long proc_value;
+
+	SAFE_FILE_SCANF(PROC_NS_PATH, "%lu", &proc_value);
+	if (proc_value == value)
+		tst_res(TPASS, "%s %s  got %lu expectedly",
+				message, PROC_NS_PATH, proc_value);
+	else
+		tst_res(TFAIL, "%s %s expected %lu got %lu",
+				message, PROC_NS_PATH, value, proc_value);
+}
+
+static void check_get_timerslack(char *message, unsigned long value)
+{
+	TEST(prctl(PR_GET_TIMERSLACK));
+	if ((unsigned long)TST_RET == value)
+		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
+				message, value);
+	else
+		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
+				message, value, TST_RET);
+
+	if (proc_flag)
+		check_proc_ns(message, value);
+
+}
+
+static void verify_prctl(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int pid;
+
+	struct timespec timereq = { .tv_sec = 0, .tv_nsec = 50000 };
+	struct timespec timecmp = { .tv_sec = 0, .tv_nsec = tc->cmptime};
+
+	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
+					  tc->setvalue);
+		return;
+	}
+
+	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
+	check_get_timerslack("Parent process", tc->setvalue);
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		/*check the current value of child process*/
+		check_get_timerslack("Child process", tc->setvalue);
+		prctl(PR_SET_TIMERSLACK, 0);
+		/*check the default value of child process*/
+		check_get_timerslack("After reset to 0, child process", tc->setvalue);
+		tst_timer_start(CLOCK_MONOTONIC);
+		TEST(nanosleep(&timereq, NULL));
+		tst_timer_stop();
+
+		if (tst_timespec_lt(tst_timer_elapsed(), timecmp))
+			tst_brk(TFAIL, "nanosleep() slept less than timecmp");
+
+		tst_res(TPASS, "nanosleep() slept more than timecmp, %llius",
+				tst_timer_elapsed_us());
+		exit(0);
+	}
+}
+
+static void setup(void)
+{
+	if (access(PROC_NS_PATH, F_OK) == -1) {
+		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
+		proc_flag = 0;
+	}
+
+	TEST(prctl(PR_GET_TIMERSLACK));
+	if (TST_RET == 50000)
+		tst_res(TINFO, "current timerslack value is 50000");
+	else
+		tst_brk(TCONF,
+			"current environment doesn't meet test, please set timerslack to 50us");
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.test = verify_prctl,
+	.tcnt = ARRAY_SIZE(tcases),
+	.forks_child = 1,
+};
-- 
2.18.1




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

* [LTP] [PATCH v3] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  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
  0 siblings, 1 reply; 20+ messages in thread
From: Cyril Hrubis @ 2019-10-09 12:19 UTC (permalink / raw)
  To: ltp

Hi!
> -----
> v2->v3:
> 1.add some check
> 2.compare time should not expire early before sleep
>  I want to take more samples, but .sample and .test have conflict and I
> don't konw how to slove it.

Well, you can't have a single test that implements both timer sampling
tests and, at the same time, regular test function. You have to split
these into two separate testcases. I guess that the best would be
splitting the test into two, one that just sets arnd reads back the
slack values and one that samples a timer.

> -----
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  include/lapi/prctl.h                       |   5 +
>  runtest/syscalls                           |   1 +
>  testcases/kernel/syscalls/prctl/.gitignore |   1 +
>  testcases/kernel/syscalls/prctl/Makefile   |   1 +
>  testcases/kernel/syscalls/prctl/prctl08.c  | 129 +++++++++++++++++++++
>  5 files changed, 137 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c
> 
> diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
> index 8ee492259..0b4e196c3 100644
> --- a/include/lapi/prctl.h
> +++ b/include/lapi/prctl.h
> @@ -19,6 +19,11 @@
>  # define PR_SET_SECCOMP  22
>  #endif
>  
> +#ifndef PR_SET_TIMERSLACK
> +# define PR_SET_TIMERSLACK 29
> +# define PR_GET_TIMERSLACK 30
> +#endif
> +
>  #ifndef PR_SET_CHILD_SUBREAPER
>  # define PR_SET_CHILD_SUBREAPER	36
>  # define PR_GET_CHILD_SUBREAPER	37
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 4e6310193..76961a684 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -878,6 +878,7 @@ prctl04 prctl04
>  prctl05 prctl05
>  prctl06 prctl06
>  prctl07 prctl07
> +prctl08 prctl08
>  
>  pread01 pread01
>  pread01_64 pread01_64
> diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
> index 2178db366..fe36a8e0f 100644
> --- a/testcases/kernel/syscalls/prctl/.gitignore
> +++ b/testcases/kernel/syscalls/prctl/.gitignore
> @@ -6,3 +6,4 @@
>  /prctl06
>  /prctl06_execve
>  /prctl07
> +/prctl08
> diff --git a/testcases/kernel/syscalls/prctl/Makefile b/testcases/kernel/syscalls/prctl/Makefile
> index cf19507c0..f0adc6fae 100644
> --- a/testcases/kernel/syscalls/prctl/Makefile
> +++ b/testcases/kernel/syscalls/prctl/Makefile
> @@ -21,5 +21,6 @@ top_srcdir		?= ../../../..
>  include $(top_srcdir)/include/mk/testcases.mk
>  
>  prctl07: LDLIBS += $(CAP_LIBS)
> +prctl08: LDLIBS += -lrt
>  
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
> new file mode 100644
> index 000000000..d0384c95c
> --- /dev/null
> +++ b/testcases/kernel/syscalls/prctl/prctl08.c
> @@ -0,0 +1,129 @@
> +// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
> + * 1)Each thread has two associated timer slack values: a "default"
> + *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
> + *   timer slack value for the calling thread.
> + * 2)When a new thread is created, the two timer slack values are made
> + *   the same as the "current" value of the creating thread.
> + * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
> + *   is a valid value(about 4s). On 64bit machines, it is about 500 years
> + *   and no person will set this over 4s.  prctl return value is int, so
> + *   we test themaximum value is INT_MAX.
> + * 4)we also check current value via /proc/self/timerslack_ns if it is
> + *  supported.
> + */
> +
> +#include <sys/prctl.h>
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/limits.h>
> +#include "lapi/syscalls.h"
> +#include "lapi/prctl.h"
> +#include "tst_timer_test.h"
> +#include "tst_test.h"
> +
> +#define PROC_NS_PATH "/proc/self/timerslack_ns"
> +
> +static struct tcase {
> +	unsigned long setvalue;
> +	unsigned long cmptime;
> +} tcases[] = {
> +	{1, 50000},
> +	{70000, 50000},
> +	{INT_MAX, 50000},
> +};
> +
> +static int proc_flag = 1;
> +
> +static void check_proc_ns(char *message, unsigned long value)
> +{
> +	unsigned long proc_value;
> +
> +	SAFE_FILE_SCANF(PROC_NS_PATH, "%lu", &proc_value);
> +	if (proc_value == value)
> +		tst_res(TPASS, "%s %s  got %lu expectedly",
> +				message, PROC_NS_PATH, proc_value);
> +	else
> +		tst_res(TFAIL, "%s %s expected %lu got %lu",
> +				message, PROC_NS_PATH, value, proc_value);
> +}
> +
> +static void check_get_timerslack(char *message, unsigned long value)
> +{
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if ((unsigned long)TST_RET == value)
> +		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
> +				message, value);
> +	else
> +		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
> +				message, value, TST_RET);
> +
> +	if (proc_flag)
> +		check_proc_ns(message, value);
> +
> +}
> +
> +static void verify_prctl(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +	int pid;
> +
> +	struct timespec timereq = { .tv_sec = 0, .tv_nsec = 50000 };
> +	struct timespec timecmp = { .tv_sec = 0, .tv_nsec = tc->cmptime};
> +
> +	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
> +					  tc->setvalue);
> +		return;
> +	}
> +
> +	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
> +	check_get_timerslack("Parent process", tc->setvalue);
> +
> +	pid = SAFE_FORK();
> +	if (pid == 0) {
> +		/*check the current value of child process*/
> +		check_get_timerslack("Child process", tc->setvalue);
> +		prctl(PR_SET_TIMERSLACK, 0);
> +		/*check the default value of child process*/
> +		check_get_timerslack("After reset to 0, child process", tc->setvalue);
> +		tst_timer_start(CLOCK_MONOTONIC);
> +		TEST(nanosleep(&timereq, NULL));
> +		tst_timer_stop();
> +
> +		if (tst_timespec_lt(tst_timer_elapsed(), timecmp))
> +			tst_brk(TFAIL, "nanosleep() slept less than timecmp");
> +
> +		tst_res(TPASS, "nanosleep() slept more than timecmp, %llius",
> +				tst_timer_elapsed_us());
> +		exit(0);
> +	}
> +}
> +
> +static void setup(void)
> +{
> +	if (access(PROC_NS_PATH, F_OK) == -1) {
> +		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
> +		proc_flag = 0;
> +	}
> +
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if (TST_RET == 50000)
> +		tst_res(TINFO, "current timerslack value is 50000");
> +	else
> +		tst_brk(TCONF,
> +			"current environment doesn't meet test, please set timerslack to 50us");
> +}
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test = verify_prctl,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.forks_child = 1,
> +};
> -- 
> 2.18.1
> 
> 
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v4 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  2019-10-09 12:19 ` Cyril Hrubis
@ 2019-10-11  4:23   ` Yang Xu
  2019-10-11  4:23     ` [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
                       ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Yang Xu @ 2019-10-11  4:23 UTC (permalink / raw)
  To: ltp

------
v3->v4:
split it into two cases, prctl08 test read/set timer slack value and
prctl09 is a timer samle test.
Also, in prctl08, I split into 5 point(0,1,middle,max and inherit).
-----

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 include/lapi/prctl.h                       |   5 +
 runtest/syscalls                           |   1 +
 testcases/kernel/syscalls/prctl/.gitignore |   1 +
 testcases/kernel/syscalls/prctl/prctl08.c  | 135 +++++++++++++++++++++
 4 files changed, 142 insertions(+)
 create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c

diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
index 8ee492259..0b4e196c3 100644
--- a/include/lapi/prctl.h
+++ b/include/lapi/prctl.h
@@ -19,6 +19,11 @@
 # define PR_SET_SECCOMP  22
 #endif
 
+#ifndef PR_SET_TIMERSLACK
+# define PR_SET_TIMERSLACK 29
+# define PR_GET_TIMERSLACK 30
+#endif
+
 #ifndef PR_SET_CHILD_SUBREAPER
 # define PR_SET_CHILD_SUBREAPER	36
 # define PR_GET_CHILD_SUBREAPER	37
diff --git a/runtest/syscalls b/runtest/syscalls
index 4e6310193..76961a684 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -878,6 +878,7 @@ prctl04 prctl04
 prctl05 prctl05
 prctl06 prctl06
 prctl07 prctl07
+prctl08 prctl08
 
 pread01 pread01
 pread01_64 pread01_64
diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
index 2178db366..fe36a8e0f 100644
--- a/testcases/kernel/syscalls/prctl/.gitignore
+++ b/testcases/kernel/syscalls/prctl/.gitignore
@@ -6,3 +6,4 @@
 /prctl06
 /prctl06_execve
 /prctl07
+/prctl08
diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
new file mode 100644
index 000000000..9aa15b06d
--- /dev/null
+++ b/testcases/kernel/syscalls/prctl/prctl08.c
@@ -0,0 +1,135 @@
+// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
+ * 1)Each thread has two associated timer slack values: a "default"
+ *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
+ *   timer slack value for the calling thread.
+ * 2)When a new thread is created, the two timer slack values are made
+ *   the same as the "current" value of the creating thread.
+ * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
+ *   is a valid value(about 4s). On 64bit machines, it is about 500 years
+ *   and no person will set this over 4s.  prctl return value is int, so
+ *   we test themaximum value is INT_MAX.
+ * 4)we also check current value via /proc/self/timerslack_ns if it is
+ *  supported.
+ */
+
+#include <sys/prctl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/limits.h>
+#include "lapi/syscalls.h"
+#include "lapi/prctl.h"
+#include "tst_test.h"
+
+#define PROC_TIMERSLACK_PATH "/proc/self/timerslack_ns"
+
+static void check_get_timerslack(char *message, unsigned long value);
+static void check_inherit_timerslack(char *message, unsigned long value);
+
+static struct tcase {
+	void (*func_check)();
+	unsigned long setvalue;
+	unsigned long expvalue;
+	char message[50];
+} tcases[] = {
+	{check_get_timerslack, 0, 50000, "Reset"},
+	{check_get_timerslack, 1, 1, "Min"},
+	{check_get_timerslack, 70000, 70000, "Middle"},
+	{check_get_timerslack, INT_MAX, INT_MAX, "Max"},
+	{check_inherit_timerslack, 70000, 70000, "Child process"},
+};
+
+static int proc_flag = 1;
+
+static void check_proc_timerslack(char *message, unsigned long value)
+{
+	unsigned long proc_value;
+
+	SAFE_FILE_SCANF(PROC_TIMERSLACK_PATH, "%lu", &proc_value);
+	if (proc_value == value)
+		tst_res(TPASS, "%s %s  got %lu expectedly",
+				message, PROC_TIMERSLACK_PATH, proc_value);
+	else
+		tst_res(TFAIL, "%s %s expected %lu got %lu",
+				message, PROC_TIMERSLACK_PATH, value, proc_value);
+}
+
+static void check_get_timerslack(char *message, unsigned long value)
+{
+	TEST(prctl(PR_GET_TIMERSLACK));
+	if ((unsigned long)TST_RET == value)
+		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
+				message, value);
+	else
+		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
+				message, value, TST_RET);
+
+	if (proc_flag)
+		check_proc_timerslack(message, value);
+
+}
+
+static void check_inherit_timerslack(char *message, unsigned long value)
+{
+	int pid;
+	unsigned long current_value;
+	unsigned long default_value;
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		current_value = prctl(PR_GET_TIMERSLACK);
+		prctl(PR_SET_TIMERSLACK, 0);
+		default_value = prctl(PR_GET_TIMERSLACK);
+		if (current_value == value && default_value == value)
+			tst_res(TPASS,
+				"%s two timer slack values are made the same as the current value(%lu) of the creating thread.",
+				message, value);
+		else
+			tst_res(TFAIL,
+				"%s current_value is %lu, default value is %lu, the parent current value is %lu",
+				message, current_value, default_value, value);
+	}
+
+}
+
+static void verify_prctl(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
+					  tc->setvalue);
+		return;
+	}
+
+	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
+	tc->func_check(tc->message, tc->expvalue);
+}
+
+static void setup(void)
+{
+	if (access(PROC_TIMERSLACK_PATH, F_OK) == -1) {
+		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
+		proc_flag = 0;
+	}
+
+	TEST(prctl(PR_GET_TIMERSLACK));
+	if (TST_RET == 50000)
+		tst_res(TINFO, "current timerslack value is 50us");
+	else
+		tst_brk(TCONF,
+			"current environment doesn't meet test, please set timerslack to 50us");
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.test = verify_prctl,
+	.tcnt = ARRAY_SIZE(tcases),
+	.forks_child = 1,
+};
-- 
2.18.1




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

* [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  2019-10-11  4:23   ` [LTP] [PATCH v4 1/2] " Yang Xu
@ 2019-10-11  4:23     ` Yang Xu
  2019-11-07 13:23       ` Cyril Hrubis
  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
  2 siblings, 1 reply; 20+ messages in thread
From: Yang Xu @ 2019-10-11  4:23 UTC (permalink / raw)
  To: ltp

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 runtest/syscalls                           |  1 +
 testcases/kernel/syscalls/prctl/.gitignore |  1 +
 testcases/kernel/syscalls/prctl/Makefile   |  2 +-
 testcases/kernel/syscalls/prctl/prctl09.c  | 45 ++++++++++++++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 testcases/kernel/syscalls/prctl/prctl09.c

diff --git a/runtest/syscalls b/runtest/syscalls
index 76961a684..705d7f87e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -879,6 +879,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..e8d9aabd0
--- /dev/null
+++ b/testcases/kernel/syscalls/prctl/prctl09.c
@@ -0,0 +1,45 @@
+// 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 sampling tests 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);
+
+	TEST(prctl(PR_SET_TIMERSLACK, 200000));
+	if (TST_RET != 0) {
+		tst_res(TFAIL | TTERRNO,
+			"prctl(), returned %li", TST_RET);
+		return 1;
+	}
+
+	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 struct tst_test test = {
+	.scall = "prctl()",
+	.sample = sample_fn,
+};
-- 
2.18.1




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

* [LTP] [PATCH v4 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  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-10-21 13:00     ` Yang Xu
  2019-11-07 13:05     ` Cyril Hrubis
  2 siblings, 0 replies; 20+ messages in thread
From: Yang Xu @ 2019-10-21 13:00 UTC (permalink / raw)
  To: ltp

Hi Cyril
Ping.

> ------
> v3->v4:
> split it into two cases, prctl08 test read/set timer slack value and
> prctl09 is a timer samle test.
> Also, in prctl08, I split into 5 point(0,1,middle,max and inherit).
> -----
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>   include/lapi/prctl.h                       |   5 +
>   runtest/syscalls                           |   1 +
>   testcases/kernel/syscalls/prctl/.gitignore |   1 +
>   testcases/kernel/syscalls/prctl/prctl08.c  | 135 +++++++++++++++++++++
>   4 files changed, 142 insertions(+)
>   create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c
> 
> diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
> index 8ee492259..0b4e196c3 100644
> --- a/include/lapi/prctl.h
> +++ b/include/lapi/prctl.h
> @@ -19,6 +19,11 @@
>   # define PR_SET_SECCOMP  22
>   #endif
>   
> +#ifndef PR_SET_TIMERSLACK
> +# define PR_SET_TIMERSLACK 29
> +# define PR_GET_TIMERSLACK 30
> +#endif
> +
>   #ifndef PR_SET_CHILD_SUBREAPER
>   # define PR_SET_CHILD_SUBREAPER	36
>   # define PR_GET_CHILD_SUBREAPER	37
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 4e6310193..76961a684 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -878,6 +878,7 @@ prctl04 prctl04
>   prctl05 prctl05
>   prctl06 prctl06
>   prctl07 prctl07
> +prctl08 prctl08
>   
>   pread01 pread01
>   pread01_64 pread01_64
> diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
> index 2178db366..fe36a8e0f 100644
> --- a/testcases/kernel/syscalls/prctl/.gitignore
> +++ b/testcases/kernel/syscalls/prctl/.gitignore
> @@ -6,3 +6,4 @@
>   /prctl06
>   /prctl06_execve
>   /prctl07
> +/prctl08
> diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
> new file mode 100644
> index 000000000..9aa15b06d
> --- /dev/null
> +++ b/testcases/kernel/syscalls/prctl/prctl08.c
> @@ -0,0 +1,135 @@
> +// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
> + * 1)Each thread has two associated timer slack values: a "default"
> + *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
> + *   timer slack value for the calling thread.
> + * 2)When a new thread is created, the two timer slack values are made
> + *   the same as the "current" value of the creating thread.
> + * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
> + *   is a valid value(about 4s). On 64bit machines, it is about 500 years
> + *   and no person will set this over 4s.  prctl return value is int, so
> + *   we test themaximum value is INT_MAX.
> + * 4)we also check current value via /proc/self/timerslack_ns if it is
> + *  supported.
> + */
> +
> +#include <sys/prctl.h>
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/limits.h>
> +#include "lapi/syscalls.h"
> +#include "lapi/prctl.h"
> +#include "tst_test.h"
> +
> +#define PROC_TIMERSLACK_PATH "/proc/self/timerslack_ns"
> +
> +static void check_get_timerslack(char *message, unsigned long value);
> +static void check_inherit_timerslack(char *message, unsigned long value);
> +
> +static struct tcase {
> +	void (*func_check)();
> +	unsigned long setvalue;
> +	unsigned long expvalue;
> +	char message[50];
> +} tcases[] = {
> +	{check_get_timerslack, 0, 50000, "Reset"},
> +	{check_get_timerslack, 1, 1, "Min"},
> +	{check_get_timerslack, 70000, 70000, "Middle"},
> +	{check_get_timerslack, INT_MAX, INT_MAX, "Max"},
> +	{check_inherit_timerslack, 70000, 70000, "Child process"},
> +};
> +
> +static int proc_flag = 1;
> +
> +static void check_proc_timerslack(char *message, unsigned long value)
> +{
> +	unsigned long proc_value;
> +
> +	SAFE_FILE_SCANF(PROC_TIMERSLACK_PATH, "%lu", &proc_value);
> +	if (proc_value == value)
> +		tst_res(TPASS, "%s %s  got %lu expectedly",
> +				message, PROC_TIMERSLACK_PATH, proc_value);
> +	else
> +		tst_res(TFAIL, "%s %s expected %lu got %lu",
> +				message, PROC_TIMERSLACK_PATH, value, proc_value);
> +}
> +
> +static void check_get_timerslack(char *message, unsigned long value)
> +{
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if ((unsigned long)TST_RET == value)
> +		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
> +				message, value);
> +	else
> +		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
> +				message, value, TST_RET);
> +
> +	if (proc_flag)
> +		check_proc_timerslack(message, value);
> +
> +}
> +
> +static void check_inherit_timerslack(char *message, unsigned long value)
> +{
> +	int pid;
> +	unsigned long current_value;
> +	unsigned long default_value;
> +
> +	pid = SAFE_FORK();
> +	if (pid == 0) {
> +		current_value = prctl(PR_GET_TIMERSLACK);
> +		prctl(PR_SET_TIMERSLACK, 0);
> +		default_value = prctl(PR_GET_TIMERSLACK);
> +		if (current_value == value && default_value == value)
> +			tst_res(TPASS,
> +				"%s two timer slack values are made the same as the current value(%lu) of the creating thread.",
> +				message, value);
> +		else
> +			tst_res(TFAIL,
> +				"%s current_value is %lu, default value is %lu, the parent current value is %lu",
> +				message, current_value, default_value, value);
> +	}
> +
> +}
> +
> +static void verify_prctl(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +
> +	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
> +					  tc->setvalue);
> +		return;
> +	}
> +
> +	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
> +	tc->func_check(tc->message, tc->expvalue);
> +}
> +
> +static void setup(void)
> +{
> +	if (access(PROC_TIMERSLACK_PATH, F_OK) == -1) {
> +		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
> +		proc_flag = 0;
> +	}
> +
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if (TST_RET == 50000)
> +		tst_res(TINFO, "current timerslack value is 50us");
> +	else
> +		tst_brk(TCONF,
> +			"current environment doesn't meet test, please set timerslack to 50us");
> +}
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test = verify_prctl,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.forks_child = 1,
> +};
> 



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

* [LTP] [PATCH v4 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  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-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
  2 siblings, 2 replies; 20+ messages in thread
From: Cyril Hrubis @ 2019-11-07 13:05 UTC (permalink / raw)
  To: ltp

Hi!
> ------
> v3->v4:
> split it into two cases, prctl08 test read/set timer slack value and
> prctl09 is a timer samle test.
> Also, in prctl08, I split into 5 point(0,1,middle,max and inherit).
> -----
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  include/lapi/prctl.h                       |   5 +
>  runtest/syscalls                           |   1 +
>  testcases/kernel/syscalls/prctl/.gitignore |   1 +
>  testcases/kernel/syscalls/prctl/prctl08.c  | 135 +++++++++++++++++++++
>  4 files changed, 142 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c
> 
> diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
> index 8ee492259..0b4e196c3 100644
> --- a/include/lapi/prctl.h
> +++ b/include/lapi/prctl.h
> @@ -19,6 +19,11 @@
>  # define PR_SET_SECCOMP  22
>  #endif
>  
> +#ifndef PR_SET_TIMERSLACK
> +# define PR_SET_TIMERSLACK 29
> +# define PR_GET_TIMERSLACK 30
> +#endif
> +
>  #ifndef PR_SET_CHILD_SUBREAPER
>  # define PR_SET_CHILD_SUBREAPER	36
>  # define PR_GET_CHILD_SUBREAPER	37
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 4e6310193..76961a684 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -878,6 +878,7 @@ prctl04 prctl04
>  prctl05 prctl05
>  prctl06 prctl06
>  prctl07 prctl07
> +prctl08 prctl08
>  
>  pread01 pread01
>  pread01_64 pread01_64
> diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
> index 2178db366..fe36a8e0f 100644
> --- a/testcases/kernel/syscalls/prctl/.gitignore
> +++ b/testcases/kernel/syscalls/prctl/.gitignore
> @@ -6,3 +6,4 @@
>  /prctl06
>  /prctl06_execve
>  /prctl07
> +/prctl08
> diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
> new file mode 100644
> index 000000000..9aa15b06d
> --- /dev/null
> +++ b/testcases/kernel/syscalls/prctl/prctl08.c
> @@ -0,0 +1,135 @@
> +// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
> + * 1)Each thread has two associated timer slack values: a "default"
> + *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
> + *   timer slack value for the calling thread.
> + * 2)When a new thread is created, the two timer slack values are made
> + *   the same as the "current" value of the creating thread.
> + * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
> + *   is a valid value(about 4s). On 64bit machines, it is about 500 years
> + *   and no person will set this over 4s.  prctl return value is int, so
> + *   we test themaximum value is INT_MAX.
> + * 4)we also check current value via /proc/self/timerslack_ns if it is
> + *  supported.
> + */
> +
> +#include <sys/prctl.h>
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/limits.h>
> +#include "lapi/syscalls.h"
> +#include "lapi/prctl.h"
> +#include "tst_test.h"
> +
> +#define PROC_TIMERSLACK_PATH "/proc/self/timerslack_ns"
> +
> +static void check_get_timerslack(char *message, unsigned long value);
> +static void check_inherit_timerslack(char *message, unsigned long value);
> +
> +static struct tcase {
> +	void (*func_check)();
> +	unsigned long setvalue;
> +	unsigned long expvalue;
> +	char message[50];
> +} tcases[] = {
> +	{check_get_timerslack, 0, 50000, "Reset"},
> +	{check_get_timerslack, 1, 1, "Min"},
> +	{check_get_timerslack, 70000, 70000, "Middle"},
> +	{check_get_timerslack, INT_MAX, INT_MAX, "Max"},
> +	{check_inherit_timerslack, 70000, 70000, "Child process"},
> +};
> +
> +static int proc_flag = 1;
> +
> +static void check_proc_timerslack(char *message, unsigned long value)
> +{
> +	unsigned long proc_value;
> +
> +	SAFE_FILE_SCANF(PROC_TIMERSLACK_PATH, "%lu", &proc_value);
> +	if (proc_value == value)
> +		tst_res(TPASS, "%s %s  got %lu expectedly",
> +				message, PROC_TIMERSLACK_PATH, proc_value);
> +	else
> +		tst_res(TFAIL, "%s %s expected %lu got %lu",
> +				message, PROC_TIMERSLACK_PATH, value, proc_value);
> +}
> +
> +static void check_get_timerslack(char *message, unsigned long value)
> +{
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if ((unsigned long)TST_RET == value)
> +		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
> +				message, value);
> +	else
> +		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
> +				message, value, TST_RET);
> +
> +	if (proc_flag)
> +		check_proc_timerslack(message, value);
> +
> +}
> +
> +static void check_inherit_timerslack(char *message, unsigned long value)
> +{
> +	int pid;
> +	unsigned long current_value;
> +	unsigned long default_value;
> +
> +	pid = SAFE_FORK();
> +	if (pid == 0) {
> +		current_value = prctl(PR_GET_TIMERSLACK);
> +		prctl(PR_SET_TIMERSLACK, 0);
> +		default_value = prctl(PR_GET_TIMERSLACK);
> +		if (current_value == value && default_value == value)
> +			tst_res(TPASS,
> +				"%s two timer slack values are made the same as the current value(%lu) of the creating thread.",
> +				message, value);
> +		else
> +			tst_res(TFAIL,
> +				"%s current_value is %lu, default value is %lu, the parent current value is %lu",
> +				message, current_value, default_value, value);
> +	}
> +
> +}
> +
> +static void verify_prctl(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +
> +	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
> +					  tc->setvalue);
> +		return;
> +	}
> +
> +	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
> +	tc->func_check(tc->message, tc->expvalue);
> +}
> +
> +static void setup(void)
> +{
> +	if (access(PROC_TIMERSLACK_PATH, F_OK) == -1) {
> +		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
> +		proc_flag = 0;
> +	}
> +
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if (TST_RET == 50000)
> +		tst_res(TINFO, "current timerslack value is 50us");
> +	else
> +		tst_brk(TCONF,
> +			"current environment doesn't meet test, please set timerslack to 50us");

Why can't we just store the result here into a global and use it later
on in the reset case?

Given that we have check function already all we need to do is to add
one more function that passes the global to the check_get_timerslack()
instead of the expected value.

> +}
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test = verify_prctl,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.forks_child = 1,
> +};
> -- 
> 2.18.1
> 
> 
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  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
  0 siblings, 1 reply; 20+ messages in thread
From: Cyril Hrubis @ 2019-11-07 13:23 UTC (permalink / raw)
  To: ltp

Hi!
> +#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);
> +
> +	TEST(prctl(PR_SET_TIMERSLACK, 200000));

This is a bit more complicated.

First of all it does not make sense to set the timerslack in the sample
function. It should be done once in the test setup.

Also in the tst_timer_test.c we store the timerslack value in the
timer_setup(), which executes the test setup() at the end of the
function, so we would have to move the part that gets the timerslack()
after the test setup() function so that the library includes the newly
set timerslack in the calculation.

> +	if (TST_RET != 0) {
> +		tst_res(TFAIL | TTERRNO,
> +			"prctl(), returned %li", TST_RET);
> +		return 1;
> +	}
> +
> +	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 struct tst_test test = {
> +	.scall = "prctl()",
> +	.sample = sample_fn,
> +};
> -- 
> 2.18.1
> 
> 
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v4 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  2019-11-07 13:05     ` Cyril Hrubis
@ 2019-11-08 11:03       ` Yang Xu
  2019-11-08 12:00       ` [LTP] [PATCH v5 " Yang Xu
  1 sibling, 0 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-08 11:03 UTC (permalink / raw)
  To: ltp

on 2019/11/07 21:05, Cyril Hrubis wrote:

> Hi!
>> ------
>> v3->v4:
>> split it into two cases, prctl08 test read/set timer slack value and
>> prctl09 is a timer samle test.
>> Also, in prctl08, I split into 5 point(0,1,middle,max and inherit).
>> -----
>>
>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> ---
>>   include/lapi/prctl.h                       |   5 +
>>   runtest/syscalls                           |   1 +
>>   testcases/kernel/syscalls/prctl/.gitignore |   1 +
>>   testcases/kernel/syscalls/prctl/prctl08.c  | 135 +++++++++++++++++++++
>>   4 files changed, 142 insertions(+)
>>   create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c
>>
>> diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
>> index 8ee492259..0b4e196c3 100644
>> --- a/include/lapi/prctl.h
>> +++ b/include/lapi/prctl.h
>> @@ -19,6 +19,11 @@
>>   # define PR_SET_SECCOMP  22
>>   #endif
>>   
>> +#ifndef PR_SET_TIMERSLACK
>> +# define PR_SET_TIMERSLACK 29
>> +# define PR_GET_TIMERSLACK 30
>> +#endif
>> +
>>   #ifndef PR_SET_CHILD_SUBREAPER
>>   # define PR_SET_CHILD_SUBREAPER	36
>>   # define PR_GET_CHILD_SUBREAPER	37
>> diff --git a/runtest/syscalls b/runtest/syscalls
>> index 4e6310193..76961a684 100644
>> --- a/runtest/syscalls
>> +++ b/runtest/syscalls
>> @@ -878,6 +878,7 @@ prctl04 prctl04
>>   prctl05 prctl05
>>   prctl06 prctl06
>>   prctl07 prctl07
>> +prctl08 prctl08
>>   
>>   pread01 pread01
>>   pread01_64 pread01_64
>> diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
>> index 2178db366..fe36a8e0f 100644
>> --- a/testcases/kernel/syscalls/prctl/.gitignore
>> +++ b/testcases/kernel/syscalls/prctl/.gitignore
>> @@ -6,3 +6,4 @@
>>   /prctl06
>>   /prctl06_execve
>>   /prctl07
>> +/prctl08
>> diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
>> new file mode 100644
>> index 000000000..9aa15b06d
>> --- /dev/null
>> +++ b/testcases/kernel/syscalls/prctl/prctl08.c
>> @@ -0,0 +1,135 @@
>> +// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
>> + * 1)Each thread has two associated timer slack values: a "default"
>> + *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
>> + *   timer slack value for the calling thread.
>> + * 2)When a new thread is created, the two timer slack values are made
>> + *   the same as the "current" value of the creating thread.
>> + * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
>> + *   is a valid value(about 4s). On 64bit machines, it is about 500 years
>> + *   and no person will set this over 4s.  prctl return value is int, so
>> + *   we test themaximum value is INT_MAX.
>> + * 4)we also check current value via /proc/self/timerslack_ns if it is
>> + *  supported.
>> + */
>> +
>> +#include <sys/prctl.h>
>> +#include <string.h>
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <linux/limits.h>
>> +#include "lapi/syscalls.h"
>> +#include "lapi/prctl.h"
>> +#include "tst_test.h"
>> +
>> +#define PROC_TIMERSLACK_PATH "/proc/self/timerslack_ns"
>> +
>> +static void check_get_timerslack(char *message, unsigned long value);
>> +static void check_inherit_timerslack(char *message, unsigned long value);
>> +
>> +static struct tcase {
>> +	void (*func_check)();
>> +	unsigned long setvalue;
>> +	unsigned long expvalue;
>> +	char message[50];
>> +} tcases[] = {
>> +	{check_get_timerslack, 0, 50000, "Reset"},
>> +	{check_get_timerslack, 1, 1, "Min"},
>> +	{check_get_timerslack, 70000, 70000, "Middle"},
>> +	{check_get_timerslack, INT_MAX, INT_MAX, "Max"},
>> +	{check_inherit_timerslack, 70000, 70000, "Child process"},
>> +};
>> +
>> +static int proc_flag = 1;
>> +
>> +static void check_proc_timerslack(char *message, unsigned long value)
>> +{
>> +	unsigned long proc_value;
>> +
>> +	SAFE_FILE_SCANF(PROC_TIMERSLACK_PATH, "%lu", &proc_value);
>> +	if (proc_value == value)
>> +		tst_res(TPASS, "%s %s  got %lu expectedly",
>> +				message, PROC_TIMERSLACK_PATH, proc_value);
>> +	else
>> +		tst_res(TFAIL, "%s %s expected %lu got %lu",
>> +				message, PROC_TIMERSLACK_PATH, value, proc_value);
>> +}
>> +
>> +static void check_get_timerslack(char *message, unsigned long value)
>> +{
>> +	TEST(prctl(PR_GET_TIMERSLACK));
>> +	if ((unsigned long)TST_RET == value)
>> +		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
>> +				message, value);
>> +	else
>> +		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
>> +				message, value, TST_RET);
>> +
>> +	if (proc_flag)
>> +		check_proc_timerslack(message, value);
>> +
>> +}
>> +
>> +static void check_inherit_timerslack(char *message, unsigned long value)
>> +{
>> +	int pid;
>> +	unsigned long current_value;
>> +	unsigned long default_value;
>> +
>> +	pid = SAFE_FORK();
>> +	if (pid == 0) {
>> +		current_value = prctl(PR_GET_TIMERSLACK);
>> +		prctl(PR_SET_TIMERSLACK, 0);
>> +		default_value = prctl(PR_GET_TIMERSLACK);
>> +		if (current_value == value && default_value == value)
>> +			tst_res(TPASS,
>> +				"%s two timer slack values are made the same as the current value(%lu) of the creating thread.",
>> +				message, value);
>> +		else
>> +			tst_res(TFAIL,
>> +				"%s current_value is %lu, default value is %lu, the parent current value is %lu",
>> +				message, current_value, default_value, value);
>> +	}
>> +
>> +}
>> +
>> +static void verify_prctl(unsigned int n)
>> +{
>> +	struct tcase *tc = &tcases[n];
>> +
>> +	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
>> +	if (TST_RET == -1) {
>> +		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
>> +					  tc->setvalue);
>> +		return;
>> +	}
>> +
>> +	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
>> +	tc->func_check(tc->message, tc->expvalue);
>> +}
>> +
>> +static void setup(void)
>> +{
>> +	if (access(PROC_TIMERSLACK_PATH, F_OK) == -1) {
>> +		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
>> +		proc_flag = 0;
>> +	}
>> +
>> +	TEST(prctl(PR_GET_TIMERSLACK));
>> +	if (TST_RET == 50000)
>> +		tst_res(TINFO, "current timerslack value is 50us");
>> +	else
>> +		tst_brk(TCONF,
>> +			"current environment doesn't meet test, please set timerslack to 50us");
> Why can't we just store the result here into a global and use it later
> on in the reset case?
>
> Given that we have check function already all we need to do is to add
> one more function that passes the global to the check_get_timerslack()
> instead of the expected value.

Hi Cyril

It sounds reasonable. We should not limit it in 50us. I will follow your advise.

Thanks
Yang Xu

>> +}
>> +
>> +static struct tst_test test = {
>> +	.setup = setup,
>> +	.test = verify_prctl,
>> +	.tcnt = ARRAY_SIZE(tcases),
>> +	.forks_child = 1,
>> +};
>> -- 
>> 2.18.1
>>
>>
>>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191108/ff1610fb/attachment.htm>

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

* [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  2019-11-07 13:23       ` Cyril Hrubis
@ 2019-11-08 11:21         ` Yang Xu
  0 siblings, 0 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-08 11:21 UTC (permalink / raw)
  To: ltp


on 2019/11/07 21:23, Cyril Hrubis wrote:

> Hi!
>> +#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);
>> +
>> +	TEST(prctl(PR_SET_TIMERSLACK, 200000));
> This is a bit more complicated.
>
> First of all it does not make sense to set the timerslack in the sample
> function. It should be done once in the test setup.
>
> Also in the tst_timer_test.c we store the timerslack value in the
> timer_setup(), which executes the test setup() at the end of the
> function, so we would have to move the part that gets the timerslack()
> after the test setup() function so that the library includes the newly
> set timerslack in the calculation.

Ok. I will set timerslack to 200us in setup and move timer_setup after test set up so that
we can get the 200us value.

>
>> +	if (TST_RET != 0) {
>> +		tst_res(TFAIL | TTERRNO,
>> +			"prctl(), returned %li", TST_RET);
>> +		return 1;
>> +	}
>> +
>> +	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 struct tst_test test = {
>> +	.scall = "prctl()",
>> +	.sample = sample_fn,
>> +};
>> -- 
>> 2.18.1
>>
>>
>>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191108/8c6cfde6/attachment.htm>

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

* [LTP] [PATCH v5 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  2019-11-07 13:05     ` Cyril Hrubis
  2019-11-08 11:03       ` Yang Xu
@ 2019-11-08 12:00       ` Yang Xu
  2019-11-08 12:00         ` [LTP] [PATCH v5 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
                           ` (2 more replies)
  1 sibling, 3 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-08 12:00 UTC (permalink / raw)
  To: ltp

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 include/lapi/prctl.h                       |   5 +
 runtest/syscalls                           |   1 +
 testcases/kernel/syscalls/prctl/.gitignore |   1 +
 testcases/kernel/syscalls/prctl/prctl08.c  | 139 +++++++++++++++++++++
 4 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c

diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
index 8ee492259..0b4e196c3 100644
--- a/include/lapi/prctl.h
+++ b/include/lapi/prctl.h
@@ -19,6 +19,11 @@
 # define PR_SET_SECCOMP  22
 #endif
 
+#ifndef PR_SET_TIMERSLACK
+# define PR_SET_TIMERSLACK 29
+# define PR_GET_TIMERSLACK 30
+#endif
+
 #ifndef PR_SET_CHILD_SUBREAPER
 # define PR_SET_CHILD_SUBREAPER	36
 # define PR_GET_CHILD_SUBREAPER	37
diff --git a/runtest/syscalls b/runtest/syscalls
index 12d3e0d3b..fee91f909 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -879,6 +879,7 @@ prctl04 prctl04
 prctl05 prctl05
 prctl06 prctl06
 prctl07 prctl07
+prctl08 prctl08
 
 pread01 pread01
 pread01_64 pread01_64
diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
index 2178db366..fe36a8e0f 100644
--- a/testcases/kernel/syscalls/prctl/.gitignore
+++ b/testcases/kernel/syscalls/prctl/.gitignore
@@ -6,3 +6,4 @@
 /prctl06
 /prctl06_execve
 /prctl07
+/prctl08
diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
new file mode 100644
index 000000000..fd8ccb6ad
--- /dev/null
+++ b/testcases/kernel/syscalls/prctl/prctl08.c
@@ -0,0 +1,139 @@
+// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
+ * 1)Each thread has two associated timer slack values: a "default"
+ *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
+ *   timer slack value for the calling thread.
+ * 2)When a new thread is created, the two timer slack values are made
+ *   the same as the "current" value of the creating thread.
+ * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
+ *   is a valid value(about 4s). On 64bit machines, it is about 500 years
+ *   and no person will set this over 4s.  prctl return value is int, so
+ *   we test themaximum value is INT_MAX.
+ * 4)we also check current value via /proc/self/timerslack_ns if it is
+ *  supported.
+ */
+
+#include <sys/prctl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/limits.h>
+#include "lapi/syscalls.h"
+#include "lapi/prctl.h"
+#include "tst_test.h"
+
+#define PROC_TIMERSLACK_PATH "/proc/self/timerslack_ns"
+
+static void check_reset_timerslack(char *message);
+static void check_get_timerslack(char *message, unsigned long value);
+static void check_inherit_timerslack(char *message, unsigned long value);
+static unsigned long origin_value;
+
+static struct tcase {
+	void (*func_check)();
+	unsigned long setvalue;
+	unsigned long expvalue;
+	char message[50];
+} tcases[] = {
+	{check_reset_timerslack, 0, 50000, "Reset"},
+	{check_get_timerslack, 1, 1, "Min"},
+	{check_get_timerslack, 70000, 70000, "Middle"},
+	{check_get_timerslack, INT_MAX, INT_MAX, "Max"},
+	{check_inherit_timerslack, 70000, 70000, "Child process"},
+};
+
+static int proc_flag = 1;
+
+static void check_reset_timerslack(char *message)
+{
+	check_get_timerslack(message, origin_value);
+}
+
+static void check_proc_timerslack(char *message, unsigned long value)
+{
+	unsigned long proc_value;
+
+	SAFE_FILE_SCANF(PROC_TIMERSLACK_PATH, "%lu", &proc_value);
+	if (proc_value == value)
+		tst_res(TPASS, "%s %s  got %lu expectedly",
+				message, PROC_TIMERSLACK_PATH, proc_value);
+	else
+		tst_res(TFAIL, "%s %s expected %lu got %lu",
+				message, PROC_TIMERSLACK_PATH, value, proc_value);
+}
+
+static void check_get_timerslack(char *message, unsigned long value)
+{
+	TEST(prctl(PR_GET_TIMERSLACK));
+	if ((unsigned long)TST_RET == value)
+		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
+				message, value);
+	else
+		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
+				message, value, TST_RET);
+
+	if (proc_flag)
+		check_proc_timerslack(message, value);
+
+}
+
+static void check_inherit_timerslack(char *message, unsigned long value)
+{
+	int pid;
+	unsigned long current_value;
+	unsigned long default_value;
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		current_value = prctl(PR_GET_TIMERSLACK);
+		prctl(PR_SET_TIMERSLACK, 0);
+		default_value = prctl(PR_GET_TIMERSLACK);
+		if (current_value == value && default_value == value)
+			tst_res(TPASS,
+				"%s two timer slack values are made the same as the current value(%lu) of the creating thread.",
+				message, value);
+		else
+			tst_res(TFAIL,
+				"%s current_value is %lu, default value is %lu, the parent current value is %lu",
+				message, current_value, default_value, value);
+	}
+
+}
+
+static void verify_prctl(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
+					  tc->setvalue);
+		return;
+	}
+
+	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
+	tc->func_check(tc->message, tc->expvalue);
+}
+
+static void setup(void)
+{
+	if (access(PROC_TIMERSLACK_PATH, F_OK) == -1) {
+		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
+		proc_flag = 0;
+	}
+
+	TEST(prctl(PR_GET_TIMERSLACK));
+	origin_value = TST_RET;
+	tst_res(TINFO, "current timerslack value is %lu", origin_value);
+}
+
+static struct tst_test test = {
+	.setup = setup,
+	.test = verify_prctl,
+	.tcnt = ARRAY_SIZE(tcases),
+	.forks_child = 1,
+};
-- 
2.18.0




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

* [LTP] [PATCH v5 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  2019-11-08 12:00       ` [LTP] [PATCH v5 " Yang Xu
@ 2019-11-08 12:00         ` Yang Xu
  2019-11-15 16:35           ` Cyril Hrubis
  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
  2 siblings, 1 reply; 20+ messages in thread
From: Yang Xu @ 2019-11-08 12:00 UTC (permalink / raw)
  To: ltp

It also moves test setup function before timer setup function,
so we can get this set value.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 lib/tst_timer_test.c                       |  8 ++--
 runtest/syscalls                           |  1 +
 testcases/kernel/syscalls/prctl/.gitignore |  1 +
 testcases/kernel/syscalls/prctl/Makefile   |  2 +-
 testcases/kernel/syscalls/prctl/prctl09.c  | 47 ++++++++++++++++++++++
 5 files changed, 53 insertions(+), 6 deletions(-)
 create mode 100644 testcases/kernel/syscalls/prctl/prctl09.c

diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index f6459e5c0..13e9deff2 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -340,6 +340,9 @@ static void timer_setup(void)
 	struct timespec t;
 	int ret;
 
+	if (setup)
+		setup();
+
 	tst_clock_getres(CLOCK_MONOTONIC, &t);
 
 	tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec);
@@ -360,16 +363,11 @@ static void timer_setup(void)
 	tst_res(TINFO, "PR_GET_TIMERSLACK not defined, using %uus",
 		timerslack);
 #endif /* PR_GET_TIMERSLACK */
-
 	parse_timer_opts();
 
 	samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt));
-
 	if (set_latency() < 0)
 		tst_res(TINFO, "Failed to set zero latency constraint: %m");
-
-	if (setup)
-		setup();
 }
 
 static void timer_cleanup(void)
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..e4d76ef85
--- /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 sampling tests 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




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

* [LTP] [PATCH v5 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  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  9:01         ` Yang Xu
  2019-11-15 16:34         ` Cyril Hrubis
  2 siblings, 0 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-15  9:01 UTC (permalink / raw)
  To: ltp

Hi
Does anyone have some comments for this two patches?


> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>   include/lapi/prctl.h                       |   5 +
>   runtest/syscalls                           |   1 +
>   testcases/kernel/syscalls/prctl/.gitignore |   1 +
>   testcases/kernel/syscalls/prctl/prctl08.c  | 139 +++++++++++++++++++++
>   4 files changed, 146 insertions(+)
>   create mode 100644 testcases/kernel/syscalls/prctl/prctl08.c
>
> diff --git a/include/lapi/prctl.h b/include/lapi/prctl.h
> index 8ee492259..0b4e196c3 100644
> --- a/include/lapi/prctl.h
> +++ b/include/lapi/prctl.h
> @@ -19,6 +19,11 @@
>   # define PR_SET_SECCOMP  22
>   #endif
>   
> +#ifndef PR_SET_TIMERSLACK
> +# define PR_SET_TIMERSLACK 29
> +# define PR_GET_TIMERSLACK 30
> +#endif
> +
>   #ifndef PR_SET_CHILD_SUBREAPER
>   # define PR_SET_CHILD_SUBREAPER	36
>   # define PR_GET_CHILD_SUBREAPER	37
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 12d3e0d3b..fee91f909 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -879,6 +879,7 @@ prctl04 prctl04
>   prctl05 prctl05
>   prctl06 prctl06
>   prctl07 prctl07
> +prctl08 prctl08
>   
>   pread01 pread01
>   pread01_64 pread01_64
> diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore
> index 2178db366..fe36a8e0f 100644
> --- a/testcases/kernel/syscalls/prctl/.gitignore
> +++ b/testcases/kernel/syscalls/prctl/.gitignore
> @@ -6,3 +6,4 @@
>   /prctl06
>   /prctl06_execve
>   /prctl07
> +/prctl08
> diff --git a/testcases/kernel/syscalls/prctl/prctl08.c b/testcases/kernel/syscalls/prctl/prctl08.c
> new file mode 100644
> index 000000000..fd8ccb6ad
> --- /dev/null
> +++ b/testcases/kernel/syscalls/prctl/prctl08.c
> @@ -0,0 +1,139 @@
> +// 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 PR_GET_TIMERSLACK and PR_SET_TIMERSLACK of prctl(2).
> + * 1)Each thread has two associated timer slack values: a "default"
> + *   value, and a "current" value. PR_SET_TIMERSLACK sets the "current"
> + *   timer slack value for the calling thread.
> + * 2)When a new thread is created, the two timer slack values are made
> + *   the same as the "current" value of the creating thread.
> + * 3)The maximum timer slack value is ULONG_MAX. On 32bit machines, it
> + *   is a valid value(about 4s). On 64bit machines, it is about 500 years
> + *   and no person will set this over 4s.  prctl return value is int, so
> + *   we test themaximum value is INT_MAX.
> + * 4)we also check current value via /proc/self/timerslack_ns if it is
> + *  supported.
> + */
> +
> +#include <sys/prctl.h>
> +#include <string.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <linux/limits.h>
> +#include "lapi/syscalls.h"
> +#include "lapi/prctl.h"
> +#include "tst_test.h"
> +
> +#define PROC_TIMERSLACK_PATH "/proc/self/timerslack_ns"
> +
> +static void check_reset_timerslack(char *message);
> +static void check_get_timerslack(char *message, unsigned long value);
> +static void check_inherit_timerslack(char *message, unsigned long value);
> +static unsigned long origin_value;
> +
> +static struct tcase {
> +	void (*func_check)();
> +	unsigned long setvalue;
> +	unsigned long expvalue;
> +	char message[50];
> +} tcases[] = {
> +	{check_reset_timerslack, 0, 50000, "Reset"},
> +	{check_get_timerslack, 1, 1, "Min"},
> +	{check_get_timerslack, 70000, 70000, "Middle"},
> +	{check_get_timerslack, INT_MAX, INT_MAX, "Max"},
> +	{check_inherit_timerslack, 70000, 70000, "Child process"},
> +};
> +
> +static int proc_flag = 1;
> +
> +static void check_reset_timerslack(char *message)
> +{
> +	check_get_timerslack(message, origin_value);
> +}
> +
> +static void check_proc_timerslack(char *message, unsigned long value)
> +{
> +	unsigned long proc_value;
> +
> +	SAFE_FILE_SCANF(PROC_TIMERSLACK_PATH, "%lu", &proc_value);
> +	if (proc_value == value)
> +		tst_res(TPASS, "%s %s  got %lu expectedly",
> +				message, PROC_TIMERSLACK_PATH, proc_value);
> +	else
> +		tst_res(TFAIL, "%s %s expected %lu got %lu",
> +				message, PROC_TIMERSLACK_PATH, value, proc_value);
> +}
> +
> +static void check_get_timerslack(char *message, unsigned long value)
> +{
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	if ((unsigned long)TST_RET == value)
> +		tst_res(TPASS, "%s prctl(PR_GET_TIMERSLACK) got %lu expectedly",
> +				message, value);
> +	else
> +		tst_res(TFAIL, "%s prctl(PR_GET_TIMERSLACK) expected %lu got %lu",
> +				message, value, TST_RET);
> +
> +	if (proc_flag)
> +		check_proc_timerslack(message, value);
> +
> +}
> +
> +static void check_inherit_timerslack(char *message, unsigned long value)
> +{
> +	int pid;
> +	unsigned long current_value;
> +	unsigned long default_value;
> +
> +	pid = SAFE_FORK();
> +	if (pid == 0) {
> +		current_value = prctl(PR_GET_TIMERSLACK);
> +		prctl(PR_SET_TIMERSLACK, 0);
> +		default_value = prctl(PR_GET_TIMERSLACK);
> +		if (current_value == value && default_value == value)
> +			tst_res(TPASS,
> +				"%s two timer slack values are made the same as the current value(%lu) of the creating thread.",
> +				message, value);
> +		else
> +			tst_res(TFAIL,
> +				"%s current_value is %lu, default value is %lu, the parent current value is %lu",
> +				message, current_value, default_value, value);
> +	}
> +
> +}
> +
> +static void verify_prctl(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +
> +	TEST(prctl(PR_SET_TIMERSLACK, tc->setvalue));
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_TIMERSLACK, %lu) failed",
> +					  tc->setvalue);
> +		return;
> +	}
> +
> +	tst_res(TPASS, "prctl(PR_SET_TIMERSLACK, %lu) succeed", tc->setvalue);
> +	tc->func_check(tc->message, tc->expvalue);
> +}
> +
> +static void setup(void)
> +{
> +	if (access(PROC_TIMERSLACK_PATH, F_OK) == -1) {
> +		tst_res(TCONF, "proc doesn't support timerslack_ns interface");
> +		proc_flag = 0;
> +	}
> +
> +	TEST(prctl(PR_GET_TIMERSLACK));
> +	origin_value = TST_RET;
> +	tst_res(TINFO, "current timerslack value is %lu", origin_value);
> +}
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.test = verify_prctl,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.forks_child = 1,
> +};


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191115/5b6e3ef4/attachment.htm>

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

* [LTP] [PATCH v5 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK
  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  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
  2 siblings, 0 replies; 20+ messages in thread
From: Cyril Hrubis @ 2019-11-15 16:34 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v5 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  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
  0 siblings, 2 replies; 20+ messages in thread
From: Cyril Hrubis @ 2019-11-15 16:35 UTC (permalink / raw)
  To: ltp

Hi!
> It also moves test setup function before timer setup function,
> so we can get this set value.

Can we please change the library code in a separate patch with
appropripate description of the change?

Otherwise it looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v5 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  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
  1 sibling, 0 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-18  1:21 UTC (permalink / raw)
  To: ltp


on 2019/11/16 0:35, Cyril Hrubis wrote:

> Hi!
>> It also moves test setup function before timer setup function,
>> so we can get this set value.
> Can we please change the library code in a separate patch with
> appropripate description of the change?

Of course. I will put the library code change in a separate patch.

>
> Otherwise it looks good.
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191118/1549998d/attachment.htm>

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

* [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK
  2019-11-15 16:35           ` Cyril Hrubis
  2019-11-18  1:21             ` Yang Xu
@ 2019-11-18  2:34             ` Yang Xu
  2019-11-18  2:34               ` [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
  2019-11-20  6:54               ` [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK Yang Xu
  1 sibling, 2 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-18  2:34 UTC (permalink / raw)
  To: ltp

Move test setup function before PR_GET_TIMERSLACK in timer setup function so
that the library includes the newly set timerslack in the calculation.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_timer_test.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index f6459e5c0..13e9deff2 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -340,6 +340,9 @@ static void timer_setup(void)
 	struct timespec t;
 	int ret;
 
+	if (setup)
+		setup();
+
 	tst_clock_getres(CLOCK_MONOTONIC, &t);
 
 	tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec);
@@ -360,16 +363,11 @@ static void timer_setup(void)
 	tst_res(TINFO, "PR_GET_TIMERSLACK not defined, using %uus",
 		timerslack);
 #endif /* PR_GET_TIMERSLACK */
-
 	parse_timer_opts();
 
 	samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt));
-
 	if (set_latency() < 0)
 		tst_res(TINFO, "Failed to set zero latency constraint: %m");
-
-	if (setup)
-		setup();
 }
 
 static void timer_cleanup(void)
-- 
2.18.0




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

* [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  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
  2019-11-25 11:07                 ` 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
  1 sibling, 1 reply; 20+ messages in thread
From: Yang Xu @ 2019-11-18  2:34 UTC (permalink / raw)
  To: ltp

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




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

* [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK
  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               ` [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
@ 2019-11-20  6:54               ` Yang Xu
  2019-11-25 10:18                 ` Yang Xu
  1 sibling, 1 reply; 20+ messages in thread
From: Yang Xu @ 2019-11-20  6:54 UTC (permalink / raw)
  To: ltp

Hi Cyril

 ?I think this patch can be merged if it is ok.

Thanks
Yang Xu

> Move test setup function before PR_GET_TIMERSLACK in timer setup function so
> that the library includes the newly set timerslack in the calculation.
>
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>   lib/tst_timer_test.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
> index f6459e5c0..13e9deff2 100644
> --- a/lib/tst_timer_test.c
> +++ b/lib/tst_timer_test.c
> @@ -340,6 +340,9 @@ static void timer_setup(void)
>   	struct timespec t;
>   	int ret;
>   
> +	if (setup)
> +		setup();
> +
>   	tst_clock_getres(CLOCK_MONOTONIC, &t);
>   
>   	tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec);
> @@ -360,16 +363,11 @@ static void timer_setup(void)
>   	tst_res(TINFO, "PR_GET_TIMERSLACK not defined, using %uus",
>   		timerslack);
>   #endif /* PR_GET_TIMERSLACK */
> -
>   	parse_timer_opts();
>   
>   	samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt));
> -
>   	if (set_latency() < 0)
>   		tst_res(TINFO, "Failed to set zero latency constraint: %m");
> -
> -	if (setup)
> -		setup();
>   }
>   
>   static void timer_cleanup(void)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191120/b98d0025/attachment.htm>

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

* [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK
  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
  0 siblings, 0 replies; 20+ messages in thread
From: Yang Xu @ 2019-11-25 10:18 UTC (permalink / raw)
  To: ltp

Hi

ping.

> Hi Cyril
>  ?I think this patch can be merged if it is ok.
> Thanks
> Yang Xu
>> Move test setup function before PR_GET_TIMERSLACK in timer setup function so
>> that the library includes the newly set timerslack in the calculation.
>>
>> Signed-off-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
>> ---
>>   lib/tst_timer_test.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
>> index f6459e5c0..13e9deff2 100644
>> --- a/lib/tst_timer_test.c
>> +++ b/lib/tst_timer_test.c
>> @@ -340,6 +340,9 @@ static void timer_setup(void)
>>   	struct timespec t;
>>   	int ret;
>>   
>> +	if (setup)
>> +		setup();
>> +
>>   	tst_clock_getres(CLOCK_MONOTONIC, &t);
>>   
>>   	tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec);
>> @@ -360,16 +363,11 @@ static void timer_setup(void)
>>   	tst_res(TINFO, "PR_GET_TIMERSLACK not defined, using %uus",
>>   		timerslack);
>>   #endif /* PR_GET_TIMERSLACK */
>> -
>>   	parse_timer_opts();
>>   
>>   	samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt));
>> -
>>   	if (set_latency() < 0)
>>   		tst_res(TINFO, "Failed to set zero latency constraint: %m");
>> -
>> -	if (setup)
>> -		setup();
>>   }
>>   
>>   static void timer_cleanup(void)
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191125/2bb2fafe/attachment.htm>

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

* [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
  2019-11-18  2:34               ` [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
@ 2019-11-25 11:07                 ` Cyril Hrubis
  0 siblings, 0 replies; 20+ messages in thread
From: Cyril Hrubis @ 2019-11-25 11:07 UTC (permalink / raw)
  To: ltp

Hi!
Both pushed, thanks.

Sorry for the delay.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2019-11-25 11:07 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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               ` [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
2019-11-25 11:07                 ` 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

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.