Browse code

fix test requirement about devicemapper and not overlay

Signed-off-by: mYmNeo <thomassong@tencent.com>
(cherry picked from commit 90f512427f3a10144a8f589ea9b18d36cf48b94c)

mYmNeo authored on 2016/04/06 10:45:30
Showing 3 changed files
... ...
@@ -54,6 +54,11 @@ var (
54 54
 	dockerBasePath       string
55 55
 	volumesConfigPath    string
56 56
 	containerStoragePath string
57
+
58
+	// daemonStorageDriver is held globally so that tests can know the storage
59
+	// driver of the daemon. This is initialized in docker_utils by sending
60
+	// a version call to the daemon and examining the response header.
61
+	daemonStorageDriver string
57 62
 )
58 63
 
59 64
 const (
... ...
@@ -86,6 +86,7 @@ func init() {
86 86
 
87 87
 	var info types.Info
88 88
 	err = json.Unmarshal(body, &info)
89
+	daemonStorageDriver = info.Driver
89 90
 	dockerBasePath = info.DockerRootDir
90 91
 	volumesConfigPath = filepath.Join(dockerBasePath, "volumes")
91 92
 	containerStoragePath = filepath.Join(dockerBasePath, "containers")
... ...
@@ -109,22 +109,14 @@ var (
109 109
 	}
110 110
 	NotOverlay = testRequirement{
111 111
 		func() bool {
112
-			cmd := exec.Command("grep", "^overlay / overlay", "/proc/mounts")
113
-			if err := cmd.Run(); err != nil {
114
-				return true
115
-			}
116
-			return false
112
+			return !strings.HasPrefix(daemonStorageDriver, "overlay")
117 113
 		},
118 114
 		"Test requires underlying root filesystem not be backed by overlay.",
119 115
 	}
120 116
 
121 117
 	Devicemapper = testRequirement{
122 118
 		func() bool {
123
-			cmd := exec.Command("grep", "^devicemapper / devicemapper", "/proc/mounts")
124
-			if err := cmd.Run(); err != nil {
125
-				return false
126
-			}
127
-			return true
119
+			return strings.HasPrefix(daemonStorageDriver, "devicemapper")
128 120
 		},
129 121
 		"Test requires underlying root filesystem to be backed by devicemapper.",
130 122
 	}