From: "flichtenheld (Code Review)" Date: Mon, 11 Dec 2023 15:53:58 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ViBFkZolc10="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: tests: fork default automake test-driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --ViBFkZolc10= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/478?usp=3Demail to review the following change. Change subject: tests: fork default automake test-driver ...................................................................... tests: fork default automake test-driver We don't really like the default log behavior and there seems no easy way to change that except to fork the driver. The license seems unproblematic since we're GPL anyway. Change-Id: I67d461afbcc9c06b1fc5ab4477141d7b8bd9ba8e Signed-off-by: Frank Lichtenheld --- A forked-test-driver M tests/Makefile.am M tests/unit_tests/example_test/Makefile.am M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/plugins/auth-pam/Makefile.am 5 files changed, 157 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/478/1 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 redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# 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, you 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 +# bugs to or send patches to +# . + +# Make unconditional expansion of undefined 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 <"$log_file" +"$@" >>"$log_file" 2>&1 +estatus=3D$? + +if test $enable_hard_errors =3D no && test $estatus -eq 99; then + tweaked_estatus=3D1 +else + tweaked_estatus=3D$estatus +fi + +case $tweaked_estatus:$expect_failure in + 0:yes) col=3D$red res=3DXPASS recheck=3Dyes gcopy=3Dyes;; + 0:*) col=3D$grn res=3DPASS recheck=3Dno gcopy=3Dno;; + 77:*) col=3D$blu res=3DSKIP recheck=3Dno gcopy=3Dyes;; + 99:*) col=3D$mgn res=3DERROR recheck=3Dyes gcopy=3Dyes;; + *:yes) col=3D$lgn res=3DXFAIL recheck=3Dno gcopy=3Dyes;; + *:*) col=3D$red res=3DFAIL recheck=3Dyes gcopy=3Dyes;; +esac + +# Report the test outcome and exit status in the logs, so that one can +# know whether the test passed or failed simply by looking at the '.log' +# file, without the need of also peaking into the corresponding '.trs' +# file (automake bug#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-result: $res" >> $trs_file +echo ":recheck: $recheck" >> $trs_file +echo ":copy-in-global-log: $gcopy" >> $trs_file + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=3D" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/tests/Makefile.am b/tests/Makefile.am index 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' +LOG_DRIVER =3D $(SHELL) $(top_srcdir)/forked-test-driver if !WIN32 test_scripts =3D t_client.sh t_lpback.sh t_cltsrv.sh diff --git a/tests/unit_tests/example_test/Makefile.am b/tests/unit_tests/e= xample_test/Makefile.am index 1ae80c8..988366a 100644 --- a/tests/unit_tests/example_test/Makefile.am +++ b/tests/unit_tests/example_test/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS =3D foreign AM_TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKAGE_STRING) example Unit-Tests' +LOG_DRIVER =3D $(SHELL) $(top_srcdir)/forked-test-driver check_PROGRAMS =3D example_testdriver example2_testdriver diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvp= n/Makefile.am index cecf4dc..80001bf 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS =3D foreign AM_TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKAGE_STRING) Unit-Tests' +LOG_DRIVER =3D $(SHELL) $(top_srcdir)/forked-test-driver test_binaries=3D diff --git a/tests/unit_tests/plugins/auth-pam/Makefile.am b/tests/unit_tes= ts/plugins/auth-pam/Makefile.am index ba32013..385922f 100644 --- a/tests/unit_tests/plugins/auth-pam/Makefile.am +++ b/tests/unit_tests/plugins/auth-pam/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS =3D foreign AM_TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKAGE_STRING) auth_pam Plugin Un= it-Tests' +LOG_DRIVER =3D $(SHELL) $(top_srcdir)/forked-test-driver if ENABLE_PLUGIN_AUTH_PAM check_PROGRAMS =3D auth_pam_testdriver -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/478?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I67d461afbcc9c06b1fc5ab4477141d7b8bd9ba8e Gerrit-Change-Number: 478 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --ViBFkZolc10= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

Vi= ew Change

tests: fork default automake test-driver

We don't = really like the default log behavior and
there seems no easy way to chan= ge that except to fork
the driver. The license seems unproblematic since= we're
GPL anyway.

