summaryrefslogtreecommitdiff
path: root/tests/tests.yml
blob: b6b28f4b062ecd9527635ae34a8c8dfab7bcb96a (plain)
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
- name: basic .tar
  filenames: test-1.23.tar
  baseline: |
    tar -xf $1

- name: basic .tar.gz
  filenames: test-1.23.tar.gz
  baseline: |
    tar -zxf $1

- name: basic .tar.bz2
  filenames: test-1.23.tar.bz2
  baseline: |
    mkdir test-1.23
    cd test-1.23
    tar -jxf ../$1

- name: basic .zip
  filenames: test-1.23.zip
  baseline: |
    mkdir test-1.23
    cd test-1.23
    unzip -q ../$1

- name: basic .deb
  filenames: test-1.23_all.deb
  baseline: |
    mkdir test-1.23
    cd test-1.23
    ar p ../$1 data.tar.gz | tar -zx

- name: .deb with LZMA compression
  filenames: test-2_all.deb
  baseline: |
    mkdir test-2
    cd test-2
    ar p ../$1 data.tar.lzma | lzcat | tar -x

- name: basic .gem
  filenames: test-1.23.gem
  baseline: |
    mkdir test-1.23
    cd test-1.23
    tar -xOf ../$1 data.tar.gz | tar -zx

- name: basic .7z
  filenames: test-1.23.7z
  baseline: |
    7z x $1

- name: basic .lzma
  filenames: test-1.23.tar.lzma
  baseline: |
    lzcat $1 | tar -x

- name: basic .cpio
  filenames: test-1.23.cpio
  baseline: |
    cpio -i --make-directories <$1
  antigrep: blocks?

- name: .deb metadata
  filenames: test-1.23_all.deb
  options: --metadata
  baseline: |
    mkdir test-1.23
    cd test-1.23
    ar p ../$1 control.tar.gz | tar -zx
    
- name: .gem metadata
  filenames: test-1.23.gem
  options: -m
  baseline: |
    tar -xOf $1 metadata.gz | zcat > test-1.23.gem-metadata.txt
  cleanup: rm -f test-1.23.gem-metadata.txt
  posttest: |
    if [ "x`cat test-1.23.gem-metadata.txt`" != "xhi" ]; then exit 1; fi

- name: recursion and permissions
  filenames: test-recursive-badperms.tar.bz2
  options: -n -r
  baseline: |
    mkdir test-recursive-badperms
    cd test-recursive-badperms
    tar -jxf ../$1
    mkdir test-badperms
    cd test-badperms
    tar -xf ../test-badperms.tar
    chmod 700 testdir
  posttest: |
    if [ "x`cat test-recursive-badperms/test-badperms/testdir/testfile`" != \
         "xhey" ]; then exit 1; fi

- name: decompressing gz
  directory: inside-dir
  filenames: ../test-text.gz
  baseline: |
    zcat $1 >test-text
  posttest: |
    if [ "x`cat test-text`" != "xhi" ]; then exit 1; fi

- name: decompressing bz2
  directory: inside-dir
  filenames: ../test-text.bz2
  baseline: |
    bzcat $1 >test-text
  posttest: |
    if [ "x`cat test-text`" != "xhi" ]; then exit 1; fi

- name: decompression with -r
  directory: inside-dir
  filenames: ../test-text.gz
  options: -n -r
  baseline: |
    zcat $1 >test-text

- name: decompression with -fr
  directory: inside-dir
  filenames: ../test-text.gz
  options: -n -fr
  baseline: |
    zcat $1 >test-text

- name: overwrite protection
  filenames: test-1.23.tar.bz2
  baseline: |
    mkdir test-1.23.1
    cd test-1.23.1
    tar -jxf ../$1
  prerun: |
    mkdir test-1.23

- name: overwrite option
  filenames: test-1.23.tar.bz2
  options: -n -o
  baseline: |
    cd test-1.23
    tar -jxf ../$1
  prerun: |
    mkdir test-1.23 

- name: flat option
  directory: inside-dir
  filenames: ../test-1.23.tar.bz2
  options: -n -f
  baseline: |
    tar -jxf $1

- name: flat recursion and permissions
  directory: inside-dir
  filenames: ../test-recursive-badperms.tar.bz2
  options: -n -fr
  baseline: |
    tar -jxf $1
    tar -xf test-badperms.tar
    chmod 700 testdir
  posttest: |
    if [ "x`cat testdir/testfile`" != "xhey" ]; then exit 1; fi

