summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2020-05-27 22:32:22 +0000
committerschwarze <>2020-05-27 22:32:22 +0000
commit10d283a99b1f9c8f3c8ae9e1228f7afbc771863e (patch)
tree4b293c4b4974d78b12de25deea3531294aad1f52
parent0ea23439e30b2add8b59fc2da3d3c74cd8f6da2a (diff)
downloadopenbsd-10d283a99b1f9c8f3c8ae9e1228f7afbc771863e.tar.gz
openbsd-10d283a99b1f9c8f3c8ae9e1228f7afbc771863e.tar.bz2
openbsd-10d283a99b1f9c8f3c8ae9e1228f7afbc771863e.zip
more tests after getopt_long.c rev. 1.32;
OK martijn@
-rw-r--r--src/regress/lib/libc/getopt/getopt.sh53
1 files changed, 43 insertions, 10 deletions
diff --git a/src/regress/lib/libc/getopt/getopt.sh b/src/regress/lib/libc/getopt/getopt.sh
index 97668fc262..6e02163d5b 100644
--- a/src/regress/lib/libc/getopt/getopt.sh
+++ b/src/regress/lib/libc/getopt/getopt.sh
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $OpenBSD: getopt.sh,v 1.1 2020/03/23 03:01:21 schwarze Exp $ 3# $OpenBSD: getopt.sh,v 1.2 2020/05/27 22:32:22 schwarze Exp $
4# 4#
5# Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 5# Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
6# 6#
@@ -53,15 +53,33 @@ test3_getopt()
53 53
54irc=0 54irc=0
55 55
56# isolated options without arguments 56# valid isolated options without arguments
57test3_getopt ax '-a -x arg' 'OPT(a)OPT(x)ARG(arg)' 57test3_getopt ax '-a -x arg' 'OPT(a)OPT(x)ARG(arg)'
58test3_getopt x- '- -x arg' 'OPT(-)OPT(x)ARG(arg)'
59
60# invalid isolated options without arguments
58test3_getopt ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)' 61test3_getopt ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)'
59test1_getopt :ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)' 62test1_getopt :ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)'
63test2_getopt x '- -x arg' 'ARG(-)ARG(-x)ARG(arg)'
64test1_getopt -x '- -x arg' 'NONE(-)OPT(x)NONE(arg)'
65test3_getopt a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
66test1_getopt :a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
60 67
61# grouped options without arguments 68# valid grouped options without arguments
62test3_getopt ax '-ax arg' 'OPT(a)OPT(x)ARG(arg)' 69test3_getopt ax '-ax arg' 'OPT(a)OPT(x)ARG(arg)'
70test3_getopt ax- '-a- -x arg' 'OPT(a)OPT(-)OPT(x)ARG(arg)'
71test3_getopt abx- '-a-b -x arg' 'OPT(a)OPT(-)OPT(b)OPT(x)ARG(arg)'
72test3_getopt ax- '--a -x arg' 'OPT(-)OPT(a)OPT(x)ARG(arg)'
73
74# invalid grouped options without arguments
63test3_getopt ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)' 75test3_getopt ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)'
64test1_getopt :ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)' 76test1_getopt :ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)'
77test3_getopt ax '-a- -x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
78test1_getopt :ax '-a- -x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
79test3_getopt abx '-a-b -x arg' 'OPT(a)ERR(?-)OPT(b)OPT(x)ARG(arg)'
80test1_getopt :abx '-a-b -x arg' 'OPT(a)ERR(?-)OPT(b)OPT(x)ARG(arg)'
81test3_getopt ax '--a -x arg' 'ERR(?-)OPT(a)OPT(x)ARG(arg)'
82test1_getopt :ax '--a -x arg' 'ERR(?-)OPT(a)OPT(x)ARG(arg)'
65 83
66# non-option arguments terminating option processing 84# non-option arguments terminating option processing
67test2_getopt ax '-a arg -x' 'OPT(a)ARG(arg)ARG(-x)' 85test2_getopt ax '-a arg -x' 'OPT(a)ARG(arg)ARG(-x)'
@@ -71,13 +89,6 @@ test1_getopt -ax '-a -- -x' 'OPT(a)ARG(-x)'
71test2_getopt ax '-a - -x' 'OPT(a)ARG(-)ARG(-x)' 89test2_getopt ax '-a - -x' 'OPT(a)ARG(-)ARG(-x)'
72test1_getopt -ax '-a - -x arg' 'OPT(a)NONE(-)OPT(x)NONE(arg)' 90test1_getopt -ax '-a - -x arg' 'OPT(a)NONE(-)OPT(x)NONE(arg)'
73 91
74# the '-' option only works when isolated
75test3_getopt a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
76test1_getopt :a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)'
77test1_getopt --a '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)NONE(arg)'
78test3_getopt ax '-a-x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
79test3_getopt a-x '-a-x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)'
80
81# the ':' option never works 92# the ':' option never works
82test1_getopt ::a '-:a arg' 'ERR(?:)OPT(a)ARG(arg)' 93test1_getopt ::a '-:a arg' 'ERR(?:)OPT(a)ARG(arg)'
83test1_getopt :::a '-: arg -a' 'ERR(?:)ARG(arg)ARG(-a)' 94test1_getopt :::a '-: arg -a' 'ERR(?:)ARG(arg)ARG(-a)'
@@ -85,19 +96,41 @@ test1_getopt :::a '-: arg -a' 'ERR(?:)ARG(arg)ARG(-a)'
85# isolated options with arguments 96# isolated options with arguments
86test3_getopt o: '-o' 'ERR(?o)' 97test3_getopt o: '-o' 'ERR(?o)'
87test1_getopt :o: '-o' 'ERR(:o)' 98test1_getopt :o: '-o' 'ERR(:o)'
99test3_getopt o-: '-' 'ERR(?-)'
100test1_getopt :-: '-' 'ERR(:-)'
88test3_getopt o:x '-o arg -x arg' 'OPT(oarg)OPT(x)ARG(arg)' 101test3_getopt o:x '-o arg -x arg' 'OPT(oarg)OPT(x)ARG(arg)'
102test3_getopt o:x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)'
89test3_getopt o::x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)' 103test3_getopt o::x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)'
90test2_getopt o::x '-o arg -x' 'OPT(o)ARG(arg)ARG(-x)' 104test2_getopt o::x '-o arg -x' 'OPT(o)ARG(arg)ARG(-x)'
91test1_getopt -o::x '-o arg1 -x arg2' 'OPT(o)NONE(arg1)OPT(x)NONE(arg2)' 105test1_getopt -o::x '-o arg1 -x arg2' 'OPT(o)NONE(arg1)OPT(x)NONE(arg2)'
106test3_getopt o:x '-o -x arg' 'OPT(o-x)ARG(arg)'
92test3_getopt o:x '-o -- -x arg' 'OPT(o--)OPT(x)ARG(arg)' 107test3_getopt o:x '-o -- -x arg' 'OPT(o--)OPT(x)ARG(arg)'
108test3_getopt x-: '- arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)'
109test3_getopt x-: '--arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)'
110test3_getopt x-:: '--arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)'
111test2_getopt x-:: '- arg -x' 'OPT(-)ARG(arg)ARG(-x)'
112test1_getopt --::x '- arg1 -x arg2' 'OPT(-)NONE(arg1)OPT(x)NONE(arg2)'
113test3_getopt x-: '- -x arg' 'OPT(--x)ARG(arg)'
114test3_getopt x-: '- -- -x arg' 'OPT(---)OPT(x)ARG(arg)'
93 115
94# grouped options with arguments 116# grouped options with arguments
95test3_getopt ao: '-ao' 'OPT(a)ERR(?o)' 117test3_getopt ao: '-ao' 'OPT(a)ERR(?o)'
96test1_getopt :ao: '-ao' 'OPT(a)ERR(:o)' 118test1_getopt :ao: '-ao' 'OPT(a)ERR(:o)'
119test3_getopt a-: '-a-' 'OPT(a)ERR(?-)'
120test1_getopt :a-: '-a-' 'OPT(a)ERR(:-)'
97test3_getopt ao:x '-ao arg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)' 121test3_getopt ao:x '-ao arg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)'
122test3_getopt ao:x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)'
98test3_getopt ao::x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)' 123test3_getopt ao::x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)'
99test2_getopt ao::x '-ao arg -x' 'OPT(a)OPT(o)ARG(arg)ARG(-x)' 124test2_getopt ao::x '-ao arg -x' 'OPT(a)OPT(o)ARG(arg)ARG(-x)'
100test1_getopt -ao::x '-ao arg1 -x arg2' 'OPT(a)OPT(o)NONE(arg1)OPT(x)NONE(arg2)' 125test1_getopt -ao::x '-ao arg1 -x arg2' 'OPT(a)OPT(o)NONE(arg1)OPT(x)NONE(arg2)'
126test3_getopt ao:x '-ao -x arg' 'OPT(a)OPT(o-x)ARG(arg)'
101test3_getopt ao:x '-ao -- -x arg' 'OPT(a)OPT(o--)OPT(x)ARG(arg)' 127test3_getopt ao:x '-ao -- -x arg' 'OPT(a)OPT(o--)OPT(x)ARG(arg)'
128test3_getopt a-:x '-a- arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)'
129test3_getopt a-:x '-a-arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)'
130test3_getopt a-::x '-a-arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)'
131test2_getopt a-::x '-a- arg -x' 'OPT(a)OPT(-)ARG(arg)ARG(-x)'
132test1_getopt -a-::x '-a- arg1 -x arg2' 'OPT(a)OPT(-)NONE(arg1)OPT(x)NONE(arg2)'
133test3_getopt a-:x '-a- -x arg' 'OPT(a)OPT(--x)ARG(arg)'
134test3_getopt a-:x '-a- -- -x arg' 'OPT(a)OPT(---)OPT(x)ARG(arg)'
102 135
103exit $irc 136exit $irc