diff --git a/tests/p_bzip2/0_install_bzip2.sh b/tests/p_bzip2/0_install_bzip2.sh new file mode 100755 index 0000000..6f560ef --- /dev/null +++ b/tests/p_bzip2/0_install_bzip2.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - attempting to install bzip2." +t_InstallPackage bzip2 + diff --git a/tests/p_bzip2/10-bzip2-test.sh b/tests/p_bzip2/10-bzip2-test.sh new file mode 100755 index 0000000..b9f5e16 --- /dev/null +++ b/tests/p_bzip2/10-bzip2-test.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Author: Athmane Madjoudj <athmanem@gmail.com> +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - run a file through bzip2,bzcat and bunzip2 test." + +# create file +FILE=/var/tmp/bzip2-test.txt + +cat > $FILE <<EOF +bzip2-test of single file +EOF + +# run file through bzip2 +bzip2 $FILE +#just to make shure +/bin/rm -rf $FILE + +#run file through bzcat +bzcat $FILE.bz2 | grep -q 'bzip2-test of single file' +if [ $? == 1 ] + then + t_Log 'bzcat failed' + exit +fi + +#run file through bunzip2 +bunzip2 $FILE.bz2 + +#checking file contents +grep -q 'bzip2-test of single file' $FILE + +t_CheckExitStatus $? + +#reversing changes +/bin/rm -rf $FILE* diff --git a/tests/p_gzip/0_install_gzip.sh b/tests/p_gzip/0_install_gzip.sh new file mode 100755 index 0000000..a73d659 --- /dev/null +++ b/tests/p_gzip/0_install_gzip.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - attempting to install gzip." +t_InstallPackage gzip + diff --git a/tests/p_gzip/10-gzip-test.sh b/tests/p_gzip/10-gzip-test.sh new file mode 100755 index 0000000..89fe1bb --- /dev/null +++ b/tests/p_gzip/10-gzip-test.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Author: Athmane Madjoudj <athmanem@gmail.com> +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - run a file through gzip,zcat and gunzip test." + +# create file +FILE=/var/tmp/gzip-test.txt + +cat > $FILE <<EOF +gzip-test of single file +EOF + +# run file through gzip +gzip $FILE +#just to make shure +/bin/rm -rf $FILE + +#run file through zcat +zcat $FILE.gz | grep -q 'gzip-test of single file' +if [ $? == 1 ] + then + t_Log 'zcat failed' + exit +fi + + +#run file through gunzip +gunzip $FILE.gz + +#checking file contents +grep -q 'gzip-test of single file' $FILE + +t_CheckExitStatus $? + +#reversing changes +/bin/rm -rf $FILE* diff --git a/tests/p_zip/0_install_zip.sh b/tests/p_zip/0_install_zip.sh new file mode 100755 index 0000000..bfe2c8d --- /dev/null +++ b/tests/p_zip/0_install_zip.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - attempting to install zip." +t_InstallPackage zip + diff --git a/tests/p_zip/10-zip-test.sh b/tests/p_zip/10-zip-test.sh new file mode 100755 index 0000000..b00b6bc --- /dev/null +++ b/tests/p_zip/10-zip-test.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Author: Athmane Madjoudj <athmanem@gmail.com> +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - zip create and extract archive test." + +# create dir and two files +ZIPDIR='/var/tmp/zip-test' +FILE1=$ZIPDIR/file1.txt +FILE2=$ZIPDIR/file2.txt + +mkdir -p $ZIPDIR +cat > $FILE1 <<EOF +file #1 +EOF + +cat > $FILE2 <<EOF +file #2 +EOF + +# creating archive, remove source-dir +zip -q /var/tmp/testfile.zip $ZIPDIR/* +/bin/rm -rf $ZIPDIR +if [ -e $ZIPDIR ] + then + t_log "something went wrong with deleting $ZIPDIR" + exit +fi + +#reextract from zip +unzip -q /var/tmp/testfile.zip -d / +#checking file contents +grep -q 'file #1' $FILE1 +RESULT1=$? +grep -q 'file #2' $FILE2 +RESULT2=$? + +if ([ $RESULT1 == 0 ] && [ $RESULT2 == 0 ]) + then + ret_val=0 +fi + +t_CheckExitStatus $ret_val + +#reversing changes +/bin/rm -rf /var/tmp/testfile.zip $ZIPDIR