Browse code

Make sure we are trying to unmount a mounted /etc/resolv.conf

Signed-off-by: Alvaro Saurin <alvaro.saurin@gmail.com>

Alvaro Saurin authored on 2016/06/21 17:38:45
Showing 1 changed files
... ...
@@ -1448,10 +1448,16 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *check.C) {
1448 1448
 	// This test case is meant to test monitoring resolv.conf when it is
1449 1449
 	// a regular file not a bind mounc. So we unmount resolv.conf and replace
1450 1450
 	// it with a file containing the original settings.
1451
-	cmd := exec.Command("umount", "/etc/resolv.conf")
1452
-	if _, err = runCommand(cmd); err != nil {
1451
+	mounted, err := mount.Mounted("/etc/resolv.conf")
1452
+	if err != nil {
1453 1453
 		c.Fatal(err)
1454 1454
 	}
1455
+	if mounted {
1456
+		cmd := exec.Command("umount", "/etc/resolv.conf")
1457
+		if _, err = runCommand(cmd); err != nil {
1458
+			c.Fatal(err)
1459
+		}
1460
+	}
1455 1461
 
1456 1462
 	//cleanup
1457 1463
 	defer func() {