From 36beb6ac93362790ba6633f56109cde5f01d20c4 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 24 Apr 2017 13:29:30 -0700 Subject: 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.) --- tests/zcat.test | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) mode change 100755 => 100644 tests/zcat.test (limited to 'tests/zcat.test') diff --git a/tests/zcat.test b/tests/zcat.test old mode 100755 new mode 100644 index ccd472cd..57af1097 --- a/tests/zcat.test +++ b/tests/zcat.test @@ -1,26 +1,20 @@ #!/bin/bash -# Copyright 2014 Divya Kothari -# Copyright 2014 Naha Maggu - [ -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 -- cgit v1.2.3