Skip to content

Commit 9f03e83

Browse files
Bryan C. Millsgopherbot
authored andcommitted
os: skip Chown tests for auxiliary groups that fail due to permission errors
This addresses the failure mode described in https://git.alpinelinux.org/aports/commit/community/go/tests-filter-overflow-gid.patch?id=9851dde0f5d2a5a50f7f3b5323d1b2ff22e1d028, but without special-casing an implementation-specific group ID. For #62053. Change-Id: I70b1046837b8146889fff7085497213349cd2bf0 Reviewed-on: https://go-review.googlesource.com/c/go/+/520055 Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent 5b8ceb3 commit 9f03e83

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/os/os_unix_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func TestChown(t *testing.T) {
7575
t.Log("groups: ", groups)
7676
for _, g := range groups {
7777
if err = Chown(f.Name(), -1, g); err != nil {
78+
if testenv.SyscallIsNotSupported(err) {
79+
t.Logf("chown %s -1 %d: %s (error ignored)", f.Name(), g, err)
80+
// Since the Chown call failed, the file should be unmodified.
81+
checkUidGid(t, f.Name(), int(sys.Uid), gid)
82+
continue
83+
}
7884
t.Fatalf("chown %s -1 %d: %s", f.Name(), g, err)
7985
}
8086
checkUidGid(t, f.Name(), int(sys.Uid), g)
@@ -123,6 +129,12 @@ func TestFileChown(t *testing.T) {
123129
t.Log("groups: ", groups)
124130
for _, g := range groups {
125131
if err = f.Chown(-1, g); err != nil {
132+
if testenv.SyscallIsNotSupported(err) {
133+
t.Logf("chown %s -1 %d: %s (error ignored)", f.Name(), g, err)
134+
// Since the Chown call failed, the file should be unmodified.
135+
checkUidGid(t, f.Name(), int(sys.Uid), gid)
136+
continue
137+
}
126138
t.Fatalf("fchown %s -1 %d: %s", f.Name(), g, err)
127139
}
128140
checkUidGid(t, f.Name(), int(sys.Uid), g)
@@ -181,12 +193,22 @@ func TestLchown(t *testing.T) {
181193
t.Log("groups: ", groups)
182194
for _, g := range groups {
183195
if err = Lchown(linkname, -1, g); err != nil {
196+
if testenv.SyscallIsNotSupported(err) {
197+
t.Logf("lchown %s -1 %d: %s (error ignored)", f.Name(), g, err)
198+
// Since the Lchown call failed, the file should be unmodified.
199+
checkUidGid(t, f.Name(), int(sys.Uid), gid)
200+
continue
201+
}
184202
t.Fatalf("lchown %s -1 %d: %s", linkname, g, err)
185203
}
186204
checkUidGid(t, linkname, int(sys.Uid), g)
187205

188206
// Check that link target's gid is unchanged.
189207
checkUidGid(t, f.Name(), int(sys.Uid), int(sys.Gid))
208+
209+
if err = Lchown(linkname, -1, gid); err != nil {
210+
t.Fatalf("lchown %s -1 %d: %s", f.Name(), gid, err)
211+
}
190212
}
191213
}
192214

0 commit comments

Comments
 (0)