severity 14840 minor tags 14840 + patch close 14840 stop Hi Vasiliy, thanks for the report.
On 07/11/2013 04:10 PM, Vasiliy wrote: > Dear AutoMake Team, > > I have tracked down a problem with 'test-driver'. Look at that: > > $ gdb --args /usr/bin/sh /usr/share/automake-1.14/test-driver > GNU gdb (GDB) 7.6.50.20130320-cvs > Copyright (C) 2013 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "x86_64-unknown-cygwin". > For bug reporting instructions, please see: > <http://www.gnu.org/software/gdb/bugs/>... > Reading symbols from /usr/bin/sh...Reading symbols from > /usr/lib/debug/usr/bin/sh.exe.dbg...done. > done. > (gdb) run > Starting program: /usr/bin/sh /usr/share/automake-1.14/test-driver > [New Thread 9900.0xc10] > [New Thread 9900.0x1bec] > [New Thread 9900.0xe38] > /usr/share/automake-1.14/test-driver: line 95: $log_file: ambiguous redirect > FAIL: > /usr/share/automake-1.14/test-driver: line 114: $trs_file: ambiguous redirect > /usr/share/automake-1.14/test-driver: line 115: $trs_file: ambiguous redirect > /usr/share/automake-1.14/test-driver: line 116: $trs_file: ambiguous redirect > /usr/share/automake-1.14/test-driver: line 117: $trs_file: ambiguous redirect > [Inferior 1 (process 9900) exited with code 01] > (gdb) quit > That's because the test-driver script didn't properly check whether it has received a correct command line (there hasn't been any pressing need for such a check so far, since 'test-driver' is an internal script only, and not meant to be used outside the Automake-generated makefiles). Still, this limitation is easy to fix, and now that you have noticed and reported it, I see no reason not to do so. The attached patch should take care of that. > $ gdb --args /usr/bin/sh /usr/share/automake-1.14/test-driver --log-file=/tmp > The use of "=" to specify the argument of a long option is not supported. This is not a big deal IMHO, since as I said 'test-driver' is not meant to be used directly from the command line or by third-party scripts; but I wouldn't reject a patch to improve the situation, if somebody wants to submit it ;-) > GNU gdb (GDB) 7.6.50.20130320-cvs > Copyright (C) 2013 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "x86_64-unknown-cygwin". > For bug reporting instructions, please see: > <http://www.gnu.org/software/gdb/bugs/>... > Reading symbols from /usr/bin/sh...Reading symbols from > /usr/lib/debug/usr/bin/sh.exe.dbg...done. > done. > (gdb) run > Starting program: /usr/bin/sh /usr/share/automake-1.14/test-driver > --log-file=/tmp > [New Thread 2164.0x164c] > [New Thread 2164.0x24a4] > [New Thread 2164.0x2550] > /usr/share/automake-1.14/test-driver: invalid option: '--log-file=/tmp' > [New Thread 2164.0x19d4] > 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}] [--] TEST-SCRIPT > The '--test-name', '--log-file' and '--trs-file' options are mandatory. > > So, there is a problem with 'test-driver' either because a testsuite > may not provide --test-name=NAME or because --log-file=/tmp or > --log-file=/tmp/delme is wrongly considered an invalid option. It > applies to automake 1.13 as well. > Again, please note that the 'test-driver' script is only meant to be used internally by the automake-generated testsuite harnesses, and not by third-party projects. Are you trying to use the script in such a project. If yes, why? > If so, it fails dramatically with messages like this: > ...<some_software>/./build-aux/test-driver: line 95: <PID> > Segmentation fault (core dumped) "$@" > $log_file 2>&1 > > Could AutoMake Developers change this behavior, or, > at least, make omitting --test-name not so critical? > Done :-) > Best regards, > Vasiliy > BTW, might ask you your complete name if that's OK with you? So that I'll be able to add you to the THANKS file. Thanks, Stefano
>From 9dbc94e9692260fcc972bc1c9861d62c248b93da Mon Sep 17 00:00:00 2001 Message-Id: <9dbc94e9692260fcc972bc1c9861d62c248b93da.1373755820.git.stefano.lattar...@gmail.com> From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Sat, 13 Jul 2013 23:50:15 +0100 Subject: [PATCH] test harness: improve catching of usage errors in script 'test-driver' Fixes automake bug#14840. * lib/test-driver: Catch and report usage errors where the caller has forgotten to specify one of the mandatory options (--test-name, --log-file, --trs-file) or has passed a wrong number of non-option arguments (there should be just one of such arguments). Also, be sure to work correctly even when no '--' special argument is passed to separate option from non-options arguments. Signed-off-by: Stefano Lattarini <stefano.lattar...@gmail.com> --- lib/test-driver | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/test-driver b/lib/test-driver index 32bf39e..feb0c01 100755 --- a/lib/test-driver +++ b/lib/test-driver @@ -1,7 +1,7 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2012-06-27.10; # UTC +scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2013 Free Software Foundation, Inc. # @@ -49,8 +49,6 @@ The '--test-name', '--log-file' and '--trs-file' options are mandatory. END } -# TODO: better error handling in option parsing (in particular, ensure -# TODO: $log_file, $trs_file and $test_name are defined). test_name= # Used for reporting. log_file= # Where to save the output of the test script. trs_file= # Where to save the metadata of the test run. @@ -69,10 +67,25 @@ while test $# -gt 0; do --enable-hard-errors) enable_hard_errors=$2; shift;; --) shift; break;; -*) usage_error "invalid option: '$1'";; + *) break;; esac shift done +missing_opts= +test x"$test_name" = x && missing_opts="$missing_opts --test-name" +test x"$log_file" = x && missing_opts="$missing_opts --log-file" +test x"$trs_file" = x && missing_opts="$missing_opts --trs-file" +if test x"$missing_opts" != x; then + usage_error "the following mandatory options are missing:$missing_opts" +fi + +case $# in + 0) usage_error "missing argument";; + 1) ;; + *) usage_error "too many non-option arguments";; +esac + if test $color_tests = yes; then # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'. red='[0;31m' # Red. -- 1.8.3.1.605.g85318f5