- name: no files
  error: true
  grep: "[Uu]sage"

- name: bad file
  error: true
  filenames: nonexistent-file.tar

- name: not an archive
  error: true
  filenames: tests.yml

- name: bad options
  options: -n --nonexistent-option
  filenames: test-1.23.tar
  error: true

- name: --version
  options: -n --version
  grep: ersion \d+\.\d+
  filenames: test-1.23.tar
  baseline: |
    exit 0

- name: one good archive of many
  filenames: tests.yml test-1.23.tar nonexistent-file.tar
  error: true
  baseline: |
    tar -xf $2

- name: silence
  filenames: tests.yml
  options: -n -qq
  error: true
  antigrep: .

- name: can't write to directory
  directory: inside-dir
  filenames: ../test-1.23.tar
  error: true
  grep: ERROR
  antigrep: Traceback
  prerun: |
    chmod 500 .

- name: list contents of one file
  options: -n -l
  filenames: test-1.23.tar
  output: |
    test-1.23/
    test-1.23/1/
    test-1.23/1/2/
    test-1.23/1/2/3
    test-1.23/a/
    test-1.23/a/b
    test-1.23/foobar

- name: list contents of .cpio
  options: -n -l
  filenames: test-1.23.cpio
  grep: ^test-1\.23/1/2/3$
  antigrep: blocks?

- name: list contents of multiple files
  options: -n --table
  filenames: test-1.23_all.deb test-1.23.zip
  output: |
    test-1.23_all.deb:
    1/
    1/2/
    1/2/3
    a/
    a/b
    foobar
    
    test-1.23.zip:
    1/2/3
    a/b
    foobar

- name: list contents of compressed file
  options: -n -t
  filenames: test-text.gz
  output: test-text

- name: default behavior with one directory (gz)
  options: -n
  filenames: test-onedir.tar.gz
  baseline: |
    mkdir test-onedir
    cd test-onedir
    tar -zxf ../$1

- name: one directory extracted inside another interactively (gz)
  options: ""
  filenames: test-onedir.tar.gz
  grep: one directory
  input: i
  baseline: |
    mkdir test-onedir
    cd test-onedir
    tar -zxf ../$1

- name: one directory extracted with rename interactively (gz)
  options: ""
  filenames: test-onedir.tar.gz
  input: r
  baseline: |
    tar -zxf $1
    mv test test-onedir

- name: one directory extracted here interactively (gz)
  options: ""
  filenames: test-onedir.tar.gz
  input: h
  baseline: |
    tar -zxf $1

- name: --one=inside
  options: "--one=inside -n"
  filenames: test-onedir.tar.gz
  baseline: |
    mkdir test-onedir
    cd test-onedir
    tar -zxf ../$1

- name: --one=rename
  options: "--one-entry=rename -n"
  filenames: test-onedir.tar.gz
  baseline: |
    tar -zxf $1
    mv test test-onedir

- name: --one=here
  options: "--one=here -n"
  filenames: test-onedir.tar.gz
  baseline: |
    tar -zxf $1

- name: default behavior with one directory (bz2)
  options: -n
  filenames: test-onedir.tar.gz
  baseline: |
    mkdir test-onedir
    cd test-onedir
    tar -zxf ../$1

- name: one directory extracted inside another (bz2)
  options: ""
  filenames: test-onedir.tar.gz
  input: i
  baseline: |
    mkdir test-onedir
    cd test-onedir
    tar -zxf ../$1

- name: one directory extracted with rename (bz2)
  options: ""
  filenames: test-onedir.tar.gz
  input: r
  baseline: |
    tar -zxf $1
    mv test test-onedir

- name: one directory extracted here (bz2)
  options: ""
  filenames: test-onedir.tar.gz
  input: h
  baseline: |
    tar -zxf $1

- name: default behavior with one file
  options: -n
  filenames: test-onefile.tar.gz
  baseline: |
    mkdir test-onefile
    cd test-onefile
    tar -zxf ../$1

- name: one file extracted inside a directory
  options: ""
  filenames: test-onefile.tar.gz
  input: i
  grep: one file
  baseline: |
    mkdir test-onefile
    cd test-onefile
    tar -zxf ../$1

- name: prompt wording with one file
  options: ""
  filenames: test-onefile.tar.gz
  input: i
  grep: file _I_nside

