|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. |
| 4 | +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 5 | +# |
| 6 | +# This code is free software; you can redistribute it and/or modify it |
| 7 | +# under the terms of the GNU General Public License version 2 only, as |
| 8 | +# published by the Free Software Foundation. |
| 9 | +# |
| 10 | +# This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | +# version 2 for more details (a copy is included in the LICENSE file that |
| 14 | +# accompanied this code). |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License version |
| 17 | +# 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | +# |
| 20 | +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 21 | +# or visit www.oracle.com if you need additional information or have any |
| 22 | +# questions. |
| 23 | + |
| 24 | +# @test DynamicCodeGeneratedTest.sh |
| 25 | +# @bug 8212155 |
| 26 | +# @summary Test concurrent enabling and posting of DynamicCodeGenerated events. |
| 27 | +# @run shell DynamicCodeGeneratedTest.sh |
| 28 | + |
| 29 | +if [ "$TESTSRC" = "" ] |
| 30 | +then TESTSRC=. |
| 31 | +fi |
| 32 | + |
| 33 | +if [ "$TESTJAVA" = "" ] |
| 34 | +then |
| 35 | + PARENT=$(dirname $(which java)) |
| 36 | + TESTJAVA=$(dirname $PARENT) |
| 37 | + echo "TESTJAVA not set, selecting " $TESTJAVA |
| 38 | + echo "If this is incorrect, try setting the variable manually." |
| 39 | +fi |
| 40 | + |
| 41 | +# set platform-dependent variables |
| 42 | +OS=$(uname -s) |
| 43 | +case "$OS" in |
| 44 | + Linux ) |
| 45 | + ARCHFLAG= |
| 46 | + $TESTJAVA/bin/java -version 2>&1 | grep '64-Bit' > /dev/null |
| 47 | + if [ $? -eq '0' ] |
| 48 | + then |
| 49 | + ARCH="amd64" |
| 50 | + else |
| 51 | + ARCH="i386" |
| 52 | + ARCHFLAG="-m32 -march=i386" |
| 53 | + fi |
| 54 | + ;; |
| 55 | + * ) |
| 56 | + echo "Test passed, unrecognized system." |
| 57 | + exit 0; |
| 58 | + ;; |
| 59 | +esac |
| 60 | + |
| 61 | +echo "OS-ARCH is" linux-$ARCH |
| 62 | +$TESTJAVA/jre/bin/java -fullversion 2>&1 |
| 63 | + |
| 64 | +which gcc >/dev/null 2>&1 |
| 65 | +if [ "$?" -ne '0' ] |
| 66 | +then |
| 67 | + echo "No C compiler found. Test passed." |
| 68 | + exit 0 |
| 69 | +fi |
| 70 | + |
| 71 | +JAVA=$TESTJAVA/jre/bin/java |
| 72 | +JAVAC=$TESTJAVA/bin/javac |
| 73 | +JAVAH=$TESTJAVA/bin/javah |
| 74 | + |
| 75 | +$JAVAC -d . $TESTSRC/DynamicCodeGenerated.java |
| 76 | +$JAVAH -jni -classpath . -d . DynamicCodeGenerated |
| 77 | + |
| 78 | +gcc --shared $ARCHFLAG -fPIC -O -I$TESTJAVA/include -I$TESTJAVA/include/linux -I. -o libDynamicCodeGenerated.so $TESTSRC/libDynamicCodeGenerated.cpp |
| 79 | + |
| 80 | +LD_LIBRARY_PATH=. $JAVA -classpath . -agentlib:DynamicCodeGenerated DynamicCodeGenerated |
| 81 | + |
| 82 | +exit $? |
0 commit comments