aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/run-java-trial.sh
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-05-14 04:45:20 +0200
committerSven Gothel <[email protected]>2022-05-14 04:45:20 +0200
commit313b27cfcf5aa6ea6c16eaec0e6a8452e998d481 (patch)
treee7f57f495f384f8a55a81ae19437a84a24d70088 /scripts/run-java-trial.sh
parent044c55d46de095721104ed8d511f70c47ee3d008 (diff)
C++/JNI Lifecycle Fix: BTManager must be passed as shared_ptr<> and hold as such in BTAdapter, ... (API CHANGE)
BTAdapter removes itself from BTManager, hence needs to ensure BTManager is not yet destructed. This goes well along with our new JNI mapping, holding the shared_ptr reference in nativeInstance.
Diffstat (limited to 'scripts/run-java-trial.sh')
-rwxr-xr-xscripts/run-java-trial.sh55
1 files changed, 47 insertions, 8 deletions
diff --git a/scripts/run-java-trial.sh b/scripts/run-java-trial.sh
index 446e5398..889fc4ae 100755
--- a/scripts/run-java-trial.sh
+++ b/scripts/run-java-trial.sh
@@ -1,5 +1,14 @@
#!/bin/bash
+#
+# See scripts/scripts/run-native-example.sh for general details,
+# however, commandline arguments are not used for trials but '-log <logfile>'
+#
+
+#
+# JAVA_PROPS="-Dorg.direct_bt.debug=true -Dorg.direct_bt.verbose=true"
+#
+
script_args="$@"
sdir=`dirname $(readlink -f $0)`
rootdir=`dirname $sdir`
@@ -7,6 +16,8 @@ bname=`basename $0 .sh`
. $sdir/setup-machine-arch.sh
+build_dir=${rootdir}/build-${archabi}
+
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
@@ -16,23 +27,51 @@ 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}"
-test_class=trial.org.direct_bt.TestDBTClientServer10_NoEnc
+if [ "$1" = "-log" ] ; then
+ logfile=$2
+ shift 2
+else
+ logfile=
+fi
+test_class=trial.org.direct_bt.TestDBTClientServer10_NoEnc
if [ ! -z "$1" ] ; then
test_class=$1
shift 1
fi
-
test_basename=`echo ${test_class} | sed 's/.*\.//g'`
-logfile=$rootdir/${bname}-${test_basename}-${archabi}.log
+if [ -z "${logfile}" ] ; then
+ logfile=~/${bname}-${test_basename}-${archabi}.log
+fi
rm -f $logfile
+logbasename=`basename ${logfile} .log`
+
+valgrindlogfile=$logbasename-valgrind.log
+rm -f $valgrindlogfile
+
+callgrindoutfile=$logbasename-callgrind.out
+rm -f $callgrindoutfile
+
+echo 'core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern
+ulimit -c unlimited
-java=${JAVA_HOME}/bin/java
+# 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
-project_dir=/usr/local/projects/zafena/direct_bt
-build_dir=${project_dir}/build-${archabi}
+# export JAVA_PROPS="-Xint"
+# export EXE_WRAPPER="valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --num-callers=24 --malloc-fill=0xff --free-fill=0xfe --error-limit=no --default-suppressions=yes --suppressions=$sdir/valgrind.supp --suppressions=$sdir/valgrind-jvm.supp --gen-suppressions=all -s --log-file=$valgrindlogfile"
+# export EXE_WRAPPER="valgrind --tool=helgrind --track-lockorders=yes --num-callers=24 --ignore-thread-creation=yes --default-suppressions=yes --suppressions=$sdir/valgrind.supp --suppressions=$sdir/valgrind-jvm.supp --gen-suppressions=all -s --log-file=$valgrindlogfile"
+# export EXE_WRAPPER="valgrind --tool=drd --segment-merging=no --ignore-thread-creation=yes --trace-barrier=no --trace-cond=no --trace-fork-join=no --trace-mutex=no --trace-rwlock=no --trace-semaphore=no --default-suppressions=yes --suppressions=$sdir/valgrind.supp --suppressions=$sdir/valgrind-jvm.supp --gen-suppressions=all -s --log-file=$valgrindlogfile"
+# export EXE_WRAPPER="valgrind --tool=callgrind --instr-atstart=yes --collect-atstart=yes --collect-systime=yes --combine-dumps=yes --separate-threads=no --callgrind-out-file=$callgrindoutfile --log-file=$valgrindlogfile"
test_classpath=/usr/share/java/junit4.jar:${build_dir}/java/direct_bt.jar:${build_dir}/jaulib/java_base/jaulib_base.jar:${build_dir}/jaulib/test/java/jaulib-test.jar:${build_dir}/trial/java/direct_bt-trial.jar
@@ -40,9 +79,9 @@ do_test() {
echo "script invocation: $0 ${script_args}"
echo logfile $logfile
- echo "/usr/bin/sudo" "/sbin/capsh" "--caps=cap_net_raw,cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" "--keep=1" "--user=sven" "--addamb=cap_net_raw,cap_net_admin+eip" "--" "-c" "ulimit -c unlimited; $EXE_WRAPPER ${java} -cp ${test_classpath} -Djava.library.path=${project_dir}/dist-${archabi}/lib org.junit.runner.JUnitCore ${test_class} ${*@Q}"
+ echo "/usr/bin/sudo" "/sbin/capsh" "--caps=cap_net_raw,cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" "--keep=1" "--user=sven" "--addamb=cap_net_raw,cap_net_admin+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}"
- "/usr/bin/sudo" "/sbin/capsh" "--caps=cap_net_raw,cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" "--keep=1" "--user=sven" "--addamb=cap_net_raw,cap_net_admin+eip" "--" "-c" "ulimit -c unlimited; $EXE_WRAPPER ${java} -cp ${test_classpath} -Djava.library.path=${project_dir}/dist-${archabi}/lib org.junit.runner.JUnitCore ${test_class} ${*@Q}"
+ "/usr/bin/sudo" "/sbin/capsh" "--caps=cap_net_raw,cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" "--keep=1" "--user=sven" "--addamb=cap_net_raw,cap_net_admin+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 $?
}