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 # run JMH with premain prototype
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 JAVA=$1; shift
32 JAR=specjbb2005-jmh-1.25.jar
33 CMDLINE="-jar $JAR Jbb -t 1 -f 0 -r 1 -i 2 -wi 0"
34 APP=specjbb2005-jmh
35
36 ONLYTEST=$1
37
38 TEST_NUM=0
39
40 function do_test () {
41 TEST_NUM=$(expr $TEST_NUM + 1)
42
43 echo ========================================
44 echo Test $TEST_NUM $1
45
46 shift
47 if test "$ONLYTEST" != "" -a "$ONLYTEST" != "$TEST_NUM"; then
48 echo "$@"
49 echo "SKIPPED"
50 return 0
51 else
52 local before_errfiles=$(ls hs_err* 2> /dev/null | sort)
53 echo "$@"
54 if eval "$@"; then
55 true
56 else
57 echo "FAILED; command line was:"
58 echo "$@";
59 exit 1
60 fi
61 local after_errfiles=$(ls hs_err* 2> /dev/null | sort)
62 if test "$before_errfiles" != "$after_errfiles"; then
63 echo "HotSpot crashed (check hs_err errfiles); command line was:"
64 echo "$@"
65 exit 1
66 fi
67 echo "PASSED $TEST_NUM"
68 if test "$ONLYTEST" = "$TEST_NUM"; then
69 echo "Exiting after test $TEST_NUM has passed. Further tests may have been skipped"
70 exit 0
71 fi
72 fi
73 }
74
75 do_test "(STEP 1 of 5) Dump classlist" \
76 $JAVA -Xshare:off -XX:DumpLoadedClassList=$APP.classlist $CMDLINE
77
78 do_test "(STEP 2 of 5) Create Static $APP-static.jsa" \
79 $JAVA -Xshare:dump -XX:SharedArchiveFile=$APP-static.jsa -XX:SharedClassListFile=$APP.classlist -cp $JAR \
80 -Xlog:cds=debug,cds+class=debug,cds+resolve=debug:file=$APP-static.dump.log
81
82 if false; then
83 do_test "Run with $APP-static.jsa" \
84 $JAVA -XX:SharedArchiveFile=$APP-static.jsa $CMDLINE
85 fi
86
87 do_test "(STEP 3 of 5) Run with $APP-static.jsa and dump profile in $APP-dynamic.jsa (With Training Data Replay)" \
88 $JAVA -XX:SharedArchiveFile=$APP-static.jsa -XX:ArchiveClassesAtExit=$APP-dynamic.jsa -XX:+UnlockDiagnosticVMOptions -XX:+AOTRecordTraining \
89 -Xlog:cds=debug,cds+class=debug:file=$APP-dynamic.dump.log \
90 $CMDLINE
91
92 do_test "(STEP 4 of 5) Run with $APP-dynamic.jsa and generate AOT code" \
93 $JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+UnlockDiagnosticVMOptions -XX:+AOTReplayTraining -XX:+StoreCachedCode \
94 -Xlog:aot+codecache*=warning:file=$APP-store-sc.log \
95 -XX:CachedCodeFile=$APP-dynamic.jsa-sc -XX:CachedCodeMaxSize=100M $CMDLINE
96
97 do_test "(STEP 5 of 5) Final production run: with $APP-dynamic.jsa and load AOT code" \
98 $JAVA -XX:SharedArchiveFile=$APP-dynamic.jsa -XX:+UnlockDiagnosticVMOptions -XX:+AOTReplayTraining -XX:+LoadCachedCode \
99 -Xlog:aot+codecache*=warning:file=$APP-load-sc.log \
100 -XX:CachedCodeFile=$APP-dynamic.jsa-sc $CMDLINE