diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-13 02:59:00 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-13 02:59:00 +0200 |
commit | 007ce9f807c99e14799c6579c8d06f422eccfcb2 (patch) | |
tree | e45e06ff46a7737a0553245d4fb397997705aff7 | |
parent | 419db0391e47444dd12fb052613fd415694d04f0 (diff) | |
download | busybox-w32-007ce9f807c99e14799c6579c8d06f422eccfcb2.tar.gz busybox-w32-007ce9f807c99e14799c6579c8d06f422eccfcb2.tar.bz2 busybox-w32-007ce9f807c99e14799c6579c8d06f422eccfcb2.zip |
shell: tweak getopts tests, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
6 files changed, 34 insertions, 4 deletions
diff --git a/shell/ash_test/ash-getopts/getopt_test_libc_bug.tests b/shell/ash_test/ash-getopts/getopt_test_libc_bug.tests index 6c0781f20..fcaac81a2 100755 --- a/shell/ash_test/ash-getopts/getopt_test_libc_bug.tests +++ b/shell/ash_test/ash-getopts/getopt_test_libc_bug.tests | |||
@@ -1,6 +1,6 @@ | |||
1 | # This test can fail with libc with buggy getopt() implementation. | 1 | # This test can fail with libc with buggy getopt() implementation. |
2 | # If getopt() wants to parse multi-option args (-abc), | 2 | # If getopt() wants to parse multi-option args (-abc), |
3 | # it needs to remember a position withit current arg. | 3 | # it needs to remember a position within current arg. |
4 | # | 4 | # |
5 | # If this position is kept as a POINTER, not an offset, | 5 | # If this position is kept as a POINTER, not an offset, |
6 | # and if argv[] ADDRESSES (not contents!) change, it blows up. | 6 | # and if argv[] ADDRESSES (not contents!) change, it blows up. |
@@ -24,7 +24,7 @@ VAR111=NEWVAL; getopts "ac" var -a -b -c -d e; echo "3 rc:$? var:'$var' OPTIND:$ | |||
24 | VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 24 | VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
25 | VAR333=NEWVAL; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 25 | VAR333=NEWVAL; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
26 | 26 | ||
27 | # Sligntly different attempts to force reallocations | 27 | # Slightly different attempts to force reallocations |
28 | 28 | ||
29 | echo | 29 | echo |
30 | echo "*** optstring:'ac' args:-a -b -c -d e" | 30 | echo "*** optstring:'ac' args:-a -b -c -d e" |
diff --git a/shell/hush_test/hush-getopts/getopt_optarg.tests b/shell/hush_test/hush-getopts/getopt_optarg.tests index 33682e868..881cc7884 100755 --- a/shell/hush_test/hush-getopts/getopt_optarg.tests +++ b/shell/hush_test/hush-getopts/getopt_optarg.tests | |||
@@ -1,3 +1,5 @@ | |||
1 | ( | ||
2 | |||
1 | set -- -q -w e -r -t -y | 3 | set -- -q -w e -r -t -y |
2 | echo "*** no OPTIND, optstring:'w:et' args:$*" | 4 | echo "*** no OPTIND, optstring:'w:et' args:$*" |
3 | var=QWERTY | 5 | var=QWERTY |
@@ -16,3 +18,7 @@ while getopts "w:et" var; do | |||
16 | OPTARG=ASDFGH | 18 | OPTARG=ASDFGH |
17 | done | 19 | done |
18 | echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 20 | echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
21 | |||
22 | ) 2>&1 \ | ||
23 | | sed -e 's/ unrecognized option: / invalid option -- /' \ | ||
24 | -e 's/ illegal option -- / invalid option -- /' \ | ||
diff --git a/shell/hush_test/hush-getopts/getopt_positional.tests b/shell/hush_test/hush-getopts/getopt_positional.tests index ddf063363..20716bb0c 100755 --- a/shell/hush_test/hush-getopts/getopt_positional.tests +++ b/shell/hush_test/hush-getopts/getopt_positional.tests | |||
@@ -1,3 +1,5 @@ | |||
1 | ( | ||
2 | |||
1 | set -- -q -w -e r -t -y | 3 | set -- -q -w -e r -t -y |
2 | echo "*** no OPTIND, optstring:'we' args:$*" | 4 | echo "*** no OPTIND, optstring:'we' args:$*" |
3 | var=QWERTY | 5 | var=QWERTY |
@@ -5,3 +7,7 @@ while getopts "we" var; do | |||
5 | echo "var:'$var' OPTIND:$OPTIND" | 7 | echo "var:'$var' OPTIND:$OPTIND" |
6 | done | 8 | done |
7 | echo "exited: var:'$var' OPTIND:$OPTIND" | 9 | echo "exited: var:'$var' OPTIND:$OPTIND" |
10 | |||
11 | ) 2>&1 \ | ||
12 | | sed -e 's/ unrecognized option: / invalid option -- /' \ | ||
13 | -e 's/ illegal option -- / invalid option -- /' \ | ||
diff --git a/shell/hush_test/hush-getopts/getopt_silent.tests b/shell/hush_test/hush-getopts/getopt_silent.tests index 097d7ba85..5f255db7f 100755 --- a/shell/hush_test/hush-getopts/getopt_silent.tests +++ b/shell/hush_test/hush-getopts/getopt_silent.tests | |||
@@ -11,6 +11,8 @@ | |||
11 | # and OPTARG shall be set to the option character found. | 11 | # and OPTARG shall be set to the option character found. |
12 | # """ | 12 | # """ |
13 | 13 | ||
14 | ( | ||
15 | |||
14 | echo "*** optstring:':ac' args:-a -b -c" | 16 | echo "*** optstring:':ac' args:-a -b -c" |
15 | getopts ":ac" var -a -b -c; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 17 | getopts ":ac" var -a -b -c; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
16 | getopts ":ac" var -a -b -c; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 18 | getopts ":ac" var -a -b -c; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
@@ -21,3 +23,7 @@ getopts ":ac" var -a -b -c; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPT | |||
21 | # Nevertheless, let's verify that calling it yet another time doesn't do | 23 | # Nevertheless, let's verify that calling it yet another time doesn't do |
22 | # anything weird: | 24 | # anything weird: |
23 | getopts ":ac" var -a -b -c; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 25 | getopts ":ac" var -a -b -c; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
26 | |||
27 | ) 2>&1 \ | ||
28 | | sed -e 's/ unrecognized option: / invalid option -- /' \ | ||
29 | -e 's/ illegal option -- / invalid option -- /' \ | ||
diff --git a/shell/hush_test/hush-getopts/getopt_simple.tests b/shell/hush_test/hush-getopts/getopt_simple.tests index 8615ae366..50718cc98 100755 --- a/shell/hush_test/hush-getopts/getopt_simple.tests +++ b/shell/hush_test/hush-getopts/getopt_simple.tests | |||
@@ -10,6 +10,8 @@ | |||
10 | # We check that loop does not stop on unknown option (sets "?"), | 10 | # We check that loop does not stop on unknown option (sets "?"), |
11 | # stops on _first_ non-option argument. | 11 | # stops on _first_ non-option argument. |
12 | 12 | ||
13 | ( | ||
14 | |||
13 | echo "*** no OPTIND, optstring:'ab' args:-a -b c" | 15 | echo "*** no OPTIND, optstring:'ab' args:-a -b c" |
14 | var=QWERTY | 16 | var=QWERTY |
15 | while getopts "ab" var -a -b c; do | 17 | while getopts "ab" var -a -b c; do |
@@ -73,3 +75,7 @@ while getopts "ab" var -a -c -b d; do | |||
73 | echo "var:'$var' OPTIND:$OPTIND" | 75 | echo "var:'$var' OPTIND:$OPTIND" |
74 | done | 76 | done |
75 | echo "exited: rc:$? var:'$var' OPTIND:$OPTIND" | 77 | echo "exited: rc:$? var:'$var' OPTIND:$OPTIND" |
78 | |||
79 | ) 2>&1 \ | ||
80 | | sed -e 's/ unrecognized option: / invalid option -- /' \ | ||
81 | -e 's/ illegal option -- / invalid option -- /' \ | ||
diff --git a/shell/hush_test/hush-getopts/getopt_test_libc_bug.tests b/shell/hush_test/hush-getopts/getopt_test_libc_bug.tests index 6c0781f20..ab7bc3b09 100755 --- a/shell/hush_test/hush-getopts/getopt_test_libc_bug.tests +++ b/shell/hush_test/hush-getopts/getopt_test_libc_bug.tests | |||
@@ -1,10 +1,12 @@ | |||
1 | # This test can fail with libc with buggy getopt() implementation. | 1 | # This test can fail with libc with buggy getopt() implementation. |
2 | # If getopt() wants to parse multi-option args (-abc), | 2 | # If getopt() wants to parse multi-option args (-abc), |
3 | # it needs to remember a position withit current arg. | 3 | # it needs to remember a position within current arg. |
4 | # | 4 | # |
5 | # If this position is kept as a POINTER, not an offset, | 5 | # If this position is kept as a POINTER, not an offset, |
6 | # and if argv[] ADDRESSES (not contents!) change, it blows up. | 6 | # and if argv[] ADDRESSES (not contents!) change, it blows up. |
7 | 7 | ||
8 | ( | ||
9 | |||
8 | echo "*** optstring:'ac' args:-a -b -c -d e" | 10 | echo "*** optstring:'ac' args:-a -b -c -d e" |
9 | getopts "ac" var -a -b -c -d e; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 11 | getopts "ac" var -a -b -c -d e; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
10 | getopts "ac" var -a -b -c -d e; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 12 | getopts "ac" var -a -b -c -d e; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
@@ -24,7 +26,7 @@ VAR111=NEWVAL; getopts "ac" var -a -b -c -d e; echo "3 rc:$? var:'$var' OPTIND:$ | |||
24 | VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 26 | VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
25 | VAR333=NEWVAL; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 27 | VAR333=NEWVAL; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
26 | 28 | ||
27 | # Sligntly different attempts to force reallocations | 29 | # Slightly different attempts to force reallocations |
28 | 30 | ||
29 | echo | 31 | echo |
30 | echo "*** optstring:'ac' args:-a -b -c -d e" | 32 | echo "*** optstring:'ac' args:-a -b -c -d e" |
@@ -36,3 +38,7 @@ export VAR222; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$ | |||
36 | export VAR333; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" | 38 | export VAR333; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" |
37 | 39 | ||
38 | # All copies of code above should generate identical output | 40 | # All copies of code above should generate identical output |
41 | |||
42 | ) 2>&1 \ | ||
43 | | sed -e 's/ unrecognized option: / invalid option -- /' \ | ||
44 | -e 's/ illegal option -- / invalid option -- /' \ | ||