8020791: [TESTBUG] runtime/jsig/Test8017498.sh failed to compile native code
authorccheung
Fri, 19 Jul 2013 14:54:54 -0700
changeset 18952 dd89db581bca
parent 18948 28a8224681eb
child 18953 dedc970b6f72
8020791: [TESTBUG] runtime/jsig/Test8017498.sh failed to compile native code Summary: Added -DLINUX to the gcc command and improved the .sh script Reviewed-by: dcubed, dholmes, minqi
hotspot/test/runtime/jsig/Test8017498.sh
hotspot/test/runtime/jsig/TestJNI.c
--- a/hotspot/test/runtime/jsig/Test8017498.sh	Fri Jul 19 17:56:27 2013 +0200
+++ b/hotspot/test/runtime/jsig/Test8017498.sh	Fri Jul 19 14:54:54 2013 -0700
@@ -26,8 +26,9 @@
 ##
 ## @test Test8017498.sh
 ## @bug 8017498
+## @bug 8020791
 ## @summary sigaction(sig) results in process hang/timed-out if sig is much greater than SIGRTMAX
-## @run shell Test8017498.sh
+## @run shell/timeout=30 Test8017498.sh
 ##
 
 if [ "${TESTSRC}" = "" ]
@@ -46,17 +47,13 @@
     echo "Testing on Linux"
     if [ "$VM_BITS" = "64" ]
     then
-        LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}amd64${FS}libjsig.so
+        MY_LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}amd64${FS}libjsig.so
     else
-        LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}i386${FS}libjsig.so
+        MY_LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}i386${FS}libjsig.so
     fi
-    echo LD_PRELOAD = ${LD_PRELOAD}
-    export LD_PRELOAD=${LD_PRELOAD}
+    echo MY_LD_PRELOAD = ${MY_LD_PRELOAD}
     ;;
   *)
-    NULL=NUL
-    PS=";"
-    FS="\\"
     echo "Test passed; only valid for Linux"
     exit 0;
     ;;
@@ -67,29 +64,29 @@
 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
 ${TESTJAVA}${FS}bin${FS}javac *.java
 
-gcc -fPIC -shared -o ${TESTSRC}${FS}libTestJNI.so -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}TestJNI.c
+gcc -DLINUX -fPIC -shared \
+    -o ${TESTSRC}${FS}libTestJNI.so \
+    -I${TESTJAVA}${FS}include \
+    -I${TESTJAVA}${FS}include${FS}linux \
+    ${TESTSRC}${FS}TestJNI.c
+if [ $? != 0 ]
+then
+    echo "WARNING: the gcc command failed." 2>&1
+fi
 
 # run the java test in the background
-echo ${TESTJAVA}${FS}bin${FS}java -Djava.library.path=${TESTSRC}${FS} -server TestJNI 100 > test.out 2>&1 &
-${TESTJAVA}${FS}bin${FS}java -Djava.library.path=${TESTSRC}${FS} -server TestJNI 100 > test.out 2>&1 &
-
-# obtain the process id
-C_PID=$!
+cmd="LD_PRELOAD=$MY_LD_PRELOAD \
+    ${TESTJAVA}${FS}bin${FS}java \
+    -Djava.library.path=${TESTSRC}${FS} -server TestJNI 100"
+echo "$cmd > test.out 2>&1"
+eval $cmd > test.out 2>&1
 
-# sleep for 1s
-sleep 1
-
-# reset LD_PRELOAD
-unset LD_PRELOAD
-
-# check the output file (test.out)
 grep "old handler" test.out > ${NULL}
 if [ $? = 0 ]
 then
     echo "Test Passed"
     exit 0
-else
-    kill -9 ${C_PID}
-    echo "Test Failed"
-    exit 1
 fi
+
+echo "Test Failed"
+exit 1
--- a/hotspot/test/runtime/jsig/TestJNI.c	Fri Jul 19 17:56:27 2013 +0200
+++ b/hotspot/test/runtime/jsig/TestJNI.c	Fri Jul 19 14:54:54 2013 -0700
@@ -21,9 +21,9 @@
  * questions.
  */
 
+#define _GNU_SOURCE // for the definition of REG_RIP in ucontext.h
 #include <stdio.h>
 #include <jni.h>
-#define __USE_GNU
 #include <signal.h>
 #include <sys/ucontext.h>
 
@@ -42,8 +42,6 @@
 JNIEXPORT void JNICALL Java_TestJNI_doSomething(JNIEnv *env, jclass klass, jint val) {
     struct sigaction act;
     struct sigaction oact;
-    pthread_attr_t attr;
-    stack_t stack;
 
     act.sa_flags = SA_ONSTACK|SA_RESTART|SA_SIGINFO;
     sigfillset(&act.sa_mask);