From: "flichtenheld (Code Review)" Attention is currently required from: plaisthos. flichtenheld uploaded patch set #3 to this change.
tests: fork default automake test-driver
For some of the te= st we don't like the default log behavior
and there seems no easy wa= y to change that except to fork
the driver. The license seems unproblema= tic since we're
GPL anyway.
Note that this commit does not ch= ange the test-driver in any
way. We just copy the original version and c= hange some tests
to use it. Any changes will be done in separate commits= , so
we can track them.
v2:
- Do not use forked-test-driver f= or UTs. Default behavior
is fine for those.
Change-Id: I67d461= afbcc9c06b1fc5ab4477141d7b8bd9ba8e
Signed-off-by: Frank Lichtenheld <= frank@...2641...>
---
M Makefile.am
A forked-test-driver
M t= ests/Makefile.am
3 files changed, 156 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/478/3<= /pre>diff --git a/Makefile.am b/Makefile.am
index 2305ab= 4..6deecf3 100644
--- a/Makefile.am
+++ b/M= akefile.am
@@ -44,7 +44,8 @@
debug \
CMakeLists.txt \
CMakePresets.json \=
- config.h.cmake.in
+ config.h.cmake.in \+ forked-test-driver
.PHONY: config-version.h doxygen
diff --git a/forked-test-driver b/forked-test-driver
new file mode 100755
index 0000000..be73b80
--- /dev/null
+++ b/forked-test-driver=
@@ -0,0 +1,153 @@
+#! /bin/sh
+#= test-driver - basic testsuite driver script.
+
+scriptversion=3D2018-03-07.03; # UTC
+
+# Copyright (C) 2011-2021 Free Software Foundation, Inc.+#
+# This program is free software; you can redistribu= te it and/or modify
+= # it under the terms of the GNU General Public License as published by
+# the Free Software Foun= dation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,<= /span>
+# but WITHOUT ANY WA= RRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURP= OSE. See the
+# GNU = General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this progra= m. If not, see <https://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License,= if you
+# distribute= this file as part of a program that contains a
+# configuration script generated by Autoconf, y= ou may include it under
+# the same distribution terms that you use for the rest of that program= .
+
+# This file is maintained in Automake= , please report
+# bu= gs to <bug-automake@...1269...> or send patches to
+# <automake-patches@...1269...>.=
+
+# Make unconditional expansion of unde= fined variables an error. This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+usage_error ()
+{
+ echo "$0:= $*" >&2
= + print_usage >&2
+ exit 2
+}
+
+print_usage ()
+{
+ cat <<END
+Usage:
+ te= st-driver --test-name NAME --log-file PATH --trs-file PATH
+ [--expect-failure {yes= |no}] [--color-tests {yes|no}]
+ [--enable-hard-errors {yes|no}] [--]+ TEST-SCRIPT [TEST-S= CRIPT-ARGUMENTS]
+
+The '--test-name= 39;, '--log-file' and '--trs-file' options are mandatory.= span>
+See the GNU Automake = documentation for information.
+END
+}
+
+test_name=3D # Used for reporting.=
+log_file=3D # Where to sa= ve the output of the test script.
+trs_file=3D # Where to save the metadata of the test run.
+expect_failure=3Dno
+color_tests=3Dno
+enable_hard_errors=3Dyes<= /span>
+while test $# -gt 0;= do
+ case $1 in
+ --help) print_usage; = exit $?;;
+ --versio= n) echo "test-driver $scriptversion"; exit $?;;
+ --test-name) test_name=3D$2; shift;= ;
+ --log-file) log_= file=3D$2; shift;;
+ = --trs-file) trs_file=3D$2; shift;;
+ --color-tests) color_tests=3D$2; shift;;
+ --expect-failure) expect_failure= =3D$2; shift;;
+ --e= nable-hard-errors) enable_hard_errors=3D$2; shift;;
+ --) shift; break;;
+ -*) usage_error "invalid option: = '$1'";;
= + *) break;;
+ esa= c
+ shift
= +done
+
+missing_opts=3D
+test x"$test_name" =3D x && missing_opts=3D"$= missing_opts --test-name"
+test x"$log_file" =3D x && missing_opts=3D&qu= ot;$missing_opts --log-file"
+test x"$trs_file" =3D x && missing_opts=3D= "$missing_opts --trs-file"
+if test x"$missing_opts" !=3D x; then
= + usage_error "the follow= ing mandatory options are missing:$missing_opts"
+fi
+
+if= test $# -eq 0; then
= + usage_error "missing argument"
+fi
+
+if test $col= or_tests =3D yes; then
+ # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.<= /span>
+ red=3D'=1B[0;3= 1m' # Red.
+ grn= =3D'=1B[0;32m' # Green.
+ lgn=3D'=1B[1;32m' # Light green.
+ blu=3D'=1B[1;34m' # Blue.
+ mgn=3D'=1B[0;35m= 39; # Magenta.
+ std= =3D'=1B[m' # No color.
+else
+= red=3D grn=3D lgn=3D blu=3D mgn=3D std=3D
+fi
+
+do_exit=3D= 39;rm -f $log_file $trs_file; (exit $st); exit $st'
+trap "st=3D129; $do_exit" 1= span>
+trap "st=3D130; = $do_exit" 2
+tra= p "st=3D141; $do_exit" 13
+trap "st=3D143; $do_exit" 15
+
+# Test script is run here. We create the file first, then a= ppend to it,
+# to am= eliorate tests themselves also writing to the log file. Our tests
+# don't, but others can (= automake bug#35762).
= +: >"$log_file"
+"$@" >>"$log_file" 2>&1
+estatus=3D$?
+
+if test $enable_hard_errors =3D no && test $est= atus -eq 99; then
+ = tweaked_estatus=3D1
+= else
+ tweaked_estat= us=3D$estatus
+fi
+
+case $tweaked_estatus:$expect_failure in<= /span>
+ 0:yes) col=3D$red = res=3DXPASS recheck=3Dyes gcopy=3Dyes;;
+ 0:*) col=3D$grn res=3DPASS recheck=3Dno gcopy=3Dn= o;;
+ 77:*) col=3D$= blu res=3DSKIP recheck=3Dno gcopy=3Dyes;;
+ 99:*) col=3D$mgn res=3DERROR recheck=3Dyes gcopy= =3Dyes;;
+ *:yes) co= l=3D$lgn res=3DXFAIL recheck=3Dno gcopy=3Dyes;;
+ *:*) col=3D$red res=3DFAIL recheck=3Dyes = gcopy=3Dyes;;
+esac= span>
+
+# Report the test outcome and exit statu= s in the logs, so that one can
+# know whether the test passed or failed simply by looking at th= e '.log'
+# f= ile, without the need of also peaking into the corresponding '.trs'=
+# file (automake bu= g#11814).
+echo "= ;$res $test_name (exit status: $estatus)" >>"$log_file"= ;
+
+# Report outcome to console.+echo "${col}${res}${std= }: $test_name"
+=
+# Register the test= result, and other relevant metadata.
+echo ":test-result: $res" > $trs_file=
+echo ":global-test-re= sult: $res" >> $trs_file
+echo ":recheck: $recheck" >> $trs_file
+echo ":copy-in-glob= al-log: $gcopy" >> $trs_file
+
= +# Local Variables:
+= # mode: shell-script
= +# sh-indentation: 2
= +# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: "scriptversi= on=3D"
+# time-s= tamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
= +# time-stamp-end: "; # UT= C"
+# End:
diff --git a/tests/Makefile.am b/tests/Makefile.amindex 6c71067..b3b2d74 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,6 +15,7 @@
SUBDIRS =3D unit_tests
AM_= TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKAGE_STRING) System Tests'<= /span>
+LOG_DRIVER =3D $(SHE= LL) $(top_srcdir)/forked-test-driver
if = !WIN32
test_scripts =3D t_client.sh t_lpback.sh t_cltsrv.s= hTo view, visit change 478. To unsubscribe,= or for help writing mail filters, visit settings.
--6zvs6byYKtE=--