diff --git a/containersQa/109_HUM151_jreCompileAsRoot.sh b/containersQa/109_HUM151_jreCompileAsRoot.sh new file mode 100644 index 0000000..805878a --- /dev/null +++ b/containersQa/109_HUM151_jreCompileAsRoot.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -ex +set -o pipefail + +## resolve folder of this script, following all symlinks, +## http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in +SCRIPT_SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )" + SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")" + # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + [[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE" +done +readonly SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )" + +source $SCRIPT_DIR/testlib.bash + +if ! which sudo; then + echo "$SKIPPED9" + exit +fi + +parseArguments "$@" +processArguments +setup +tryJreCompilation sudo 2>&1| tee $REPORT_FILE diff --git a/containersQa/testlib.bash b/containersQa/testlib.bash index 89f0c38..ba97e4d 100644 --- a/containersQa/testlib.bash +++ b/containersQa/testlib.bash @@ -84,6 +84,9 @@ function pretest() { SKIPPED6="!skipped! rhel 7 based images do not support this functionality." SKIPPED7="!skipped! rhel 7 Os version of Podman does not support this functionality." SKIPPED8="!skipped! Skipping FIPS algorithms/providers tests." + SKIPPED9='!skipped! No sudo on system' + SKIPPED10='!skipped! mount do not work' + SKIPPED11='!skipped! Skipping runtime compilation on 8 and 11' export DISPLAY=:0 if [ "x$OTOOL_CONTAINER_RUNTIME" = "x" ] ; then export PD_PROVIDER=podman @@ -231,7 +234,9 @@ function runOnBaseDirBash() { function runOnBaseDirBashWithMount() { local d=$(mktemp -d) cp -r $LIBCQA_SCRIPT_DIR/*.java "${d}" - $PD_PROVIDER run -v="${d}:/testsDir" -i "$HASH" bash -c "${1}" + chmod 777 "${d}" + ls -ld ${d} + ${2} $PD_PROVIDER run -v="${d}:/testsDir:Z" -i "$HASH" bash -c "${1}" rm -rf "${d}" } @@ -1163,13 +1168,20 @@ function assertCryptoProviders() { function tryJreCompilation() { - runOnBaseDirBashWithMount "ls /testsDir | grep \\.java$" + local mountFailures=0 + runOnBaseDirBashWithMount "ls -l /" "$1" || let mountFailures="$mountFailures+1" + runOnBaseDirBashWithMount "ls -ld /testsDir" "$1" || let mountFailures="$mountFailures+10" + runOnBaseDirBashWithMount "ls -l /testsDir | grep \\.java$" "$1" || let mountFailures="$mountFailures+100" + if [ "0$mountFailures" -gt 0 ] ; then + echo "$SKIPPED10" + exit 0 + fi local v=$(runOnBaseDirBashWithMount "java -version " 2>&1 | grep "openjdk version" | head -n 1) if echo "$v" | grep '"1.8' || echo "$v" | grep '"11' ; then - echo '!skipped! Skipping runtime compilation on 8 and 11' + echo "$SKIPPED11" exit 0 else echo '17+, going on' fi - runOnBaseDirBashWithMount "java /testsDir/InProcessCompileDemo.java" + runOnBaseDirBashWithMount "java /testsDir/InProcessCompileDemo.java" "$1" }