cpio/large-files-exit-code/runtest.sh
Ondrej Dubaj 97ae451a0c Added new tests for CI in Fedora
Added fmf metadata for executing tests with tmt
2021-03-03 08:38:37 +01:00

154 lines
3.5 KiB
Bash
Executable file

#! /bin/bash
# File: runtest.sh
# RHTS test for bugs 183224, 172865
# Description: with files >= 4GB, "cpio -o..." gives 0 exit code
# even though file isn't stored completely
# source the test script helpers
. /usr/bin/rhts_environment.sh
# feel free to change as needed
OUTPUTFILE=`mktemp /mnt/testarea/large-files-exit-code.log.XXXXX`
# ----- Start test -----
exec >> "${OUTPUTFILE}" 2>&1
# tests functionality of cpio against bug
# params: @ $1 format
# @ $2 size in MB
# @ $3 expected exit code
#
cpioTest()
{
echo "-------------------------------------------------------"
echo "test $TESTNUM"
echo
echo $TESTFILE | /bin/cpio -o -H $1 > $TESTCPIO
EXITCODE=$?
if [ $EXITCODE -ne $3 ] ; then
echo "+ exitcode of '/bin/cpio -o -H $1' > $TESTCPIO was $EXITCODE"
echo "+ expected was $3"
echo "*** Create problem "
echo "--- Format \"$1\" size $2"
echo
let "score += 1" # increment number of failures
fi
if [ $3 -eq 1 ] ; then
echo "*** Nothing to extract. Skipping '/bin/cpio -iv < $TESTCPIO'"
echo
let "TESTNUM += 1"
return;
fi
rm $TESTFILE
/bin/cpio -iv < $TESTCPIO
EXITCODE=$?
if [ $EXITCODE -eq 1 ] ; then
echo "++ exitcode of '/bin/cpio -iv < $TESTCPIO' was $EXITCODE"
echo "*** Extract problem"
echo "--- Format \"$1\" size $2"
echo
let "score += 1" # increment number of failures
fi
let "TESTNUM += 1"
}
chck_disk_space ()
{
#TODO add checking for available disk free space....
echo "----- disk usage -----"
df -hlP
echo "----- folder size -----"
du -h ./
echo "-----------------------"
}
result=FAIL
score=0
TESTNUM=1
TOTALTESTNUM=16
TESTFILE="cpio-testfile"
TESTCPIO="$TESTFILE.cpio"
echo "===== Start test =============================="
echo "Testing cpio bugs 183224, 172865"
echo "Log: $OUTPUTFILE"
date
uname -a
echo
echo
size=5
echo "===== Checking small("$size"MB) file ================"
dd if=/dev/zero of="$TESTFILE" bs=1M count=$size
cpioTest bin $size 0
cpioTest odc $size 0
cpioTest newc $size 0
cpioTest crc $size 0
echo
size=3075
echo "===== Checking big("$size"MB) file ==============="
dd if=/dev/zero of="$TESTFILE" bs=1M count=$size
cpioTest bin $size 0
cpioTest odc $size 0
cpioTest newc $size 0
cpioTest crc $size 0
echo
size=6075
echo "===== Checking extra big("$size"MB) file ========="
dd if=/dev/zero of="$TESTFILE" bs=1M count=$size
cpioTest bin $size 1
cpioTest newc $size 1
cpioTest crc $size 1
cpioTest odc $size 0
echo
size=9075
echo "===== Checking extra big("$size"MB) file ========="
dd if=/dev/zero of="$TESTFILE" bs=1M count=$size
cpioTest bin $size 1
cpioTest newc $size 1
cpioTest crc $size 1
cpioTest odc $size 1
echo
echo "==============================================="
echo
rm $TESTCPIO
rm $TESTFILE
# ----- End test -----
if [ $score -eq 0 ] ; then
result=PASS
fi
# check if all tests were run
let "TESTNUM -= 1"
if [ $TESTNUM -ne $TOTALTESTNUM ] ; then
result=FAIL
echo "Not all tests were run. Premature interruption?"
fi
echo "===== Summary ================================="
echo "Total # of testcases run: $TESTNUM"
echo "Expected # of testcases: $TOTALTESTNUM"
echo "Result: $result"
echo
# ----- Report results -----
echo "-----------------------------------------------"
echo "Test:$TEST Result:$result Score:$score"
echo
report_result $TEST $result $score