Properly set alarm value in gdb.threads/non-stop-fair-events.exp
authorYao Qi <yao.qi@linaro.org>
Tue, 7 Apr 2015 10:30:07 +0000 (11:30 +0100)
committerYao Qi <yao.qi@linaro.org>
Tue, 7 Apr 2015 10:30:07 +0000 (11:30 +0100)
Nowadays, the alarm value is 60, and alarm is generated on some slow
boards.  This patch is to pass DejaGNU timeout value to the program,
and move the alarm call before going to infinite loop.  If any thread
has activities, the alarm is reset.

gdb/testsuite:

2015-04-07  Yao Qi  <yao.qi@linaro.org>

* gdb.threads/non-stop-fair-events.c (SECONDS): New macro.
(child_function): Call alarm.
(main): Move call to alarm into the loop.
* gdb.threads/non-stop-fair-events.exp: Build program with
-DTIMEOUT=$timeout.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/non-stop-fair-events.c
gdb/testsuite/gdb.threads/non-stop-fair-events.exp

index 8c179f9e15f75704a804ed38ffe1a9a8362af7ae..723bfd113755ba8f9b1c45484b5f04eb94935382 100644 (file)
@@ -1,3 +1,11 @@
+2015-04-07  Yao Qi  <yao.qi@linaro.org>
+
+       * gdb.threads/non-stop-fair-events.c (SECONDS): New macro.
+       (child_function): Call alarm.
+       (main): Move call to alarm into the loop.
+       * gdb.threads/non-stop-fair-events.exp: Build program with
+       -DTIMEOUT=$timeout.
+
 2015-04-06  Doug Evans  <xdje42@gmail.com>
 
        * lib/pascal.exp (gpc_compile): Rename dest arg to destfile.
index 6a9d31d1650f803c7cfca32fad82a2e1768faa06..f82c366a6815f7e6d03b27fefd0df4c94f949f41 100644 (file)
@@ -22,6 +22,9 @@
 
 #define NUM_THREADS 10
 const int num_threads = NUM_THREADS;
+/* Allow for as much timeout as DejaGnu wants, plus a bit of
+   slack.  */
+#define SECONDS (TIMEOUT + 20)
 
 pthread_t child_thread[NUM_THREADS];
 volatile pthread_t signal_thread;
@@ -53,6 +56,8 @@ child_function (void *arg)
 
   while (1)
     {
+      /* Reset the timer before going to INF_LOOP.  */
+      alarm (SECONDS);
       INF_LOOP; /* set thread breakpoint here */
       loop_broke ();
     }
@@ -64,8 +69,6 @@ main (void)
   int res;
   int i;
 
-  alarm (60);
-
   signal (SIGUSR1, handler);
 
   for (i = 0; i < NUM_THREADS; i++)
@@ -76,6 +79,8 @@ main (void)
   while (1)
     {
       pthread_kill (signal_thread, SIGUSR1); /* set kill breakpoint here */
+      /* Reset the timer before going to INF_LOOP.  */
+      alarm (SECONDS);
       INF_LOOP;
       loop_broke ();
     }
index 9b7b9ca2696af006001d31abb06cbf8cd9e3ffb7..e2d3f7d43d4fc4f8ef17793e3d0c8f148206f525 100644 (file)
@@ -24,7 +24,8 @@ if [target_info exists gdb,nosignals] {
     return -1
 }
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
+set options { "additional_flags=-DTIMEOUT=$timeout" debug pthreads }
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1} {
     return -1
 }
 
This page took 0.030538 seconds and 4 git commands to generate.