Change-Id: I67d461afbcc9c06b1fc5ab4477141d= 7b8bd9ba8e
Signed-off-by: Frank Lichtenheld <frank@...2641...>
= ---
A forked-test-driver
M tests/Makefile.am
M tests/unit_tests/ex= ample_test/Makefile.am
M tests/unit_tests/openvpn/Makefile.am
M tests= /unit_tests/plugins/auth-pam/Makefile.am
5 files changed, 157 insertions= (+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openv=
pn refs/changes/78/478/1
diff --git a/forked-test-driver b/forked-t=
est-driver
new file mode 100755
index 00000= 00..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 redistribute it and/or modify
+# it under the terms of the GNU General Public License as pub= lished by
+# the Free= Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it wi= ll be useful,
+# but = WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A P= ARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Publi= c License
+# along wi= th this program. If not, see <https://www.gnu.org/licenses/>.=
+
+# As a special exception to the GNU General P= ublic License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated = by Autoconf, you may include it under
+# the same distribution terms that you use for the rest o= f that program.
+

+# This file is maintain= ed in Automake, please report
+# bugs to <bug-automake@...1269...> or send patches to

+# <automake-patches@...220...= ..1269...>.
+
+# Make unconditional exp= ansion of undefined 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:
+ test-driver --test-name NAME --log-file PATH --trs-file PATH
+ [--expect= -failure {yes|no}] [--color-tests {yes|no}]
+ [--enable-hard-errors {yes|no}] [--]<= /span>
+ TEST-S= CRIPT [TEST-SCRIPT-ARGUMENTS]
+
+The '= --test-name', '--log-file' and '--trs-file' options are= mandatory.
+See the = GNU Automake documentation for information.
+END
+}
++test_name=3D # Used for repor= ting.
+log_file=3D #= Where to save the output of the test script.
+trs_file=3D # Where to save the metadata of the = test run.
+expect_fai= lure=3Dno
+color_test= s=3Dno
+enable_hard_e= rrors=3Dyes
+while te= st $# -gt 0; do
+ ca= se $1 in
+ --help) p= rint_usage; exit $?;;
+ --version) echo "test-driver $scriptversion"; exit $?;;

+ --test-name) test_name= =3D$2; shift;;
+ --l= og-file) log_file=3D$2; shift;;
+ --trs-file) trs_file=3D$2; shift;;
+ --color-tests) color_tests=3D$2; shift;;
+ --expect-failure) exp= ect_failure=3D$2; shift;;
+ --enable-hard-errors) enable_hard_errors=3D$2; shift;;
+ --) shift; break;;

<= span style=3D"color: hsl(120, 100%, 40%);">+ -*) usage_error "invalid= option: '$1'";;
+ *) break;;
+ esac
+ 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"$missing_opts --log-file"
+test x"$trs_file" =3D x && missi= ng_opts=3D"$missing_opts --trs-file"
+if test x"$missing_opts" !=3D x; then<= /span>
+ usage_error "= the following mandatory options are missing:$missing_opts"
<= span style=3D"color: hsl(120, 100%, 40%);">+fi

+
+if test $# -eq 0; then
+ usage_error "missing argument"
+fi
+
+if= test $color_tests =3D yes; then
+ # Keep this in sync with 'lib/am/check.am:$(am__tty_colo= rs)'.
+ red=3D&#= 39;=1B[0;31m' # 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' # Magenta.
+ std=3D'=1B[m' # No color.
+else
+ red=3D grn=3D lgn=3D blu=3D mgn=3D std=3D
+fi
+
+d= o_exit=3D'rm -f $log_file $trs_file; (exit $st); exit $st'+trap "st=3D129; $do_exi= t" 1
+trap "= ;st=3D130; $do_exit" 2
+trap "st=3D141; $do_exit" 13
+trap "st=3D143; $do_exit" 15+
+# Test script is run here. We create the file fi= rst, then append to it,
+# to ameliorate tests themselves also writing to the log file. Our test= s
+# don't, but o= thers can (automake bug#35762).
+: >"$log_file"
+"$@" >>"$log_file" 2>&= 1
+estatus=3D$?

+
+if test $enable_hard_errors =3D no &&= ; test $estatus -eq 99; then
+ tweaked_estatus=3D1
+else
+ tw= eaked_estatus=3D$estatus
+fi
+
<= span style=3D"color: hsl(120, 100%, 40%);">+case $tweaked_estatus:$expect_f= ailure in
+ 0:yes) c= ol=3D$red res=3DXPASS recheck=3Dyes gcopy=3Dyes;;
+ 0:*) col=3D$grn res=3DPASS recheck=3Dno = gcopy=3Dno;;
+ 77:*= ) col=3D$blu res=3DSKIP recheck=3Dno gcopy=3Dyes;;
+ 99:*) col=3D$mgn res=3DERROR recheck= =3Dyes gcopy=3Dyes;;
= + *:yes) col=3D$lgn res=3DXFAIL recheck=3Dno gcopy=3Dyes;;
+ *:*) col=3D$red res=3DFAIL re= check=3Dyes gcopy=3Dyes;;
+esac
++# Report the test outcome an= d exit status in the logs, so that one can
+# know whether the test passed or failed simply by l= ooking at the '.log'
+# file, without the need of also peaking into the corresponding &#= 39;.trs'
+# file = (automake bug#11814).
+echo "$res $test_name (exit status: $estatus)" >>"$l= og_file"
+
+# Report outcome to conso= le.
+echo "${col= }${res}${std}: $test_name"
+
+# Regis= ter the test result, and other relevant metadata.
+echo ":test-result: $res" > $trs= _file
+echo ":gl= obal-test-result: $res" >> $trs_file
+echo ":recheck: $recheck" >> $t= rs_file
+echo ":= copy-in-global-log: $gcopy" >> $trs_file
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'before-save-hook 'time-stamp)
+# time-stamp-start: &qu= ot;scriptversion=3D"
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0&qu= ot;
+# time-stamp-end= : "; # UTC"
+# End:
diff --git a/tests/Makefile.am b/tests/Makefile.am=
index 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) Syst= em Tests'
+LOG_DR= IVER =3D $(SHELL) $(top_srcdir)/forked-test-driver
=
if !WIN32
test_scripts =3D t_client.sh t_lpback= .sh t_cltsrv.sh
diff --git a/tests/unit_tests/example_test/= Makefile.am b/tests/unit_tests/example_test/Makefile.am
ind= ex 1ae80c8..988366a 100644
--- a/tests/unit_tests/example_t= est/Makefile.am
+++ b/tests/unit_tests/example_test/Makefil= e.am
@@ -1,6 +1,7 @@
AUTOMAKE_OPTIONS =3D = foreign

AM_TESTSUITE_SUMMARY_HEADER =3D = ' for $(PACKAGE_STRING) example Unit-Tests'
+LOG_DRIVER =3D $(SHELL) $(top_srcdir)/for= ked-test-driver

check_PROGRAMS =3D examp= le_testdriver example2_testdriver

diff --= git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makef= ile.am
index cecf4dc..80001bf 100644
--- a/= tests/unit_tests/openvpn/Makefile.am
+++ b/tests/unit_tests= /openvpn/Makefile.am
@@ -1,6 +1,7 @@
AUTOM= AKE_OPTIONS =3D foreign

AM_TESTSUITE_SUM= MARY_HEADER =3D ' for $(PACKAGE_STRING) Unit-Tests'
+LOG_DRIVER =3D $(SHELL) $(top_srcdi= r)/forked-test-driver


test_binaries=3D

diff --git a/tests/unit_tests/plugins/auth= -pam/Makefile.am b/tests/unit_tests/plugins/auth-pam/Makefile.am
= index ba32013..385922f 100644
--- a/tests/unit_tests/= plugins/auth-pam/Makefile.am
+++ b/tests/unit_tests/plugins= /auth-pam/Makefile.am
@@ -1,6 +1,7 @@
AUTO= MAKE_OPTIONS =3D foreign

AM_TESTSUITE_SU= MMARY_HEADER =3D ' for $(PACKAGE_STRING) auth_pam Plugin Unit-Tests'= ;
+LOG_DRIVER =3D $(S= HELL) $(top_srcdir)/forked-test-driver

i= f ENABLE_PLUGIN_AUTH_PAM
check_PROGRAMS =3D auth_pam_testd= river

To view, visit change 478. To unsubscr= ibe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I67d461afbcc9c06b1fc5ab44771= 41d7b8bd9ba8e
Gerrit-Change-Number: 478
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newchange
--ViBFkZolc10=--