testmfs, testisofs: MFS format, ISO functionality

testmfs: catch MFS format changes

This test tests mkfs.mfs will generate the same FS image given the same
input files. mkproto creates a proto file (normalizing directory entry
order). The assumption is that a change in the output flags a tacit
change in FS format, and that a FS format change will cause the image
to change.

        . Changes to mkfs.mfs that innocently change the format can
          change the sha1 output in the script along with it.
        . The assumption is that corresponding versions of mkfs.mfs and
          MFS will always work together; otherwise a lot breaks (ramdisk etc.)
        . Therefore, as long as a generated FS image stays the same with the
          same input now, incompatible MFS changes will still be flagged,
          even if they work together with the current mkfs.mfs.

testisofs: test ISO filesystem

        . to test isofs: prepare an ISO FS image using writeisofs, copy it
          to a RAM device, mount it using the iso9660fs server, compare the
          SHA1 contents of the files on the ISO with the inputs.
        . use su to run certain commands in the script as root

run script: run shell script tests

	. they are installed without .sh so should be
	  searched for as such
	. add diagnostic when tests are skipped

Change-Id: I30daff58e1e43903dacf3c99996a4a0e7d819b6b
This commit is contained in:
Ben Gras 2013-11-19 16:01:23 +00:00
parent 740c1a7425
commit d3e3c78051
4 changed files with 155 additions and 2 deletions

View file

@ -74,7 +74,7 @@ PROGS+= test${t}
PROGS+= t10a t11a t11b t40a t40b t40c t40d t40e t40f t60a t60b \
t67a t67b t68a t68b
SCRIPTS+= run testinterp.sh testsh1.sh testsh2.sh
SCRIPTS+= run testinterp.sh testsh1.sh testsh2.sh testmfs.sh testisofs.sh
.if ${MKPIC} == "yes"
# Build them as dynamic executables by default if shared libraries

View file

@ -25,7 +25,7 @@ alltests=" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
61 62 63 64 65 66 67 68 69 70 71 72 75 \
sh1.sh sh2.sh interp.sh"
sh1 sh2 interp mfs isofs"
tests_no=`expr 0`
# test mmap only if enabled in sysenv
@ -147,6 +147,7 @@ do
rm -f $out
fi
else
echo "${diagprefix}warning: skipping test$i"
skipped=`expr $skipped + 1`
fi
done

67
test/testisofs.sh Normal file
View file

@ -0,0 +1,67 @@
# Create and verify a simple ISO filesystem
#
#!/bin/sh
set -e
echo -n "isofs test "
ramdev=/dev/ram
mp=/mnt
testdir=isofstest
fsimage=isofsimage
contents=CONTENTS
out1=v1
out2=v2
rm -rf $testdir $fsimage $out1 $out2
if [ -d $testdir ]
then
echo "dir?"
exit 1
fi
mkdir -p $testdir $testdir/$contents
if [ ! -d $testdir ]
then
echo "no dir?"
exit 1
fi
# Make some small & big & bigger files
prevf=$testdir/$contents/FILE
echo "Test contents 123" >$prevf
for double in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do fn=$testdir/$contents/FN.$double
cat $prevf $prevf >$fn
prevf=$fn
done
# Make an ISO filesystem image out of it
writeisofs -s0x0 -l MINIX $testdir $fsimage >/dev/null 2>&1
# umount previous things
su root -c "umount $ramdev >/dev/null 2>&1 || true"
su root -c "umount $mp >/dev/null 2>&1 || true"
# Mount it on a RAM disk
su root -c "ramdisk 50000 $ramdev >/dev/null 2>&1"
su root -c "cp $fsimage $ramdev"
su root -c "mount -t isofs $ramdev $mp >/dev/null 2>&1"
# compare contents
(cd $testdir/$contents && sha1 * | sort) >$out1
(cd $mp/$contents && sha1 * | sort) >$out2
diff -u $out1 $out2
su root -c "umount $ramdev >/dev/null 2>&1"
# cleanup
rm -rf $testdir $fsimage $out1 $out2
echo ok
exit 0

85
test/testmfs.sh Executable file
View file

@ -0,0 +1,85 @@
#!/bin/sh
# expected sha1sum of the FS image
expect=55d61f457204c206628c848771a1f9d75cfa3afa
set -e
# ownership matters for the proto file.
# the run script runs us with uid 2, gid 0.
if [ "`id -u`" != 2 -o "`id -g`" != 0 ]
then
echo "test script should be run with uid 2, gid 0."
exit 1
fi
echo -n "mfs test "
testdir=fstest
protofile=proto
fsimage=fsimage
rm -rf $testdir $protofile $fsimage
if [ -d $testdir ]
then
echo "dir?"
exit 1
fi
mkdir -p $testdir $testdir/contents $testdir/modes
if [ ! -d $testdir ]
then
echo "no dir?"
exit 1
fi
# Make some small & big & bigger files
prevf=$testdir/contents/file
echo "Test contents 123" >$prevf
for double in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do fn=$testdir/contents/fn.$double
cat $prevf $prevf >$fn
prevf=$fn
done
# Make some files with various modes & mtimes
for many in 0 1 2 3 4 5 6 7 8 9
do for m1 in 0 1 2 3 4 5 6 7
do for m2 in 0 1 2 3 4 5 6 7
do for m3 in 0 1 2 3 4 5 6 7
do
mode=${m1}${m2}${m3}
fn=$testdir/modes/m${mode}${many}
echo "$many $m1 $m2 $m3 $mode" > $fn
chmod $mode $fn
done
done
done
done
# Make an MFS filesystem image out of it
BS=4096
BLOCKS=15000
INODES=6000
dd if=/dev/zero seek=$BLOCKS of=$fsimage count=1 bs=$BS >/dev/null 2>&1
# -s keeps modes
mkproto -s -b $BLOCKS -i $INODES $testdir >$protofile
mkfs.mfs -T 1 -b $BLOCKS -i $INODES $fsimage $protofile >/dev/null 2>&1
sum="`sha1 $fsimage | awk '{ print $4 }'`"
if [ $sum != $expect ]
then
echo sum $sum is not expected $expect
exit 1
fi
echo ok
exit 0