1# 
2#  Copyright (c) 2012, Red Hat, Inc.
3#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4# 
5#  This code is free software; you can redistribute it and/or modify it
6#  under the terms of the GNU General Public License version 2 only, as
7#  published by the Free Software Foundation.
8# 
9#  This code is distributed in the hope that it will be useful, but WITHOUT
10#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12#  version 2 for more details (a copy is included in the LICENSE file that
13#  accompanied this code).
14# 
15#  You should have received a copy of the GNU General Public License version
16#  2 along with this work; if not, write to the Free Software Foundation,
17#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18# 
19#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20#  or visit www.oracle.com if you need additional information or have any
21#  questions.
22# 
23
24# @test SDTProbesGNULinuxTest.sh
25# @bug 7170638
26# @summary Test SDT probes available on GNU/Linux when DTRACE_ENABLED
27# @run shell SDTProbesGNULinuxTest.sh
28
29# This test only matters on GNU/Linux, others trivially PASS.
30OS=`uname -s`
31case "$OS" in
32  Linux )
33    ;;
34  *)
35    echo "Not testing on anything but GNU/Linux. PASSED"
36    exit 0;
37    ;;
38esac
39
40# Where is our java (parent) directory? 
41if [ "${TESTJAVA}" = "" ]; then
42  PARENT=$(dirname $(readlink -f $(which java)))
43  TESTJAVA=`dirname ${PARENT}`
44  echo "TESTJAVA directory not set, using " ${TESTJAVA}
45fi
46
47# This test only matters when build with DTRACE_ENABLED. 
48${TESTJAVA}/bin/java -XX:+ExtendedDTraceProbes -version
49if [ "$?" != "0" ]; then
50  echo "Not build using DTRACE_ENABLED. PASSED"
51  exit 0
52fi
53
54# Test all available libjvm.so variants
55for libjvm in $(find ${TESTJAVA} -name libjvm.so); do
56  echo "Testing ${libjvm}"
57  # Check whether the SDT probes are compiled in.
58  readelf -S ${libjvm} | grep '.note.stapsdt'
59  if [ "$?" != "0" ]; then
60    echo "Failed: ${libjvm} doesn't contain SDT probes."
61    exit 1
62  fi
63  # We could iterate over all SDT probes and test them individually
64  # with readelf -n, but older readelf versions don't understand them.
65done
66
67echo "Passed."
68exit 0
69