@@ -411,6 +411,40 @@ func TestGetMountFromLink(t *testing.T) {
411411 }
412412}
413413
414+ // Test that makeLink() is including the expected information in links.
415+ func TestMakeLink (t * testing.T ) {
416+ mnt , err := getTestMount (t )
417+ if err != nil {
418+ t .Skip (err )
419+ }
420+ link , err := makeLink (mnt )
421+ if err != nil {
422+ t .Fatal (err )
423+ }
424+
425+ // Normally, both UUID and PATH should be included.
426+ if ! strings .Contains (link , "UUID=" ) {
427+ t .Fatal ("Link doesn't contain UUID" )
428+ }
429+ if ! strings .Contains (link , "PATH=" ) {
430+ t .Fatal ("Link doesn't contain PATH" )
431+ }
432+
433+ // Without a valid device number, only PATH should be included.
434+ mntCopy := * mnt
435+ mntCopy .DeviceNumber = 0
436+ link , err = makeLink (& mntCopy )
437+ if err != nil {
438+ t .Fatal (err )
439+ }
440+ if strings .Contains (link , "UUID=" ) {
441+ t .Fatal ("Link shouldn't contain UUID" )
442+ }
443+ if ! strings .Contains (link , "PATH=" ) {
444+ t .Fatal ("Link doesn't contain PATH" )
445+ }
446+ }
447+
414448// Test that old filesystem links that contain a UUID only still work.
415449func TestGetMountFromLegacyLink (t * testing.T ) {
416450 mnt , err := getTestMount (t )
@@ -456,6 +490,16 @@ func TestGetMountFromLinkFallback(t *testing.T) {
456490 t .Fatal ("Link doesn't point to the same Mount" )
457491 }
458492
493+ // only PATH given at all (should succeed)
494+ link = fmt .Sprintf ("PATH=%s\n " , mnt .Path )
495+ linkedMnt , err = getMountFromLink (link )
496+ if err != nil {
497+ t .Fatal (err )
498+ }
499+ if linkedMnt != mnt {
500+ t .Fatal ("Link doesn't point to the same Mount" )
501+ }
502+
459503 // only UUID valid (should succeed)
460504 link = fmt .Sprintf ("UUID=%s\n PATH=%s\n " , goodUUID , badPath )
461505 if linkedMnt , err = getMountFromLink (link ); err != nil {
0 commit comments