aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-07-05 01:01:24 +0200
committerSven Gothel <[email protected]>2022-07-05 01:01:24 +0200
commitb9d1c558884dd5f5ce23ee7d35e2f14201a2c4c2 (patch)
tree7b7893d228d21bf292bad37350ab17836500ee50 /scripts
parent2ba71f91fd852fd609943a2625be26e1c67c8507 (diff)
mount/umount: Cover `testsudo_fileutils02.cpp` with `TestsudoFileUtils02.java`; API-doc: Detail mount/umount capabilities (alt to sudo)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/testsudo_java.sh99
1 files changed, 99 insertions, 0 deletions
diff --git a/scripts/testsudo_java.sh b/scripts/testsudo_java.sh
new file mode 100755
index 0000000..3f8dd8a
--- /dev/null
+++ b/scripts/testsudo_java.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+# export jau_debug=true
+# export jau_verbose=true
+
+#
+# JAVA_PROPS="-Djau.debug=true -Djau.verbose=true"
+#
+
+script_args="$@"
+sdir=`dirname $(readlink -f $0)`
+rootdir=`dirname $sdir`
+bname=`basename $0 .sh`
+
+. $sdir/setup-machine-arch.sh
+
+build_dir=${rootdir}/build-${archabi}
+dist_dir=$rootdir/dist-$archabi
+
+if [ ! -e $dist_dir/lib/java/jaulib-test.jar ] ; then
+ echo "test exe $dist_dir/lib/java/jaulib-test.jar not existing"
+ exit 1
+fi
+
+if [ -e /usr/lib/jvm/java-17-openjdk-$archabi ] ; then
+ export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$archabi
+elif [ -e /usr/lib/jvm/java-11-openjdk-$archabi ] ; then
+ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi
+fi
+if [ ! -e $JAVA_HOME ] ; then
+ echo $JAVA_HOME does not exist
+ exit 1
+fi
+JAVA_EXE=${JAVA_HOME}/bin/java
+# JAVA_EXE=`readlink -f $(which java)`
+# JAVA_CMD="${JAVA_EXE} -Xcheck:jni -verbose:jni"
+JAVA_CMD="${JAVA_EXE}"
+
+if [ "$1" = "-log" ] ; then
+ logfile=$2
+ shift 2
+else
+ logfile=
+fi
+
+test_class=jau.test.fs.TestsudoFileUtils02
+if [ ! -z "$1" ] ; then
+ test_class=$1
+ shift 1
+fi
+test_basename=`echo ${test_class} | sed 's/.*\.//g'`
+
+if [ -z "${logfile}" ] ; then
+ logfile=~/${bname}-${test_basename}-${archabi}.log
+fi
+rm -f $logfile
+logbasename=`basename ${logfile} .log`
+
+ulimit -c unlimited
+
+# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8'
+# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8'
+export LC_MEASUREMENT=en_US.UTF-8
+export LC_ALL=en_US.UTF-8
+export LANG=en_US.UTF-8
+
+# export JAVA_PROPS="-Xint"
+# export EXE_WRAPPER="nice -20"
+
+test_classpath=/usr/share/java/junit4.jar:${dist_dir}/lib/java/jaulib.jar:${build_dir}/test/java/jaulib-test.jar
+#test_classpath=/usr/share/java/junit4.jar:${dist_dir}/lib/java/jaulib-fat.jar:${build_dir}/test/java/jaulib-test.jar
+
+do_test() {
+ echo "script invocation: $0 ${script_args}"
+ echo EXE_WRAPPER $EXE_WRAPPER
+ echo jau_debug $jau_debug
+ echo jau_verbose $jau_verbose
+ echo logbasename $logbasename
+ echo logfile $logfile
+ echo test_class ${test_class}
+
+ test_dir="${build_dir}/test/java/"
+ echo "cd ${test_dir}"
+ cd ${test_dir}
+ pwd
+
+ echo "$EXE_WRAPPER ${JAVA_CMD} ${JAVA_PROPS} -cp ${test_classpath} -Djava.library.path=${rootdir}/dist-${archabi}/lib org.junit.runner.JUnitCore ${test_class} ${*@Q}"
+
+ ulimit -c unlimited
+ # $EXE_WRAPPER ${JAVA_CMD} ${JAVA_PROPS} -cp ${test_classpath} -Djava.library.path=${rootdir}/dist-${archabi}/lib org.junit.runner.JUnitCore ${test_class} ${*@Q}
+ # $EXE_WRAPPER ${JAVA_CMD} ${JAVA_PROPS} -cp ${test_classpath} org.junit.runner.JUnitCore ${test_class} ${*@Q}
+
+ "/usr/bin/sudo" -E "/sbin/capsh" "--caps=cap_sys_admin,cap_setuid,cap_setgid+eip cap_setpcap+ep" "--keep=1" "--user=${USER}" "--addamb=cap_sys_admin,cap_setuid,cap_setgid+eip" "--" "-c" "ulimit -c unlimited; $EXE_WRAPPER ${JAVA_CMD} ${JAVA_PROPS} -cp ${test_classpath} -Djava.library.path=${rootdir}/dist-${archabi}/lib org.junit.runner.JUnitCore ${test_class} ${*@Q}"
+
+ exit $?
+}
+
+do_test "$@" 2>&1 | tee $logfile
+