aboutsummaryrefslogtreecommitdiff
path: root/tests/zcat.test
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-04-24 13:29:30 -0700
committerRob Landley <rob@landley.net>2018-01-09 11:15:58 -0600
commit36beb6ac93362790ba6633f56109cde5f01d20c4 (patch)
treed62e28956c9d75bdd1fff75dae9e004307038ef5 /tests/zcat.test
parentb432aee484bfca4d53cdce13343e6ee5c850d0f3 (diff)
downloadtoybox-36beb6ac93362790ba6633f56109cde5f01d20c4.tar.gz
Add the gzip/gunzip/zcat tests I wrote for toolbox gzip/gunzip/zcat.
Bringing the zlib-based gzip/gunzip/zcat over to toybox is a problem for another day, but at least the tests are easy... (These tests pass with TEST_HOST and on the toolbox versions, but the toybox toys are in pending and very broken.)
Diffstat (limited to 'tests/zcat.test')
-rw-r--r--[-rwxr-xr-x]tests/zcat.test34
1 files changed, 14 insertions, 20 deletions
diff --git a/tests/zcat.test b/tests/zcat.test
index ccd472cd..57af1097 100755..100644
--- a/tests/zcat.test
+++ b/tests/zcat.test
@@ -1,26 +1,20 @@
#!/bin/bash
-# Copyright 2014 Divya Kothari <divya.s.kothari@gmail.com>
-# Copyright 2014 Naha Maggu <maggu.neha@gmail.com>
-
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
-echo "hello" > file
-tar -czf file.gz file
-# Get system zcat
-zcatExe=`which zcat`
-$zcatExe file.gz > zcatOut
-testing "- decompresses a single file" "zcat file.gz > Tempfile && echo "yes"; diff Tempfile zcatOut && echo "yes"; rm -rf file* zcatOut Tempfile" "yes\nyes\n" "" ""
-#testing "name" "command" "result" "infile" "stdin"
-echo "hello" > file1
-echo "hi" > file2
-echo "Hi, Good morning !! I am a bzcat tester" > file3
-tar -czf file1.gz file1
-tar -czf file2.gz file2
-tar -czf file3.gz file3
-# Get system zcat
-zcatExe=`which zcat`
-$zcatExe file1.gz file2.gz file3.gz > zcatOut
-testing "- decompresses multiple files" "zcat file1.gz file2.gz file3.gz > Tempfile && echo "yes" ; diff Tempfile zcatOut && echo "yes"; rm -rf file* zcatOut Tempfile " "yes\nyes\n" "" ""
+echo -n "foo " | gzip > f1.gz
+echo "bar" | gzip > f2.gz
+
+# zcat is basically just `gzip -dc`...
+testing "files" "zcat f1.gz f2.gz && test -f f1.gz && test -f f2.gz" \
+ "foo bar\n" "" ""
+
+# zcat -c is allowed, but the -c changes nothing.
+testing "-c" "zcat -c f1.gz f2.gz && test -f f1.gz && test -f f2.gz" \
+ "foo bar\n" "" ""
+
+# TODO: how to test "zcat -f"?
+
+rm -f f1 f2 f1.gz f2.gz