summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wagner <wagi@monom.org>2019-06-05 17:16:50 +0200
committerJohn Kacur <jkacur@redhat.com>2019-06-19 01:43:22 +0200
commit37516acefc6c95648931d01ee08607ab56f80bf6 (patch)
tree6a5af246990c5f4a7eb81cb03c6638fdace12ec2
parent74e9face21a2baa56f4d7a4cb2ebbc83dbf3e774 (diff)
downloadrt-tests-37516acefc6c95648931d01ee08607ab56f80bf6.tar.gz
rt-tests-37516acefc6c95648931d01ee08607ab56f80bf6.tar.xz
rt-migrate-test: Add duration command line argument
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 rt-migrate-test -D 10m Signed-off-by: Daniel Wagner <wagi@monom.org> Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--src/rt-migrate-test/rt-migrate-test.85
-rw-r--r--src/rt-migrate-test/rt-migrate-test.c12
2 files changed, 16 insertions, 1 deletions
diff --git a/src/rt-migrate-test/rt-migrate-test.8 b/src/rt-migrate-test/rt-migrate-test.8
index 8af50e5..b9c07f1 100644
--- a/src/rt-migrate-test/rt-migrate-test.8
+++ b/src/rt-migrate-test/rt-migrate-test.8
@@ -15,6 +15,11 @@ This program follows the usual GNU command line syntax, with long options starti
In the summary of options, a value in brackets (), indicates a default value
.br
.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 \-p, \-\-prio=prio
base priority to start RT tasks with (2)
.br
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
index 0a0bb77..8223d66 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -41,6 +41,7 @@
#include <errno.h>
#include <sched.h>
#include <pthread.h>
+#include "rt-utils.h"
#define gettid() syscall(__NR_gettid)
@@ -115,6 +116,7 @@ static unsigned long long now;
static int done;
static int loop;
+static int duration;
static pthread_barrier_t start_barrier;
static pthread_barrier_t end_barrier;
@@ -180,6 +182,8 @@ static void usage(char **argv)
"-s time --sleep-time time Sleep time (ms) between intervals (100)\n"
"-m time --maxerr time Max allowed error (microsecs)\n"
"-l loops --loops loops Number of iterations to run (50)\n"
+ "-D --duration=TIME specify a length for the test run.\n"
+ " Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
"-e Use equal prio for #CPU-1 tasks (requires > 2 CPUS)\n"
"-c --check Stop if lower prio task is quicker than higher (off)\n"
"-h --help\n"
@@ -199,11 +203,12 @@ static void parse_options (int argc, char *argv[])
{"sleep-time", required_argument, NULL, 's'},
{"maxerr", required_argument, NULL, 'm'},
{"loops", required_argument, NULL, 'l'},
+ {"duration", required_argument, NULL, 'D'},
{"check", no_argument, NULL, 'c'},
{"help", no_argument, NULL, '?'},
{NULL, 0, NULL, 0}
};
- int c = getopt_long (argc, argv, "p:r:s:m:l:ech",
+ int c = getopt_long (argc, argv, "p:r:s:m:l:D:ech",
long_options, &option_index);
if (c == -1)
break;
@@ -214,6 +219,7 @@ static void parse_options (int argc, char *argv[])
break;
case 's': interval = atoi(optarg); break;
case 'l': nr_runs = atoi(optarg); break;
+ case 'D': duration = parse_time_string(optarg); break;
case 'm': max_err = usec2nano(atoi(optarg)); break;
case 'e': equal = 1; break;
case 'c': check = 1; break;
@@ -472,6 +478,10 @@ int main (int argc, char **argv)
parse_options(argc, argv);
signal(SIGINT, stop_log);
+ signal(SIGALRM, stop_log);
+
+ if (duration)
+ alarm(duration);
if (argc >= (optind + 1))
nr_tasks = atoi(argv[optind]);