2016-04-16 15:27:10 -05:00
|
|
|
#!/usr/bin/env bash
|
2016-04-11 12:21:16 -05:00
|
|
|
#
|
|
|
|
# DO NOT EDIT - this file is generated from run_unit.sh.in.
|
|
|
|
#
|
2016-04-05 17:04:40 -05:00
|
|
|
|
2016-04-15 10:39:05 -05:00
|
|
|
# substituted variables in one place:
|
2016-04-16 15:27:10 -05:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
abs_top_builddir="${DIR}/.."
|
2016-04-15 10:39:05 -05:00
|
|
|
systemplate_path="@SYSTEMPLATE_PATH@"
|
|
|
|
enable_debug="@ENABLE_DEBUG@"
|
|
|
|
jails_path="@JAILS_PATH@"
|
|
|
|
lo_path="@LO_PATH@"
|
2016-05-12 17:40:59 -05:00
|
|
|
valgrind_cmd="valgrind --tool=memcheck --trace-children=no -v --read-var-info=yes"
|
2016-04-05 17:04:40 -05:00
|
|
|
|
2016-05-03 03:08:50 -05:00
|
|
|
# run the test on a dedicated port
|
2016-05-04 06:06:34 -05:00
|
|
|
# TODO when we update test execution that the tests run in parallel, we'll
|
|
|
|
# needd ifferent numbers for the tests run in parallel here
|
2016-05-03 03:08:50 -05:00
|
|
|
export LOOL_TEST_CLIENT_PORT=9984
|
2016-05-04 06:06:34 -05:00
|
|
|
export LOOL_TEST_MASTER_PORT=9985
|
2016-05-03 03:08:50 -05:00
|
|
|
|
2016-04-30 12:15:41 -05:00
|
|
|
tst=
|
2016-04-15 10:39:05 -05:00
|
|
|
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;;
|
2016-05-12 17:40:59 -05:00
|
|
|
--valgrind) valgrind=$valgrind_cmd; shift;;
|
2016-04-15 10:39:05 -05:00
|
|
|
-*) ;; # ignore
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2016-04-30 12:15:41 -05:00
|
|
|
# drop .la suffix
|
|
|
|
tst=`echo $tst | sed s/\.la//`;
|
2016-04-11 12:21:16 -05:00
|
|
|
|
2016-04-15 16:04:15 -05:00
|
|
|
export LOOL_LOGLEVEL=trace
|
2016-04-12 04:00:33 -05:00
|
|
|
|
2016-04-15 10:39:05 -05:00
|
|
|
if test "z$enable_debug" != "ztrue"; then
|
2016-04-12 04:00:33 -05:00
|
|
|
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
|
2016-04-06 13:50:55 -05:00
|
|
|
|
|
|
|
# result logging
|
2016-04-30 12:15:41 -05:00
|
|
|
echo "test output is '$test_output'"
|
2016-04-15 10:39:05 -05:00
|
|
|
echo > $test_output
|
|
|
|
|
2016-04-30 12:15:41 -05:00
|
|
|
if test "z$tst" == "z"; then
|
2016-04-15 10:39:05 -05:00
|
|
|
echo "executing external tests"
|
2016-05-12 17:40:59 -05:00
|
|
|
${valgrind} \
|
2016-05-04 06:06:34 -05:00
|
|
|
${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
|
2016-04-15 10:39:05 -05:00
|
|
|
--lotemplate="$lo_path" \
|
|
|
|
--childroot="$jails_path" \
|
2016-05-04 06:06:34 -05:00
|
|
|
--allowlocalstorage > "$tst_log" 2>&1 &
|
2016-04-15 10:39:05 -05:00
|
|
|
|
|
|
|
echo " executing test"
|
|
|
|
|
|
|
|
oldpath=`pwd`
|
|
|
|
cd "${abs_top_builddir}/test"
|
2016-05-12 17:40:59 -05:00
|
|
|
if ${valgrind} ./test; then
|
2016-04-15 10:39:05 -05:00
|
|
|
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 ...";
|
2016-05-12 17:40:59 -05:00
|
|
|
if ${valgrind} \
|
|
|
|
${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
|
2016-04-15 10:39:05 -05:00
|
|
|
--lotemplate="$lo_path" \
|
|
|
|
--childroot="$jails_path" \
|
2016-04-18 08:29:17 -05:00
|
|
|
--allowlocalstorage \
|
2016-04-19 15:50:43 -05:00
|
|
|
--admincreds="admin/admin" \
|
2016-05-03 07:51:40 -05:00
|
|
|
--unitlib=".libs/$tst.so" > "$tst_log" 2>&1; then
|
2016-04-15 10:39:05 -05:00
|
|
|
echo "Test $tst passed."
|
|
|
|
echo ":test-result: PASS $tst" >> $test_output
|
2016-04-05 17:04:40 -05:00
|
|
|
else
|
2016-04-15 10:39:05 -05:00
|
|
|
cat "$tst_log"
|
2016-04-06 13:50:55 -05:00
|
|
|
echo "============================================================="
|
2016-04-15 10:39:05 -05:00
|
|
|
echo "Test failed on unit: $tst re-run with:"
|
2016-05-02 06:37:38 -05:00
|
|
|
echo " $ gdb --args ../loolwsd --systemplate=\"$systemplate_path\" \\"
|
|
|
|
echo " --lotemplate=\"$lo_path\" \\"
|
|
|
|
echo " --childroot=\"$jails_path\" --allowlocalstorage --admincreds="admin/admin" \\"
|
|
|
|
echo " --unitlib=\".libs/$tst.so\""
|
|
|
|
echo "============================================================="
|
|
|
|
echo ":test-result: FAIL $tst" >> $test_output
|
2016-04-05 17:04:40 -05:00
|
|
|
fi
|
2016-04-15 10:39:05 -05:00
|
|
|
fi
|