diff mbox

[1/5] common/fuzzy: if the fuzz verb is random, keep fuzzing until we get a new value

Message ID 151079534548.25590.4625031168242667972.stgit@magnolia (mailing list archive)
State New, archived
Headers show

Commit Message

Darrick J. Wong Nov. 16, 2017, 1:22 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

If the fuzz verb is 'random', keep generating new random values until
we get one that is distinct from the previous value.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/fuzzy |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/common/fuzzy b/common/fuzzy
index b9c7399..390f91f 100644
--- a/common/fuzzy
+++ b/common/fuzzy
@@ -179,9 +179,14 @@  _scratch_xfs_fuzz_metadata_field() {
 	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