Blame tests/p_zip/10-zip-test.sh
|
Christoph Galuschka |
4fdfe1 |
#!/bin/sh
|
|
Christoph Galuschka |
4fdfe1 |
# Author: Athmane Madjoudj <athmanem@gmail.com>
|
|
Christoph Galuschka |
4fdfe1 |
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
t_Log "Running $0 - zip create and extract archive test."
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
# create dir and two files
|
|
Christoph Galuschka |
4fdfe1 |
ZIPDIR='/var/tmp/zip-test'
|
|
Christoph Galuschka |
4fdfe1 |
FILE1=$ZIPDIR/file1.txt
|
|
Christoph Galuschka |
4fdfe1 |
FILE2=$ZIPDIR/file2.txt
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
mkdir -p $ZIPDIR
|
|
Christoph Galuschka |
4fdfe1 |
cat > $FILE1 <
|
|
Athmane Madjoudj |
907a39 |
file 1
|
|
Christoph Galuschka |
4fdfe1 |
EOF
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
cat > $FILE2 <
|
|
Athmane Madjoudj |
907a39 |
file 2
|
|
Christoph Galuschka |
4fdfe1 |
EOF
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
# creating archive, remove source-dir
|
|
Christoph Galuschka |
4fdfe1 |
zip -q /var/tmp/testfile.zip $ZIPDIR/*
|
|
Christoph Galuschka |
4fdfe1 |
/bin/rm -rf $ZIPDIR
|
|
Christoph Galuschka |
4fdfe1 |
if [ -e $ZIPDIR ]
|
|
Christoph Galuschka |
4fdfe1 |
then
|
|
|
6d1bce |
t_Log "something went wrong with deleting $ZIPDIR"
|
|
Christoph Galuschka |
4fdfe1 |
exit
|
|
Christoph Galuschka |
4fdfe1 |
fi
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
#reextract from zip
|
|
Christoph Galuschka |
4fdfe1 |
unzip -q /var/tmp/testfile.zip -d /
|
|
Christoph Galuschka |
4fdfe1 |
#checking file contents
|
|
Athmane Madjoudj |
907a39 |
grep -q 'file 1' $FILE1
|
|
Christoph Galuschka |
4fdfe1 |
RESULT1=$?
|
|
Athmane Madjoudj |
907a39 |
grep -q 'file 2' $FILE2
|
|
Christoph Galuschka |
4fdfe1 |
RESULT2=$?
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
if ([ $RESULT1 == 0 ] && [ $RESULT2 == 0 ])
|
|
Christoph Galuschka |
4fdfe1 |
then
|
|
Christoph Galuschka |
4fdfe1 |
ret_val=0
|
|
Christoph Galuschka |
4fdfe1 |
fi
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
t_CheckExitStatus $ret_val
|
|
Christoph Galuschka |
4fdfe1 |
|
|
Christoph Galuschka |
4fdfe1 |
#reversing changes
|
|
Christoph Galuschka |
4fdfe1 |
/bin/rm -rf /var/tmp/testfile.zip $ZIPDIR
|