mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
common: Improve _link_output_file to be more versatile
Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like: feat1,feat2: suffix The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected. Update all tests using _link_out_file to the new calling convention. Signed-off-by: Jan Kara <jack@suse.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
@@ -2200,15 +2200,52 @@ _get_os_name()
|
||||
fi
|
||||
}
|
||||
|
||||
_link_out_file_named()
|
||||
{
|
||||
export FEATURES=$2
|
||||
SUFFIX=$(perl -e '
|
||||
my %feathash;
|
||||
my $feature, $result, $suffix, $opts;
|
||||
|
||||
foreach $feature (split(/,/, $ENV{"FEATURES"})) {
|
||||
$feathash{$feature} = 1;
|
||||
}
|
||||
$result = "default";
|
||||
while (<>) {
|
||||
my $found = 1;
|
||||
|
||||
chomp;
|
||||
($opts, $suffix) = split(/ *: */);
|
||||
foreach my $opt (split(/,/, $opts)) {
|
||||
if (!exists($feathash{$opt})) {
|
||||
$found = 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if ($found == 1) {
|
||||
$result = $suffix;
|
||||
last;
|
||||
}
|
||||
}
|
||||
print $result
|
||||
' <$seqfull.cfg)
|
||||
rm -f $1
|
||||
SRC=$(basename $1)
|
||||
ln -fs $SRC.$SUFFIX $1
|
||||
}
|
||||
|
||||
_link_out_file()
|
||||
{
|
||||
if [ -z "$1" -o -z "$2" ]; then
|
||||
echo Error must pass src and dst.
|
||||
exit
|
||||
if [ $# -eq 0 ]; then
|
||||
FEATURES="$(_get_os_name)"
|
||||
if [ -n "$MOUNT_OPTIONS" ]; then
|
||||
FEATURES=$FEATURES,${MOUNT_OPTIONS##"-o "}
|
||||
fi
|
||||
else
|
||||
FEATURES=$1
|
||||
fi
|
||||
rm -f $2
|
||||
SUFFIX=$(_get_os_name())
|
||||
ln -s $1.$SUFFIX $2
|
||||
|
||||
_link_out_file_named $seqfull.out "$FEATURES"
|
||||
}
|
||||
|
||||
_die()
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ _filter()
|
||||
}
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
# real QA test starts here
|
||||
_supported_fs generic
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+1
-1
@@ -54,7 +54,7 @@ _require_scratch
|
||||
_require_v2log
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.op $seqfull.op
|
||||
_link_out_file_named $seqfull.op $(_get_os_name)
|
||||
|
||||
echo "*** init FS"
|
||||
umount $SCRATCH_DEV >/dev/null 2>&1
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+1
-1
@@ -39,7 +39,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
|
||||
. ./common/dump
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
# real QA test starts here
|
||||
_supported_fs xfs
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+1
-1
@@ -38,7 +38,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
|
||||
. ./common/dump
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
# real QA test starts here
|
||||
_supported_fs xfs
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+1
-1
@@ -46,7 +46,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
. ./common/repair
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
# nuke the superblock, AGI, AGF, AGFL; then try repair the damage
|
||||
#
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+1
-1
@@ -39,7 +39,7 @@ rm -f $seqres.full
|
||||
. ./common/filter
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
_check_repair()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+3
-3
@@ -84,11 +84,11 @@ _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
||||
_scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1
|
||||
|
||||
# link correct .out file
|
||||
FEATURES=$(_get_os_name)
|
||||
if [ $_fs_has_crcs -eq 1 ]; then
|
||||
_link_out_file $seq.crc.out $seqfull.out
|
||||
else
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
FEATURES=$FEATURES,crc
|
||||
fi
|
||||
_link_out_file_named $seqfull.out "$FEATURES"
|
||||
|
||||
`xfs_db -r -c sb -c p $SCRATCH_DEV | grep 'ino = ' | \
|
||||
sed -e 's/ //g' -e 's/^/export /'`
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
irix: irix
|
||||
linux,crc: crc.linux
|
||||
linux: linux
|
||||
+1
-1
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
|
||||
. ./common/dump
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
# real QA test starts here
|
||||
_supported_fs xfs
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
+1
-1
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
|
||||
. ./common/dump
|
||||
|
||||
# link correct .out file
|
||||
_link_out_file $seq.out $seqfull.out
|
||||
_link_out_file
|
||||
|
||||
# real QA test starts here
|
||||
_supported_fs xfs
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
irix: irix
|
||||
linux: linux
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user