dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] GCC test case g++.dg/tls/thread_local5.C


From: Sebastian Huber
Subject: [PATCH] GCC test case g++.dg/tls/thread_local5.C
Date: Wed, 10 Jul 2013 11:58:36 +0200

I run into a problem with GCC test case g++.dg/tls/thread_local5.C on
non-native targets.  The DejaGnu testing framework uses text output to
return status information for non-native targets, e.g.

Executing on host:
[...]
PASS: g++.dg/tls/thread_local6.C (test for excess errors)
spawn psim -i ./thread_local6.exe
powerpc-rtems4.11-run is /opt/rtems-4.11/bin/powerpc-rtems4.11-run
OpenPIC Version 1.2 (2 CPUs and 17 IRQ sources) at 0x0C130000
OpenPIC Vendor 0 (Unknown), Device 0 (Unknown), Stepping 0
Overriding NumSources (17) from configuration with 16
OpenPIC timer frequency is 1 Hz
*** EXIT code 1
FAIL: g++.dg/tls/thread_local6.C execution test

In order to prevent multiple output from exit() and _exit() calls there
is a global variable done_exit_message in testglue.c (part of DejaGnu)
which is used in the wrapper functions __wrap_exit() and __wrap__exit().

Now in g++.dg/tls/thread_local6.C we have the problem that the main
thread returns with a status code of 1 and the test succeeds if a
thread-local object of the main thread is destroyed properly.  In this
case _exit(0) is called. This happens in my case, but the output is
suppressed due to done_exit_message == 1.

How can I address this problem?  I don't think it is possible to alter
the test in GCC to fix this problem.  One option is to store the latest
exit code in testglue.c and print a new exit status it is different.

This will lead to:

Executing on host:
[...]
PASS: g++.dg/tls/thread_local6.C -std=gnu++11 (test for excess errors)
spawn psim -i ./thread_local6.exe
powerpc-rtems4.11-run is /opt/rtems-4.11/bin/powerpc-rtems4.11-run
OpenPIC Version 1.2 (2 CPUs and 17 IRQ sources) at 0x0C130000
OpenPIC Vendor 0 (Unknown), Device 0 (Unknown), Stepping 0
Overriding NumSources (17) from configuration with 16
OpenPIC timer frequency is 1 Hz
*** EXIT code 1
*** EXIT code 0
PASS: g++.dg/tls/thread_local6.C -std=gnu++11 execution test

Is this a reasonable approach?
---
 testglue.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/testglue.c b/testglue.c
index 06f4a90..d2b1142 100644
--- a/testglue.c
+++ b/testglue.c
@@ -57,6 +57,7 @@ extern void REAL__EXIT ();
 #endif
 
 static int done_exit_message = 0;
+static int last_exit_code = 0;
 int ___constval = 1;
 
 #ifdef VXWORKS
@@ -91,6 +92,7 @@ ORIG_EXIT (code)
 #ifdef VXWORKS
   __runexit ();
 #endif
+  last_exit_code = code;
   strcpy (buf, "\n*** EXIT code ");
   ptr = write_int (code, buf + strlen(buf));
   *(ptr++) = '\n';
@@ -109,8 +111,9 @@ ORIG__EXIT (code)
   char *ptr;
 
   /* Since exit may call _exit, we need to avoid a second message.  */
-  if (! done_exit_message)
+  if (! done_exit_message || code != last_exit_code)
     {
+      last_exit_code = code;
       strcpy (buf, "\n*** EXIT code ");
       ptr = write_int (code, buf + strlen(buf));
       *(ptr++) = '\n';
-- 
1.7.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]