common/fuzzy: if the fuzz verb is random, keep fuzzing until we get a new value
[xfstests-dev.git] / common / fuzzy
index 3d86e1c8654f14f0d6938a8d5b1d605748bfbae5..d70964f4766133649ddf13e9947f2eafd60a7b94 100644 (file)
@@ -179,9 +179,14 @@ _scratch_xfs_fuzz_metadata_field() {
        for arg in "$@"; do
                cmds+=("-c" "${arg}")
        done
        for arg in "$@"; do
                cmds+=("-c" "${arg}")
        done
-       _scratch_xfs_db -x "${cmds[@]}" -c "fuzz ${fuzz_arg} ${key} ${value}"
-       echo
-       newval="$(_scratch_xfs_get_metadata_field "${key}" "$@" 2> /dev/null)"
+       while true; do
+               _scratch_xfs_db -x "${cmds[@]}" -c "fuzz ${fuzz_arg} ${key} ${value}"
+               echo
+               newval="$(_scratch_xfs_get_metadata_field "${key}" "$@" 2> /dev/null)"
+               if [ "${key}" != "random" ] || [ "${oldval}" != "${newval}" ]; then
+                       break;
+               fi
+       done
        if [ "${oldval}" = "${newval}" ]; then
                echo "Field ${key} already set to ${newval}, skipping test."
                return 1
        if [ "${oldval}" = "${newval}" ]; then
                echo "Field ${key} already set to ${newval}, skipping test."
                return 1