libreoffice-online/loolwsd/test/run_unit.sh.in
2016-04-15 22:04:15 +01:00

90 lines
2.7 KiB
Bash
Executable file

#!/bin/sh
#
# DO NOT EDIT - this file is generated from run_unit.sh.in.
#
# substituted variables in one place:
abs_top_builddir="/opt/libreoffice/online/loolwsd"
systemplate_path="@SYSTEMPLATE_PATH@"
enable_debug="@ENABLE_DEBUG@"
jails_path="@JAILS_PATH@"
lo_path="@LO_PATH@"
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;;
-*) ;; # ignore
esac
shift
done
test_mode=
if test "z$tst" != "zrun_test.sh"; then
# drop .la suffix
tst=`echo $tst | sed s/\.la//`;
else
test_mode=old
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
if test "z$test_mode" == "zold"; then
echo "executing external tests"
${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
--lotemplate="$lo_path" \
--childroot="$jails_path" \
--allowlocalstorage 2> "$tst_log" &
echo " waiting for loolwsd to start"
sleep 1 # sad - need to add a wait to the start of test.cpp ...
echo " executing test"
oldpath=`pwd`
cd "${abs_top_builddir}/test"
if ./test; then
echo "Test run_test.sh passed."
echo ":test-result: PASS run_test.sh" >> $oldpath/$test_output
retval=0
else
echo "============================================================="
echo "Test failed on unit:"
echo "============================================================="
echo ":test-result: FAIL run_test.sh" >> $oldpath/$test_output
retval=1
fi
kill $!
exit $retval
else # newer unit tests.
echo "Running $tst | $tst_log ...";
if ${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
--lotemplate="$lo_path" \
--childroot="$jails_path" \
--unitlib=".libs/$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 ../loolwsd --systemplate=\"$systemplate_path\" --lotemplate=\"$lo_path\" \\"
echo " --childroot=\"$jails_path\" --unitlib=\".libs/$tst.so\""
echo "============================================================="
echo ":test-result: FAIL $tst" >> $test_output
fi
fi