1#!/bin/ksh -p 2 3# 4# Copyright (c) 2016, 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 Try to force GTK3. We must bail out to GTK2 if no 3 available. 29# 30# @key headful 31# @compile ProvokeGTK.java 32# @requires os.family == "linux" 33# @run shell/timeout=400 DemandGTK3.sh 34 35# 36# Note that we depend on 37# strace in the PATH 38# /sbin/ldconfig (which may be is not in PATH) 39# It is true for OEL 7 and Ubuntu 14, 16 40# but may fail in future. Save tomorrow for tomorrow. 41# 42 43which strace 44if [ $? -ne 0 ] 45then 46 echo "Please provide strace: \"which strace\" failed." 47 exit 1 48fi 49 50HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l` 51 52 53if [ "${HAVE_3}" = "0" ] 54then 55 56 echo "No GTK 3 library found: we should bail out to 2" 57 strace -o strace.log -fe open ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=3 ProvokeGTK 58 EXECRES=$? 59 grep 'libgtk-x11.*=\ *[0-9]*$' strace.log > logg 60else 61 echo "There is GTK 3 library: we should use it" 62 strace -o strace.log -fe open ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=3 ProvokeGTK 63 EXECRES=$? 64 grep 'libgtk-3.*=\ *[0-9]*$' strace.log > logg 65fi 66 67if [ ${EXECRES} -ne 0 ] 68then 69 echo "java execution failed for unknown reason, see logs" 70 exit 2 71fi 72 73cat logg 74if [ -s logg ] 75then 76 echo "Success." 77 exit 0 78else 79 echo "Failed. Examine logs." 80 exit 3 81fi 82 83