-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-debian-distro-info
executable file
·365 lines (301 loc) · 12.9 KB
/
test-debian-distro-info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/bin/sh
# Copyright (C) 2012-2014, Benjamin Drung <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
COMMAND="${COMMAND:-${0%/*}/debian-distro-info}"
. "${0%/*}/shunit2-helper-functions.sh"
testAlias() {
success "--alias sid" "unstable"
success "--date 2010-10-20 --alias squeeze" "testing"
success "--date 2011-11-20 --alias squeeze" "stable"
success "--alias whatever" "whatever"
}
testAll() {
local result="buzz
rex
bo
hamm
slink
potato
woody
sarge
etch
lenny
squeeze
sid
experimental"
local pattern=$(echo $result | sed "s/ /\\\\|/g")
success "--date 2007-07-07 --all | grep -w \"$pattern\"" "$result"
success "-a | grep -w \"$pattern\"" "$result"
}
testDevel() {
success "--date 2011-01-10 --devel" "sid"
success "-d --date=2002-01-10 --codename" "sid"
}
testOldstable() {
success "--oldstable --date=2011-01-10" "etch"
success "-c --date=2008-07-06 -o" "sarge"
# Compatibility with 0.2.2
success "--old --date=2011-01-10" "etch"
}
testStable() {
success "--date=2011-01-10 --stable" "lenny"
success "--date=2001-02-10 -s" "potato"
}
testSupported() {
local result="lenny
squeeze
sid
experimental"
success "--date=2011-01-10 --supported" "$result"
}
testLTS() {
success "--date=2016-02-28 --lts" "squeeze"
}
testELTS() {
success "--date=2018-09-01 --elts" "wheezy"
}
testUnsupported() {
local result="buzz
rex
bo
hamm
slink
potato
woody
sarge
etch"
success "--date=2011-01-10 --unsupported" "$result"
}
testTesting() {
success "--date=2011-01-10 --testing" "squeeze"
success "-t --date=2010-01-10" "squeeze"
}
testFullname() {
success "--date=2011-01-10 --stable --fullname" 'Debian 5.0 "Lenny"'
success "--date=2011-01-10 --stable --fullname -ycreated" \
'Debian 5.0 "Lenny" -1373'
success "--date=2011-01-10 --stable --fullname --days=created" \
'Debian 5.0 "Lenny" -1373'
success "--date=2011-01-10 --stable --fullname -y" \
'Debian 5.0 "Lenny" -695'
success "--date=2011-01-10 --stable --fullname --days" \
'Debian 5.0 "Lenny" -695'
success "--date=2011-01-10 --stable --fullname -yrelease" \
'Debian 5.0 "Lenny" -695'
success "--date=2011-01-10 --stable --fullname --days=release" \
'Debian 5.0 "Lenny" -695'
success "--date=2011-01-10 --stable --fullname -yeol" \
'Debian 5.0 "Lenny" 392'
success "--date=2011-01-10 --stable --fullname --days=eol" \
'Debian 5.0 "Lenny" 392'
success "--date=2011-01-10 -f --testing" 'Debian 6.0 "Squeeze"'
success "--date=2011-01-10 -f --testing -ycreated" \
'Debian 6.0 "Squeeze" -695'
success "--date=2011-01-10 -f --testing --days=created" \
'Debian 6.0 "Squeeze" -695'
success "--date=2011-01-10 -f --testing -y" \
'Debian 6.0 "Squeeze" 27'
success "--date=2011-01-10 -f --testing --days" \
'Debian 6.0 "Squeeze" 27'
success "--date=2011-01-10 -f --testing -yrelease" \
'Debian 6.0 "Squeeze" 27'
success "--date=2011-01-10 -f --testing --days=release" \
'Debian 6.0 "Squeeze" 27'
# sid is never released so can never go eol
success "--date=2011-01-10 -f --devel -yeol" \
'Debian "Sid" (unknown)'
success "--date=2011-01-10 -f --devel --days=eol" \
'Debian "Sid" (unknown)'
}
testRelease() {
success "--date=2011-01-10 -r --devel" "sid"
success "--date=2011-01-10 --testing --release" "6.0"
success "--date=2011-01-10 --release --stable" "5.0"
}
testSeries() {
success "-r --series rex" "1.2"
}
testCombinedShortform() {
success "-rd" "sid"
}
testReleaseDate() {
success "--date 2009-02-13 -o" "sarge"
success "--date 2009-02-13 -s" "etch"
success "--date 2009-02-13 -t" "lenny"
success "--date 2009-02-13 -d" "sid"
success "--date 2009-02-14 -o" "etch"
success "--date 2009-02-14 -s" "lenny"
success "--date 2009-02-14 -t" "squeeze"
success "--date 2009-02-14 -d" "sid"
}
testHelp() {
local help='Usage: debian-distro-info [options]
Options:
-h --help show this help message and exit
--date=DATE date for calculating the version (default: today)
--series=SERIES series to calculate the version for
-y[MILESTONE] additionally, display days until milestone
--days=[MILESTONE] (created, release, eol, eol-lts, eol-elts)
--alias=DIST print the alias (oldstable, stable, testing, unstable)
relative to the given distribution codename
-a --all list all known versions
-d --devel latest development version
-t --testing current testing version
-s --stable latest stable version
-o --oldstable latest oldstable version
--supported list of all supported versions (including development)
-l --lts list of all LTS supported versions
-e --elts list of all Extended LTS supported versions
--unsupported list of all unsupported stable versions
-c --codename print the codename (default)
-f --fullname print the full name
-r --release print the release version
See debian-distro-info(1) for more info.'
success "--help" "$help"
success "-h" "$help"
}
testExactlyOne() {
local result='debian-distro-info: You have to select exactly one of --alias, --all, --devel, --elts, --lts, --oldstable, --stable, --supported, --series, --testing, --unsupported.'
failure "" "$result"
failure "-ad" "$result"
failure "--alias foo -a" "$result"
}
testUnrecognizedOption() {
failure "--foo" "debian-distro-info: unrecognized option \`--foo'"
failure "-x" "debian-distro-info: unrecognized option \`-x'"
failure "--supported-esm" "debian-distro-info: unrecognized option \`--supported-esm'"
}
testUnrecognizedArguments() {
failure "bar" "debian-distro-info: unrecognized arguments: bar"
failure "baz -s foo" "debian-distro-info: unrecognized arguments: baz foo"
}
testMissingArgumentAlias() {
failure "--alias" "debian-distro-info: option \`--alias' requires an argument DIST"
}
testMissingArgumentDate() {
failure "--date" "debian-distro-info: option \`--date' requires an argument DATE"
}
testMissingArgumentSeries() {
failure "--series" "debian-distro-info: option \`--series' requires an argument SERIES"
}
testInvalidAlias() {
failure "--alias Sid" "debian-distro-info: invalid distribution codename \`Sid'"
failure "--alias wr0ng" "debian-distro-info: invalid distribution codename \`wr0ng'"
}
testInvalidDate() {
failure "--date fail -s" "debian-distro-info: invalid date \`fail'"
failure "--date=2010-02-30 -d" "debian-distro-info: invalid date \`2010-02-30'"
}
testInvalidSeries() {
failure "--series wr0ng" "debian-distro-info: invalid distribution series \`wr0ng'"
}
testMultipleAlias() {
failure "--alias a --alias b" "debian-distro-info: --alias requested multiple times."
}
testMultipleDates() {
failure "--date 2007-06-05 -s --date 2004-03-02" "debian-distro-info: Date specified multiple times."
}
testMultipleSeries() {
failure "--series wheezy --series jessie" "debian-distro-info: series requested multiple times."
}
testUnknownSeries() {
failure "--series foobar" "debian-distro-info: unknown distribution series \`foobar'"
}
testDays() {
# day after lenny released
date=2009-02-15
success "--date=$date --stable " "lenny"
success "--date=$date --stable --days=created" "-679"
success "--date=$date --stable --days=created -c" "lenny -679"
success "--date=$date --stable --days=created -f" "Debian 5.0 \"Lenny\" -679"
success "--date=$date --stable --days=created -r" "5.0 -679"
success "--date=$date --stable --days=release" "-1"
success "--date=$date --stable --days=release -c" "lenny -1"
success "--date=$date --stable --days=release -f" "Debian 5.0 \"Lenny\" -1"
success "--date=$date --stable --days=release -r" "5.0 -1"
success "--date=$date --stable --days" "-1"
success "--date=$date --stable --days -c" "lenny -1"
success "--date=$date --stable --days -f" "Debian 5.0 \"Lenny\" -1"
success "--date=$date --stable --days -r" "5.0 -1"
success "--date=$date --stable --days=eol" "1086"
success "--date=$date --stable --days=eol -c" "lenny 1086"
success "--date=$date --stable --days=eol -f" "Debian 5.0 \"Lenny\" 1086"
success "--date=$date --stable --days=eol -r" "5.0 1086"
# date woody released
date=2002-07-19
success "--date=$date --stable" "woody"
success "--date=$date --stable --days=created" "-703"
success "--date=$date --stable --days=created -c" "woody -703"
success "--date=$date --stable --days=created -f" "Debian 3.0 \"Woody\" -703"
success "--date=$date --stable --days=created -r" "3.0 -703"
success "--date=$date --stable --days=release" "0"
success "--date=$date --stable --days=release -c" "woody 0"
success "--date=$date --stable --days=release -f" "Debian 3.0 \"Woody\" 0"
success "--date=$date --stable --days=release -r" "3.0 0"
success "--date=$date --stable --days" "0"
success "--date=$date --stable --days -c" "woody 0"
success "--date=$date --stable --days -f" "Debian 3.0 \"Woody\" 0"
success "--date=$date --stable --days -r" "3.0 0"
success "--date=$date --stable --days=eol" "1442"
success "--date=$date --stable --days=eol -c" "woody 1442"
success "--date=$date --stable --days=eol -f" "Debian 3.0 \"Woody\" 1442"
success "--date=$date --stable --days=eol -r" "3.0 1442"
# day before etch was released
date=2007-04-07
success "--testing --date=$date" "etch"
success "--testing --date=$date --days=created" "-670"
success "--testing --date=$date --days=created -c" "etch -670"
success "--testing --date=$date --days=created -f" "Debian 4.0 \"Etch\" -670"
success "--testing --date=$date --days=created -r" "4.0 -670"
success "--testing --date=$date --days" "1"
success "--testing --date=$date --days -c" "etch 1"
success "--testing --date=$date --days -f" "Debian 4.0 \"Etch\" 1"
success "--testing --date=$date --days -r" "4.0 1"
success "--testing --date=$date --days=release" "1"
success "--testing --date=$date --days=release -c" "etch 1"
success "--testing --date=$date --days=release -f" "Debian 4.0 \"Etch\" 1"
success "--testing --date=$date --days=release -r" "4.0 1"
success "--testing --date=$date --days=eol" "1045"
success "--testing --date=$date --days=eol -c" "etch 1045"
success "--testing --date=$date --days=eol -f" "Debian 4.0 \"Etch\" 1045"
success "--testing --date=$date --days=eol -r" "4.0 1045"
# day before wheezy was released
date=2013-05-03
success "--testing --date=$date" "wheezy"
success "--testing --date=$date --days=created" "-817"
success "--testing --date=$date --days=created -c" "wheezy -817"
success "--testing --date=$date --days=created -f" "Debian 7 \"Wheezy\" -817"
success "--testing --date=$date --days=created -r" "7 -817"
success "--testing --date=$date --days" "1"
success "--testing --date=$date --days -c" "wheezy 1"
success "--testing --date=$date --days -f" "Debian 7 \"Wheezy\" 1"
success "--testing --date=$date --days -r" "7 1"
success "--testing --date=$date --days=release" "1"
success "--testing --date=$date --days=release -c" "wheezy 1"
success "--testing --date=$date --days=release -f" "Debian 7 \"Wheezy\" 1"
success "--testing --date=$date --days=release -r" "7 1"
success "--testing --date=$date --days=eol" "1089"
success "--testing --date=$date --days=eol -c" "wheezy 1089"
success "--testing --date=$date --days=eol -f" "Debian 7 \"Wheezy\" 1089"
success "--testing --date=$date --days=eol -r" "7 1089"
success "--testing --date=$date --days=eol-lts" "1854"
success "--testing --date=$date --days=eol-lts -c" "wheezy 1854"
success "--testing --date=$date --days=eol-lts -f" "Debian 7 \"Wheezy\" 1854"
success "--testing --date=$date --days=eol-lts -r" "7 1854"
success "--testing --date=$date --days=eol-elts" "2615"
success "--testing --date=$date --days=eol-elts -c" "wheezy 2615"
success "--testing --date=$date --days=eol-elts -f" "Debian 7 \"Wheezy\" 2615"
success "--testing --date=$date --days=eol-elts -r" "7 2615"
}
. shunit2