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-12-08 11:30:53 -06:00
|
|
|
cmd_line="$0 $@"
|
2016-11-06 22:44:11 -06: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@"
|
2021-02-26 06:46:03 -06:00
|
|
|
if test -z "@ENABLE_SETCAP@"; then
|
|
|
|
capabilities=false
|
|
|
|
else
|
|
|
|
capabilities=true
|
|
|
|
fi
|
2016-04-15 10:39:05 -05:00
|
|
|
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"
|
2017-04-07 08:37:20 -05:00
|
|
|
verbose=''
|
2021-07-22 09:37:57 -05:00
|
|
|
capabilities="@ENABLE_SETCAP@"
|
2023-10-01 02:19:18 -05:00
|
|
|
fail_fast=''
|
2021-07-22 09:37:57 -05:00
|
|
|
|
|
|
|
if test "h$capabilities" != "htrue"; then
|
|
|
|
capabilities=false
|
|
|
|
fi
|
2016-04-05 17:04:40 -05:00
|
|
|
|
2016-10-17 04:44:58 -05:00
|
|
|
# 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.
|
|
|
|
|
2017-09-15 10:59:56 -05:00
|
|
|
print_help ()
|
|
|
|
{
|
2019-05-27 02:09:49 -05:00
|
|
|
echo "Usage: run_unit.sh --test-name <name.la> [OPTIONS]"
|
2017-09-15 10:59:56 -05:00
|
|
|
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)"
|
2019-09-05 08:09:51 -05:00
|
|
|
echo " --gdb Run under gdb if enabled"
|
2017-09-15 10:59:56 -05:00
|
|
|
echo " --valgrind Run under valgrind if enabled"
|
2023-10-01 02:19:18 -05:00
|
|
|
echo " --fail-fast If a test fails, subsequent tests will not run and no report is generated"
|
2017-09-15 10:59:56 -05:00
|
|
|
echo " --verbose Print out more stuff - if you run out of things to read"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2016-04-30 12:15:41 -05:00
|
|
|
tst=
|
2017-09-15 10:59:56 -05:00
|
|
|
tst_log=/dev/stderr
|
|
|
|
tst_output=/dev/stderr
|
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;;
|
2019-09-05 08:09:51 -05:00
|
|
|
--gdb) trace='gdb --args'; shift;;
|
|
|
|
--valgrind) trace=$valgrind_cmd; shift;;
|
2023-10-01 02:19:18 -05:00
|
|
|
--fail-fast) fail_fast='true'; shift;;
|
2017-04-07 08:37:20 -05:00
|
|
|
--verbose) verbose="--verbose";;
|
2017-09-15 10:59:56 -05:00
|
|
|
--help) print_help ;;
|
2016-04-15 10:39:05 -05:00
|
|
|
-*) ;; # ignore
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-03-06 08:06:12 -06:00
|
|
|
# drop .la suffix
|
|
|
|
tst=`echo $tst | sed "s/\.la//"`;
|
|
|
|
|
2016-04-06 13:50:55 -05:00
|
|
|
# result logging
|
2016-04-15 10:39:05 -05:00
|
|
|
echo > $test_output
|
|
|
|
|
2022-03-06 08:06:12 -06:00
|
|
|
printf "\nRunning $tst | $tst_log | $test_output $cmd_line\n";
|
2021-01-19 20:40:54 -06:00
|
|
|
echo > $tst_log
|
2020-01-17 15:18:42 -06:00
|
|
|
if ${trace} \
|
2021-11-17 08:12:57 -06:00
|
|
|
${abs_top_builddir}/coolwsd --o:sys_template_path="$systemplate_path" \
|
2021-02-26 06:46:03 -06:00
|
|
|
--o:child_root_path="$jails_path" \
|
|
|
|
--o:security.capabilities="${capabilities}" \
|
|
|
|
--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 \
|
|
|
|
--o:storage.ssl.enable=false \
|
2023-08-24 07:19:23 -05:00
|
|
|
--o:experimental_features=true \
|
2022-02-15 20:04:37 -06:00
|
|
|
--unattended \
|
2022-02-23 21:32:24 -06:00
|
|
|
--unitlib="${abs_top_builddir}/test/.libs/$tst.so" 2> "$tst_log" 1>&2; then
|
2022-03-06 08:06:12 -06:00
|
|
|
echo "Test $tst passed. Finished in ${SECONDS}s."
|
2021-02-26 06:46:03 -06:00
|
|
|
echo ":test-result: PASS $tst" >> $test_output
|
2023-09-23 12:02:44 -05:00
|
|
|
exit 0
|
2020-01-17 15:18:42 -06:00
|
|
|
else
|
2022-03-06 08:06:12 -06:00
|
|
|
echo "Test $tst FAILED. Finished in ${SECONDS}s."
|
2017-05-11 21:08:20 -05:00
|
|
|
cat $tst_log
|
2021-02-26 06:46:03 -06:00
|
|
|
echo "============================================================="
|
2022-06-14 05:27:36 -05:00
|
|
|
echo "Test failed on $tst after ${SECONDS}s. Re-run with (remove --unattended to run without gdb and get prompted):"
|
2021-11-17 08:12:57 -06:00
|
|
|
echo " $ gdb --args ${abs_top_builddir}/coolwsd --o:sys_template_path=\"$systemplate_path\" \\"
|
2021-02-26 06:46:03 -06:00
|
|
|
echo " --o:child_root_path=\"$jails_path\" \\"
|
2021-03-23 14:11:52 -05:00
|
|
|
echo " --o:security.capabilities=\"${capabilities}\" \\"
|
2021-02-26 06:46:03 -06:00
|
|
|
echo " --o:storage.filesystem[@allow]=true \\"
|
2021-03-23 14:11:52 -05:00
|
|
|
echo " --o:logging.level=error\\" # logs and gdb don't go well together
|
2021-02-26 06:46:03 -06:00
|
|
|
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 \\"
|
2021-03-23 14:11:52 -05:00
|
|
|
echo " --o:storage.ssl.enable=false \\"
|
2022-02-23 21:32:24 -06:00
|
|
|
echo " --unattended \\"
|
2021-02-26 06:46:03 -06:00
|
|
|
echo " --unitlib=\"${abs_top_builddir}/test/.libs/$tst.so\""
|
2017-05-11 21:08:20 -05:00
|
|
|
echo ""
|
|
|
|
echo " $ less $tst_log # for detailed failure log files"
|
2021-02-26 06:46:03 -06:00
|
|
|
echo "============================================================="
|
|
|
|
echo ":test-result: FAIL $tst" >> $test_output
|
2016-04-15 10:39:05 -05:00
|
|
|
fi
|
2023-10-01 02:19:18 -05:00
|
|
|
|
|
|
|
if test "z$fail_fast" == "ztrue"; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-07-08 02:04:27 -05:00
|
|
|
|
|
|
|
# vim:set shiftwidth=4 expandtab:
|