case5 987 Bytes
#!/bin/bash 

TESTFILE=testfile.$$

./mkcart > $TESTFILE
. ./testlib.sh

export BBC_BAD_BLKS=
export BBC_READ_DBE_BLKS=
export BBC_WRITE_ERR_BLKS=

#
# Test 5: Add file and Read back
#         
echo "Test (5) Add $1 and Read back"
cp ./$TESTFILE bkup.$$
sk=$(($RANDOM % 256))
dd if=common/rdata of=tmp1.$$ bs=1 count=16384 skip=$sk >$OUTPUT 2>&1
emsh << END_OF_FILE >out5.$$ 2>err5.$$
u ./$TESTFILE
B
F
A
P$2 tmp1.$$
G$2 tmp_bk.$$
END_OF_FILE

check_log 5 out
check_log 5 err

#### check cert.sys was write to blk 4079 #####
sk=$((4079 * 16400))
diff tmp1.$$ tmp_bk.$$ >$OUTPUT 2>&1 || {
    echo "Test (5) Failed: wrong $1 "
    cp ./$TESTFILE data
    exit
}
sz=4079
check_unchange bkup.$$ ./$TESTFILE 0 $sz "input" "result"
gzip  -d -c Golden/$TESTID/fat5.gz > out.$$
sz=$((4080 * 16400))
dd if=./$TESTFILE of=tmp.$$ skip=$sz bs=1 >$OUTPUT 2>&1
if ! cmp tmp.$$ out.$$; then
    echo "Failed fat does not match"
    exit
fi
rm -rf  ./$TESTFILE err5.$$ out.$$ tmp*.$$  bkup.$$ 

exit 0