78 lines
1.4 KiB
Bash
Executable File
78 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/sh
|
|
WORK=$(/usr/bin/mktemp -d /tmp/sqfs.XXXXXXXX)
|
|
SRC=$WORK/src/
|
|
MNT=$WORK/mnt/
|
|
UNSQ=$WORK/unsq/
|
|
SQSH=$WORK/squash.sqsh
|
|
DIFF1=$WORK/sqfs_mnt.diff
|
|
DIFF2=$WORK/unsqfs.diff
|
|
MKSQ_OUT=$WORK/mksquashfs.out
|
|
UNSQ_OUT=$WORK/unsquashfs.out
|
|
|
|
/usr/bin/mkdir $SRC $MNT
|
|
if [ $? -ne 0 ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
# Copy over src files
|
|
/usr/bin/cp -R /etc/* $SRC
|
|
if [ $? -ne 0 ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
/usr/sbin/modprobe squashfs
|
|
if [ $? -ne 0 ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
/usr/sbin/mksquashfs $SRC $SQSH > $MKSQ_OUT 2>&1
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "mksquashfs failed: See $MKSQ_OUT"
|
|
exit 1
|
|
fi
|
|
|
|
/usr/bin/mount $SQSH $MNT -t squashfs -o loop
|
|
if [ $? -ne 0 ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
/usr/bin/diff -Nupr --no-dereference $SRC $MNT > $DIFF1 2>&1
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "Squashfs mount inconsistent with source"
|
|
echo "Test directory: $WORK"
|
|
exit 1
|
|
fi
|
|
|
|
/usr/bin/umount $MNT
|
|
if [ $? -ne 0 ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
echo "Test succeeded 1/2: Squashfs filesystem consistent with source"
|
|
|
|
/usr/sbin/unsquashfs -d $UNSQ $SQSH > $UNSQ_OUT 2>&1
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "unsquashfs failed: See $UNSQ_OUT"
|
|
exit 1
|
|
fi
|
|
|
|
/usr/bin/diff -Nupr --no-dereference $SRC $UNSQ > $DIFF2 2>&1
|
|
if [ $? -ne 0 ]
|
|
then
|
|
echo "Unsquashfs extracted output inconsistent with source"
|
|
echo "Test directory: $WORK"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Test succeeded 2/2: Unsquashfs extracted output consistent with source"
|
|
|
|
/usr/bin/rm -Rf $WORK
|