Blame tests/p_tar/10-tar-test.sh

Christoph Galuschka dcd6e0
#!/bin/sh
Christoph Galuschka dcd6e0
# Author: Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka dcd6e0
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
t_Log "Running $0 - tar create and extract archive test."
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
# create dir and two files
Christoph Galuschka dcd6e0
TARDIR='/var/tmp/tar-test'
Christoph Galuschka dcd6e0
FILE1=$TARDIR/file1.txt
Christoph Galuschka dcd6e0
FILE2=$TARDIR/file2.txt
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
mkdir -p $TARDIR
Christoph Galuschka dcd6e0
cat > $FILE1 <
Christoph Galuschka dcd6e0
file #1
Christoph Galuschka dcd6e0
EOF
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
cat > $FILE2 <
Christoph Galuschka dcd6e0
file #2
Christoph Galuschka dcd6e0
EOF
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
# creating archive, remove source-dir
Christoph Galuschka dcd6e0
tar -c $TARDIR -f /var/tmp/tarfile.tar > /dev/null 2>&1
Christoph Galuschka dcd6e0
/bin/rm -rf $TARDIR
Christoph Galuschka dcd6e0
if [ -e $TARDIR ]
Christoph Galuschka dcd6e0
  then
6d1bce
  t_Log "something went wrong with deleting $TARDIR"
Christoph Galuschka dcd6e0
  exit
Christoph Galuschka dcd6e0
fi
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
#reextract from tar
Christoph Galuschka dcd6e0
tar -C / -xf /var/tmp/tarfile.tar
Christoph Galuschka dcd6e0
#checking file contents
Christoph Galuschka dcd6e0
grep -q 'file #1' $FILE1
Christoph Galuschka dcd6e0
RESULT1=$?
Christoph Galuschka dcd6e0
grep -q 'file #2' $FILE2
Christoph Galuschka dcd6e0
RESULT2=$?
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
if ([ $RESULT1 == 0 ] && [ $RESULT2 == 0 ])
Christoph Galuschka dcd6e0
  then 
Christoph Galuschka dcd6e0
  ret_val=0
Christoph Galuschka dcd6e0
fi
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
t_CheckExitStatus $ret_val
Christoph Galuschka dcd6e0
Christoph Galuschka dcd6e0
#reversing changes
Christoph Galuschka dcd6e0
/bin/rm -rf /var/tmp/tarfile.tar $TARDIR