- name: one file extracted with rename, with Expected text
  options: ""
  filenames: test-onefile.tar.gz
  input: r
  grep: "Expected: test-onefile"
  baseline: |
    tar -zxOf $1 >test-onefile

- name: one file extracted here, with Actual text
  options: ""
  filenames: test-onefile.tar.gz
  input: h
  grep: "  Actual: test-text"
  baseline: |
    tar -zxf $1

- name: bomb with preceding dot in the table
  filenames: test-dot-first-bomb.tar.gz
  options: ""
  antigrep: one
  baseline: |
    mkdir test-dot-first-bomb
    cd test-dot-first-bomb
    tar -zxf ../$1

- name: one directory preceded by dot in the table
  filenames: test-dot-first-onedir.tar.gz
  options: ""
  grep: "Actual: (./)?dir/"
  input: h
  baseline: |
    tar -zxf $1

- name: two one-item archives with different answers
  filenames: test-onedir.tar.gz test-onedir.tar.gz
  options: ""
  input: |
    h
    r
  baseline: |
    tar -zxf $1
    mv test test-onedir
    tar -zxf $1

- name: interactive recursion (always)
  filenames: test-recursive-badperms.tar.bz2 test-recursive-badperms.tar.bz2
  options: ""
  input: |
    i
    a
    i
  baseline: |
    extract() {
      mkdir test-recursive-badperms$2
      cd test-recursive-badperms$2
      tar -jxf ../$1
      mkdir test-badperms
      cd test-badperms
      tar -xf ../test-badperms.tar
      chmod 700 testdir
      cd ../..
    }
    extract $1
    extract $1 .1

- name: interactive recursion (once)
  filenames: test-recursive-badperms.tar.bz2 test-recursive-badperms.tar.bz2
  options: ""
  input: |
    i
    o
    i
    n
  baseline: |
    mkdir test-recursive-badperms
    cd test-recursive-badperms
    tar -jxf ../$1
    mkdir test-badperms
    cd test-badperms
    tar -xf ../test-badperms.tar
    chmod 700 testdir
    cd ../..
    mkdir test-recursive-badperms.1
    cd test-recursive-badperms.1
    tar -jxf ../$1

- name: interactive recursion (never)
  filenames: test-recursive-badperms.tar.bz2 test-recursive-badperms.tar.bz2
  options: ""
  input: |
    i
    v
    i
  baseline: |
    extract() {
      mkdir test-recursive-badperms$2
      cd test-recursive-badperms$2
      tar -jxf ../$1
      cd ..
    }
    extract $1
    extract $1 .1

- name: recursion in subdirectories here
  filenames: test-deep-recursion.tar
  options: ""
  input: |
    h
    o
  grep: 'contains 2 other archive file\(s\), out of 2 file\(s\)'
  baseline: |
    tar -xf $1
    cd subdir
    zcat test-text.gz > test-text
    cd subsubdir
    zcat test-text.gz > test-text

- name: recursion in subdirectories with rename
  filenames: test-deep-recursion.tar
  options: ""
  input: |
    r
    o
  grep: "contains 2"
  baseline: |
    tar -xf $1
    mv subdir test-deep-recursion
    cd test-deep-recursion
    zcat test-text.gz > test-text
    cd subsubdir
    zcat test-text.gz > test-text

- name: recursion in subdirectories inside new dir
  filenames: test-deep-recursion.tar
  options: ""
  input: |
    i
    o
  grep: "contains 2"
  baseline: |
    mkdir test-deep-recursion
    cd test-deep-recursion
    tar -xf ../$1
    cd subdir
    zcat test-text.gz > test-text
    cd subsubdir
    zcat test-text.gz > test-text

- name: extracting file with bad extension
  filenames: test-1.23.bin
  prerun: cp ${1}test-1.23.tar.gz ${1}test-1.23.bin
  cleanup: rm -f ${1}test-1.23.bin
  baseline: |
    tar -zxf $1

- name: extracting file with misleading extension
  filenames: trickery.tar.gz
  prerun: cp ${1}test-1.23.zip ${1}trickery.tar.gz
  cleanup: rm -f ${1}trickery.tar.gz
  antigrep: .
  baseline: |
    mkdir trickery
    cd trickery
    unzip -q ../$1

