e2fsprogs/tests/f_detect_xfs/script
Andreas Dilger c5d9d3ce5f tests: don't run sed multiple times on test output
Don't call sed multiple times on the output, and avoid the use
of temporary files, or if possible.  It would be convenient to
use "sed -i" to only update the output file once, but this is
not portable to all platforms.

[ Fixed a few test regression failures --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 17:59:35 -04:00

38 lines
846 B
Bash

#!/bin/bash
FSCK_OPT=-fn
IMAGE=$test_dir/image.bz2
bzip2 -d < $IMAGE > $TMPFILE
# Run fsck to fix things?
if [ -x $DEBUGFS_EXE ]; then
EXP=$test_dir/expect
else
EXP=$test_dir/expect.nodebugfs
fi
OUT=$test_name.log
rm -f $test_name.failed $test_name.ok
echo "*** e2fsck" > $OUT
$FSCK $FSCK_OPT $TMPFILE >> $OUT 2>&1
echo "*** debugfs" >> $OUT
test -x $DEBUGFS_EXE && $DEBUGFS -R 'quit' $TMPFILE >> $OUT 2>&1
echo "*** tune2fs" >> $OUT
$TUNE2FS -i 0 $TMPFILE >> $OUT 2>&1
echo "*** mke2fs" >> $OUT
$MKE2FS -n -b 1024 $TMPFILE >> $OUT 2>&1
sed -f $cmd_dir/filter.sed < $OUT > $OUT.new
mv $OUT.new $OUT
# Figure out what happened
if cmp -s $EXP $OUT; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else
echo "$test_name: $test_description: failed"
diff -u $EXP $OUT >> $test_name.failed
fi
unset EXP OUT FSCK_OPT IMAGE