mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/mount/TestMount: fix wrt selinux
Sometimes docker-master CI fails on rhel4+selinux configuration,
like this:
--- FAIL: TestMount (0.12s)
--- FAIL: TestMount/none-remount,size=128k (0.01s)
mounter_linux_test.go:209: unexpected mount option "seclabel" expected "rw,size=128k"
--- FAIL: TestMount/none-remount,ro,size=128k (0.01s)
mounter_linux_test.go:209: unexpected mount option "seclabel" expected "ro,size=128k"
Earlier, commit 8bebd42df2
(PR #34965) fixed this failure,
but not entirely (i.e. the test is now flaky). It looks like
either selinux detection code is not always working (it won't
work in d-in-d), or the kernel might or might not add 'seclabel'
option).
As the subject of this test case is definitely not selinux,
it can just ignore the option added by it.
While at it, fix error messages:
- add missing commas;
- fix a typo;
- allow for clear distinction between mount
and vfs (per-superblock) options.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
de3eafeee1
commit
d78e885326
1 changed files with 8 additions and 14 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue