From: Cyril H. <su...@li...> - 2011-11-09 15:31:21
|
The branch, master, has been updated via fea169d80c1a71c44d0ea11672d99aa78d6e0aa0 (commit) from d72816da85567f7467b65e9430a175811e53ae9f (commit) - Log ----------------------------------------------------------------- commit fea169d80c1a71c44d0ea11672d99aa78d6e0aa0 Author: Cyril Hrubis <ch...@su...> Date: Wed Nov 9 16:28:30 2011 +0100 Cleanup mtest06/*.c tests. Use alarm() instead of overly compilcated setitimer(). Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/mem/mtest06/mmap1.c | 16 +-------------- testcases/kernel/mem/mtest06/mmap2.c | 32 +----------------------------- testcases/kernel/mem/mtest06/mmap3.c | 32 +----------------------------- testcases/kernel/mem/mtest06/shmat1.c | 34 +------------------------------- 4 files changed, 7 insertions(+), 107 deletions(-) diff --git a/testcases/kernel/mem/mtest06/mmap1.c b/testcases/kernel/mem/mtest06/mmap1.c index 87cf406..b60c8f8 100644 --- a/testcases/kernel/mem/mtest06/mmap1.c +++ b/testcases/kernel/mem/mtest06/mmap1.c @@ -107,20 +107,6 @@ static void sig_handler_mapped(int signal, siginfo_t *info, void *ut) } } -static void set_timer(double run_time) -{ - struct itimerval timer; - - memset(&timer, 0, sizeof(struct itimerval)); - timer.it_interval.tv_usec = 0; - timer.it_interval.tv_sec = 0; - timer.it_value.tv_usec = 0; - timer.it_value.tv_sec = (time_t)(run_time * 3600); - - if (setitimer(ITIMER_REAL, &timer, NULL)) - tst_brkm(TBROK|TERRNO, NULL, "setitimer() failed"); -} - int mkfile(int size) { char template[] = "/tmp/ashfileXXXXXX"; @@ -354,7 +340,7 @@ int main(int argc, char **argv) "Number of mmap/write/read: %d", file_size, exec_time, num_iter); - set_timer(exec_time); + alarm(exec_time * 3600); /* Do not mask SIGSEGV, as we are interested in handling it. */ sigptr.sa_sigaction = sig_handler; diff --git a/testcases/kernel/mem/mtest06/mmap2.c b/testcases/kernel/mem/mtest06/mmap2.c index 90641eb..aa9dc33 100644 --- a/testcases/kernel/mem/mtest06/mmap2.c +++ b/testcases/kernel/mem/mtest06/mmap2.c @@ -165,34 +165,6 @@ sig_handler(int signal) /* signal number, set to handle SIGALRM */ exit(0); } -/******************************************************************************/ -/* */ -/* Function: set_timer */ -/* */ -/* Description: set up a timer to user specified number of hours. SIGALRM is */ -/* raised when the timer expires. */ -/* */ -/* Input: run_time - number of hours the test is intended to run. */ -/* */ -/* Return: NONE */ -/* */ -/******************************************************************************/ -static void -set_timer(float run_time) /* period for which test is intended to run */{ - struct itimerval timer; /* timer structure, tv_sec is set to run_time */ - memset(&timer, 0, sizeof(struct itimerval)); - timer.it_interval.tv_usec = 0; - timer.it_interval.tv_sec = 0; - timer.it_value.tv_usec = 0; - timer.it_value.tv_sec = (time_t)(run_time * 3600.0); - - if (setitimer(ITIMER_REAL, &timer, NULL)) - { - perror("set_timer(): setitimer()"); - exit(1); - } -} - /******************************************************************************//* */ /* Function: usage */ /* */ @@ -298,7 +270,7 @@ int main(int argc, /* number of input parameters. */ exec_time, fsize); /* set up time for which test has to be run */ - set_timer(exec_time); + alarm(exec_time * 3600.00); /* set up signals */ sigptr.sa_handler = (void (*)(int signal))sig_handler; @@ -368,4 +340,4 @@ int main(int argc, /* number of input parameters. */ sync(); }while (TRUE && !run_once); exit (0); -} \ No newline at end of file +} diff --git a/testcases/kernel/mem/mtest06/mmap3.c b/testcases/kernel/mem/mtest06/mmap3.c index f5131ef..5d06d1a 100644 --- a/testcases/kernel/mem/mtest06/mmap3.c +++ b/testcases/kernel/mem/mtest06/mmap3.c @@ -167,34 +167,6 @@ sig_handler(int signal) /* signal number, set to handle SIGALRM */ exit(0); } -/******************************************************************************/ -/* */ -/* Function: set_timer */ -/* */ -/* Description: set up a timer to user specified number of hours. SIGALRM is */ -/* raised when the timer expires. */ -/* */ -/* Input: run_time - number of hours the test is intended to run. */ -/* */ -/* Return: NONE */ -/* */ -/******************************************************************************/ -static void -set_timer(float run_time) /* period for which test is intended to run */{ - struct itimerval timer; /* timer structure, tv_sec is set to run_time */ - memset(&timer, 0, sizeof(struct itimerval)); - timer.it_interval.tv_usec = 0; - timer.it_interval.tv_sec = 0; - timer.it_value.tv_usec = 0; - timer.it_value.tv_sec = (time_t)(run_time * 3600.0); - - if (setitimer(ITIMER_REAL, &timer, NULL)) - { - perror("set_timer(): setitimer()"); - exit(1); - } -} - /******************************************************************************//* */ /* Function: usage */ /* */ @@ -379,7 +351,7 @@ main(int argc, /* number of input parameters. */ } chld_args[0] = num_iter; chld_args[1] = map_private; - set_timer(exec_time); + alarm(exec_time * 3600.00); fprintf(stdout, "\n\n\nTest is set to run with the following parameters:\n" "\tDuration of test: [%f]hrs\n" @@ -423,4 +395,4 @@ main(int argc, /* number of input parameters. */ } } exit(0); -} \ No newline at end of file +} diff --git a/testcases/kernel/mem/mtest06/shmat1.c b/testcases/kernel/mem/mtest06/shmat1.c index ad02f3c..746ccbd 100644 --- a/testcases/kernel/mem/mtest06/shmat1.c +++ b/testcases/kernel/mem/mtest06/shmat1.c @@ -199,36 +199,6 @@ sig_handler(int signal, /* signal number, set to handle SIGALRM */ #endif } -/******************************************************************************/ -/* */ -/* Function: set_timer */ -/* */ -/* Description: set up a timer to user specified number of hours. SIGALRM is */ -/* raised when the timer expires. */ -/* */ -/* Input: run_time - number of hours the test is intended to run. */ -/* */ -/* Return: NONE */ -/* */ -/******************************************************************************/ -static void -set_timer(double run_time) /* period for which test is intended to run */ -{ - struct itimerval timer; /* timer structure, tv_sec is set to run_time */ - - memset(&timer, 0, sizeof(struct itimerval)); - timer.it_interval.tv_usec = 0; - timer.it_interval.tv_sec = 0; - timer.it_value.tv_usec = 0; - timer.it_value.tv_sec = (time_t)(run_time * 3600.0); - - if (setitimer(ITIMER_REAL, &timer, NULL)) - { - perror("set_timer(): setitimer()"); - exit(1); - } -} - /******************************************************************************//* */ /* Function: usage */ /* */ @@ -524,7 +494,7 @@ main(int argc, /* number of input parameters. */ } chld_args[0] = num_iter; - set_timer(exec_time); + alarm(exec_time * 3600.00); for (;;) { @@ -587,4 +557,4 @@ main(int argc, /* number of input parameters. */ } fprintf(stdout, "TEST PASSED\n"); return 0; -} \ No newline at end of file +} hooks/post-receive -- ltp |