libreoffice-online/test/run_unit.sh.in
Tor Lillqvist bd00d9fd05 Get rid of use of GNU libtool
It is is complicated enough to build the iOS app. Requiring GNU
libtool brings with it the risk of polluting the command environment
as there already is a completely different command in macOS with the
same name, /usr/bin/libtool. And as GNU libtool was used only to build
the unit tests for the "normal" server-based Online that are built and
run only on Linux anyway, we don't really need any of the
"portability" that GNU libtool brings.

Without GNU libtool, we compile all the $(wsd_sources) (see
test/Makefile.am) that the unit-* tests use into a single object file,
WsdSources.o. (Because they need to be compiled as PIC we can't use
the already compiled object files for the Online server programs.)
This required some additional minor changes to a few source files.

Change-Id: I20a2c523170376fa4c1a0d9d8d6b693a9779376f
Reviewed-on: https://gerrit.libreoffice.org/72840
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
2019-05-24 09:50:16 +02:00

161 lines
6 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@"
jails_path="@JAILS_PATH@"
lo_path="@LO_PATH@"
valgrind_cmd="valgrind --tool=memcheck --trace-children=no -v --read-var-info=yes"
verbose=''
# 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.so> [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 " --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;;
--valgrind) valgrind=$valgrind_cmd; shift;;
--verbose) verbose="--verbose";;
--help) print_help ;;
-*) ;; # ignore
esac
shift
done
echo
echo "Running ${tst}"
echo " $cmd_line"
# drop .so suffix
tst=`echo $tst | sed s/\.so//`;
if test "z$tst" != "z" && test "z$CPPUNIT_TEST_NAME" != "z"; then
# $tst is not empty, but $CPPUNIT_TEST_NAME is set, exit early if they
# don't match.
if test "z$tst" != "z$CPPUNIT_TEST_NAME"; then
touch $tst_log
echo ":test-result: SKIP $tst (disabled by CPPUNIT_TEST_NAME)" > $test_output
exit 0;
fi
fi
export LOOL_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
if test "z$tst" == "z"; then
# run the test on a dedicated port
export LOOL_TEST_CLIENT_PORT=9984
export LOOL_TEST_MASTER_PORT=9985
echo "Executing external tests"
${valgrind} \
${abs_top_builddir}/loolwsd --o:sys_template_path="$systemplate_path" \
--o:lo_template_path="$lo_path" \
--o:child_root_path="$jails_path" \
--o:storage.filesystem[@allow]=true \
--o:logging.level=trace \
--o:logging.file[@enable]=false \
--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 \
> "$tst_log" 2>&1 &
if test "z${SLEEPFORDEBUGGER}${SLEEPKITFORDEBUGGER}" != "z"; then
echo "sleeping for debugger"
sleep ${SLEEPFORDEBUGGER:-0}
sleep ${SLEEPKITFORDEBUGGER:-0}
fi
echo " executing test"
oldpath=`pwd`
cd "${abs_top_builddir}/test"
if eval ${valgrind} ./test ${verbose}; then
echo "Test run_test.sh passed."
echo ":test-result: PASS run_test.sh" >> $oldpath/$test_output
retval=0
else
echo ":test-result: FAIL run_test.sh" >> $oldpath/$test_output
retval=1
fi
if test "z${SLEEPFORDEBUGGER}${SLEEPKITFORDEBUGGER}" == "z"; then
echo "killing $!"
kill $!
fi
exit $retval
else # newer unit tests.
echo "Running $tst | $tst_log ...";
if ${valgrind} \
${abs_top_builddir}/loolwsd --o:sys_template_path="$systemplate_path" \
--o:lo_template_path="$lo_path" \
--o:child_root_path="$jails_path" \
--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 \
--unitlib="${abs_top_builddir}/test/$tst.so" 2> "$tst_log"; then
echo "Test $tst passed."
echo ":test-result: PASS $tst" >> $test_output
else
cat $tst_log
echo "============================================================="
echo "Test failed on unit: $tst re-run with:"
echo " $ gdb --args ${abs_top_builddir}/loolwsd --o:sys_template_path=\"$systemplate_path\" \\"
echo " --o:lo_template_path=\"$lo_path\" \\"
echo " --o:child_root_path=\"$jails_path\" \\"
echo " --o:storage.filesystem[@allow]=true \\"
echo " --o:logging.level=trace \\"
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 " --unitlib=\"${abs_top_builddir}/test/$tst.so\""
echo ""
echo " $ less $tst_log # for detailed failure log files"
echo "============================================================="
echo ":test-result: FAIL $tst" >> $test_output
fi
fi
# vim:set shiftwidth=4 expandtab: