1dnl 2dnl Automated Testing Framework (atf) 3dnl 4dnl Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. 5dnl All rights reserved. 6dnl 7dnl Redistribution and use in source and binary forms, with or without 8dnl modification, are permitted provided that the following conditions 9dnl are met: 10dnl 1. Redistributions of source code must retain the above copyright 11dnl notice, this list of conditions and the following disclaimer. 12dnl 2. Redistributions in binary form must reproduce the above copyright 13dnl notice, this list of conditions and the following disclaimer in the 14dnl documentation and/or other materials provided with the distribution. 15dnl 16dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28dnl 29 30AT_SETUP([application: arguments and options handling]) 31 32dnl Check that an application that does not redefine any method does 33dnl not show strange flags in the usage message. 34AT_CHECK([APP_HELPER(app_empty) -h], 0, [stdout], []) 35AT_CHECK([grep ' -d ' stdout], 1, [ignore], []) 36AT_CHECK([grep ' -h ' stdout], 0, [ignore], []) 37AT_CHECK([grep ' -v ' stdout], 1, [ignore], []) 38AT_CHECK([grep ' -z ' stdout], 1, [ignore], []) 39 40dnl Check that an application that adds its own options shows them in 41dnl the usage message. 42AT_CHECK([APP_HELPER(app_opts_args) -h], 0, [stdout], []) 43AT_CHECK([grep ' -d ' stdout], 0, [ignore], []) 44AT_CHECK([grep ' -h ' stdout], 0, [ignore], []) 45AT_CHECK([grep ' -v ' stdout], 0, [ignore], []) 46AT_CHECK([grep ' -z ' stdout], 1, [ignore], []) 47 48dnl Check that an application that does not redefine any method does 49dnl not recognize strange flags. 50AT_CHECK([APP_HELPER(app_empty) -d], 1, [], [stderr]) 51AT_CHECK([grep 'Unknown option.*-d' stderr], 0, [ignore], []) 52AT_CHECK([APP_HELPER(app_empty) -v], 1, [], [stderr]) 53AT_CHECK([grep 'Unknown option.*-v' stderr], 0, [ignore], []) 54AT_CHECK([APP_HELPER(app_empty) -z], 1, [], [stderr]) 55AT_CHECK([grep 'Unknown option.*-z' stderr], 0, [ignore], []) 56 57dnl Check that an application that adds its own options is able to 58dnl properly handle them. 59AT_CHECK([APP_HELPER(app_opts_args) -d], 0, [stdout], []) 60AT_CHECK([grep -- '-d given' stdout], 0, [ignore], []) 61AT_CHECK([APP_HELPER(app_opts_args) -v], 1, [], [stderr]) 62AT_CHECK([grep 'Option.*-v.*requires an argument' stderr], 0, [ignore], []) 63AT_CHECK([APP_HELPER(app_opts_args) -v foo], 0, [stdout], []) 64AT_CHECK([grep -- '-v given with argument foo' stdout], 0, [ignore], []) 65AT_CHECK([APP_HELPER(app_opts_args) -z], 1, [], [stderr]) 66AT_CHECK([grep 'Unknown option.*-z' stderr], 0, [ignore], []) 67 68dnl Check that option processing stops after an argument. 69AT_CHECK([APP_HELPER(app_opts_args) -- -d], 0, [stdout], []) 70AT_CHECK([grep -- '-d given' stdout], 1, [], []) 71AT_CHECK([APP_HELPER(app_opts_args) arg -d], 0, [stdout], []) 72AT_CHECK([grep -- '-d given' stdout], 1, [], []) 73 74dnl Check that an application that does not redefine any method does 75dnl not show unexpected arguments in the usage message. 76AT_CHECK([APP_HELPER(app_empty) -h], 0, [stdout], []) 77AT_CHECK([grep '\@<:@options\@:>@$' stdout], 0, [ignore], []) 78 79dnl Check that an application that defines the arguments it takes 80dnl shows them in the usage message. 81AT_CHECK([APP_HELPER(app_opts_args) -h], 0, [stdout], []) 82AT_CHECK([grep '\@<:@options\@:>@ <arg1> <arg2>' stdout], 0, [ignore], []) 83 84AT_CLEANUP() 85 86dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4 87