On 07/08/17 15:23, Ilya Shipitsin wrote: > inspired by > https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13808.html > --- > tests/Makefile.am | 2 +- > tests/t_usage.sh | 29 +++++++++++++++++++++++++++++ > 2 files changed, 30 insertions(+), 1 deletion(-) > create mode 100755 tests/t_usage.sh > > diff --git a/tests/Makefile.am b/tests/Makefile.am > index 0795680c..7306d1d1 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -14,7 +14,7 @@ MAINTAINERCLEANFILES = \ > > SUBDIRS = unit_tests > > -test_scripts = t_client.sh > +test_scripts = t_client.sh t_usage.sh > if ENABLE_CRYPTO > test_scripts += t_lpback.sh t_cltsrv.sh > endif > diff --git a/tests/t_usage.sh b/tests/t_usage.sh > new file mode 100755 > index 00000000..f4845468 > --- /dev/null > +++ b/tests/t_usage.sh > @@ -0,0 +1,29 @@ > +#!/bin/sh > +# > +# run "openvpn --help" > +# - check that openvpn did not crash > +# > +# prerequisites: > +# - openvpn binary in current directory > +# > +# inspired by > https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13808.html > +# > + > +top_builddir="${top_builddir:-..}" > + > +if [ ! -x "${top_builddir}/src/openvpn/openvpn" ] > +then > + echo "no (executable) openvpn binary in current build tree. FAIL." >&2 > + exit 1 > +fi > + > +exit_code=0 > + > +"${top_builddir}/src/openvpn/openvpn" --help >/dev/null > + > +if [ $? -ne 1 ] > +then > + exit_code=1 > +fi
This check is odd. Where the --help option is parsed, it calls usage(), usage_small(). And those functions will always call: openvpn_exit(OPENVPN_EXIT_STATUS_USAGE); And OPENVPN_EXIT_STATUS_USAGE is defined as: error.h:#define OPENVPN_EXIT_STATUS_USAGE 1 I would rather recommend you to grep for some information you expect to be listed in --help and check if that was found instead. For example: $ ./openvpn --help | grep -- ^-- | wc -l 238 As we might vary number of options from time to time, I wouldn't check against 238. But that it should be above 220 in the foreseeable future would not be an unreasonable assumption. *BUT* the number of options might differ more in some other builds (depending on --enable-*/--disable-* arguments given to ./configure). -- kind regards, David Sommerseth OpenVPN Technologies, Inc
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel