Commit c85c594d authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

tests: TestDirectMount: better coverage, clearer output

Also test several max_write values, and different fs names.
And make the fail output easier to read.

Change-Id: Idbc9003554dfd7320890488f0b16cd5cfce1d6b4
parent 80c1c822
...@@ -125,7 +125,9 @@ func mountCheckOptions(t *testing.T, opts MountOptions) (info mountinfo.Info) { ...@@ -125,7 +125,9 @@ func mountCheckOptions(t *testing.T, opts MountOptions) (info mountinfo.Info) {
t.Errorf("Could not find mountpoint %q in /proc/self/mountinfo", mnt) t.Errorf("Could not find mountpoint %q in /proc/self/mountinfo", mnt)
} }
orig := *mounts[0] orig := *mounts[0]
if testing.Verbose() {
t.Logf("full mountinfo: %#v", orig) t.Logf("full mountinfo: %#v", orig)
}
// We are only interested in some fields, as the others are arbitrary id numbers // We are only interested in some fields, as the others are arbitrary id numbers
// or contain random strings like "/tmp/TestDirectMount1126361240". // or contain random strings like "/tmp/TestDirectMount1126361240".
// //
...@@ -150,28 +152,38 @@ func mountCheckOptions(t *testing.T, opts MountOptions) (info mountinfo.Info) { ...@@ -150,28 +152,38 @@ func mountCheckOptions(t *testing.T, opts MountOptions) (info mountinfo.Info) {
// TestDirectMount checks that DirectMount and DirectMountStrict work and show the // TestDirectMount checks that DirectMount and DirectMountStrict work and show the
// same effective mount options in /proc/self/mounts // same effective mount options in /proc/self/mounts
func TestDirectMount(t *testing.T) { func TestDirectMount(t *testing.T) {
opts := MountOptions{ optsTable := []MountOptions{
Debug: true, {Debug: true},
} {Debug: true, AllowOther: true},
{Debug: true, MaxWrite: 9999},
{Debug: true, FsName: "aaa"},
{Debug: true, Name: "bbb"},
{Debug: true, FsName: "ccc", Name: "ddd"},
}
for _, opts := range optsTable {
// Without DirectMount - i.e. using fusermount // Without DirectMount - i.e. using fusermount
t.Log("Normal fusermount mount")
o1 := mountCheckOptions(t, opts) o1 := mountCheckOptions(t, opts)
// With DirectMount // With DirectMount
t.Log("DirectMount")
opts.DirectMount = true opts.DirectMount = true
o2 := mountCheckOptions(t, opts) o2 := mountCheckOptions(t, opts)
if o2 != o1 { if o2 != o1 {
t.Errorf("Effective mount options differ between DirectMount and fusermount mount:\n%#v\n%#v", t.Errorf(`DirectMount effective mount options mismatch:
o2, o1) DirectMount: %#v
fusermount: %#v`, o2, o1)
// When this already fails then DirectMountStrict will fail the same way.
// Skip it for less noise in the logs.
continue
} }
// With DirectMountStrict
if os.Geteuid() == 0 { if os.Geteuid() == 0 {
t.Log("DirectMountStrict") // With DirectMountStrict
opts.DirectMountStrict = true opts.DirectMountStrict = true
o3 := mountCheckOptions(t, opts) o3 := mountCheckOptions(t, opts)
if o3 != o1 { if o3 != o1 {
t.Errorf("Effective mount options differ between DirectMountStrict and fusermount mount: \n%#v\n%#v", t.Errorf(`DirectMountStrict effective mount options mismatch:
o3, o1) DirectMountStrict: %#v
fusermount: %#v`, o3, o1)
}
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment