diff options
author | Sami Kerola | 2014-12-04 23:39:21 +0100 |
---|---|---|
committer | Sami Kerola | 2014-12-08 21:07:00 +0100 |
commit | 93575f2943332d18e8b49441f9519ba2a093e0c3 (patch) | |
tree | 3a3f67e43fa9ff470f8985f5e8cb26a76d6392d0 /tests/ts/misc | |
parent | getopt: sync with 1.1.6 release (diff) | |
download | kernel-qcow2-util-linux-93575f2943332d18e8b49441f9519ba2a093e0c3.tar.gz kernel-qcow2-util-linux-93575f2943332d18e8b49441f9519ba2a093e0c3.tar.xz kernel-qcow2-util-linux-93575f2943332d18e8b49441f9519ba2a093e0c3.zip |
tests: copy test-suite from Frodo Looijaard's getopt
The test cases and their names are the same, but the surrounding testing
facility with Frodo's svn and util-linux are pretty different so this is
not exactly 1:1 copy.
Reference: svn://svn.frodo.looijaard.name/public/getopt/trunk/tests
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'tests/ts/misc')
-rwxr-xr-x | tests/ts/misc/getopt2 | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/tests/ts/misc/getopt2 b/tests/ts/misc/getopt2 new file mode 100755 index 000000000..14deb0d0e --- /dev/null +++ b/tests/ts/misc/getopt2 @@ -0,0 +1,176 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# This file 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 of the License, or +# (at your option) any later version. +# +# This file 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. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="getopt2" + +. $TS_TOPDIR/functions.sh + +ts_init "$*" +ts_check_test_command "$TS_CMD_GETOPT" + +export LANG=C + +ts_init_subtest alternative_option_clash +$TS_CMD_GETOPT -a -o abcde -l abcde -- -a -ab -abc -ac >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest alternative_option_long +$TS_CMD_GETOPT --alternative -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest alternative_option_short +$TS_CMD_GETOPT -a -o a -l one,two:,three::,four:: -- -a -one -two=MANDATORY -three=OPTIONAL >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest invalid_getopt_option +$TS_CMD_GETOPT -b >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,1s/.*\///' $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest invocation_model_one +$TS_CMD_GETOPT abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest invocation_model_three_as_one +$TS_CMD_GETOPT -o abc:d::e::f::g: -- ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest invocation_model_two_as_one +$TS_CMD_GETOPT -- abc:d::e::f::g: ARG0 -b ARG1 -d -eOPTIONAL1 -f NOT_OPTIONAL ARG2 -a -c -ISREQUIRED ARG3 -g "BECOMES THREE ARGUMENTS" >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest invocation_without_parameters +$TS_CMD_GETOPT >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest long_option_ambiguous_1 +$TS_CMD_GETOPT -o a -l long1,long2 -- --long >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,1s/.*\///' $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest longopts +$TS_CMD_GETOPT -o a -l long1,secondlong:,thirdlong::,abbriviation: -- --long1 EXTRA1 --thirdlong=ARGUMENT --secondlong=ARG --abbr ABBRARG -a >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest name_option_long +$TS_CMD_GETOPT -n THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest name_option_short +$TS_CMD_GETOPT --name THIS_PROGRAM -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest quiet_option_long +$TS_CMD_GETOPT --quiet -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest quiet_option_short +$TS_CMD_GETOPT -q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest quiet_output_option_long +$TS_CMD_GETOPT --quiet-output -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,4s/.*\///' $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest quiet_output_option_short +$TS_CMD_GETOPT -Q -o a,b: -l long1,long2 -- -c --unknown --long -b >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,4s/.*\///' $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest same_long_short_options +$TS_CMD_GETOPT -o a -l a -- -a --a >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest test_for_enhanced_getopt +$TS_CMD_GETOPT -T >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest unknown_options +$TS_CMD_GETOPT -o a -l long -- -b --long --whatever -a >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +sed -i '1,2s/.*\///' $TS_OUTPUT +ts_finalize_subtest + +echo "exit value: $?" >> $TS_OUTPUT +ts_init_subtest unquoted_option_bash +$TS_CMD_GETOPT -s bash -u -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest unquoted_option_tcsh +$TS_CMD_GETOPT -s tcsh --unquoted -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest weird_quoting_bash +$TS_CMD_GETOPT -s bash -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest weird_quoting_tcsh +$TS_CMD_GETOPT --shell tcsh -o a: -l long1: -- -a '$?!* ' --long \"\\\' 'More + than +one +line' >> $TS_OUTPUT 2>&1 +echo "exit value: $?" >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize |