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