File: root-testfail-ignore.patch

package info (click to toggle)
golang-github-containers-buildah 1.42.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,176 kB
  • sloc: sh: 2,572; makefile: 249; perl: 187; asm: 16; awk: 12; ansic: 1
file content (137 lines) | stat: -rw-r--r-- 5,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From: Reinhard Tartler <siretart@tauware.de>
Date: Wed, 10 Jul 2024 20:21:38 -0400
Subject: Skip tests that require root

===================================================================
---
 buildah_test.go                  |  3 +++
 cmd/buildah/common_test.go       |  2 +-
 convertcw_test.go                |  3 +++
 copier/copier_test.go            | 11 ++++++++++-
 internal/open/open_linux_test.go |  4 ++++
 internal/open/open_test.go       |  4 ++++
 6 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/buildah_test.go b/buildah_test.go
index 6d1579a..7d178c9 100644
--- a/buildah_test.go
+++ b/buildah_test.go
@@ -52,6 +52,9 @@ func TestOpenBuilderCommonBuildOpts(t *testing.T) {
 		GraphRoot:       t.TempDir(),
 		GraphDriverName: "vfs",
 	})
+	if err != nil {
+		t.Skipf("Not enough permissions to execute test: %s", err)
+	}
 	require.NoError(t, err)
 	t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
 	b, err := NewBuilder(ctx, store, BuilderOptions{})
diff --git a/cmd/buildah/common_test.go b/cmd/buildah/common_test.go
index b189477..16eae75 100644
--- a/cmd/buildah/common_test.go
+++ b/cmd/buildah/common_test.go
@@ -84,6 +84,6 @@ func failTestIfNotRoot(t *testing.T) {
 	if err != nil {
 		t.Log("Could not determine user.  Running without root may cause tests to fail")
 	} else if u.Uid != "0" {
-		t.Fatal("tests will fail unless run as root")
+		t.Skip("Skip tests that will fail unless run as root")
 	}
 }
diff --git a/convertcw_test.go b/convertcw_test.go
index e18375d..2561d9b 100644
--- a/convertcw_test.go
+++ b/convertcw_test.go
@@ -84,6 +84,9 @@ func TestCWConvertImage(t *testing.T) {
 						GraphDriverName: "vfs",
 					}
 					store, err := storage.GetStore(storeOptions)
+					if err != nil {
+						t.Skipf("Not enough permissions to run test: %s")
+					}
 					require.NoError(t, err)
 					t.Cleanup(func() {
 						if _, err := store.Shutdown(true); err != nil {
diff --git a/copier/copier_test.go b/copier/copier_test.go
index 9714d95..6a82ba4 100644
--- a/copier/copier_test.go
+++ b/copier/copier_test.go
@@ -204,7 +204,7 @@ var (
 	}{
 		{
 			name:     "regular",
-			rootOnly: false,
+			rootOnly: true,  // some of these tests seem to require real root
 			headers: []tar.Header{
 				{Name: "file-0", Typeflag: tar.TypeReg, Size: 123456789, Mode: 0o600, ModTime: testDate},
 				{Name: "file-a", Typeflag: tar.TypeReg, Size: 23, Mode: 0o600, ModTime: testDate},
@@ -2182,9 +2182,15 @@ func testEnsure(t *testing.T) {
 					ChmodNew:   &ugReadable,
 					ChownNew:   &idtools.IDPair{UID: 1, GID: 1},
 				})
+				if strings.Contains(err.Error(), "operation not permitted") {
+					t.Skipf("Skipping test: %v", err)
+				}
 				require.NoError(t, err, "unexpected error ensuring")
 			}
 			created, noted, err := Ensure(tmpdir, testCases[i].subdir, testCases[i].options)
+			if strings.Contains(err.Error(), "operation not permitted") {
+				t.Skipf("Skipping test: %v", err)
+			}
 			require.NoError(t, err, "unexpected error ensuring")
 			require.EqualValues(t, testCases[i].expectCreated, created, "did not expect to create these")
 			require.Equal(t, len(testCases[i].expectNoted), len(noted), "noticed the wrong number of things")
@@ -2381,6 +2387,9 @@ func testConditionalRemove(t *testing.T) {
 				})
 			}
 			created, _, err := Ensure(tmpdir, testCases[i].subdir, create)
+			if strings.Contains(err.Error(), "operation not permitted") {
+				t.Skipf("Skipping test: %v", err)
+			}
 			require.NoErrorf(t, err, "unexpected error creating %#v", create)
 			remove := testCases[i].remove
 			for _, what := range created {
diff --git a/internal/open/open_linux_test.go b/internal/open/open_linux_test.go
index e64ec6f..4d29c96 100644
--- a/internal/open/open_linux_test.go
+++ b/internal/open/open_linux_test.go
@@ -4,6 +4,7 @@ import (
 	"os"
 	"path/filepath"
 	"testing"
+	"strings"
 
 	"github.com/stretchr/testify/require"
 	"golang.org/x/sys/unix"
@@ -19,6 +20,9 @@ func TestBindFdToPath(t *testing.T) {
 	require.NoError(t, err, "opening descriptor for first directory")
 	second := t.TempDir()
 	err = BindFdToPath(uintptr(fd), second)
+	if strings.Contains(err.Error(), "operation not permitted") {
+		t.Skipf("Skipping test: %v", err)
+	}
 	require.NoError(t, err)
 	t.Cleanup(func() {
 		err := unix.Unmount(second, unix.MNT_DETACH)
diff --git a/internal/open/open_test.go b/internal/open/open_test.go
index 41ee17a..9c3d0ac 100644
--- a/internal/open/open_test.go
+++ b/internal/open/open_test.go
@@ -4,6 +4,7 @@ import (
 	"io"
 	"os"
 	"path/filepath"
+	"strings"
 	"testing"
 
 	"github.com/stretchr/testify/require"
@@ -53,6 +54,9 @@ func TestOpenInChroot(t *testing.T) {
 			},
 		},
 	})
+	if strings.Contains(result.Err, "operation not permitted") {
+		t.Skipf("Skipping test: %v", result.Err)
+	}
 	require.Empty(t, result.Err, "result from second client")
 	require.Equal(t, 1, len(result.Open), "results from second client")
 	require.Empty(t, result.Open[0].Err, "first (only) result from second client")