Signed-off-by: mYmNeo <thomassong@tencent.com>
| ... | ... |
@@ -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 ( |
| ... | ... |
@@ -67,6 +67,7 @@ func init() {
|
| 67 | 67 |
panic(fmt.Errorf("Init failed to unmarshal docker info: %v", err))
|
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 |
+ daemonStorageDriver = info.Driver |
|
| 70 | 71 |
dockerBasePath = info.DockerRootDir |
| 71 | 72 |
volumesConfigPath = filepath.Join(dockerBasePath, "volumes") |
| 72 | 73 |
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 |
} |