1 # Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. 2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 # 4 # This code is free software; you can redistribute it and/or modify it 5 # under the terms of the GNU General Public License version 2 only, as 6 # published by the Free Software Foundation. 7 # 8 # This code is distributed in the hope that it will be useful, but WITHOUT 9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 # version 2 for more details (a copy is included in the LICENSE file that 12 # accompanied this code). 13 # 14 # You should have received a copy of the GNU General Public License version 15 # 2 along with this work; if not, write to the Free Software Foundation, 16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 # 18 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 # or visit www.oracle.com if you need additional information or have any 20 # questions. 21 22 # Note: the specifics of the test is defined by files such as ../simple/run.sh 23 24 # run all tests 25 # bash run.sh $JAVA 26 # run a single test 27 # bash run.sh $JAVA 2 28 # clean up 29 # make clean 30 31 ONLYTEST=$1 32 33 TEST_NUM=0 34 35 function do_test () { 36 TEST_NUM=$(expr $TEST_NUM + 1) 37 38 echo ======================================== 39 echo Test $TEST_NUM $1 40 41 shift 42 if test "$ONLYTEST" != "" -a "$ONLYTEST" != "$TEST_NUM"; then 43 echo "$@" 44 echo "SKIPPED" 45 return 0 46 else 47 local before_errfiles=$(ls hs_err* 2> /dev/null | sort) 48 echo "$@" 49 if eval "$@"; then 50 true 51 else 52 echo "FAILED; command line was:" 53 echo "$@"; 54 exit 1 55 fi 56 local after_errfiles=$(ls hs_err* 2> /dev/null | sort) 57 if test "$before_errfiles" != "$after_errfiles"; then 58 echo "HotSpot crashed (check hs_err errfiles); command line was:" 59 echo "$@" 60 exit 1 61 fi 62 echo "PASSED $TEST_NUM" 63 if test "$ONLYTEST" = "$TEST_NUM"; then 64 echo "Exiting after test $TEST_NUM has passed. Further tests may have been skipped" 65 exit 0 66 fi 67 fi 68 } 69 70 do_test "(STEP 1 of 5) Dump classlist" \ 71 $JAVA -Xshare:off -XX:DumpLoadedClassList=$APP.classlist $CMDLINE 72 73 if test "$JAR" != ""; then 74 DUMP_CP="-cp" 75 else 76 DUMP_CP= 77 fi 78 79 do_test "(STEP 2 of 5) Create Static $APP-static.jsa" \ 80 $JAVA -Xshare:dump -XX:SharedArchiveFile=$APP-static.jsa -XX:SharedClassListFile=$APP.classlist $DUMP_CP $JAR \ 81 -Xlog:cds=debug,cds+class=debug,cds+resolve=debug:file=$APP-static.dump.log::filesize=0 $DUMP_EXTRA_ARGS 82 83 if false; then 84 do_test "Run with $APP-static.jsa" \ 85 $JAVA -XX:SharedArchiveFile=$APP-static.jsa $CMDLINE 86 fi 87 88 do_test "(STEP 3 of 5) Run with $APP-static.jsa and dump profile in $APP-dynamic.jsa (With Training Data Replay)" \ 89 $JAVA -XX:SharedArchiveFile=$APP-static.jsa -XX:ArchiveClassesAtExit=$APP-dynamic.jsa -XX:+RecordTraining \ 90 -Xlog:cds=debug,cds+class=debug:file=$APP-dynamic.dump.log::filesize=0 \ 91 $CMDLINE 92 93 do_test "(STEP 4 of 5) Run with $APP-dynamic.jsa and generate AOT code" \ 94 $JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+ReplayTraining -XX:+StoreCachedCode \ 95 -Xlog:scc*=warning:file=$APP-store-sc.log::filesize=0 \ 96 -XX:CachedCodeFile=$APP-dynamic.jsa-sc -XX:CachedCodeMaxSize=100M $CMDLINE 97 98 do_test "(STEP 5 of 5) Final production run: with $APP-dynamic.jsa and load AOT code" \ 99 $JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+ReplayTraining -XX:+LoadCachedCode \ 100 -Xlog:scc*=warning:file=$APP-load-sc.log::filesize=0 \ 101 -XX:CachedCodeFile=$APP-dynamic.jsa-sc $CMDLINE