- name: listing file with misleading extension
  options: -l
  filenames: trickery.tar.gz
  prerun: cp ${1}test-1.23.zip ${1}trickery.tar.gz
  cleanup: rm -f ${1}trickery.tar.gz
  grep: "^1/2/3$"
  antigrep: "^dtrx:"

- name: listing multiple file with misleading extensions
  options: -l
  filenames: trickery.tar.gz trickery.tar.gz
  prerun: cp ${1}test-1.23.zip ${1}trickery.tar.gz
  cleanup: rm -f ${1}trickery.tar.gz
  output: |
    trickery.tar.gz:
    1/2/3
    a/b
    foobar
    
    trickery.tar.gz:
    1/2/3
    a/b
    foobar

- name: non-archive error
  filenames: /dev/null
  error: true
  grep: "not a known archive type"

- name: no such file error
  filenames: nonexistent-file.tar.gz
  error: true
  grep: "[Nn]o such file"

- name: no such file error with no extension
  filenames: nonexistent-file
  error: true
  grep: "[Nn]o such file"

- name: try to extract a directory error
  filenames: test-directory
  prerun: mkdir test-directory
  error: true
  grep: "cannot work with a directory"

- name: permission denied error
  filenames: unreadable-file.tar.gz
  prerun: |
    touch unreadable-file.tar.gz
    chmod 000 unreadable-file.tar.gz
  cleanup: rm -f unreadable-file.tar.gz
  error: true
  grep: "[Pp]ermission denied"

- name: permission denied no-pipe file error
  filenames: unreadable-file.zip
  prerun: |
    touch unreadable-file.zip
    chmod 000 unreadable-file.zip
  cleanup: rm -f unreadable-file.zip
  error: true
  grep: "[Pp]ermission denied"

- name: bad file error
  filenames: bogus-file.tar.gz
  prerun: |
    touch bogus-file.tar.gz
  cleanup: rm -f bogus-file.tar.gz
  error: true
  grep: "returned status code [^0]"

- name: try to extract in unwritable directory
  directory: unwritable-dir
  filenames: ../test-1.23.tar.gz
  prerun: chmod 500 .
  error: true
  grep: "cannot extract here: [Pp]ermission denied"

- name: recursive listing is a no-op
  options: -rl
  filenames: test-recursive-badperms.tar.bz2
  grep: test-badperms.tar
  antigrep: testdir/

- name: graceful coping when many extraction directories are taken
  directory: busydir
  prerun: |
    mkdir test-1.23
    for i in $(seq 1 10); do mkdir test-1.23.$i; done
  filenames: ../test-1.23.tar.gz
  grep: "WARNING: extracting"

- name: graceful coping when many decompression targets are taken
  directory: busydir
  prerun: |
    touch test-text
    for i in $(seq 1 10); do touch test-text.$i; done
  filenames: ../test-text.gz
  grep: "WARNING: extracting"

- name: output filenames with -v
  options: -v -n
  filenames: test-onedir.tar.gz test-text.gz
  output: |
    test-onedir.tar.gz:
    test-onedir/
    test-onedir/test/
    test-onedir/test/foobar
    test-onedir/test/quux
    
    test-text.gz:
    test-text

- name: output filenames with -v and -f
  options: -nvf
  directory: busydir
  filenames: ../test-onedir.tar.gz
  output: |
    test/
    test/foobar
    test/quux

- name: list recursive archives
  options: ""
  filenames: test-deep-recursion.tar
  input: |
    r
    l
    n
  grep: '^test-deep-recursion/subsubdir/test-text\.gz$'

- name: partly failed extraction
  options: -n
  filenames: test-tar-with-node.tar.gz
  baseline: |
    mkdir test-tar-with-node
    cd test-tar-with-node
    tar -zxf ../$1
  grep: Cannot mknod

- name: flat extraction of one-file archive
  directory: inside-dir
  options: -f
  filenames: ../test-onefile.tar.gz
  baseline: tar -zxf $1
  antigrep: "contains"

- name: test recursive extraction of one archive
  directory: inside-dir
  options: ""
  filenames: ../test-one-archive.tar.gz
  baseline: |
    tar -zxf $1
    zcat test-text.gz >test-text
  input: |
    h
    o

- name: extracting empty archive
  filenames: test-empty.tar.bz2
  baseline: ""

- name: listing empty archive
  filenames: test-empty.tar.bz2
  options: -l
  antigrep: .