Skip to contentSkip to conversation

rt-tests: Add --duration argument to tests

PATCH In review Daniel Wagner 2 participants 21 messages Jun 5, 2019 – Jun 16, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover rt-tests: Add --duration argument to tests

An updated version of the --duration series.
It is also available from github:

https://github.com/igaw/rt-tests/tree/dw-devel

changes since v1:
- '--duration' patch splitted up
- added short option support to pi_stress
- added build warning
- added 32bit ARM 'support' to queuelat patch

Daniel Wagner (12):
rt_numa.h: Remove unused function
queuelat: Use clock syscall for ARM 32 bit
rt-utils: Move parse_time_string()
pi_stress: Allow short command line arguments
pi_stress: Rename -t command line option to -D
pmqtest: Add duration command line argument
ptsematest: Add duration command line argument
cyclicdeadline: Add duration command line argument
signaltest: Add duration command line argument
sigwaittest: Add duration command line argument
svsematest: Add duration command line argument
rt-migrate-test: Add duration command line argument

 src/cyclictest/cyclictest.c           | 33 --------------------------
 src/cyclictest/rt_numa.h              |  7 ------
 src/include/rt-utils.h                |  2 ++
 src/lib/rt-utils.c                    | 34 +++++++++++++++++++++++++++
 src/pi_tests/pi_stress.8              |  4 ++++
 src/pi_tests/pi_stress.c              | 12 +++++-----
 src/pmqtest/pmqtest.8                 |  5 ++++
 src/pmqtest/pmqtest.c                 | 17 ++++++++++++--
 src/ptsematest/ptsematest.8           |  5 ++++
 src/ptsematest/ptsematest.c           | 14 ++++++++++-
 src/queuelat/queuelat.c               | 31 ++++++++++++++++++++----
 src/rt-migrate-test/rt-migrate-test.8 |  5 ++++
 src/rt-migrate-test/rt-migrate-test.c | 12 +++++++++-
 src/sched_deadline/cyclicdeadline.c   | 12 +++++++++-
 src/signaltest/signaltest.8           |  5 ++++
 src/signaltest/signaltest.c           | 14 ++++++++++-
 src/sigwaittest/sigwaittest.8         |  5 ++++
 src/sigwaittest/sigwaittest.c         | 15 +++++++++++-
 src/svsematest/svsematest.8           |  5 ++++
 src/svsematest/svsematest.c           | 15 +++++++++++-
 20 files changed, 193 insertions(+), 59 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/12 rt_numa.h: Remove unused function

From: Daniel Wagner <[email protected]>

GCC on a BeagleBoneBlack complains:

In file included from src/cyclictest/cyclictest.c:39:0:
src/cyclictest/rt_numa.h:253:13: warning: ‘numa_on_and_available’ defined but not used [-Wunused-function]
static void numa_on_and_available()

             ^~~~~~~~~~~~~~~~~~~~~
---
 src/cyclictest/rt_numa.h | 7 -------
 1 file changed, 7 deletions(-)
src/cyclictest/rt_numa.h +0 -7
index e8cd7f481baa..e0f4b2e9d8b2 100644
@@ -249,13 +249,6 @@ static inline void rt_bitmask_free(struct bitmask *mask)
 	free(mask);
 }
 
