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]
t.Logf("full mountinfo: %#v", orig) if testing.Verbose() {
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},
// Without DirectMount - i.e. using fusermount {Debug: true, MaxWrite: 9999},
t.Log("Normal fusermount mount") {Debug: true, FsName: "aaa"},
o1 := mountCheckOptions(t, opts) {Debug: true, Name: "bbb"},
// With DirectMount {Debug: true, FsName: "ccc", Name: "ddd"},
t.Log("DirectMount") }
opts.DirectMount = true for _, opts := range optsTable {
o2 := mountCheckOptions(t, opts) // Without DirectMount - i.e. using fusermount
if o2 != o1 { o1 := mountCheckOptions(t, opts)
t.Errorf("Effective mount options differ between DirectMount and fusermount mount:\n%#v\n%#v", // With DirectMount
o2, o1) opts.DirectMount = true
} o2 := mountCheckOptions(t, opts)
// With DirectMountStrict if o2 != o1 {
if os.Geteuid() == 0 { t.Errorf(`DirectMount effective mount options mismatch:
t.Log("DirectMountStrict") DirectMount: %#v
opts.DirectMountStrict = true fusermount: %#v`, o2, o1)
o3 := mountCheckOptions(t, opts)
if o3 != o1 { // When this already fails then DirectMountStrict will fail the same way.
t.Errorf("Effective mount options differ between DirectMountStrict and fusermount mount: \n%#v\n%#v", // Skip it for less noise in the logs.
o3, o1) continue
}
if os.Geteuid() == 0 {
// With DirectMountStrict
opts.DirectMountStrict = true
o3 := mountCheckOptions(t, opts)
if o3 != o1 {
t.Errorf(`DirectMountStrict effective mount options mismatch:
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