if test -x $DEBUGFS_EXE; then

OUT=$test_name.log
EXP=$test_dir/expect
VERIFY_FSCK_OPT=-yf

TEST_DATA=$test_name.tmp
VERIFY_DATA=$test_name.ver.tmp

echo "debugfs edit extended attributes" > $OUT

dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1

echo "mke2fs -Fq -b 1024 test.img 512" >> $OUT

$MKE2FS -Fq $TMPFILE 512 > /dev/null 2>&1
status=$?
echo Exit status is $status >> $OUT

echo "ea_set / user.joe smith" > $OUT.new
$DEBUGFS -w -R "ea_set / user.joe smith" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_set / user.moo FEE_FIE_FOE_FUMMMMMM" > $OUT.new
$DEBUGFS -w -R "ea_set / user.moo FEE_FIE_FOE_FUMMMMMM" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_list /" > $OUT.new
$DEBUGFS -w -R "ea_list /" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_get / user.moo" > $OUT.new
$DEBUGFS -w -R "ea_get / user.moo" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_get / nosuchea" > $OUT.new
$DEBUGFS -w -R "ea_get / nosuchea" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_rm / user.moo" > $OUT.new
$DEBUGFS -w -R "ea_rm / user.moo" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_rm / nosuchea" > $OUT.new
$DEBUGFS -w -R "ea_rm / nosuchea" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_list /" > $OUT.new
$DEBUGFS -w -R "ea_list /" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_get / user.moo" > $OUT.new
$DEBUGFS -w -R "ea_get / user.moo" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_rm / user.joe" > $OUT.new
$DEBUGFS -w -R "ea_rm / user.joe" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_list /" > $OUT.new
$DEBUGFS -w -R "ea_list /" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567" > $TEST_DATA
echo "ea_set -f $TEST_DATA / user.file_based_xattr" > $OUT.new
$DEBUGFS -w -R "ea_set -f $TEST_DATA / user.file_based_xattr" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_list /" > $OUT.new
$DEBUGFS -w -R "ea_list /" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "ea_get -f $VERIFY_DATA / user.file_based_xattr" > $OUT.new
$DEBUGFS -w -R "ea_get -f $VERIFY_DATA / user.file_based_xattr" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo "Compare big attribute" > $OUT.new
diff -u $TEST_DATA $VERIFY_DATA >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
$FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new >> $OUT

#
# Do the verification
#

rm -f $TMPFILE $OUT.new
cmp -s $OUT $EXP
status=$?

if [ "$status" = 0 ] ; then
	echo "$test_name: $test_description: ok"
	touch $test_name.ok
else
	echo "$test_name: $test_description: failed"
	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
fi

unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA

else #if test -x $DEBUGFS_EXE; then
	echo "$test_name: $test_description: skipped"
fi