-
-static void numa_on_and_available()
-{
-	if (numa) /* NUMA is not defined here */
-		fatal("numa mode and numa functions not available.\n");
-}
-
 #endif	/* NUMA */
 
 /*
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH v2 01/12] rt_numa.h: Remove unused function

Quoted 23 lines · Daniel Wagner

From: Daniel Wagner <[email protected]>

GCC on a BeagleBoneBlack complains:

In file included from src/cyclictest/cyclictest.c:39:0:
src/cyclictest/rt_numa.h:253:13: warning: ‘numa_on_and_available’ defined but not used [-Wunused-function]
static void numa_on_and_available()

             ^~~~~~~~~~~~~~~~~~~~~
---
 src/cyclictest/rt_numa.h | 7 -------
 1 file changed, 7 deletions(-)
src/cyclictest/rt_numa.h +0 -0
index e8cd7f481baa..e0f4b2e9d8b2 100644
@@ -249,13 +249,6 @@ static inline void rt_bitmask_free(struct bitmask *mask)
 	free(mask);
 }
 

src/cyclictest/rt_numa.h static inline void rt_bitmask_free(struct bitmask *mask) · line 254

Quoted 10 lines
src/cyclictest/rt_numa.h +0 -7
-
-static void numa_on_and_available()
-{
-	if (numa) /* NUMA is not defined here */
-		fatal("numa mode and numa functions not available.\n");
-}
-
 #endif	/* NUMA */
 
 /*
#3 lore raw

PATCH v2 2/12 queuelat: Use clock syscall for ARM 32 bit

In reply to Daniel Wagner

CPUs such as Cortex-M8 don't have a rdtsc instruction. Fallback using a syscall.

---
 src/queuelat/queuelat.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
src/queuelat/queuelat.c +26 -5
index 3b291f168768..a5525e41776a 100644
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <signal.h>
+#include <time.h>
 
 #define NSEC_PER_SEC 1000000000
 
@@ -249,6 +250,8 @@ typedef unsigned long long cycles_t;
 typedef unsigned long long usecs_t;
 typedef unsigned long long u64;
 
+#if defined __x86_64__ || defined __i386__
+
 #ifdef __x86_64__
 #define DECLARE_ARGS(val, low, high)    unsigned low, high
 #define EAX_EDX_VAL(val, low, high)     ((low) | ((u64)(high) << 32))
@@ -270,7 +273,25 @@ static inline unsigned long long __rdtscll(void)
         return EAX_EDX_VAL(val, low, high);
 }
 
-#define rdtscll(val) do { (val) = __rdtscll(); } while (0)
+#define gettick(val) do { (val) = __rdtscll(); } while (0)
+
+#elif defined __arm__
+
+static inline unsigned long long __clock_gettime(void)
+{
+	struct timespec now;
+	int ret;
+
+	ret = clock_gettime(CLOCK_MONOTONIC, &now);
+	if (ret < 0)
+		return 0;
+
+	return now.tv_nsec;
+}
+
+#define gettick(val) do { (val) = __clock_gettime(); } while (0)
+
+#endif
 
 static void init_buckets(void)
 {
@@ -348,9 +369,9 @@ static void run_n(int n)
 
 	memmove(dest, src, n);
 	for (i = 0; i < loops; i++) {
-		rdtscll(b);
+		gettick(b);
 		memmove(dest, src, n);
-		rdtscll(a);
+		gettick(a);
 		delta = (a - b) * cycles_to_ns;
 		account(delta);
 	}
@@ -446,9 +467,9 @@ void main_loop(void)
 		int ret;
 		int nr_packets_fill;
 
-		rdtscll(b);
+		gettick(b);
 		memmove(dest, src, default_n);
-		rdtscll(a);
+		gettick(a);
 		delta = (a - b) * cycles_to_ns;
 		account(delta);
 
Signature · 1 line
2.20.1
#4 lore raw

Re: [PATCH v2 02/12] queuelat: Use clock syscall for ARM 32 bit

Quoted 71 lines · Daniel Wagner

CPUs such as Cortex-M8 don't have a rdtsc instruction. Fallback using a syscall.

---
 src/queuelat/queuelat.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
src/queuelat/queuelat.c +24 -3
index 3b291f168768..a5525e41776a 100644
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <signal.h>
+#include <time.h>
 
 #define NSEC_PER_SEC 1000000000
 
@@ -249,6 +250,8 @@ typedef unsigned long long cycles_t;
 typedef unsigned long long usecs_t;
 typedef unsigned long long u64;
 
+#if defined __x86_64__ || defined __i386__
+
 #ifdef __x86_64__
 #define DECLARE_ARGS(val, low, high)    unsigned low, high
 #define EAX_EDX_VAL(val, low, high)     ((low) | ((u64)(high) << 32))
@@ -270,7 +273,25 @@ static inline unsigned long long __rdtscll(void)
         return EAX_EDX_VAL(val, low, high);
 }
 
-#define rdtscll(val) do { (val) = __rdtscll(); } while (0)
+#define gettick(val) do { (val) = __rdtscll(); } while (0)
+
+#elif defined __arm__
+
+static inline unsigned long long __clock_gettime(void)
+{
+	struct timespec now;
+	int ret;
+
+	ret = clock_gettime(CLOCK_MONOTONIC, &now);
+	if (ret < 0)
+		return 0;
+
+	return now.tv_nsec;
+}
+
+#define gettick(val) do { (val) = __clock_gettime(); } while (0)
+
+#endif
 
 static void init_buckets(void)
 {
@@ -348,9 +369,9 @@ static void run_n(int n)
 
 	memmove(dest, src, n);
 	for (i = 0; i < loops; i++) {
-		rdtscll(b);
+		gettick(b);
 		memmove(dest, src, n);
-		rdtscll(a);
+		gettick(a);
 		delta = (a - b) * cycles_to_ns;
 		account(delta);
 	}
@@ -446,9 +467,9 @@ void main_loop(void)
 		int ret;

src/queuelat/queuelat.c void main_loop(void) · line 475

Quoted 10 lines
src/queuelat/queuelat.c +2 -2
 		int nr_packets_fill;
 
-		rdtscll(b);
+		gettick(b);
 		memmove(dest, src, default_n);
-		rdtscll(a);
+		gettick(a);
 		delta = (a - b) * cycles_to_ns;
 		account(delta);
 
#5 lore raw

PATCH v2 3/12 rt-utils: Move parse_time_string()

In reply to Daniel Wagner

Move parse_time_string() to rt-utils.c so we can re use it.

---
 src/cyclictest/cyclictest.c | 33 ---------------------------------
 src/include/rt-utils.h      |  2 ++
 src/lib/rt-utils.c          | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 33 deletions(-)
src/cyclictest/cyclictest.c +0 -33
index ed59edefbf97..03d56e4f520c 100644
@@ -406,39 +406,6 @@ static void enable_trace_mark(void)
 	open_tracemark_fd();
 }
 
-/*
- * parse an input value as a base10 value followed by an optional
- * suffix. The input value is presumed to be in seconds, unless
- * followed by a modifier suffix: m=minutes, h=hours, d=days
- *
- * the return value is a value in seconds
- */
-static int parse_time_string(char *val)
-{
-	char *end;
-	int t = strtol(val, &end, 10);
-	if (end) {
-		switch (*end) {
-		case 'm':
-		case 'M':
-			t *= 60;
-			break;
-
-		case 'h':
-		case 'H':
-			t *= 60*60;
-			break;
-
-		case 'd':
-		case 'D':
-			t *= 24*60*60;
-			break;
-
-		}
-	}
-	return t;
-}
-
 /*
  * Raise the soft priority limit up to prio, if that is less than or equal
  * to the hard limit
src/include/rt-utils.h +2 -0
index ef0f6acf4ab5..405fa7855346 100644
@@ -24,4 +24,6 @@ uint32_t string_to_policy(const char *str);
 
 pid_t gettid(void);
 
+int parse_time_string(char *val);
+
 #endif	/* __RT_UTILS.H */
src/lib/rt-utils.c +34 -0
index ac6878ccacf1..e1b166afcd6c 100644
@@ -13,6 +13,7 @@
 #include <sched.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <ctype.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -320,3 +321,36 @@ pid_t gettid(void)
 {
 	return syscall(SYS_gettid);
 }
