case1 1018 Bytes
#!/bin/bash

## 1 -- which file, say cert.sys
## 2 -- valid file length
## 3 -- which command

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

#
# Test 1: Add file 
#         
echo "Test (1) Add $1"
cp ./$TESTFILE bkup.$$
st=$(($RANDOM % 256))
dd if=common/rdata of=tmp.$$ bs=1 count=16384 skip=$st >$OUTPUT 2>&1
emsh << END_OF_FILE >out1.$$ 2>err1.$$
u ./$TESTFILE
B
F
A
P$2 tmp.$$
END_OF_FILE

check_log 1 out
check_log 1 err

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

exit 0