aoqi@0: #!/bin/sh aoqi@0: # aoqi@0: # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: # aoqi@0: aoqi@0: # $1 - error code aoqi@0: # $2 - test name aoqi@0: # $3,.. - decription aoqi@0: test_fail() { aoqi@0: error=$1 aoqi@0: shift aoqi@0: name=$1 aoqi@0: shift aoqi@0: echo "TEST [$name] FAILED:" aoqi@0: echo "$@" aoqi@0: exit $error aoqi@0: } aoqi@0: aoqi@0: # $@ - additional vm opts aoqi@0: start_test() { aoqi@0: # disable core dump on *nix aoqi@0: ulimit -S -c 0 aoqi@0: # disable core dump on windows aoqi@0: VMOPTS="$@ -XX:-CreateMinidumpOnCrash" aoqi@0: cmd="${JAVA} ${VMOPTS} -XX:+ReplayCompiles -XX:ReplayDataFile=${replay_data}" aoqi@0: echo $cmd aoqi@0: $cmd aoqi@0: return $? aoqi@0: } aoqi@0: aoqi@0: # $1 - error_code aoqi@0: # $2 - test name aoqi@0: # $3,.. - additional vm opts aoqi@0: positive_test() { aoqi@0: error=$1 aoqi@0: shift aoqi@0: name=$1 aoqi@0: shift aoqi@0: VMOPTS="${TESTVMOPTS} $@" aoqi@0: echo "POSITIVE TEST [$name]" aoqi@0: start_test ${VMOPTS} aoqi@0: exit_code=$? aoqi@0: if [ ${exit_code} -ne 0 ] aoqi@0: then aoqi@0: test_fail $error "$name" "exit_code[${exit_code}] != 0 during replay "\ aoqi@0: "w/ vmopts: ${VMOPTS}" aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: # $1 - error_code aoqi@0: # $2 - test name aoqi@0: # $2,.. - additional vm opts aoqi@0: negative_test() { aoqi@0: error=$1 aoqi@0: shift aoqi@0: name=$1 aoqi@0: shift aoqi@0: VMOPTS="${TESTVMOPTS} $@" aoqi@0: echo "NEGATIVE TEST [$name]" aoqi@0: start_test ${VMOPTS} aoqi@0: exit_code=$? aoqi@0: if [ ${exit_code} -eq 0 ] aoqi@0: then aoqi@0: test_fail $error "$name" "exit_code[${exit_code}] == 0 during replay "\ aoqi@0: "w/ vmopts: ${VMOPTS}" aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: # $1 - initial error_code aoqi@0: common_tests() { aoqi@0: positive_test $1 "COMMON :: THE SAME FLAGS" aoqi@0: if [ $tiered_available -eq 1 ] aoqi@0: then aoqi@0: positive_test `expr $1 + 1` "COMMON :: TIERED" -XX:+TieredCompilation aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: # $1 - initial error_code aoqi@0: # $2 - non-tiered comp_level aoqi@0: nontiered_tests() { aoqi@0: level=`grep "^compile " $replay_data | awk '{print $6}'` aoqi@0: # is level available in non-tiered aoqi@0: if [ "$level" -eq $2 ] aoqi@0: then aoqi@0: positive_test $1 "NON-TIERED :: AVAILABLE COMP_LEVEL" \ aoqi@0: -XX:-TieredCompilation aoqi@0: else aoqi@0: negative_test `expr $1 + 1` "NON-TIERED :: UNAVAILABLE COMP_LEVEL" \ aoqi@0: -XX:-TieredCompilation aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: # $1 - initial error_code aoqi@0: client_tests() { aoqi@0: # testing in opposite VM aoqi@0: if [ $server_available -eq 1 ] aoqi@0: then aoqi@0: negative_test $1 "SERVER :: NON-TIERED" -XX:-TieredCompilation \ aoqi@0: -server aoqi@0: if [ $tiered_available -eq 1 ] aoqi@0: then aoqi@0: positive_test `expr $1 + 1` "SERVER :: TIERED" -XX:+TieredCompilation \ aoqi@0: -server aoqi@0: fi aoqi@0: fi aoqi@0: nontiered_tests `expr $1 + 2` $client_level aoqi@0: } aoqi@0: aoqi@0: # $1 - initial error_code aoqi@0: server_tests() { aoqi@0: # testing in opposite VM aoqi@0: if [ $client_available -eq 1 ] aoqi@0: then aoqi@0: # tiered is unavailable in client vm, so results w/ flags will be the same as w/o flags aoqi@0: negative_test $1 "CLIENT" -client aoqi@0: fi aoqi@0: nontiered_tests `expr $1 + 2` $server_level aoqi@0: } aoqi@0: aoqi@0: cleanup() { aoqi@0: ${RM} -f core* aoqi@0: ${RM} -f replay*.txt aoqi@0: ${RM} -f hs_err_pid*.log aoqi@0: ${RM} -f test_core aoqi@0: ${RM} -f test_replay.txt aoqi@0: } aoqi@0: aoqi@0: JAVA=${TESTJAVA}${FS}bin${FS}java aoqi@0: aoqi@0: replay_data=test_replay.txt aoqi@0: aoqi@0: ${JAVA} ${TESTVMOPTS} -Xinternalversion 2>&1 | grep debug aoqi@0: aoqi@0: # Only test fastdebug aoqi@0: if [ $? -ne 0 ] aoqi@0: then aoqi@0: echo TEST SKIPPED: product build aoqi@0: exit 0 aoqi@0: fi aoqi@0: aoqi@0: is_int=`${JAVA} ${TESTVMOPTS} -version 2>&1 | grep -c "interpreted mode"` aoqi@0: # Not applicable for Xint aoqi@0: if [ $is_int -ne 0 ] aoqi@0: then aoqi@0: echo TEST SKIPPED: interpreted mode aoqi@0: exit 0 aoqi@0: fi aoqi@0: aoqi@0: cleanup aoqi@0: aoqi@0: client_available=`${JAVA} ${TESTVMOPTS} -client -Xinternalversion 2>&1 | \ aoqi@0: grep -c Client` aoqi@0: server_available=`${JAVA} ${TESTVMOPTS} -server -Xinternalversion 2>&1 | \ aoqi@0: grep -c Server` aoqi@0: tiered_available=`${JAVA} ${TESTVMOPTS} -XX:+TieredCompilation -XX:+PrintFlagsFinal -version | \ aoqi@0: grep TieredCompilation | \ aoqi@0: grep -c true` aoqi@0: is_tiered=`${JAVA} ${TESTVMOPTS} -XX:+PrintFlagsFinal -version | \ aoqi@0: grep TieredCompilation | \ aoqi@0: grep -c true` aoqi@0: # CompLevel_simple -- C1 aoqi@0: client_level=1 aoqi@0: # CompLevel_full_optimization -- C2 or Shark aoqi@0: server_level=4 aoqi@0: aoqi@0: echo "client_available=$client_available" aoqi@0: echo "server_available=$server_available" aoqi@0: echo "tiered_available=$tiered_available" aoqi@0: echo "is_tiered=$is_tiered" aoqi@0: aoqi@0: # crash vm in compiler thread with generation replay data and 'small' dump-file aoqi@0: # $@ - additional vm opts aoqi@0: generate_replay() { aoqi@0: if [ $VM_OS != "windows" ] aoqi@0: then aoqi@0: # enable core dump aoqi@0: ulimit -c unlimited aoqi@0: aoqi@0: if [ $VM_OS = "solaris" ] aoqi@0: then aoqi@0: coreadm -p core $$ aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: cmd="${JAVA} ${TESTVMOPTS} $@ \ aoqi@0: -Xms8m \ aoqi@0: -Xmx32m \ aoqi@0: -XX:MetaspaceSize=4m \ aoqi@0: -XX:MaxMetaspaceSize=16m \ aoqi@0: -XX:InitialCodeCacheSize=512k \ aoqi@0: -XX:ReservedCodeCacheSize=4m \ aoqi@0: -XX:ThreadStackSize=512 \ aoqi@0: -XX:VMThreadStackSize=512 \ aoqi@0: -XX:CompilerThreadStackSize=512 \ aoqi@0: -XX:ParallelGCThreads=1 \ aoqi@0: -XX:CICompilerCount=1 \ aoqi@0: -Xcomp \ aoqi@0: -XX:CICrashAt=1 \ aoqi@0: -XX:+CreateMinidumpOnCrash \ aoqi@0: -XX:+DumpReplayDataOnError \ aoqi@0: -XX:ReplayDataFile=${replay_data} \ aoqi@0: -version" aoqi@0: echo GENERATION OF REPLAY.TXT: aoqi@0: echo $cmd aoqi@0: aoqi@0: ${cmd} > crash.out 2>&1 aoqi@0: aoqi@0: core_locations=`grep -i core crash.out | grep "location:" | \ aoqi@0: sed -e 's/.*location: //'` aoqi@0: rm crash.out aoqi@0: # processing core locations for *nix aoqi@0: if [ $VM_OS != "windows" ] aoqi@0: then aoqi@0: # remove 'or' between '/core.' and 'core' aoqi@0: core_locations=`echo $core_locations | \ aoqi@0: sed -e 's/\([^ ]*\) or \([^ ]*\)/\1 \2/'` aoqi@0: # add /core. core. aoqi@0: core_with_dir=`echo $core_locations | awk '{print $1}'` aoqi@0: dir=`dirname $core_with_dir` aoqi@0: core_with_pid=`echo $core_locations | awk '{print $2}'` aoqi@0: if [ -n ${core_with_pid} ] aoqi@0: then aoqi@0: core_locations="$core_locations $dir${FS}$core_with_pid $core_with_pid" aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: echo "LOOKING FOR CORE IN ${core_locations}" aoqi@0: for core in $core_locations aoqi@0: do aoqi@0: if [ -r "$core" ] aoqi@0: then aoqi@0: core_file=$core aoqi@0: fi aoqi@0: done aoqi@0: aoqi@0: # core-file was found aoqi@0: if [ -n "$core_file" ] aoqi@0: then aoqi@0: ${MV} "${core_file}" test_core aoqi@0: core_file=test_core aoqi@0: fi aoqi@0: aoqi@0: ${RM} -f hs_err_pid*.log aoqi@0: } aoqi@0: