libreoffice-online/test/run_unit.sh.in
Ashod Nakashian f8b05a0f83 wsd: support unattended runs
With --unattended, do not wait for a debugger
upon seg-faulting. This avoids the unnecessary wait
that prolongs failed unit-tests in automated runs.
Now run_unit.sh and Cypress Makefile set this flag.

Note that the wait only happens when in debug
builds, or when envar COOL_DEBUG is set. This
prevents us from waiting when running a debug
build where we can't see the output, or indeed
the run is on a CI build machine.

This flag can also be used by devs when reproducing
failures where there is no interest in attaching
a debugger. The logs are shorter and more
readable, too. At least in trace level.

Change-Id: Ice15482c6724abc47f5955402295198eb7f671ee
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-02-17 18:52:48 -05:00

124 lines
4.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# DO NOT EDIT - this file is generated from run_unit.sh.in.
#
cmd_line="$0 $@"
# substituted variables in one place:
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
abs_top_builddir="${DIR}/.."
systemplate_path="@SYSTEMPLATE_PATH@"
enable_debug="@ENABLE_DEBUG@"
if test -z "@ENABLE_SETCAP@"; then
capabilities=false
else
capabilities=true
fi
jails_path="@JAILS_PATH@"
lo_path="@LO_PATH@"
valgrind_cmd="valgrind --tool=memcheck --trace-children=no -v --read-var-info=yes"
verbose=''
capabilities="@ENABLE_SETCAP@"
if test "h$capabilities" != "htrue"; then
capabilities=false
fi
# Note that these options are used by commands in the Makefile that
# Automake generates. Don't be mislead by 'git grep' not showing any
# use of --test-name for instance.
print_help ()
{
echo "Usage: run_unit.sh --test-name <name.la> [OPTIONS]"
echo "Runs a specified unit test"
echo ""
echo " --log-file <file> Log output to this file - default /dev/stderr"
echo " --trs-file <file> Records the results of a test for automake (default /dev/stderr)"
echo " --gdb Run under gdb if enabled"
echo " --valgrind Run under valgrind if enabled"
echo " --verbose Print out more stuff - if you run out of things to read"
exit 1
}
tst=
tst_log=/dev/stderr
tst_output=/dev/stderr
while test $# -gt 0; do
case $1 in
--test-name) tst=$2; shift;;
--log-file) tst_log=$2; shift;;
--trs-file) test_output=$2; shift;;
--gdb) trace='gdb --args'; shift;;
--valgrind) trace=$valgrind_cmd; shift;;
--verbose) verbose="--verbose";;
--help) print_help ;;
-*) ;; # ignore
esac
shift
done
echo
echo "Running ${tst}"
echo " $cmd_line"
# drop .la suffix
tst=`echo $tst | sed "s/\.la//"`;
export COOL_LOGLEVEL=trace
if test "z$enable_debug" != "ztrue"; then
echo ""
echo "It is necessary to configure with --enable-debug for unit tests to pass"
echo ""
echo ":test-result: FAIL $tst" > $test_output
exit 1;
fi
# result logging
echo "Test output is '$test_output'"
echo > $test_output
echo "Running $tst | $tst_log ...";
echo > $tst_log
if ${trace} \
${abs_top_builddir}/coolwsd --o:sys_template_path="$systemplate_path" \
--o:child_root_path="$jails_path" \
--o:security.capabilities="${capabilities}" \
--o:storage.filesystem[@allow]=true \
--o:logging.level=trace \
--o:ssl.key_file_path="${abs_top_builddir}/etc/key.pem" \
--o:ssl.cert_file_path="${abs_top_builddir}/etc/cert.pem" \
--o:ssl.ca_file_path="${abs_top_builddir}/etc/ca-chain.cert.pem" \
--o:admin_console.username=admin --o:admin_console.password=admin \
--o:storage.ssl.enable=false \
--unattended \
--unitlib="${abs_top_builddir}/test/.libs/$tst.so" 2> "$tst_log"; then
echo "Test $tst passed."
echo ":test-result: PASS $tst" >> $test_output
else
echo "Test $tst FAILED."
cat $tst_log
echo "============================================================="
echo "Test failed on unit: $tst re-run with:"
echo " $ gdb --args ${abs_top_builddir}/coolwsd --o:sys_template_path=\"$systemplate_path\" \\"
echo " --o:child_root_path=\"$jails_path\" \\"
echo " --o:security.capabilities=\"${capabilities}\" \\"
echo " --o:storage.filesystem[@allow]=true \\"
echo " --o:logging.level=error\\" # logs and gdb don't go well together
echo " --o:ssl.key_file_path=\"${abs_top_builddir}/etc/key.pem\" \\"
echo " --o:ssl.cert_file_path=\"${abs_top_builddir}/etc/cert.pem\" \\"
echo " --o:ssl.ca_file_path=\"${abs_top_builddir}/etc/ca-chain.cert.pem\" \\"
echo " --o:admin_console.username=admin --o:admin_console.password=admin \\"
echo " --o:storage.ssl.enable=false \\"
echo " --unitlib=\"${abs_top_builddir}/test/.libs/$tst.so\""
echo ""
echo " $ less $tst_log # for detailed failure log files"
echo "============================================================="
echo ":test-result: FAIL $tst" >> $test_output
fi
echo "Finished $tst in ${SECONDS}s";
# vim:set shiftwidth=4 expandtab: