From: Reinhard Tartler <siretart@tauware.de>
Date: Wed, 7 Aug 2024 07:30:47 -0400
Subject: tolerate absence of 'netavark' binary in tests

---
 buildah_test.go            | 4 ++++
 cmd/buildah/common_test.go | 4 ++++
 commit_test.go             | 4 ++++
 common_test.go             | 4 ++++
 convertcw_test.go          | 4 ++++
 5 files changed, 20 insertions(+)

diff --git a/buildah_test.go b/buildah_test.go
index d019aba..7a7d416 100644
--- a/buildah_test.go
+++ b/buildah_test.go
@@ -4,6 +4,7 @@ import (
 	"context"
 	"flag"
 	"os"
+	"strings"
 	"testing"
 
 	imagetypes "github.com/containers/image/v5/types"
@@ -52,6 +53,9 @@ func TestOpenBuilderCommonBuildOpts(t *testing.T) {
 	require.NoError(t, err)
 	t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
 	b, err := NewBuilder(ctx, store, BuilderOptions{})
+	if strings.Contains(err.Error(), "netavark") {
+		t.Skipf("Cannot execute, failed to construct builder: %v", err)
+	}
 	require.NoError(t, err)
 	require.NotNil(t, b.CommonBuildOpts)
 	b.CommonBuildOpts = nil
diff --git a/cmd/buildah/common_test.go b/cmd/buildah/common_test.go
index 3fc7a5f..98aec62 100644
--- a/cmd/buildah/common_test.go
+++ b/cmd/buildah/common_test.go
@@ -2,6 +2,7 @@ package main
 
 import (
 	"flag"
+	"strings"
 	"os"
 	"os/user"
 	"testing"
@@ -128,6 +129,9 @@ func pullTestImage(t *testing.T) string {
 
 	b, err := buildah.NewBuilder(getContext(), store, options)
 	if err != nil {
+		if strings.Contains(err.Error(), "netavark") {
+			t.Skipf("Ignoring test setup related error: %s", err)
+		}
 		t.Fatal(err)
 	}
 	id := b.FromImageID
diff --git a/commit_test.go b/commit_test.go
index 96f540e..f473c54 100644
--- a/commit_test.go
+++ b/commit_test.go
@@ -8,6 +8,7 @@ import (
 	"io"
 	"os"
 	"path/filepath"
+	"strings"
 	"testing"
 	"time"
 
@@ -85,6 +86,9 @@ func TestCommitLinkedLayers(t *testing.T) {
 		SystemContext: &testSystemContext,
 	}
 	b, err := NewBuilder(ctx, store, builderOptions)
+	if strings.Contains(err.Error(), "netavark") {
+		t.Skipf("Skipping test: %v", err)
+	}
 	require.NoError(t, err, "creating builder")
 	b.SetCreatedBy(imageName(layerNumber))
 	firstFile := makeFile("file0", 0)
diff --git a/common_test.go b/common_test.go
index e4ba179..78a0cfe 100644
--- a/common_test.go
+++ b/common_test.go
@@ -7,6 +7,7 @@ import (
 	"encoding/json"
 	"os"
 	"path/filepath"
+	"strings"
 	"testing"
 	"time"
 
@@ -144,6 +145,9 @@ func TestRetryCopyImage(t *testing.T) {
 		require.NoError(t, policyContext.Destroy(), "destroying policy context")
 	})
 	_, err = retryCopyImage(ctx, policyContext, destRef, srcRef, destRef, &cp.Options{}, 3, 1*time.Second)
+	if strings.Contains(err.Error(), "operation not permitted") {
+		t.Skipf("Skipping test: %v", err)
+	}
 	require.NoError(t, err, "copying image")
 	_, err = retryCopyImage(ctx, policyContext, destRef, srcRef, destRef, &cp.Options{}, 3, 1*time.Second)
 	require.NoError(t, err, "copying image")
diff --git a/convertcw_test.go b/convertcw_test.go
index a6fb860..b01faab 100644
--- a/convertcw_test.go
+++ b/convertcw_test.go
@@ -12,6 +12,7 @@ import (
 	"os"
 	"path/filepath"
 	"sync"
+	"strings"
 	"testing"
 
 	"github.com/containers/buildah/internal/mkcw"
@@ -119,6 +120,9 @@ func TestCWConvertImage(t *testing.T) {
 						return
 					}
 					if ignoreChainRetrievalErrors && ignoreAttestationErrors {
+						if strings.Contains(err.Error(), "netavark") {
+							t.Skipf("Test setup failed: %v", err)
+						}
 						assert.NoError(t, err)
 					}
 					if err != nil {
