Browse code

pkg/mount: testing mountinfo fields

Signed-off-by: Vincent Batts <vbatts@redhat.com>

Vincent Batts authored on 2014/11/18 06:17:06
Showing 1 changed files
... ...
@@ -446,3 +446,32 @@ func TestParseGentooMountinfo(t *testing.T) {
446 446
 		t.Fatal(err)
447 447
 	}
448 448
 }
449
+
450
+func TestParseFedoraMountinfoFields(t *testing.T) {
451
+	r := bytes.NewBuffer([]byte(fedoraMountinfo))
452
+	infos, err := parseInfoFile(r)
453
+	if err != nil {
454
+		t.Fatal(err)
455
+	}
456
+	expectedLength := 58
457
+	if len(infos) != expectedLength {
458
+		t.Fatalf("Expected %d entries, got %d", expectedLength, len(infos))
459
+	}
460
+	mi := MountInfo{
461
+		Id:         15,
462
+		Parent:     35,
463
+		Major:      0,
464
+		Minor:      3,
465
+		Root:       "/",
466
+		Mountpoint: "/proc",
467
+		Opts:       "rw,nosuid,nodev,noexec,relatime",
468
+		Optional:   "shared:5",
469
+		Fstype:     "proc",
470
+		Source:     "proc",
471
+		VfsOpts:    "rw",
472
+	}
473
+
474
+	if *infos[0] != mi {
475
+		t.Fatalf("expected %#v, got %#v", mi, infos[0])
476
+	}
477
+}