test/runtime/6878713/Test6878713.sh

changeset 5772
10cc3b624f8f
parent 4832
d1897e7e0488
equal deleted inserted replaced
5771:b960c9df4f11 5772:10cc3b624f8f
1 #!/bin/sh
2
3 #
4 # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 #
7 # This code is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License version 2 only, as
9 # published by the Free Software Foundation.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26
27
28 ##
29 ## @test
30 ## @bug 6878713
31 ## @bug 7030610
32 ## @bug 7037122
33 ## @bug 7123945
34 ## @summary Verifier heap corruption, relating to backward jsrs
35 ## @run shell Test6878713.sh
36 ##
37 ## some tests require path to find test source dir
38 if [ "${TESTSRC}" = "" ]
39 then
40 TESTSRC=${PWD}
41 echo "TESTSRC not set. Using "${TESTSRC}" as default"
42 fi
43 echo "TESTSRC=${TESTSRC}"
44 ## Adding common setup Variables for running shell tests.
45 . ${TESTSRC}/../../test_env.sh
46
47 TARGET_CLASS=OOMCrashClass1960_2
48
49 echo "INFO: extracting the target class."
50 ${COMPILEJAVA}${FS}bin${FS}jar xvf \
51 ${TESTSRC}${FS}testcase.jar ${TARGET_CLASS}.class
52
53 # remove any hs_err_pid that might exist here
54 rm -f hs_err_pid*.log
55
56 echo "INFO: checking for 32-bit versus 64-bit VM."
57 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version 2>&1 \
58 | grep "64-Bit [^ ][^ ]* VM" > /dev/null 2>&1
59 status="$?"
60 if [ "$status" = 0 ]; then
61 echo "INFO: testing a 64-bit VM."
62 is_64_bit=true
63 else
64 echo "INFO: testing a 32-bit VM."
65 fi
66
67 if [ "$is_64_bit" = true ]; then
68 # limit is 768MB in 8-byte words (1024 * 1024 * 768 / 8) == 100663296
69 MALLOC_MAX=100663296
70 else
71 # limit is 768MB in 4-byte words (1024 * 1024 * 768 / 4) == 201326592
72 MALLOC_MAX=201326592
73 fi
74 echo "INFO: MALLOC_MAX=$MALLOC_MAX"
75
76 echo "INFO: executing the target class."
77 # -XX:+PrintCommandLineFlags for debugging purposes
78 # -XX:+IgnoreUnrecognizedVMOptions so test will run on a VM without
79 # the new -XX:MallocMaxTestWords option
80 # -XX:+UnlockDiagnosticVMOptions so we can use -XX:MallocMaxTestWords
81 # -XX:MallocMaxTestWords limits malloc to $MALLOC_MAX
82 ${TESTJAVA}${FS}bin${FS}java \
83 -XX:+PrintCommandLineFlags \
84 -XX:+IgnoreUnrecognizedVMOptions \
85 -XX:+UnlockDiagnosticVMOptions \
86 -XX:MallocMaxTestWords=$MALLOC_MAX \
87 ${TESTVMOPTS} ${TARGET_CLASS} > test.out 2>&1
88
89 echo "INFO: begin contents of test.out:"
90 cat test.out
91 echo "INFO: end contents of test.out."
92
93 echo "INFO: checking for memory allocation error message."
94 # We are looking for this specific memory allocation failure mesg so
95 # we know we exercised the right allocation path with the test class:
96 MESG1="Native memory allocation (malloc) failed to allocate 25696531[0-9][0-9] bytes"
97 grep "$MESG1" test.out
98 status="$?"
99 if [ "$status" = 0 ]; then
100 echo "INFO: found expected memory allocation error message."
101 else
102 echo "INFO: did not find expected memory allocation error message."
103
104 # If we didn't find MESG1 above, then there are several scenarios:
105 # 1) -XX:MallocMaxTestWords is not supported by the current VM and we
106 # didn't fail TARGET_CLASS's memory allocation attempt; instead
107 # we failed to find TARGET_CLASS's main() method. The TARGET_CLASS
108 # is designed to provoke a memory allocation failure during class
109 # loading; we actually don't care about running the class which is
110 # why it doesn't have a main() method.
111 # 2) we failed a memory allocation, but not the one we were looking
112 # so it might be that TARGET_CLASS no longer tickles the same
113 # memory allocation code path
114 # 3) TARGET_CLASS reproduces the failure mode (SIGSEGV) fixed by
115 # 6878713 because the test is running on a pre-fix VM.
116 echo "INFO: checking for no main() method message."
117 MESG2="Error: Main method not found in class"
118 grep "$MESG2" test.out
119 status="$?"
120 if [ "$status" = 0 ]; then
121 echo "INFO: found no main() method message."
122 else
123 echo "FAIL: did not find no main() method message."
124 # status is non-zero for exit below
125
126 if [ -s hs_err_pid*.log ]; then
127 echo "INFO: begin contents of hs_err_pid file:"
128 cat hs_err_pid*.log
129 echo "INFO: end contents of hs_err_pid file."
130 fi
131 fi
132 fi
133
134 if [ "$status" = 0 ]; then
135 echo "PASS: test found one of the expected messages."
136 fi
137 exit "$status"

mercurial