1 #!/bin/sh
   2 
   3 #
   4 # Copyright (c) 2019, Red Hat, Inc. All rights reserved.
   5 #
   6 #  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7 #
   8 #  This code is free software; you can redistribute it and/or modify it
   9 #  under the terms of the GNU General Public License version 2 only, as
  10 #  published by the Free Software Foundation.
  11 #
  12 #  This code is distributed in the hope that it will be useful, but WITHOUT
  13 #  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14 #  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15 #  version 2 for more details (a copy is included in the LICENSE file that
  16 #  accompanied this code).
  17 #
  18 #  You should have received a copy of the GNU General Public License version
  19 #  2 along with this work; if not, write to the Free Software Foundation,
  20 #  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21 #
  22 #  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23 #  or visit www.oracle.com if you need additional information or have any
  24 #  questions.
  25 #
  26 
  27 ##
  28 ## @test
  29 ## @summary test JVMTI GetLoadedClasses in Shenandoah
  30 ## @run shell/timeout=480 TestGetLoadedClasses.sh
  31 ##
  32 
  33 if [ "${TESTSRC}" = "" ]
  34 then
  35   TESTSRC=${PWD}
  36   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
  37 fi
  38 echo "TESTSRC=${TESTSRC}"
  39 ## Adding common setup Variables for running shell tests.
  40 . ${TESTSRC}/../../../test_env.sh
  41 
  42 # set platform-dependent variables
  43 if [ "$VM_OS" = "linux" ]; then
  44     echo "Testing on linux"
  45     gcc_cmd=`which gcc`
  46     if [ "x$gcc_cmd" = "x" ]; then
  47         echo "WARNING: gcc not found. Cannot execute test." 2>&1
  48         exit 0;
  49     fi
  50 else
  51     echo "Test passed; only valid for linux: $VM_OS"
  52     exit 0;
  53 fi
  54 
  55 # Unfortunately, configurations cross-compiled to 32 bits would
  56 # fail with bitness mismatch, when compiled with platform gcc.
  57 # This would be fixed with /native support in JDK-8072842.
  58 if [ "$VM_BITS" = "32" ]; then
  59     echo "Test passed; only reliable on 64-bit"
  60     exit 0;
  61 fi
  62 
  63 THIS_DIR=.
  64 
  65 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
  66 ${TESTJAVA}${FS}bin${FS}javac TestGetLoadedClasses.java
  67 
  68 $gcc_cmd -O1 -DLINUX -fPIC -shared \
  69     -o ${THIS_DIR}${FS}libTestGetLoadedClasses.so \
  70     -I${TESTJAVA}${FS}include \
  71     -I${TESTJAVA}${FS}include${FS}linux \
  72     ${TESTSRC}${FS}libTestGetLoadedClasses.c
  73 
  74 # run the java test in the background
  75 cmd="${TESTJAVA}${FS}bin${FS}java -agentpath:./libTestGetLoadedClasses.so -Xmx128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC \
  76     -XX:ShenandoahSATBBufferSize=1 -XX:+ClassUnloadingWithConcurrentMark -XX:+ClassUnloading -Djava.library.path=${THIS_DIR}${FS} TestGetLoadedClasses"
  77 
  78 echo "$cmd"
  79 eval $cmd
  80 
  81 if [ $? -ne 0 ]
  82 then
  83     echo "Test Failed"
  84     exit 1
  85 fi
  86 
  87 if [ "$VM_BITS" = "64" ]; then
  88   cmd="${TESTJAVA}${FS}bin${FS}java -agentpath:./libTestGetLoadedClasses.so -Xmx128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC \
  89       -XX:ShenandoahSATBBufferSize=1 -XX:+ClassUnloadingWithConcurrentMark -XX:+ClassUnloading -XX:-UseCompressedOops -Djava.library.path=${THIS_DIR}${FS} TestGetLoadedClasses"
  90 
  91   echo "$cmd"
  92   eval $cmd
  93 
  94   if [ $? -ne 0 ]
  95   then
  96       echo "Test Failed"
  97       exit 1
  98   fi
  99 else
 100     echo "Test passed; only valid for 64 bits"
 101     exit 0;
 102 fi