linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs/179: fix test failure when there are no snapshots to delete
@ 2021-09-24 14:06 fdmanana
  0 siblings, 0 replies; only message in thread
From: fdmanana @ 2021-09-24 14:06 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

It's very rare, but we can end up in a situation where there are no
snapshots to delete, in which case the $victim variable of the function
delete_workload() ends up being assigned with an empty string. When
that happens we end up running the command:

   btrfs subvolume delete "$SCRATCH_MNT/snapshots/"

Which fails since the argument is not a subvolume or a snapshot.
This causes the test to fail due to an unexpected error message from
the subvolume delete command:

  btrfs/179 129s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/179.out.bad)
      --- tests/btrfs/179.out	2020-10-16 23:13:46.546152332 +0100
      +++ /home/fdmanana/git/hub/xfstests/results//btrfs/179.out.bad	2021-09-24 11:15:01.404863801 +0100
      @@ -1,2 +1,3 @@
       QA output created by 179
      +ERROR: Not a Btrfs subvolume: Invalid argument
       Silence is golden
      ...

Fix that by making the delete_workload() loop skip the deletion attempt
when there are no snapshots.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/179 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/btrfs/179 b/tests/btrfs/179
index 9a3b36ab..2f17c9f9 100755
--- a/tests/btrfs/179
+++ b/tests/btrfs/179
@@ -70,6 +70,10 @@ delete_workload()
 	while true; do
 		sleep $((sleep_time * 2))
 		victim=$(ls "$SCRATCH_MNT/snapshots" | sort -R | head -n1)
+		if [ -z "$victim" ]; then
+			# No snapshots available, sleep and retry later.
+			continue
+		fi
 		$BTRFS_UTIL_PROG subvolume delete \
 			"$SCRATCH_MNT/snapshots/$victim" > /dev/null
 	done
-- 
2.33.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-24 14:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 14:06 [PATCH] btrfs/179: fix test failure when there are no snapshots to delete fdmanana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).