libreoffice-online/loolwsd/test/run_unit.sh.in
Ashod Nakashian 13469e45cb loolwsd: new check_valgrind target to run tests under valgrind
Change-Id: I1aa6d2f7435f4398111af09a4e9ddc6e300cf280
Reviewed-on: https://gerrit.libreoffice.org/24966
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-13 12:56:27 +00:00

100 lines
3.2 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@"
valgrind_cmd="valgrind --tool=memcheck --trace-children=no -v --read-var-info=yes"
# run the test on a dedicated port
# TODO when we update test execution that the tests run in parallel, we'll
# needd ifferent numbers for the tests run in parallel here
export LOOL_TEST_CLIENT_PORT=9984
export LOOL_TEST_MASTER_PORT=9985
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;;
--valgrind) valgrind=$valgrind_cmd; 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"
${valgrind} \
${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
--lotemplate="$lo_path" \
--childroot="$jails_path" \
--allowlocalstorage > "$tst_log" 2>&1 &
echo " executing test"
oldpath=`pwd`
cd "${abs_top_builddir}/test"
if ${valgrind} ./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 ${valgrind} \
${abs_top_builddir}/loolwsd --systemplate="$systemplate_path" \
--lotemplate="$lo_path" \
--childroot="$jails_path" \
--allowlocalstorage \
--admincreds="admin/admin" \
--unitlib=".libs/$tst.so" > "$tst_log" 2>&1; 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\" \\"
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
fi
fi