summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2020-05-27 22:32:23 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2020-05-27 22:32:23 +0000
commit8fafa99c7a263421c99250c1d104ca7480388e3e (patch)
treeb65e8b756173208793767363bf23333b7e48e09b /regress
parent728b1c83fa28ef2c5b0e1059c2bec27dae4e11b7 (diff)
more tests after getopt_long.c rev. 1.32;
OK martijn@
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libc/getopt/getopt.sh53
1 files changed, 43 insertions, 10 deletions
diff --git a/regress/lib/libc/getopt/getopt.sh b/regress/lib/libc/getopt/getopt.sh
index 97668fc262c..6e02163d5bc 100644
--- a/regress/lib/libc/getopt/getopt.sh
+++ b/regress/lib/libc/getopt/getopt.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $OpenBSD: getopt.sh,v 1.1 2020/03/23 03:01:21 schwarze Exp $
+# $OpenBSD: getopt.sh,v 1.2 2020/05/27 22:32:22 schwarze Exp $
#
# Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -53,15 +53,33 @@ test3_getopt()
irc=0
-# isolated options without arguments
+# valid isolated options without arguments
test3_getopt ax '-a -x arg' 'OPT(a)OPT(x)ARG(arg)'
+test3_getopt x- '- -x arg' 'OPT(-)OPT(x)ARG(arg)'
+
+# invalid isolated options without arguments
test3_getopt ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)'
test1_getopt :ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)'
+test2_getopt x '- -x arg' 'ARG(-)ARG(-x)ARG(arg)'
+test1_getopt -x '- -x arg' 'NONE(-)OPT(x)NONE(arg)'
+test3_getopt a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
+test1_getopt :a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
-# grouped options without arguments
+# valid grouped options without arguments
test3_getopt ax '-ax arg' 'OPT(a)OPT(x)ARG(arg)'
+test3_getopt ax- '-a- -x arg' 'OPT(a)OPT(-)OPT(x)ARG(arg)'
+test3_getopt abx- '-a-b -x arg' 'OPT(a)OPT(-)OPT(b)OPT(x)ARG(arg)'
+test3_getopt ax- '--a -x arg' 'OPT(-)OPT(a)OPT(x)ARG(arg)'
+
+# invalid grouped options without arguments
test3_getopt ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)'
test1_getopt :ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)'
+test3_getopt ax '-a- -x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
+test1_getopt :ax '-a- -x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
+test3_getopt abx '-a-b -x arg' 'OPT(a)ERR(?-)OPT(b)OPT(x)ARG(arg)'
+test1_getopt :abx '-a-b -x arg' 'OPT(a)ERR(?-)OPT(b)OPT(x)ARG(arg)'
+test3_getopt ax '--a -x arg' 'ERR(?-)OPT(a)OPT(x)ARG(arg)'
+test1_getopt :ax '--a -x arg' 'ERR(?-)OPT(a)OPT(x)ARG(arg)'
# non-option arguments terminating option processing
test2_getopt ax '-a arg -x' 'OPT(a)ARG(arg)ARG(-x)'
@@ -71,13 +89,6 @@ test1_getopt -ax '-a -- -x' 'OPT(a)ARG(-x)'
test2_getopt ax '-a - -x' 'OPT(a)ARG(-)ARG(-x)'
test1_getopt -ax '-a - -x arg' 'OPT(a)NONE(-)OPT(x)NONE(arg)'
-# the '-' option only works when isolated
-test3_getopt a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
-test1_getopt :a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
-test1_getopt --a '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)NONE(arg)'
-test3_getopt ax '-a-x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
-test3_getopt a-x '-a-x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
-
# the ':' option never works
test1_getopt ::a '-:a arg' 'ERR(?:)OPT(a)ARG(arg)'
test1_getopt :::a '-: arg -a' 'ERR(?:)ARG(arg)ARG(-a)'
@@ -85,19 +96,41 @@ test1_getopt :::a '-: arg -a' 'ERR(?:)ARG(arg)ARG(-a)'
# isolated options with arguments
test3_getopt o: '-o' 'ERR(?o)'
test1_getopt :o: '-o' 'ERR(:o)'
+test3_getopt o-: '-' 'ERR(?-)'
+test1_getopt :-: '-' 'ERR(:-)'
test3_getopt o:x '-o arg -x arg' 'OPT(oarg)OPT(x)ARG(arg)'
+test3_getopt o:x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)'
test3_getopt o::x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)'
test2_getopt o::x '-o arg -x' 'OPT(o)ARG(arg)ARG(-x)'
test1_getopt -o::x '-o arg1 -x arg2' 'OPT(o)NONE(arg1)OPT(x)NONE(arg2)'
+test3_getopt o:x '-o -x arg' 'OPT(o-x)ARG(arg)'
test3_getopt o:x '-o -- -x arg' 'OPT(o--)OPT(x)ARG(arg)'
+test3_getopt x-: '- arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)'
+test3_getopt x-: '--arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)'
+test3_getopt x-:: '--arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)'
+test2_getopt x-:: '- arg -x' 'OPT(-)ARG(arg)ARG(-x)'
+test1_getopt --::x '- arg1 -x arg2' 'OPT(-)NONE(arg1)OPT(x)NONE(arg2)'
+test3_getopt x-: '- -x arg' 'OPT(--x)ARG(arg)'
+test3_getopt x-: '- -- -x arg' 'OPT(---)OPT(x)ARG(arg)'
# grouped options with arguments
test3_getopt ao: '-ao' 'OPT(a)ERR(?o)'
test1_getopt :ao: '-ao' 'OPT(a)ERR(:o)'
+test3_getopt a-: '-a-' 'OPT(a)ERR(?-)'
+test1_getopt :a-: '-a-' 'OPT(a)ERR(:-)'
test3_getopt ao:x '-ao arg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)'
+test3_getopt ao:x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)'
test3_getopt ao::x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)'
test2_getopt ao::x '-ao arg -x' 'OPT(a)OPT(o)ARG(arg)ARG(-x)'
test1_getopt -ao::x '-ao arg1 -x arg2' 'OPT(a)OPT(o)NONE(arg1)OPT(x)NONE(arg2)'
+test3_getopt ao:x '-ao -x arg' 'OPT(a)OPT(o-x)ARG(arg)'
test3_getopt ao:x '-ao -- -x arg' 'OPT(a)OPT(o--)OPT(x)ARG(arg)'
+test3_getopt a-:x '-a- arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)'
+test3_getopt a-:x '-a-arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)'
+test3_getopt a-::x '-a-arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)'
+test2_getopt a-::x '-a- arg -x' 'OPT(a)OPT(-)ARG(arg)ARG(-x)'
+test1_getopt -a-::x '-a- arg1 -x arg2' 'OPT(a)OPT(-)NONE(arg1)OPT(x)NONE(arg2)'
+test3_getopt a-:x '-a- -x arg' 'OPT(a)OPT(--x)ARG(arg)'
+test3_getopt a-:x '-a- -- -x arg' 'OPT(a)OPT(---)OPT(x)ARG(arg)'
exit $irc