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

88 lines
2.7 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# DO NOT EDIT - this file is generated from run_unit.sh.in.
#
# 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@"
tst=
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
# drop .la suffix
tst=`echo $tst | sed s/\.la//`;
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
echo "executing external tests"
${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
--lotemplate="$lo_path" \
--childroot="$jails_path" \
--allowlocalstorage 2> "$tst_log" &
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" \
--allowlocalstorage \
--admincreds="admin/admin" \
--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