Fri, 12 Jun 2020 02:59:56 +0100
8233197: Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
8246703: [TESTBUG] Add test for JDK-8233197
Reviewed-by: aph, adinn, neugens
jbachorik@9925 | 1 | #!/bin/sh |
jbachorik@9925 | 2 | |
jbachorik@9925 | 3 | # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
jbachorik@9925 | 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jbachorik@9925 | 5 | # |
jbachorik@9925 | 6 | # This code is free software; you can redistribute it and/or modify it |
jbachorik@9925 | 7 | # under the terms of the GNU General Public License version 2 only, as |
jbachorik@9925 | 8 | # published by the Free Software Foundation. |
jbachorik@9925 | 9 | # |
jbachorik@9925 | 10 | # This code is distributed in the hope that it will be useful, but WITHOUT |
jbachorik@9925 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jbachorik@9925 | 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jbachorik@9925 | 13 | # version 2 for more details (a copy is included in the LICENSE file that |
jbachorik@9925 | 14 | # accompanied this code). |
jbachorik@9925 | 15 | # |
jbachorik@9925 | 16 | # You should have received a copy of the GNU General Public License version |
jbachorik@9925 | 17 | # 2 along with this work; if not, write to the Free Software Foundation, |
jbachorik@9925 | 18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jbachorik@9925 | 19 | # |
jbachorik@9925 | 20 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jbachorik@9925 | 21 | # or visit www.oracle.com if you need additional information or have any |
jbachorik@9925 | 22 | # questions. |
jbachorik@9925 | 23 | |
jbachorik@9925 | 24 | ## |
jbachorik@9925 | 25 | ## @test Test8233197.sh |
jbachorik@9925 | 26 | ## @bug 8233197 |
jbachorik@9925 | 27 | ## @summary Check that JFR subsystem can be initialized from VMStart JVMTI event |
jbachorik@9925 | 28 | ## @compile T.java |
jbachorik@9925 | 29 | ## @run shell Test8233197.sh |
jbachorik@9925 | 30 | ## |
jbachorik@9925 | 31 | |
jbachorik@9925 | 32 | set -x |
jbachorik@9925 | 33 | if [ "${TESTSRC}" = "" ] |
jbachorik@9925 | 34 | then |
jbachorik@9925 | 35 | TESTSRC=${PWD} |
jbachorik@9925 | 36 | echo "TESTSRC not set. Using "${TESTSRC}" as default" |
jbachorik@9925 | 37 | fi |
jbachorik@9925 | 38 | echo "TESTSRC=${TESTSRC}" |
jbachorik@9925 | 39 | ## Adding common setup Variables for running shell tests. |
jbachorik@9925 | 40 | . ${TESTSRC}/../../test_env.sh |
jbachorik@9925 | 41 | |
jbachorik@9925 | 42 | # set platform-dependent variables |
jbachorik@9925 | 43 | OS=`uname -s` |
jbachorik@9925 | 44 | case "$OS" in |
jbachorik@9925 | 45 | Linux) |
jbachorik@9925 | 46 | gcc_cmd=`which gcc` |
jbachorik@9925 | 47 | if [ "x$gcc_cmd" == "x" ]; then |
jbachorik@9925 | 48 | echo "WARNING: gcc not found. Cannot execute test." 2>&1 |
jbachorik@9925 | 49 | exit 0; |
jbachorik@9925 | 50 | fi |
jbachorik@9925 | 51 | NULL=/dev/null |
jbachorik@9925 | 52 | PS=":" |
jbachorik@9925 | 53 | FS="/" |
jbachorik@9925 | 54 | ;; |
jbachorik@9925 | 55 | * ) |
jbachorik@9925 | 56 | echo "Test passed; only valid for Linux" |
jbachorik@9925 | 57 | exit 0; |
jbachorik@9925 | 58 | ;; |
jbachorik@9925 | 59 | esac |
jbachorik@9925 | 60 | |
jbachorik@9925 | 61 | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1 |
jbachorik@9925 | 62 | |
jbachorik@9925 | 63 | # Bitness: |
jbachorik@9925 | 64 | # Cannot simply look at TESTVMOPTS as -d64 is not |
jbachorik@9925 | 65 | # passed if there is only a 64-bit JVM available. |
jbachorik@9925 | 66 | |
jbachorik@9925 | 67 | grep "64-Bit" vm_version.out > ${NULL} |
jbachorik@9925 | 68 | if [ "$?" = "0" ] |
jbachorik@9925 | 69 | then |
jbachorik@9925 | 70 | COMP_FLAG="-m64" |
jbachorik@9925 | 71 | else |
jbachorik@9925 | 72 | COMP_FLAG="-m32" |
jbachorik@9925 | 73 | fi |
jbachorik@9925 | 74 | |
jbachorik@9925 | 75 | |
jbachorik@9925 | 76 | # Architecture: |
jbachorik@9925 | 77 | # Translate uname output to JVM directory name, but permit testing |
jbachorik@9925 | 78 | # 32-bit x86 on an x64 platform. |
jbachorik@9925 | 79 | ARCH=`uname -m` |
jbachorik@9925 | 80 | case "$ARCH" in |
jbachorik@9925 | 81 | x86_64) |
jbachorik@9925 | 82 | if [ "$COMP_FLAG" = "-m32" ]; then |
jbachorik@9925 | 83 | ARCH=i386 |
jbachorik@9925 | 84 | else |
jbachorik@9925 | 85 | ARCH=amd64 |
jbachorik@9925 | 86 | fi |
jbachorik@9925 | 87 | ;; |
jbachorik@9925 | 88 | ppc64) |
jbachorik@9925 | 89 | if [ "$COMP_FLAG" = "-m32" ]; then |
jbachorik@9925 | 90 | ARCH=ppc |
jbachorik@9925 | 91 | else |
jbachorik@9925 | 92 | ARCH=ppc64 |
jbachorik@9925 | 93 | fi |
jbachorik@9925 | 94 | ;; |
jbachorik@9925 | 95 | sparc64) |
jbachorik@9925 | 96 | if [ "$COMP_FLAG" = "-m32" ]; then |
jbachorik@9925 | 97 | ARCH=sparc |
jbachorik@9925 | 98 | else |
jbachorik@9925 | 99 | ARCH=sparc64 |
jbachorik@9925 | 100 | fi |
jbachorik@9925 | 101 | ;; |
jbachorik@9925 | 102 | arm*) |
jbachorik@9925 | 103 | # 32-bit ARM machine: compiler may not recognise -m32 |
jbachorik@9925 | 104 | COMP_FLAG="" |
jbachorik@9925 | 105 | ARCH=arm |
jbachorik@9925 | 106 | ;; |
jbachorik@9925 | 107 | aarch64) |
jbachorik@9925 | 108 | # 64-bit arm machine, could be testing 32 or 64-bit: |
jbachorik@9925 | 109 | if [ "$COMP_FLAG" = "-m32" ]; then |
jbachorik@9925 | 110 | ARCH=arm |
jbachorik@9925 | 111 | else |
jbachorik@9925 | 112 | ARCH=aarch64 |
jbachorik@9925 | 113 | fi |
jbachorik@9925 | 114 | ;; |
jbachorik@9925 | 115 | i586) |
jbachorik@9925 | 116 | ARCH=i386 |
jbachorik@9925 | 117 | ;; |
jbachorik@9925 | 118 | i686) |
jbachorik@9925 | 119 | ARCH=i386 |
jbachorik@9925 | 120 | ;; |
jbachorik@9925 | 121 | # Assuming other ARCH values need no translation |
jbachorik@9925 | 122 | esac |
jbachorik@9925 | 123 | |
jbachorik@9925 | 124 | |
jbachorik@9925 | 125 | # VM type: need to know server or client |
jbachorik@9925 | 126 | VMTYPE=client |
jbachorik@9925 | 127 | grep Server vm_version.out > ${NULL} |
jbachorik@9925 | 128 | if [ "$?" = "0" ] |
jbachorik@9925 | 129 | then |
jbachorik@9925 | 130 | VMTYPE=server |
jbachorik@9925 | 131 | fi |
jbachorik@9925 | 132 | |
jbachorik@9925 | 133 | |
jbachorik@9925 | 134 | LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH |
jbachorik@9925 | 135 | export LD_LIBRARY_PATH |
jbachorik@9925 | 136 | |
jbachorik@9925 | 137 | cp ${TESTSRC}${FS}libJvmtiAgent.c . |
jbachorik@9925 | 138 | |
jbachorik@9925 | 139 | # Copy the result of our @compile action: |
jbachorik@9925 | 140 | cp ${TESTCLASSES}${FS}T.class . |
jbachorik@9925 | 141 | |
jbachorik@9925 | 142 | echo "Architecture: ${ARCH}" |
jbachorik@9925 | 143 | echo "Compilation flag: ${COMP_FLAG}" |
jbachorik@9925 | 144 | echo "VM type: ${VMTYPE}" |
jbachorik@9925 | 145 | |
jbachorik@9925 | 146 | $gcc_cmd -DLINUX ${COMP_FLAG} -Wl, -g -fno-strict-aliasing -fPIC -fno-omit-frame-pointer -W -Wall -Wno-unused -Wno-parentheses -c -o libJvmtiAgent.o \ |
jbachorik@9925 | 147 | -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \ |
jbachorik@9925 | 148 | -L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \ |
jbachorik@9925 | 149 | libJvmtiAgent.c |
jbachorik@9925 | 150 | $gcc_cmd -shared -o libJvmtiAgent.so libJvmtiAgent.o |
jbachorik@9925 | 151 | |
jbachorik@9925 | 152 | "$TESTJAVA/bin/java" $TESTVMOPTS -agentlib:JvmtiAgent -cp $(pwd) T > T.out |
jbachorik@9925 | 153 | exit $? |