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