From 57cd29c895a8765972fb1e623401a38a82ad7f4c Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Thu, 3 Aug 2023 07:29:38 +0800 Subject: [PATCH] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag Previous commit "btrfs-progs: dump-super: print actual metadata_uuid value" changed the value of the super_block::metadata_uuid to be printed as it is, without tweaking it depending on the METADATA_UUID flag. Apply similar tweak in the common helper functions used to read the metadata_uuid so that test-cases still be successful. Signed-off-by: Anand Jain Signed-off-by: David Sterba --- tests/misc-tests/034-metadata-uuid/test.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh index 77a310d5..f2daa763 100755 --- a/tests/misc-tests/034-metadata-uuid/test.sh +++ b/tests/misc-tests/034-metadata-uuid/test.sh @@ -15,6 +15,19 @@ if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then _not_run "METADATA_UUID feature not supported" fi +has_metadata_uuid_flag() { + local dev="$1" + + run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ + dump-super "$dev" | grep -E -q METADATA_UUID + + if [ $? -eq 0 ]; then + echo true + else + echo false + fi +} + read_fsid() { local dev="$1" @@ -24,9 +37,14 @@ read_fsid() { read_metadata_uuid() { local dev="$1" + local flag=$(has_metadata_uuid_flag "$dev") - echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ - dump-super "$dev" | awk '/metadata_uuid/ {print $2}') + if [ "$flag" == "true" ]; then + echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ + dump-super "$dev" | awk '/metadata_uuid/ {print $2}') + else + read_fsid $dev + fi } check_btrfstune() {