xref: /aosp_15_r20/external/e2fsprogs/tests/r_inline_xattr/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Workerif ! test -x $RESIZE2FS_EXE -o ! -x $DEBUGFS_EXE; then
2*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: skipped (no debugfs/resize2fs)"
3*6a54128fSAndroid Build Coastguard Worker	return 0
4*6a54128fSAndroid Build Coastguard Workerfi
5*6a54128fSAndroid Build Coastguard Worker
6*6a54128fSAndroid Build Coastguard WorkerIMAGE=$test_dir/image.gz
7*6a54128fSAndroid Build Coastguard WorkerFSCK_OPT=-yf
8*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log
9*6a54128fSAndroid Build Coastguard WorkerEXP=$test_dir/expect
10*6a54128fSAndroid Build Coastguard Worker
11*6a54128fSAndroid Build Coastguard Workergunzip < $IMAGE > $TMPFILE
12*6a54128fSAndroid Build Coastguard Worker
13*6a54128fSAndroid Build Coastguard Workerecho "resize2fs test" > $OUT.new
14*6a54128fSAndroid Build Coastguard Worker
15*6a54128fSAndroid Build Coastguard Worker# Look at existing inline extended attribute
16*6a54128fSAndroid Build Coastguard Workerecho "debugfs -R ''stat file'' test.img 2>&1 | grep -E ''^Inode\|in inode body\|user.name \\(''" >> $OUT.new
17*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -R "stat file" $TMPFILE 2>&1 | grep -E "^Inode|in inode body|user.name \(" >> $OUT.new
18*6a54128fSAndroid Build Coastguard Workerstatus=$?
19*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
20*6a54128fSAndroid Build Coastguard Worker
21*6a54128fSAndroid Build Coastguard Worker# resize it
22*6a54128fSAndroid Build Coastguard Workerecho "resize2fs test.img 5M" >> $OUT.new
23*6a54128fSAndroid Build Coastguard Worker$RESIZE2FS $TMPFILE 5M >> $OUT.new 2>&1
24*6a54128fSAndroid Build Coastguard Workerstatus=$?
25*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
26*6a54128fSAndroid Build Coastguard Worker
27*6a54128fSAndroid Build Coastguard Worker# Look at inline extended attribute in resized fs
28*6a54128fSAndroid Build Coastguard Workerecho "debugfs -R ''stat file'' test.img 2>&1 | grep -E ''^Inode\|in inode body\|user.name \\(''" >> $OUT.new
29*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -R "stat file" $TMPFILE 2>&1 | grep -E "^Inode|in inode body|user.name \(" >> $OUT.new
30*6a54128fSAndroid Build Coastguard Workerstatus=$?
31*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
32*6a54128fSAndroid Build Coastguard Worker
33*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed < $OUT.new > $OUT
34*6a54128fSAndroid Build Coastguard Workerrm $TMPFILE $OUT.new
35*6a54128fSAndroid Build Coastguard Worker
36*6a54128fSAndroid Build Coastguard Worker#
37*6a54128fSAndroid Build Coastguard Worker# Do the verification
38*6a54128fSAndroid Build Coastguard Worker#
39*6a54128fSAndroid Build Coastguard Worker
40*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP
41*6a54128fSAndroid Build Coastguard Workerstatus=$?
42*6a54128fSAndroid Build Coastguard Worker
43*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then
44*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
45*6a54128fSAndroid Build Coastguard Worker	touch $test_name.ok
46*6a54128fSAndroid Build Coastguard Workerelse
47*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
48*6a54128fSAndroid Build Coastguard Worker	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
49*6a54128fSAndroid Build Coastguard Workerfi
50*6a54128fSAndroid Build Coastguard Worker
51*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP
52