Hi Subrata,
Please accept the patch below.
Thanks,
Gowri
---
realtime: add time out option to gtod_infinite test
At present, gtod_infinite runs for ever, until we kill the test.
This behavior blocks the automated codes to use it as part of
running it and generating result graphs.
Below patch adds the option to timeout the test after specified
hours (-t option, which is for number of hours). With out using
this option, test runs for infinite hours which is its default
behavior.
Also, this patch is first step on gtod_infinite to add it into
future patch for long_running tests, where it may be scheduled
to run for 3 days.
Signed-off-by: Gowrishankar M <[email protected]>
Acked-By: Dinakar Guniguntala <[email protected]>
---
Index: ltp-full-20081231/testcases/realtime/func/gtod_latency/gtod_infinite.c
===================================================================
--- ltp-full-20081231.orig/testcases/realtime/func/gtod_latency/gtod_infinite.c 2009-01-30 16:44:39.000000000 +0530
+++ ltp-full-20081231/testcases/realtime/func/gtod_latency/gtod_infinite.c 2009-01-30 16:45:54.000000000 +0530
@@ -52,6 +52,8 @@
#include <sched.h>
#include <librttest.h>
#include <sys/mman.h>
+#include <unistd.h>
+#include <signal.h>
#define CLOCK_TO_USE CLOCK_MONOTONIC
@@ -59,12 +61,15 @@
#define REPORT_MIN 1000000
static unsigned int max_window = 0; /* infinite, don't use a window */
+static unsigned int test_duration = 0; /* infinite duration */
+static int test_stop = 0; /* 1 to stop */
void usage(void)
{
rt_help();
printf("gtod_infinite specific options:\n");
printf(" -wWINDOW iterations in max value window (default inf)\n");
+ printf(" -tDURATION test duration in finite hours (default inf)\n");
}
int parse_args(int c, char *v)
@@ -77,6 +82,9 @@
case 'w':
max_window = atoi(v);
break;
+ case 't':
+ test_duration = atoi(v);
+ break;
default:
handled = 0;
break;
@@ -84,6 +92,12 @@
return handled;
}
+void alarm_handler(int sig)
+{
+ /* Stop test execution */
+ test_stop = 1;
+}
+
int main(int argc, char *argv[])
{
int/* i,*/ rc;
@@ -94,8 +108,18 @@
struct sched_param param;
time_t tt;
unsigned int wi;
+ struct sigaction sact;
setup();
+
+ /* Set signal handler for SIGALRM */
+ sigfillset(&sact.sa_mask);
+ sact.sa_handler = alarm_handler;
+ rc = sigaction(SIGALRM, &sact, NULL);
+ if (rc) {
+ perror("sigaction");
+ exit(1);
+ }
/*
CPU_ZERO(&mask);
CPU_SET(0, &mask);
@@ -105,7 +129,7 @@
exit(1);
}
*/
- rt_init("hw:", parse_args, argc, argv);
+ rt_init("hw:t:", parse_args, argc, argv);
mlockall(MCL_CURRENT|MCL_FUTURE);
@@ -127,8 +151,17 @@
exit(1);
}
+ /* Set alarm for test duration, if specified */
+ if (test_duration > 0) {
+ rc = alarm(test_duration * 60 * 60 );
+ if (rc) {
+ perror("alarm");
+ exit(1);
+ }
+ }
+
wi = 0;
- while(1) {
+ while(test_stop != 1) {
rc = clock_gettime(CLOCK_TO_USE, &p_ts);
rc = clock_gettime(CLOCK_TO_USE, &ts);
if (rc) {
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list