1 #!/bin/bash
   2 #
   3 # Copyright (c) 2013, 2018, 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 
  25 JAVA_OPTS="$TESTJAVAOPTS $TESTVMOPTS"
  26 TESTED_JAVA_HOME="$TESTJAVA"
  27 
  28 digit="[0123456789]"
  29 number="${digit}*"
  30 size_pattern="${number}Kb"
  31 bound_pattern="0x[0123456789abcdef]*"
  32 s1=" size=${size_pattern} used=${size_pattern} max_used=${size_pattern} free=${size_pattern}"
  33 s2=" bounds \[${bound_pattern}, ${bound_pattern}, ${bound_pattern}\]"
  34 s3=" total_blobs=${number} nmethods=${number} adapters=${number}"
  35 s4=" compilation: enabled"
  36 summary_pat_nonseg="CodeCache:${s1}${s2}${s3}${s4}"
  37 summary_pat_seg="((CodeHeap.*):${s1}${s2})+${s3}${s4}"
  38 
  39 # check whether SegmentedCodeCache enabled
  40 segmented=$(${TESTED_JAVA_HOME}/bin/java ${JAVA_OPTS} -XX:+PrintFlagsFinal -version | egrep -c ' +SegmentedCodeCache +:?= +true')
  41 out=$(${TESTED_JAVA_HOME}/bin/java ${JAVA_OPTS} -XX:+PrintCodeCache -version)
  42 if [ "${segmented}" = "1" ]; then
  43         summary_pat=${summary_pat_seg}
  44         status="enabled"
  45 else
  46         summary_pat=${summary_pat_nonseg}
  47         status="disabled"
  48 fi
  49 echo "INFO: SegmentedCodeCache is ${status}"
  50 
  51 res=$(echo ${out} | egrep -c "${summary_pat}")
  52 if [ "${res}" = "1" ]; then
  53         echo "passed"
  54         true
  55 else
  56         echo ${summary_pat}
  57         echo "did not match for:"
  58         echo ${out}
  59         false
  60 fi