зеркало из https://github.com/microsoft/docker.git
Merge pull request #36750 from kolyshkin/t-mount-seclabel
pkg/mount/TestMount: fix wrt selinux
This commit is contained in:
Коммит
0846a02d54
|
@ -8,8 +8,6 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
selinux "github.com/opencontainers/selinux/go-selinux"
|
||||
)
|
||||
|
||||
func TestMount(t *testing.T) {
|
||||
|
@ -103,11 +101,7 @@ func TestMount(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
defer ensureUnmount(t, target)
|
||||
expectedVFS := tc.expectedVFS
|
||||
if selinux.GetEnabled() && expectedVFS != "" {
|
||||
expectedVFS = expectedVFS + ",seclabel"
|
||||
}
|
||||
validateMount(t, target, tc.expectedOpts, tc.expectedOptional, expectedVFS)
|
||||
validateMount(t, target, tc.expectedOpts, tc.expectedOptional, tc.expectedVFS)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -177,13 +171,13 @@ func validateMount(t *testing.T, mnt string, opts, optional, vfs string) {
|
|||
for _, opt := range strings.Split(mi.Opts, ",") {
|
||||
opt = clean(opt)
|
||||
if !has(wantedOpts, opt) && !has(pOpts, opt) {
|
||||
t.Errorf("unexpected mount option %q expected %q", opt, opts)
|
||||
t.Errorf("unexpected mount option %q, expected %q", opt, opts)
|
||||
}
|
||||
delete(wantedOpts, opt)
|
||||
}
|
||||
}
|
||||
for opt := range wantedOpts {
|
||||
t.Errorf("missing mount option %q found %q", opt, mi.Opts)
|
||||
t.Errorf("missing mount option %q, found %q", opt, mi.Opts)
|
||||
}
|
||||
|
||||
// Validate Optional
|
||||
|
@ -191,13 +185,13 @@ func validateMount(t *testing.T, mnt string, opts, optional, vfs string) {
|
|||
for _, field := range strings.Split(mi.Optional, ",") {
|
||||
field = clean(field)
|
||||
if !has(wantedOptional, field) && !has(pOptional, field) {
|
||||
t.Errorf("unexpected optional failed %q expected %q", field, optional)
|
||||
t.Errorf("unexpected optional field %q, expected %q", field, optional)
|
||||
}
|
||||
delete(wantedOptional, field)
|
||||
}
|
||||
}
|
||||
for field := range wantedOptional {
|
||||
t.Errorf("missing optional field %q found %q", field, mi.Optional)
|
||||
t.Errorf("missing optional field %q, found %q", field, mi.Optional)
|
||||
}
|
||||
|
||||
// Validate VFS if set
|
||||
|
@ -205,14 +199,14 @@ func validateMount(t *testing.T, mnt string, opts, optional, vfs string) {
|
|||
if mi.VfsOpts != "" {
|
||||
for _, opt := range strings.Split(mi.VfsOpts, ",") {
|
||||
opt = clean(opt)
|
||||
if !has(wantedVFS, opt) {
|
||||
t.Errorf("unexpected mount option %q expected %q", opt, vfs)
|
||||
if !has(wantedVFS, opt) && opt != "seclabel" { // can be added by selinux
|
||||
t.Errorf("unexpected vfs option %q, expected %q", opt, vfs)
|
||||
}
|
||||
delete(wantedVFS, opt)
|
||||
}
|
||||
}
|
||||
for opt := range wantedVFS {
|
||||
t.Errorf("missing mount option %q found %q", opt, mi.VfsOpts)
|
||||
t.Errorf("missing vfs option %q, found %q", opt, mi.VfsOpts)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче