1*6a54128fSAndroid Build Coastguard Worker#!/bin/sh 2*6a54128fSAndroid Build Coastguard Worker 3*6a54128fSAndroid Build Coastguard WorkerTDIR=${AUTOPKGTEST_TMP:-/tmp/fuse_dir} 4*6a54128fSAndroid Build Coastguard WorkerLOGDIR=${AUTOPKGTEST_ARTIFACTS:-/tmp/fuse_dir_log} 5*6a54128fSAndroid Build Coastguard WorkerIMG=$TDIR/test-image.img 6*6a54128fSAndroid Build Coastguard WorkerMNT=$TDIR/mnt 7*6a54128fSAndroid Build Coastguard Worker 8*6a54128fSAndroid Build Coastguard Worker# some autopkgtest environments may not have /etc/mtab and/or /proc/mounts 9*6a54128fSAndroid Build Coastguard WorkerEXT2FS_NO_MTAB_OK=yes 10*6a54128fSAndroid Build Coastguard Workerexport EXT2FS_NO_MTAB_OK 11*6a54128fSAndroid Build Coastguard Worker 12*6a54128fSAndroid Build Coastguard Workermkdir -p $LOGDIR $TDIR $MNT 13*6a54128fSAndroid Build Coastguard Worker 14*6a54128fSAndroid Build Coastguard Worker/sbin/mke2fs -E root_owner -q -t ext4 -d e2fsck $IMG 8M 15*6a54128fSAndroid Build Coastguard Worker/sbin/e2label $IMG test 16*6a54128fSAndroid Build Coastguard Workerfuse2fs $IMG $MNT > $LOGDIR/fuse2fs.log 2>&1 17*6a54128fSAndroid Build Coastguard Workerif test $? -ne 0 ; then 18*6a54128fSAndroid Build Coastguard Worker echo "fuse2fs failed; see $LOGDIR/fuse2fs.log" 19*6a54128fSAndroid Build Coastguard Worker exit 1 20*6a54128fSAndroid Build Coastguard Workerfi 21*6a54128fSAndroid Build Coastguard Workerdiff e2fsck/pass1.c $MNT/pass1.c 22*6a54128fSAndroid Build Coastguard Workerecho foobar > $MNT/testfile 23*6a54128fSAndroid Build Coastguard Workerfusermount -u $MNT > $LOGDIR/fusermount.log 2>&1 24*6a54128fSAndroid Build Coastguard Workerif test $? -ne 0 ; then 25*6a54128fSAndroid Build Coastguard Worker echo "fusermount failed; see $LOGDIR/fusermount.log" 26*6a54128fSAndroid Build Coastguard Worker exit 1 27*6a54128fSAndroid Build Coastguard Workerfi 28*6a54128fSAndroid Build Coastguard Worker/sbin/e2fsck -fy $IMG > $LOGDIR/e2fsck.log 2>&1 29*6a54128fSAndroid Build Coastguard Workerif test $? -ne 0 ; then 30*6a54128fSAndroid Build Coastguard Worker echo "e2fsck failed; see $LOGDIR/e2fsck.log" 31*6a54128fSAndroid Build Coastguard Worker exit 1 32*6a54128fSAndroid Build Coastguard Workerfi 33*6a54128fSAndroid Build Coastguard Workercontents=$(/sbin/debugfs -R "cat testfile" $IMG 2> $LOGDIR/debugfs.log) 34*6a54128fSAndroid Build Coastguard Workerif test "$contents" != foobar ; then 35*6a54128fSAndroid Build Coastguard Worker echo "testfile does not contain expected output" 36*6a54128fSAndroid Build Coastguard Worker exit 1 37*6a54128fSAndroid Build Coastguard Workerfi 38