1 #
2 # Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation.
8 #
9 # This code is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # version 2 for more details (a copy is included in the LICENSE file that
13 # accompanied this code).
14 #
15 # You should have received a copy of the GNU General Public License version
16 # 2 along with this work; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 #
19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 # or visit www.oracle.com if you need additional information or have any
21 # questions.
22 #
24
25 # @test Xchecksig.sh
26 # @bug 7051189
27 # @summary Need to suppress info message if -xcheck:jni used with libjsig.so
28 # @run shell Xchecksig.sh
29 #
30
31 if [ "${TESTSRC}" = "" ]
32 then TESTSRC=.
33 fi
34
35 if [ "${TESTJAVA}" = "" ]
36 then
37 PARENT=`dirname \`which java\``
38 TESTJAVA=`dirname ${PARENT}`
39 printf "TESTJAVA not set, selecting " ${TESTJAVA}
40 printf " If this is incorrect, try setting the variable manually.\n"
41 fi
42
43
44 BIT_FLAG=""
45
46 OS=`uname -s`
47 case "$OS" in
48 SunOS | Linux )
49 FS="/"
50 ## for solaris, linux it's HOME
51 FILE_LOCATION=$HOME
52 if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
53 then
54 BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT`
55 fi
56 ;;
57 Windows_* )
58 printf "Not testing libjsig.so on Windows. PASSED.\n "
59 exit 0
60 ;;
61 * )
62 printf "Not testing libjsig.so on unrecognised system. PASSED.\n "
63 exit 0
64 ;;
65 esac
66
67
68 JAVA=${TESTJAVA}${FS}bin${FS}java
69
70 # LD_PRELOAD arch needs to match the binary we run, so run the java
71 # 64-bit binary directly if we are testing 64-bit (bin/ARCH/java).
72
73 # However JPRT runs: .../solaris_x64_5.10-debug/bin/java
74 # ..which is 32-bit, when it has built the 64-bit version to test.
75 #
76 # How does this script know we are meant to run the 64-bit version?
77 # Can check for the path of the binary containing "x64" on Solaris.
78
79 if [ ${OS} -eq "SunOS" ]
80 then
81 printf "SunOS test JAVA=${JAVA}"
82 printf ${JAVA} | grep x64 > /dev/null
83 if [ $? -eq 0 ]
84 then
85 printf "SunOS x64 test, forcing -d64\n"
86 BIT_FLAG=-d64
87 fi
88 fi
89
90 ARCH=`uname -p`
91 case $ARCH in
92 i386)
93 if [ X${BIT_FLAG} != "X" ]
94 then
95 ARCH=amd64
96 JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java
97 fi
98 ;;
99 sparc)
100 if [ X${BIT_FLAG} != "X" ]
101 then
102 ARCH=sparcv9
103 JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java
104 fi
105 ;;
110 esac
111
112 LIBJSIG=${TESTJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so
113
114 # If libjsig and binary do not match, skip test.
115
116 A=`file ${LIBJSIG} | awk '{ print $3 }'`
117 B=`file ${JAVA} | awk '{ print $3 }'`
118
119 if [ $A -ne $B ]
120 then
121 printf "Mismatching binary and library to preload, skipping test.\n"
122 exit 0
123 fi
124
125 if [ ! -f ${LIBJSIG} ]
126 then
127 printf "Skipping test: libjsig missing for given architecture: ${LIBJSIG}\n"
128 exit 0
129 fi
130 # Use java -version to test, java version info appeas on stderr,
131 # the libjsig message we are removing appears on stdout.
132
133 # grep returns zero meaning found, non-zero means not found:
134
135 LD_PRELOAD=${LIBJSIG} ${JAVA} ${BIT_FLAG} -Xcheck:jni -version 2>&1 | grep "libjsig is activated"
136
137 if [ $? -eq 0 ]; then
138 printf "Failed: -Xcheck:jni prints message when libjsig.so is loaded.\n"
139 exit 1
140 fi
141
142
143 LD_PRELOAD=${LIBJSIG} ${JAVA} ${BIT_FLAG} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated"
144 if [ $? != 0 ]; then
145 printf "Failed: -Xcheck:jni does not print message when libjsig.so is loaded and -verbose:jni is set.\n"
146 exit 1
147 fi
148
149 printf "PASSED\n"
150 exit 0
151
|
1 #
2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation.
8 #
9 # This code is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # version 2 for more details (a copy is included in the LICENSE file that
13 # accompanied this code).
14 #
15 # You should have received a copy of the GNU General Public License version
16 # 2 along with this work; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 #
19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 # or visit www.oracle.com if you need additional information or have any
21 # questions.
22 #
24
25 # @test Xchecksig.sh
26 # @bug 7051189
27 # @summary Need to suppress info message if -xcheck:jni used with libjsig.so
28 # @run shell Xchecksig.sh
29 #
30
31 if [ "${TESTSRC}" = "" ]
32 then TESTSRC=.
33 fi
34
35 if [ "${TESTJAVA}" = "" ]
36 then
37 PARENT=`dirname \`which java\``
38 TESTJAVA=`dirname ${PARENT}`
39 printf "TESTJAVA not set, selecting " ${TESTJAVA}
40 printf " If this is incorrect, try setting the variable manually.\n"
41 fi
42
43
44 OS=`uname -s`
45 case "$OS" in
46 SunOS | Linux )
47 FS="/"
48 ;;
49 Windows_* )
50 printf "Not testing libjsig.so on Windows. PASSED.\n "
51 exit 0
52 ;;
53 * )
54 printf "Not testing libjsig.so on unrecognised system. PASSED.\n "
55 exit 0
56 ;;
57 esac
58
59
60 JAVA=${TESTJAVA}${FS}bin${FS}java
61
62 # LD_PRELOAD arch needs to match the binary we run, so run the java
63 # 64-bit binary directly if we are testing 64-bit (bin/ARCH/java).
64
65 # However JPRT runs: .../solaris_x64_5.10-debug/bin/java
66 # ..which is 32-bit, when it has built the 64-bit version to test,
67 # but we have TESTVMOPTS including at least -d64
68
69 if [ ${OS} -eq "SunOS" ]
70 then
71 printf "SunOS test TESTVMOPTS = ${TESTVMOPTS}"
72 printf ${TESTVMOPTS} | grep d64 > /dev/null
73 if [ $? -eq 0 ]
74 then
75 printf "SunOS x64 test, using -d64\n"
76 BIT_FLAG=-d64
77 fi
78 fi
79
80 ARCH=`uname -p`
81 case $ARCH in
82 i386)
83 if [ X${BIT_FLAG} != "X" ]
84 then
85 ARCH=amd64
86 JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java
87 fi
88 ;;
89 sparc)
90 if [ X${BIT_FLAG} != "X" ]
91 then
92 ARCH=sparcv9
93 JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java
94 fi
95 ;;
100 esac
101
102 LIBJSIG=${TESTJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so
103
104 # If libjsig and binary do not match, skip test.
105
106 A=`file ${LIBJSIG} | awk '{ print $3 }'`
107 B=`file ${JAVA} | awk '{ print $3 }'`
108
109 if [ $A -ne $B ]
110 then
111 printf "Mismatching binary and library to preload, skipping test.\n"
112 exit 0
113 fi
114
115 if [ ! -f ${LIBJSIG} ]
116 then
117 printf "Skipping test: libjsig missing for given architecture: ${LIBJSIG}\n"
118 exit 0
119 fi
120 # Use java -version to test, java version info appears on stderr,
121 # the libjsig message we are removing appears on stdout.
122
123 # grep returns zero meaning found, non-zero means not found:
124
125 LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -version 2>&1 | grep "libjsig is activated"
126 if [ $? -eq 0 ]; then
127 printf "Failed: -Xcheck:jni prints message when libjsig.so is loaded.\n"
128 exit 1
129 fi
130
131
132 LD_PRELOAD=${LIBJSIG} ${JAVA} ${TESTVMOPTS} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated"
133 if [ $? != 0 ]; then
134 printf "Failed: -Xcheck:jni does not print message when libjsig.so is loaded and -verbose:jni is set.\n"
135 exit 1
136 fi
137
138 printf "PASSED\n"
139 exit 0
140
|