changeset 1457:d9e937417636 draft

Testsuites for toybox command - "tar", "bzcat", "xzcat", "zcat" and "hostname".
author Divya Kothari <divya.s.kothari@gmail.com>
date Wed, 03 Sep 2014 13:38:18 -0500
parents 5d51c5d6df72
children 4428d64c0c40
files scripts/test/bzcat.test scripts/test/hostname.test scripts/test/tar.test scripts/test/xzcat.test scripts/test/zcat.test
diffstat 5 files changed, 169 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/test/bzcat.test	Wed Sep 03 13:38:18 2014 -0500
@@ -0,0 +1,26 @@
+#!/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 -cjf file.tar.bz2 file
+# Get system bzcat
+bzcatExe=`which bzcat`
+$bzcatExe file.tar.bz2 > bzcatOut
+testing "bzcat - decompresses a single file" "bzcat file.tar.bz2 > Tempfile && echo "yes"; diff Tempfile bzcatOut && echo "yes"; rm -rf file* bzcatOut 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 -cjf file1.tar.bz2 file1
+tar -cjf file2.tar.bz2 file2
+tar -cjf file3.tar.bz2 file3
+# Get system bzcat
+bzcatExe=`which bzcat`
+$bzcatExe file1.tar.bz2 file2.tar.bz2 file3.tar.bz2 > bzcatOut
+testing "bzcat - decompresses multiple files" "bzcat file1.tar.bz2 file2.tar.bz2 file3.tar.bz2 > Tempfile && echo "yes" ; diff Tempfile bzcatOut && echo "yes"; rm -rf file* bzcatOut Tempfile " "yes\nyes\n" "" ""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/test/hostname.test	Wed Sep 03 13:38:18 2014 -0500
@@ -0,0 +1,18 @@
+#!/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"
+
+# Get system hostname
+hostnameExe=`which hostname`
+hostnameOut=`$hostnameExe`
+
+# New hostname
+NewHostname="NewHostName.system"
+
+testing "Hostname - Get" "hostname" "$hostnameOut\n" "" ""
+testing "Hostname - Set, Get and then Reset" "hostname $NewHostname; hostname; hostname $hostnameOut; hostname" "$NewHostname\n$hostnameOut\n" "" ""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/test/tar.test	Wed Sep 03 13:38:18 2014 -0500
@@ -0,0 +1,73 @@
+#!/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 "tar 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 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 "tar 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 "tar - 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 "tar - 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 "tar -t option" "tar -czf dir.tar.gz dir/; rm -rf dir; tar -tf dir.tar.gz; rm -rf dir.tar.gz" "dir/\ndir/dir1/\ndir/dir1/file2\ndir/dir1/file4\ndir/dir1/file3\ndir/dir1/file1\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 "dir/dir4\ndir/dir3/file2" > exclude_file
+testing "Creating tar with files excluded : -X" "tar -cvzf dir.tgz dir/ -X exclude_file ; rm -rf dir ; tar -tf dir.tgz; rm -rf dir.tgz " "dir/\ndir/dir2/\ndir/dir2/file1\ndir/dir1/\ndir/dir1/file\ndir/dir3/\ndir/dir3/file1\ndir/\ndir/dir2/\ndir/dir2/file1\ndir/dir1/\ndir/dir1/file\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 "tar with pattern --exclude" "tar --exclude=dir/dir3/* -cvzf dir.tgz dir/ ; rm -rf dir ; tar -tf dir.tgz; rm -rf dir.tgz " "dir/\ndir/dir2/\ndir/dir2/file1\ndir/dir1/\ndir/dir1/file\ndir/dir3/\ndir/dir4/\ndir/dir4/file2\ndir/dir4/file1\ndir/\ndir/dir2/\ndir/dir2/file1\ndir/dir1/\ndir/dir1/file\ndir/dir3/\ndir/dir4/\ndir/dir4/file2\ndir/dir4/file1\n" "" ""
+
+#Creating directory to be compressed
+mkdir dir/dir1 -p
+echo "This is testdata" > dir/dir1/file
+mkdir temp
+testing "Extraction 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 "Creating tar extra files/directory included : -T" "tar -czf dir.tgz dir/ -T exclude_file ; rm -rf dir ; tar -tf dir.tgz; rm -rf dir.tgz " "dir/\ndir/dir2/\ndir/dir2/file1\ndir/dir1/\ndir/dir1/file\ndir/dir3/\ndir/dir3/file2\ndir/dir3/file1\ndir/dir4/\ndir/dir4/file2\ndir/dir4/file1\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 "Exctraction on 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 "  "" "" ""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/test/xzcat.test	Wed Sep 03 13:38:18 2014 -0500
@@ -0,0 +1,26 @@
+#!/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 -cJf file.xz file
+# Get system xzcat
+xzcatExe=`which xzcat`
+$xzcatExe file.xz > xzcatOut
+testing "xzcat - decompresses a single file" "xzcat file.xz > Tempfile && echo "yes"; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile" "yes\nyes\n" "" ""
+
+#testing "name" "command" "result" "infile" "stdin"
+echo "hello" > file1
+echo "hi" > file2
+echo "Hi, Good morning !! I am a xzcat tester" > file3
+tar -cJf file1.xz file1
+tar -cJf file2.xz file2
+tar -cJf file3.xz file3
+# Get system xzcat
+xzcatExe=`which xzcat`
+$xzcatExe file1.xz file2.xz file3.xz > xzcatOut
+testing "xzcat - decompresses multiple files" "xzcat file1.xz file2.xz file3.xz > Tempfile && echo "yes" ; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile " "yes\nyes\n" "" ""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/test/zcat.test	Wed Sep 03 13:38:18 2014 -0500
@@ -0,0 +1,26 @@
+#!/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 "zcat - 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 "zcat - 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" "" ""