From: Reinhard Tartler <siretart@tauware.de>
Date: Sun, 4 Aug 2024 15:48:24 -0400
Subject: Skip TestAttachLoopbackDeviceRace if /dev/loop-control is absent

---
 pkg/loopback/attach_test.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/pkg/loopback/attach_test.go b/pkg/loopback/attach_test.go
index 232eae6..bc4b5f7 100644
--- a/pkg/loopback/attach_test.go
+++ b/pkg/loopback/attach_test.go
@@ -17,6 +17,16 @@ const (
 )
 
 func TestAttachLoopbackDeviceRace(t *testing.T) {
+	_, err := os.Stat("/dev/loop-control")
+	if err != nil {
+		t.Skip("Cannot execute test with '/dev/loop-control' absent")
+	}
+	f, err := os.OpenFile("/dev/loop-control", os.O_RDONLY, 0o644)
+	if err != nil {
+		t.Skip("Cannot execute test with '/dev/loop-control' unreadable")
+	}
+	f.Close()
+
 	createLoopbackDevice := func() {
 		// Create a file to use as a backing file
 		f, err := os.CreateTemp(t.TempDir(), "loopback-test")
