aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-13 02:59:00 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-13 02:59:00 +0200
commit007ce9f807c99e14799c6579c8d06f422eccfcb2 (patch)
treee45e06ff46a7737a0553245d4fb397997705aff7
parent419db0391e47444dd12fb052613fd415694d04f0 (diff)
downloadbusybox-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>
-rwxr-xr-xshell/ash_test/ash-getopts/getopt_test_libc_bug.tests4
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_optarg.tests6
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_positional.tests6
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_silent.tests6
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_simple.tests6
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_test_libc_bug.tests10
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:$
24VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 24VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
25VAR333=NEWVAL; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 25VAR333=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
29echo 29echo
30echo "*** optstring:'ac' args:-a -b -c -d e" 30echo "*** 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
1set -- -q -w e -r -t -y 3set -- -q -w e -r -t -y
2echo "*** no OPTIND, optstring:'w:et' args:$*" 4echo "*** no OPTIND, optstring:'w:et' args:$*"
3var=QWERTY 5var=QWERTY
@@ -16,3 +18,7 @@ while getopts "w:et" var; do
16 OPTARG=ASDFGH 18 OPTARG=ASDFGH
17done 19done
18echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 20echo "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
1set -- -q -w -e r -t -y 3set -- -q -w -e r -t -y
2echo "*** no OPTIND, optstring:'we' args:$*" 4echo "*** no OPTIND, optstring:'we' args:$*"
3var=QWERTY 5var=QWERTY
@@ -5,3 +7,7 @@ while getopts "we" var; do
5 echo "var:'$var' OPTIND:$OPTIND" 7 echo "var:'$var' OPTIND:$OPTIND"
6done 8done
7echo "exited: var:'$var' OPTIND:$OPTIND" 9echo "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
14echo "*** optstring:':ac' args:-a -b -c" 16echo "*** optstring:':ac' args:-a -b -c"
15getopts ":ac" var -a -b -c; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 17getopts ":ac" var -a -b -c; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
16getopts ":ac" var -a -b -c; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 18getopts ":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:
23getopts ":ac" var -a -b -c; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 25getopts ":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
13echo "*** no OPTIND, optstring:'ab' args:-a -b c" 15echo "*** no OPTIND, optstring:'ab' args:-a -b c"
14var=QWERTY 16var=QWERTY
15while getopts "ab" var -a -b c; do 17while 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"
74done 76done
75echo "exited: rc:$? var:'$var' OPTIND:$OPTIND" 77echo "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
8echo "*** optstring:'ac' args:-a -b -c -d e" 10echo "*** optstring:'ac' args:-a -b -c -d e"
9getopts "ac" var -a -b -c -d e; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 11getopts "ac" var -a -b -c -d e; echo "1 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
10getopts "ac" var -a -b -c -d e; echo "2 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 12getopts "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:$
24VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 26VAR222=NEWVAL; getopts "ac" var -a -b -c -d e; echo "4 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
25VAR333=NEWVAL; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 27VAR333=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
29echo 31echo
30echo "*** optstring:'ac' args:-a -b -c -d e" 32echo "*** 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:$
36export VAR333; getopts "ac" var -a -b -c -d e; echo "5 rc:$? var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'" 38export 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 -- /' \