+
+/*
+ * parse an input value as a base10 value followed by an optional
+ * suffix. The input value is presumed to be in seconds, unless
+ * followed by a modifier suffix: m=minutes, h=hours, d=days
+ *
+ * the return value is a value in seconds
+ */
+int parse_time_string(char *val)
+{
+	char *end;
+	int t = strtol(val, &end, 10);
+	if (end) {
+		switch (*end) {
+		case 'm':
+		case 'M':
+			t *= 60;
+			break;
+
+		case 'h':
+		case 'H':
+			t *= 60*60;
+			break;
+
+		case 'd':
+		case 'D':
+			t *= 24*60*60;
+			break;
+
+		}
+	}
+	return t;
+}
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH v2 03/12] rt-utils: Move parse_time_string()

Quoted 104 lines · Daniel Wagner

Move parse_time_string() to rt-utils.c so we can re use it.

---
 src/cyclictest/cyclictest.c | 33 ---------------------------------
 src/include/rt-utils.h      |  2 ++
 src/lib/rt-utils.c          | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 33 deletions(-)
src/cyclictest/cyclictest.c +0 -33
index ed59edefbf97..03d56e4f520c 100644
@@ -406,39 +406,6 @@ static void enable_trace_mark(void)
 	open_tracemark_fd();
 }
 
-/*
- * parse an input value as a base10 value followed by an optional
- * suffix. The input value is presumed to be in seconds, unless
- * followed by a modifier suffix: m=minutes, h=hours, d=days
- *
- * the return value is a value in seconds
- */
-static int parse_time_string(char *val)
-{
-	char *end;
-	int t = strtol(val, &end, 10);
-	if (end) {
-		switch (*end) {
-		case 'm':
-		case 'M':
-			t *= 60;
-			break;
-
-		case 'h':
-		case 'H':
-			t *= 60*60;
-			break;
-
-		case 'd':
-		case 'D':
-			t *= 24*60*60;
-			break;
-
-		}
-	}
-	return t;
-}
-
 /*
  * Raise the soft priority limit up to prio, if that is less than or equal
  * to the hard limit
src/include/rt-utils.h +2 -0
index ef0f6acf4ab5..405fa7855346 100644
@@ -24,4 +24,6 @@ uint32_t string_to_policy(const char *str);
 
 pid_t gettid(void);
 
+int parse_time_string(char *val);
+
 #endif	/* __RT_UTILS.H */
src/lib/rt-utils.c +24 -0
index ac6878ccacf1..e1b166afcd6c 100644
@@ -13,6 +13,7 @@
 #include <sched.h>
 #include <stdarg.h>
 #include <errno.h>
+#include <ctype.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -320,3 +321,36 @@ pid_t gettid(void)
 {
 	return syscall(SYS_gettid);
 }
+
+/*
+ * parse an input value as a base10 value followed by an optional
+ * suffix. The input value is presumed to be in seconds, unless
+ * followed by a modifier suffix: m=minutes, h=hours, d=days
+ *
+ * the return value is a value in seconds
+ */
+int parse_time_string(char *val)
+{
+	char *end;
+	int t = strtol(val, &end, 10);
+	if (end) {
+		switch (*end) {
+		case 'm':
+		case 'M':
+			t *= 60;
+			break;
+
+		case 'h':
+		case 'H':
+			t *= 60*60;
+			break;

src/lib/rt-utils.c pid_t gettid(void) · line 356

Quoted 10 lines
src/lib/rt-utils.c +10 -0
+
+		case 'd':
+		case 'D':
+			t *= 24*60*60;
+			break;
+
+		}
+	}
+	return t;
+}
#7 lore raw

PATCH v2 4/12 pi_stress: Allow short command line arguments

In reply to Daniel Wagner

Add optstring to getopt_long() command line parser to support the short options as it documented in the man page and also in the usage help text.

---
 src/pi_tests/pi_stress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
src/pi_tests/pi_stress.c +1 -2
index ac7646cd2613..543106be8e18 100644
@@ -1322,9 +1322,8 @@ int process_sched_line(const char *arg)
 void process_command_line(int argc, char **argv)
 {
 	int opt;
-	while ((opt = getopt_long(argc, argv, "+", options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+ht:vqi:g:rs:pdVum", options, NULL)) != -1) {
 		switch (opt) {
-		case '?':
 		case 'h':
 			usage();
 			exit(0);
Signature · 1 line
2.20.1
#8 lore raw

Re: [PATCH v2 04/12] pi_stress: Allow short command line arguments

Quoted 27 lines · Daniel Wagner

Add optstring to getopt_long() command line parser to support the short options as it documented in the man page and also in the usage help text.

---
 src/pi_tests/pi_stress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
src/pi_tests/pi_stress.c +1 -2
index ac7646cd2613..543106be8e18 100644
@@ -1322,9 +1322,8 @@ int process_sched_line(const char *arg)
 void process_command_line(int argc, char **argv)
 {
 	int opt;
-	while ((opt = getopt_long(argc, argv, "+", options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+ht:vqi:g:rs:pdVum", options, NULL)) != -1) {
 		switch (opt) {
-		case '?':
 		case 'h':
 			usage();
 			exit(0);
Signature · 1 line
2.20.1

I actually don't see short options in the usage help text, but I do see them in the manpage.

This could use some clean-up to make sure the manpage is current and the usage text is current and synced too, if you or anyone else reading cares to address this.

#9 lore raw

Re: [PATCH v2 04/12] pi_stress: Allow short command line arguments

Hi John,

Quoted 21 lines · John Kacur
Quoted 17 lines

index ac7646cd2613..543106be8e18 100644

src/pi_tests/pi_stress.c +1 -2
@@ -1322,9 +1322,8 @@ int process_sched_line(const char *arg)
  void process_command_line(int argc, char **argv)
  {
  	int opt;
-	while ((opt = getopt_long(argc, argv, "+", options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+ht:vqi:g:rs:pdVum", options, NULL)) != -1) {
  		switch (opt) {
-		case '?':
  		case 'h':
  			usage();
  			exit(0);
Signature · 1 line
2.20.1

I actually don't see short options in the usage help text, but I do see them in the manpage.

Quoted 3 lines

This could use some clean-up to make sure the manpage is current and the usage text is current and synced too, if you or anyone else reading cares to address this.

pi_stress differs a bit in the handling of the options. Indeed it makes sense to streamline it with the other tools. Will look into it (but don't hold your breath :))

Thanks,
Daniel

#10 lore raw

PATCH v2 5/12 pi_stress: Rename -t command line option to -D

In reply to Daniel Wagner

Streamline the duration command line argument for all rt-tests. While at it also add man page.

---
 src/pi_tests/pi_stress.8 |  4 ++++
 src/pi_tests/pi_stress.c | 11 ++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)
src/pi_tests/pi_stress.8 +4 -0
index c92b4bdf5609..475d3c34f135 100644
@@ -57,6 +57,10 @@ seconds and then terminate.
 The number of inversion groups to run. Defaults to 10.
 .IP \-d|\-\-debug
 Run in debug mode; lots of extra prints
+.IP "\-D, \-\-duration=TIME"
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .IP \-v|\-\-verbose
 Run with verbose messages
 .IP \-s|\-\-signal
src/pi_tests/pi_stress.c +6 -5
index 543106be8e18..1286370c474b 100644
@@ -146,7 +146,7 @@ int lockall = 0;
 
 /* command line options */
 struct option options[] = {
-	{"duration", required_argument, NULL, 't'},
+	{"duration", required_argument, NULL, 'D'},
 	{"verbose", no_argument, NULL, 'v'},
 	{"quiet", no_argument, NULL, 'q'},
 	{"groups", required_argument, NULL, 'g'},
@@ -1027,7 +1027,8 @@ void usage(void)
 	printf("\t--verbose\t- lots of output\n");
 	printf("\t--quiet\t\t- suppress running output\n");
 	printf
-	    ("\t--duration=<n>- length of the test run in seconds [infinite]\n");
+	    ("\t--duration=<n>\t- length of the test run in seconds [infinite]\n");
+	printf("\t\t\t  Append 'm', 'h', or 'd' to specify minutes, hours or days.\n");
 	printf("\t--groups=<n>\t- set the number of inversion groups [%d]\n",
 	       ngroups);
 	printf
@@ -1322,13 +1323,13 @@ int process_sched_line(const char *arg)
 void process_command_line(int argc, char **argv)
 {
 	int opt;
-	while ((opt = getopt_long(argc, argv, "+ht:vqi:g:rs:pdVum", options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+hD:vqi:g:rs:pdVum", options, NULL)) != -1) {
 		switch (opt) {
 		case 'h':
 			usage();
 			exit(0);
-		case 't':
-			duration = strtol(optarg, NULL, 10);
+		case 'D':
+			duration = parse_time_string(optarg);
 			break;
 		case 'v':
 			verbose = 1;
Signature · 1 line
2.20.1
#11 lore raw

Re: [PATCH v2 05/12] pi_stress: Rename -t command line option to -D

Quoted 67 lines · Daniel Wagner

Streamline the duration command line argument for all rt-tests. While at it also add man page.

---
 src/pi_tests/pi_stress.8 |  4 ++++
 src/pi_tests/pi_stress.c | 11 ++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)
src/pi_tests/pi_stress.8 +4 -0
index c92b4bdf5609..475d3c34f135 100644
@@ -57,6 +57,10 @@ seconds and then terminate.
 The number of inversion groups to run. Defaults to 10.
 .IP \-d|\-\-debug
 Run in debug mode; lots of extra prints
+.IP "\-D, \-\-duration=TIME"
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .IP \-v|\-\-verbose
 Run with verbose messages
 .IP \-s|\-\-signal
src/pi_tests/pi_stress.c +6 -5
index 543106be8e18..1286370c474b 100644
@@ -146,7 +146,7 @@ int lockall = 0;
 
 /* command line options */
 struct option options[] = {
-	{"duration", required_argument, NULL, 't'},
+	{"duration", required_argument, NULL, 'D'},
 	{"verbose", no_argument, NULL, 'v'},
 	{"quiet", no_argument, NULL, 'q'},
 	{"groups", required_argument, NULL, 'g'},
@@ -1027,7 +1027,8 @@ void usage(void)
 	printf("\t--verbose\t- lots of output\n");
 	printf("\t--quiet\t\t- suppress running output\n");
 	printf
-	    ("\t--duration=<n>- length of the test run in seconds [infinite]\n");
+	    ("\t--duration=<n>\t- length of the test run in seconds [infinite]\n");
+	printf("\t\t\t  Append 'm', 'h', or 'd' to specify minutes, hours or days.\n");
 	printf("\t--groups=<n>\t- set the number of inversion groups [%d]\n",
 	       ngroups);
 	printf
@@ -1322,13 +1323,13 @@ int process_sched_line(const char *arg)
 void process_command_line(int argc, char **argv)
 {
 	int opt;
-	while ((opt = getopt_long(argc, argv, "+ht:vqi:g:rs:pdVum", options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "+hD:vqi:g:rs:pdVum", options, NULL)) != -1) {
 		switch (opt) {
 		case 'h':
 			usage();
 			exit(0);
-		case 't':
-			duration = strtol(optarg, NULL, 10);
+		case 'D':
+			duration = parse_time_string(optarg);
 			break;
 		case 'v':
 			verbose = 1;
Signature · 1 line
2.20.1
#12 lore raw

PATCH v2 6/12 pmqtest: Add duration command line argument

In reply to Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m pmqtest -D 10m
---
 src/pmqtest/pmqtest.8 |  5 +++++
 src/pmqtest/pmqtest.c | 17 +++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
src/pmqtest/pmqtest.8 +5 -0
index 05421e01e70b..9108a939b9f7 100644
@@ -21,6 +21,11 @@ It is useful to track down unexpected large latencies of a system.
 .B \-d, \-\-distance=DIST
 Set the distance of thread intervals in microseconds (default is 500 us). When pmqtest is called with the -t option and more than one thread is created, then this distance value is added to the interval of the threads: Interval(thread N) = Interval(thread N-1) + DIST
 .TP
+.B \-D, \-\-duration=TIME
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
+.TP
 .B \-f, \-\-forcetimeout=TO
 Set an artificial delay of the send function to force timeout of the receiver, requires the -T option
 .TP
src/pmqtest/pmqtest.c +15 -2
index 75d5ee8185a0..054768d161a7 100644
@@ -252,6 +252,8 @@ static void display_help(void)
 	"-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
 	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
 	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	"-D       --duration=TIME   specify a length for the test run.\n"
+	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
 	"-p PRIO  --prio=PRIO       priority\n"
 	"-S       --smp             SMP testing: options -a -t and same priority\n"
         "                           of all threads\n"
@@ -271,6 +273,7 @@ static int tracelimit;
 static int priority;
 static int num_threads = 1;
 static int max_cycles;
+static int duration;
 static int interval = 1000;
 static int distance = 500;
 static int smp;
@@ -293,6 +296,7 @@ static void process_options (int argc, char *argv[])
 			{"forcetimeout", required_argument, NULL, 'f'},
 			{"interval", required_argument, NULL, 'i'},
 			{"loops", required_argument, NULL, 'l'},
+			{"duration", required_argument, NULL, 'D'},
 			{"priority", required_argument, NULL, 'p'},
 			{"smp", no_argument, NULL, 'S'},
 			{"threads", optional_argument, NULL, 't'},
@@ -300,7 +304,7 @@ static void process_options (int argc, char *argv[])
 			{"help", no_argument, NULL, '?'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "a::b:d:f:i:l:p:St::T:",
+		int c = getopt_long (argc, argv, "a::b:d:f:i:l:D:p:St::T:",
 			long_options, &option_index);
 		if (c == -1)
 			break;
@@ -325,6 +329,7 @@ static void process_options (int argc, char *argv[])
 		case 'f': forcetimeout = atoi(optarg); break;
 		case 'i': interval = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'S':
 			smp = 1;
@@ -369,7 +374,10 @@ static void process_options (int argc, char *argv[])
 
 	if (forcetimeout && !timeout)
 		error = 1;
- 
+
+	if (duration < 0)
+		error = 1;
+
 	if (priority && smp)
 		sameprio = 1;
 
@@ -418,10 +426,15 @@ int main(int argc, char *argv[])
 	sigemptyset(&sigset);
 	sigaddset(&sigset, SIGTERM);
 	sigaddset(&sigset, SIGINT);
+	sigaddset(&sigset, SIGALRM);
 	pthread_sigmask(SIG_SETMASK, &sigset, NULL);
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	receiver = calloc(num_threads, sizeof(struct params));
 	sender = calloc(num_threads, sizeof(struct params));
Signature · 1 line
2.20.1
#13 lore raw

Re: [PATCH v2 06/12] pmqtest: Add duration command line argument

Quoted 112 lines · Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m pmqtest -D 10m
---
 src/pmqtest/pmqtest.8 |  5 +++++
 src/pmqtest/pmqtest.c | 17 +++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
src/pmqtest/pmqtest.8 +5 -0
index 05421e01e70b..9108a939b9f7 100644
@@ -21,6 +21,11 @@ It is useful to track down unexpected large latencies of a system.
 .B \-d, \-\-distance=DIST
 Set the distance of thread intervals in microseconds (default is 500 us). When pmqtest is called with the -t option and more than one thread is created, then this distance value is added to the interval of the threads: Interval(thread N) = Interval(thread N-1) + DIST
 .TP
+.B \-D, \-\-duration=TIME
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
+.TP
 .B \-f, \-\-forcetimeout=TO
 Set an artificial delay of the send function to force timeout of the receiver, requires the -T option
 .TP
src/pmqtest/pmqtest.c +15 -2
index 75d5ee8185a0..054768d161a7 100644
@@ -252,6 +252,8 @@ static void display_help(void)
 	"-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
 	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
 	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	"-D       --duration=TIME   specify a length for the test run.\n"
+	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
 	"-p PRIO  --prio=PRIO       priority\n"
 	"-S       --smp             SMP testing: options -a -t and same priority\n"
         "                           of all threads\n"
@@ -271,6 +273,7 @@ static int tracelimit;
 static int priority;
 static int num_threads = 1;
 static int max_cycles;
+static int duration;
 static int interval = 1000;
 static int distance = 500;
 static int smp;
@@ -293,6 +296,7 @@ static void process_options (int argc, char *argv[])
 			{"forcetimeout", required_argument, NULL, 'f'},
 			{"interval", required_argument, NULL, 'i'},
 			{"loops", required_argument, NULL, 'l'},
+			{"duration", required_argument, NULL, 'D'},
 			{"priority", required_argument, NULL, 'p'},
 			{"smp", no_argument, NULL, 'S'},
 			{"threads", optional_argument, NULL, 't'},
@@ -300,7 +304,7 @@ static void process_options (int argc, char *argv[])
 			{"help", no_argument, NULL, '?'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "a::b:d:f:i:l:p:St::T:",
+		int c = getopt_long (argc, argv, "a::b:d:f:i:l:D:p:St::T:",
 			long_options, &option_index);
 		if (c == -1)
 			break;
@@ -325,6 +329,7 @@ static void process_options (int argc, char *argv[])
 		case 'f': forcetimeout = atoi(optarg); break;
 		case 'i': interval = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'S':
 			smp = 1;
@@ -369,7 +374,10 @@ static void process_options (int argc, char *argv[])
 
 	if (forcetimeout && !timeout)
 		error = 1;
- 
+
+	if (duration < 0)
+		error = 1;
+
 	if (priority && smp)
 		sameprio = 1;
 
@@ -418,10 +426,15 @@ int main(int argc, char *argv[])
 	sigemptyset(&sigset);
 	sigaddset(&sigset, SIGTERM);
 	sigaddset(&sigset, SIGINT);
+	sigaddset(&sigset, SIGALRM);
 	pthread_sigmask(SIG_SETMASK, &sigset, NULL);
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	receiver = calloc(num_threads, sizeof(struct params));
 	sender = calloc(num_threads, sizeof(struct params));
Signature · 1 line
2.20.1
#14 lore raw

PATCH v2 7/12 ptsematest: Add duration command line argument

In reply to Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m ptsematest -D 10m
---
 src/ptsematest/ptsematest.8 |  5 +++++
 src/ptsematest/ptsematest.c | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
src/ptsematest/ptsematest.8 +5 -0
index 9d835337ec27..289f3a1d7ae8 100644
@@ -21,6 +21,11 @@ It is useful to track down unexpected large latencies of a system.
 .B \-d, \-\-distance=DIST
 Set the distance of thread intervals in microseconds (default is 500 us). When  cyclictest is called with the -t option and more than one thread is created, then this distance value is added to the interval of the threads: Interval(thread N) = Interval(thread N-1) + DIST
 .TP
+.B \-D, \-\-duration=TIME
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
+.TP
 .B \-i, \-\-interval=INTV
 Set the base interval of the thread(s) in microseconds (default is 1000 us). This sets the interval of the first thread. See also -d.
 .TP
src/ptsematest/ptsematest.c +13 -1
index a31c745ec928..6bedbc81b572 100644
@@ -173,6 +173,8 @@ static void display_help(void)
 	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
 	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
 	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	"-D       --duration=TIME   specify a length for the test run.\n"
+	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
 	"-p PRIO  --prio=PRIO       priority\n"
 	"-S       --smp             SMP testing: options -a -t and same priority\n"
         "                           of all threads\n"
@@ -190,6 +192,7 @@ static int tracelimit;
 static int priority;
 static int num_threads = 1;
 static int max_cycles;
+static int duration;
 static int interval = 1000;
 static int distance = 500;
 static int smp;
@@ -209,13 +212,14 @@ static void process_options (int argc, char *argv[])
 			{"distance", required_argument, NULL, 'd'},
 			{"interval", required_argument, NULL, 'i'},
 			{"loops", required_argument, NULL, 'l'},
+			{"duration", required_argument, NULL, 'D'},
 			{"priority", required_argument, NULL, 'p'},
 			{"smp", no_argument, NULL, 'S'},
 			{"threads", optional_argument, NULL, 't'},
 			{"help", no_argument, NULL, '?'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "a::b:d:i:l:p:St::",
+		int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:St::",
 			long_options, &option_index);
 		if (c == -1)
 			break;
@@ -239,6 +243,7 @@ static void process_options (int argc, char *argv[])
 		case 'd': distance = atoi(optarg); break;
 		case 'i': interval = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'S':
 			smp = 1;
@@ -280,6 +285,9 @@ static void process_options (int argc, char *argv[])
 	if (num_threads < 1)
 		error = 1;
 
+	if (duration < 0)
+		error = 1;
+
 	if (priority && smp)
 		sameprio = 1;
 
@@ -317,6 +325,10 @@ int main(int argc, char *argv[])
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	receiver = calloc(num_threads, sizeof(struct params));
 	sender = calloc(num_threads, sizeof(struct params));
Signature · 1 line
2.20.1
#15 lore raw

PATCH v2 8/12 cyclicdeadline: Add duration command line argument

In reply to Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m cyclicdeadline -D 10m
---
 src/sched_deadline/cyclicdeadline.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
src/sched_deadline/cyclicdeadline.c +11 -1
index 6d461b27ac43..47892daf747b 100644
@@ -21,6 +21,8 @@
 #include <linux/unistd.h>
 #include <linux/magic.h>
 
+#include <rt-utils.h>
+
 #ifdef __i386__
 #ifndef __NR_sched_setattr
 #define __NR_sched_setattr		351
@@ -1049,6 +1051,7 @@ int main (int argc, char **argv)
 	unsigned int interval = 1000;
 	unsigned int step = 500;
 	int percent = 60;
+	int duration = 0;
 	u64 runtime;
 	u64 start_period;
 	u64 end_period;
@@ -1062,7 +1065,7 @@ int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	while ((c = getopt(argc, argv, "+hac:i:s:t:")) >= 0) {
+	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
 		switch (c) {
 		case 'a':
 			all_cpus = 1;
@@ -1081,6 +1084,9 @@ int main (int argc, char **argv)
 		case 't':
 			nr_threads = atoi(optarg);
 			break;
+		case 'D':
+			duration = parse_time_string(optarg);
+			break;
 		case 'h':
 		default:
 			usage(argv);
@@ -1246,6 +1252,10 @@ int main (int argc, char **argv)
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	if (!fail)
 		loop(sched_data, nr_threads);
Signature · 1 line
2.20.1
#16 lore raw

Re: [PATCH v2 08/12] cyclicdeadline: Add duration command line argument

Quoted 72 lines · Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m cyclicdeadline -D 10m
---
 src/sched_deadline/cyclicdeadline.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
src/sched_deadline/cyclicdeadline.c +11 -1
index 6d461b27ac43..47892daf747b 100644
@@ -21,6 +21,8 @@
 #include <linux/unistd.h>
 #include <linux/magic.h>
 
+#include <rt-utils.h>
+
 #ifdef __i386__
 #ifndef __NR_sched_setattr
 #define __NR_sched_setattr		351
@@ -1049,6 +1051,7 @@ int main (int argc, char **argv)
 	unsigned int interval = 1000;
 	unsigned int step = 500;
 	int percent = 60;
+	int duration = 0;
 	u64 runtime;
 	u64 start_period;
 	u64 end_period;
@@ -1062,7 +1065,7 @@ int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	while ((c = getopt(argc, argv, "+hac:i:s:t:")) >= 0) {
+	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
 		switch (c) {
 		case 'a':
 			all_cpus = 1;
@@ -1081,6 +1084,9 @@ int main (int argc, char **argv)
 		case 't':
 			nr_threads = atoi(optarg);
 			break;
+		case 'D':
+			duration = parse_time_string(optarg);
+			break;
 		case 'h':
 		default:
 			usage(argv);
@@ -1246,6 +1252,10 @@ int main (int argc, char **argv)
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	if (!fail)
 		loop(sched_data, nr_threads);
Signature · 1 line
2.20.1

I'm reluctantly giving you a signed-off-by.
I say reluctantly because the program needs some work, so the problems exited before your patch, but it's a little hard to test your patch until these problems get resolved.

I can't run this without getting the message

For less than 2ms run times, you need to
have HRTICK enabled in debugfs/sched_features

- The usage message is broken
- There is no help
- There are no long options

Anyone looking for place to start hacking, this program could use some love

#17 lore raw

Re: [PATCH v2 08/12] cyclicdeadline: Add duration command line argument

In reply to Daniel Wagner
Quoted 72 lines · Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m cyclicdeadline -D 10m
---
 src/sched_deadline/cyclicdeadline.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
src/sched_deadline/cyclicdeadline.c +11 -1
index 6d461b27ac43..47892daf747b 100644
@@ -21,6 +21,8 @@
 #include <linux/unistd.h>
 #include <linux/magic.h>
 
+#include <rt-utils.h>
+
 #ifdef __i386__
 #ifndef __NR_sched_setattr
 #define __NR_sched_setattr		351
@@ -1049,6 +1051,7 @@ int main (int argc, char **argv)
 	unsigned int interval = 1000;
 	unsigned int step = 500;
 	int percent = 60;
+	int duration = 0;
 	u64 runtime;
 	u64 start_period;
 	u64 end_period;
@@ -1062,7 +1065,7 @@ int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	while ((c = getopt(argc, argv, "+hac:i:s:t:")) >= 0) {
+	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
 		switch (c) {
 		case 'a':
 			all_cpus = 1;
@@ -1081,6 +1084,9 @@ int main (int argc, char **argv)
 		case 't':
 			nr_threads = atoi(optarg);
 			break;
+		case 'D':
+			duration = parse_time_string(optarg);
+			break;
 		case 'h':
 		default:
 			usage(argv);
@@ -1246,6 +1252,10 @@ int main (int argc, char **argv)
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	if (!fail)
 		loop(sched_data, nr_threads);
Signature · 1 line
2.20.1

I fixed-up some dos like line endings you added in the man page, are you doing something weird with your editor?

Other than that

#18 lore raw

Re: [PATCH v2 08/12] cyclicdeadline: Add duration command line argument

Hi John,

Quoted 71 lines · John Kacur
Quoted 67 lines · Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

   # timeout 11m cyclicdeadline -D 10m
---
  src/sched_deadline/cyclicdeadline.c | 12 +++++++++++-
  1 file changed, 11 insertions(+), 1 deletion(-)
src/sched_deadline/cyclicdeadline.c +11 -1
index 6d461b27ac43..47892daf747b 100644
@@ -21,6 +21,8 @@
  #include <linux/unistd.h>
  #include <linux/magic.h>
 
+#include <rt-utils.h>
+
  #ifdef __i386__
  #ifndef __NR_sched_setattr
  #define __NR_sched_setattr		351
@@ -1049,6 +1051,7 @@ int main (int argc, char **argv)
  	unsigned int interval = 1000;
  	unsigned int step = 500;
  	int percent = 60;
+	int duration = 0;
  	u64 runtime;
  	u64 start_period;
  	u64 end_period;
@@ -1062,7 +1065,7 @@ int main (int argc, char **argv)
  		exit(-1);
  	}
 
-	while ((c = getopt(argc, argv, "+hac:i:s:t:")) >= 0) {
+	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
  		switch (c) {
  		case 'a':
  			all_cpus = 1;
@@ -1081,6 +1084,9 @@ int main (int argc, char **argv)
  		case 't':
  			nr_threads = atoi(optarg);
  			break;
+		case 'D':
+			duration = parse_time_string(optarg);
+			break;
  		case 'h':
  		default:
  			usage(argv);
@@ -1246,6 +1252,10 @@ int main (int argc, char **argv)
 
  	signal(SIGINT, sighand);
  	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
Quoted 8 lines
Quoted 5 lines
src/sched_deadline/cyclicdeadline.c +0 -0
  	if (!fail)
  		loop(sched_data, nr_threads);
Signature · 1 line
2.20.1

I fixed-up some dos like line endings you added in the man page, are you doing something weird with your editor?

Just guessing: my editor sees DOS encoding in the file and preserves the mode. I haven't had this problem before. Very strange.

Sorry for the additional work.

Thanks,
Daniel

#19 lore raw

PATCH v2 9/12 signaltest: Add duration command line argument

In reply to Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m signaltest -D 10m
---
 src/signaltest/signaltest.8 |  5 +++++
 src/signaltest/signaltest.c | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
src/signaltest/signaltest.8 +5 -0
index 634d392a6da5..bd6ffe5c7a36 100644
@@ -13,6 +13,11 @@ starting with two dashes ('\-\-').
 .B \-b, \-\-breaktrace=USEC
 Send break trace command when latency > USEC
 .TP
+.B \-D, \-\-duration=TIME
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
+.TP
 .B \-l, \-\-loops=LOOPS
 Number of loops: default=0 (endless)
 .TP
src/signaltest/signaltest.c +13 -1
index 59f979ec5ad1..a168191b7573 100644
@@ -208,6 +208,8 @@ static void display_help(void)
 		"signaltest <options>\n\n"
 		"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
 		"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+		"-D       --duration=TIME   specify a length for the test run.\n"
+		"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
 		"-p PRIO  --prio=PRIO       priority of highest prio thread\n"
 		"-q       --quiet           print a summary only on exit\n"
 		"-t NUM   --threads=NUM     number of threads: default=2\n"
@@ -221,6 +223,7 @@ static void display_help(void)
 static int priority;
 static int num_threads = 2;
 static int max_cycles;
+static int duration;
 static int verbose;
 static int quiet;
 static int lockall = 0;
@@ -235,6 +238,7 @@ static void process_options (int argc, char *argv[])
 		static struct option long_options[] = {
 			{"breaktrace", required_argument, NULL, 'b'},
 			{"loops", required_argument, NULL, 'l'},
+			{"duration", required_argument, NULL, 'D'},
 			{"priority", required_argument, NULL, 'p'},
 			{"quiet", no_argument, NULL, 'q'},
 			{"threads", required_argument, NULL, 't'},
@@ -243,13 +247,14 @@ static void process_options (int argc, char *argv[])
 			{"help", no_argument, NULL, '?'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "b:c:d:i:l:np:qrsmt:v",
+		int c = getopt_long (argc, argv, "b:c:d:i:l:D:np:qrsmt:v",
 			long_options, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
 		case 'b': tracelimit = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'q': quiet = 1; break;
 		case 't': num_threads = atoi(optarg); break;
@@ -259,6 +264,9 @@ static void process_options (int argc, char *argv[])
 		}
 	}
 
+	if (duration < 0)
+		error = 1;
+
 	if (priority < 0 || priority > 99)
 		error = 1;
 
@@ -340,6 +348,10 @@ int main(int argc, char **argv)
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	par = calloc(num_threads, sizeof(struct thread_param));
 	if (!par)
Signature · 1 line
2.20.1
#20 lore raw

Re: [PATCH v2 09/12] signaltest: Add duration command line argument

Quoted 104 lines · Daniel Wagner

Many of the test programs have the --loop argument for automatic stopping. The main problem with the --loop argument is how long is --loop 1000?

To simplify automated tests introduce a --duration argument which allows to set the time how long a test should run. This allows the test suite to define the execution time and also the timeout which a normal human can understand.

For example run the test for 10 minutes and timeout at 11 minutes:

  # timeout 11m signaltest -D 10m
---
 src/signaltest/signaltest.8 |  5 +++++
 src/signaltest/signaltest.c | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
src/signaltest/signaltest.8 +5 -0
index 634d392a6da5..bd6ffe5c7a36 100644
@@ -13,6 +13,11 @@ starting with two dashes ('\-\-').
 .B \-b, \-\-breaktrace=USEC
 Send break trace command when latency > USEC
 .TP
+.B \-D, \-\-duration=TIME
+Specify a length for the test run.
+.br
+Append 'm', 'h', or 'd' to specify minutes, hours or days.
+.TP
 .B \-l, \-\-loops=LOOPS
 Number of loops: default=0 (endless)
 .TP
src/signaltest/signaltest.c +13 -1
index 59f979ec5ad1..a168191b7573 100644
@@ -208,6 +208,8 @@ static void display_help(void)
 		"signaltest <options>\n\n"
 		"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
 		"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+		"-D       --duration=TIME   specify a length for the test run.\n"
+		"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
 		"-p PRIO  --prio=PRIO       priority of highest prio thread\n"
 		"-q       --quiet           print a summary only on exit\n"
 		"-t NUM   --threads=NUM     number of threads: default=2\n"
@@ -221,6 +223,7 @@ static void display_help(void)
 static int priority;
 static int num_threads = 2;
 static int max_cycles;
+static int duration;
 static int verbose;
 static int quiet;
 static int lockall = 0;
@@ -235,6 +238,7 @@ static void process_options (int argc, char *argv[])
 		static struct option long_options[] = {
 			{"breaktrace", required_argument, NULL, 'b'},
 			{"loops", required_argument, NULL, 'l'},
+			{"duration", required_argument, NULL, 'D'},
 			{"priority", required_argument, NULL, 'p'},
 			{"quiet", no_argument, NULL, 'q'},
 			{"threads", required_argument, NULL, 't'},
@@ -243,13 +247,14 @@ static void process_options (int argc, char *argv[])
 			{"help", no_argument, NULL, '?'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "b:c:d:i:l:np:qrsmt:v",
+		int c = getopt_long (argc, argv, "b:c:d:i:l:D:np:qrsmt:v",
 			long_options, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
 		case 'b': tracelimit = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'q': quiet = 1; break;
 		case 't': num_threads = atoi(optarg); break;
@@ -259,6 +264,9 @@ static void process_options (int argc, char *argv[])
 		}
 	}
 
+	if (duration < 0)
+		error = 1;
+
 	if (priority < 0 || priority > 99)
 		error = 1;
 
@@ -340,6 +348,10 @@ int main(int argc, char **argv)
 
 	signal(SIGINT, sighand);
 	signal(SIGTERM, sighand);
+	signal(SIGALRM, sighand);
+
+	if (duration)
+		alarm(duration);
 
 	par = calloc(num_threads, sizeof(struct thread_param));
 	if (!par)
Signature · 1 line
2.20.1