aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-03-22 12:49:08 -0500
committerRob Landley <rob@landley.net>2019-03-22 12:49:08 -0500
commitdaea408ef11a8df15ae4e99f422351417657e226 (patch)
tree24042970d572d7bc41bd7892a7e92654baf14c1d /tests
parent99cd706b1ad7bdc41658139f04ff30bd87ea7f3e (diff)
downloadtoybox-daea408ef11a8df15ae4e99f422351417657e226.tar.gz
More tar cleanup, add --owner and --group, and start of new tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/tar.test106
1 files changed, 8 insertions, 98 deletions
diff --git a/tests/tar.test b/tests/tar.test
index 50a94e60..31aee386 100644
--- a/tests/tar.test
+++ b/tests/tar.test
@@ -1,104 +1,14 @@
#!/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"
-#Creating dir
-mkdir dir/dir1 -p
-echo "This is testdata" > dir/dir1/file
-testing "tgz - compession, extraction and data validation" "tar -czf dir.tgz dir/ && [ -e dir.tgz ] && echo 'yes'; rm -rf dir; tar -xf dir.tgz && [ -f dir/dir1/file ] && cat dir/dir1/file; rm -rf dir.tgz" "yes\nThis is testdata\n" "" ""
-
-#Creating dir
-mkdir dir/dir1 -p
-echo "This is testdata" > dir/dir1/file
-testing "tar.gz - compession, extraction and data validation" "tar -czf dir.tar.gz dir/ && [ -e dir.tar.gz ] && echo 'yes'; rm -rf dir; tar -xf dir.tar.gz && [ -f dir/dir1/file ] && cat dir/dir1/file; rm -rf dir.tar.gz" "yes\nThis is testdata\n" "" ""
-
-#Creating dir
-mkdir dir/dir1 -p
-echo "This is testdata" > dir/dir1/file
-testing "verbose compression" "tar -cvzf dir.tgz dir/; rm -rf dir.tgz" "dir/\ndir/dir1/\ndir/dir1/file\n" "" ""
-rm -rf dir/
-
-#creating test file
-dd if=/dev/zero of=testFile ibs=4096 obs=4096 count=1000 2>/dev/null
-testing "- compession and extraction of a file" "tar -czf testFile.tgz testFile && [ -e testFile.tgz ] && echo 'yes'; rm -rf testFile; tar -xf testFile.tgz && [ -f testFile ] && echo 'yes'; rm -rf testFile.tgz" "yes\nyes\n" "" ""
-
-#creating empty test file
-touch testFile
-testing "- compession and extraction of a empty file" "tar -czf testFile.tgz testFile && [ -e testFile.tgz ] && echo 'yes'; rm -rf testFile; tar -xf testFile.tgz && [ -f testFile ] && echo 'yes'; rm -rf testFile.tgz" "yes\nyes\n" "" ""
-
-#Creating dir
-mkdir dir/dir1 -p
-touch dir/dir1/file1 dir/dir1/file2 dir/dir1/file3 dir/dir1/file4
-testing "-t option" "tar -czf dir.tar.gz dir/; rm -rf dir; tar -tf dir.tar.gz | sort; rm -rf dir.tar.gz" "dir/\ndir/dir1/\ndir/dir1/file1\ndir/dir1/file2\ndir/dir1/file3\ndir/dir1/file4\n" "" ""
-rm -rf dir/
-
-#Creating nested directory
-mkdir -p dir/dir1 dir/dir2 dir/dir3 dir/dir4
-echo "This is testdata" > dir/dir1/file; echo "Dont exclude me" > dir/dir3/file1 ;
-echo "Exclude me" > dir/dir3/file2 ; echo "YO" > dir/dir4/file1 ; echo "Hello" >dir/dir4/file2; echo "Dont" > dir/dir2/file1
-echo -ne "dir/dir4\ndir/dir3/file2\n" > exclude_file
-testing "create with files excluded : -X" "tar -czf dir.tgz dir/ -X exclude_file ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir3/file1\n" "" ""
-rm -rf exclude_file
-
-#Creating nested directory
-mkdir dir/dir1 -p ; mkdir dir/dir2 ; mkdir dir/dir3 ; mkdir dir/dir4
-echo "This is testdata" > dir/dir1/file
-echo "Dont exclude me" > dir/dir3/file1 ; echo "Exclude me" > dir/dir3/file2 ; echo "YO" > dir/dir4/file1 ; echo "Hello" >dir/dir4/file2; echo "Dont" > dir/dir2/file1
-testing "with pattern --exclude" "tar --exclude=dir/dir3/* -czf dir.tgz dir/ ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir4/\ndir/dir4/file1\ndir/dir4/file2\n" "" ""
-
-#Creating directory to be compressed
-mkdir dir/dir1 -p
-echo "This is testdata" > dir/dir1/file
-mkdir temp
-testing "extract with -C Dir" "tar -czf dir.tgz dir/ ;rm -rf dir ;tar -xf dir.tgz -C temp/ ; [ -e temp/dir ] && echo 'yes' ; rm -rf dir dir.tgz" "yes\n" "" ""
-rm -rf temp
-
-#Creating nested directory
-mkdir dir/dir1 -p ; mkdir dir/dir2 ; mkdir dir/dir3 ; mkdir dir/dir4 ; mkdir temp_dir
-echo "dir1/file" > dir/dir1/file ; echo "temp_dir/file" > temp_dir/file
-echo "dir3/file1" > dir/dir3/file1 ; echo "dir3/file2" > dir/dir3/file2 ; echo "YO" > dir/dir4/file1 ; echo "Hello" >dir/dir4/file2; echo "dir2/file1" > dir/dir2/file1
-echo "temp_dir/file" > exclude_file
-testing "create with extra files/directory included : -T" "tar -czf dir.tgz dir/ -T exclude_file ; rm -rf dir ; tar -tf dir.tgz | sort; rm -rf dir.tgz " "dir/\ndir/dir1/\ndir/dir1/file\ndir/dir2/\ndir/dir2/file1\ndir/dir3/\ndir/dir3/file1\ndir/dir3/file2\ndir/dir4/\ndir/dir4/file1\ndir/dir4/file2\ntemp_dir/file\n" "" ""
-rm -rf exclude_file
-rm -rf temp_dir
-
-#Creating dir
-mkdir dir/dir1 -p
-echo "Inside dir/dir1" > dir/dir1/file ; echo "Hello Inside dir" > dir/file
-testing "extract to STDOUT : -O" " tar -czf dir.tgz dir/ ; rm -rf dir ; tar -xf dir.tgz -O ; [ -e 'Inside dir/dir1/\nHello Inside dir\n' ] && echo 'yes'; rm -rf dir.tgz " "" "" ""
-
-#Creating short filename
-f="filename_with_100_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-echo "This is testdata" > $f
-testing "shortname filename" "tar -cf testFile.tar $f && [ -e testFile.tar ] && echo 'yes'; rm -f $f; tar -xf testFile.tar && [ -f $f ] && cat $f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -f $f" "yes\nThis is testdata\n" "" ""
-
-#Creating long filename
-f="filename_with_101_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-echo "This is testdata" > $f
-testing "longname filename" "tar -cf testFile.tar $f && [ -e testFile.tar ] && echo 'yes'; rm -f $f; tar -xf testFile.tar && [ -f $f ] && cat $f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -f $f" "yes\nThis is testdata\nLongLink\n" "" ""
-
-#Creating long pathname
-d="dirname_with_50_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-f="filename_with_50_chars_xxxxxxxxxxxxxxxxxxxxxxxxxxx"
-mkdir $d
-echo "This is testdata" > $d/$f
-testing "longname pathname" "tar -cf testFile.tar $d/$f && [ -e testFile.tar ] && echo 'yes'; rm -rf $d; tar -xf testFile.tar && [ -f $d/$f ] && cat $d/$f && strings testFile.tar | grep -o LongLink; rm -f testFile.tar; rm -rf $d" "yes\nThis is testdata\nLongLink\n" "" ""
-
-# gzip
-rm -rf d
-mkdir d
-echo "hello world" > d/f
-testing "gzip compression" "tar zcf f d && file f | grep -q gzip && echo y ; rm -rf d ; tar xf f && cat d/f" "y\nhello world\n" "" ""
-testing "gzip decompression" "tar xf $FILES/tar/tar.tgz && cat dir/file" "hello world\n" "" ""
-
-# bzip2
-rm -rf d
-mkdir d
-echo "hello world" > d/f
-testing "bzip2 compression" "tar jcf f d && file f | grep -q bzip2 && echo y ; rm -rf d ; tar xf f && cat d/f" "y\nhello world\n" "" ""
-testing "bzip2 decompression" "tar xf $FILES/tar/tar.tbz2 && cat dir/file" "hello world\n" "" ""
+TARSUM='--owner root --group root | head -c $((3*512)) | sha1sum | sed "s/ .*//"'
+touch -t 198001010101 file
+testing "create file" "tar c file $TARSUM" \
+ "d551292408833aa5e9db32c0d14d7f32e7e96882\n" "" ""
+mkdir walrus
+touch -t 198001010101 dir
+testing "create dir" "tar c dir $TARSUM" \
+ "c4e630d9c89f4f20d603a6f71ff4410ab56fe965\n" "" ""