diff options
Diffstat (limited to 'filesystem/mountpoint_test.go')
| -rw-r--r-- | filesystem/mountpoint_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/filesystem/mountpoint_test.go b/filesystem/mountpoint_test.go index f06219c..fd7e05d 100644 --- a/filesystem/mountpoint_test.go +++ b/filesystem/mountpoint_test.go @@ -27,6 +27,7 @@ import ( "fmt" "os" "path/filepath" + "reflect" "strings" "testing" ) @@ -544,3 +545,21 @@ func BenchmarkLoadFirst(b *testing.B) { } } } + +// Test mount comparison by values instead of by reference, +// as the map mountsByDevice gets recreated on each load. +// This ensures that concurrent mounts work properly. +func TestMountComparison(t *testing.T) { + var mountinfo = ` +15 0 259:3 / /home rw,relatime shared:1 - ext4 /dev/root rw,data=ordered +` + beginLoadMountInfoTest() + defer endLoadMountInfoTest() + loadMountInfoFromString(mountinfo) + firstMnt := mountForDevice("259:3") + loadMountInfoFromString(mountinfo) + secondMnt := mountForDevice("259:3") + if !reflect.DeepEqual(firstMnt, secondMnt) { + t.Errorf("Mount comparison does not work") + } +} |