Browse code

integration-cli: remove bash dependency from TestRunSetMacAddress

This change enables TestRunSetMacAddress to run on windows
without `bash` dependency. Also `defer`red call of cleanup
method.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>

Ahmet Alp Balkan authored on 2015/02/18 15:18:28
Showing 1 changed files
... ...
@@ -2303,17 +2303,18 @@ func TestRunNetworkNotInitializedNoneMode(t *testing.T) {
2303 2303
 
2304 2304
 func TestRunSetMacAddress(t *testing.T) {
2305 2305
 	mac := "12:34:56:78:9a:bc"
2306
-	cmd := exec.Command("/bin/bash", "-c", dockerBinary+` run -i --rm --mac-address=`+mac+` busybox /bin/sh -c "ip link show eth0 | tail -1 | awk '{ print \$2 }'"`)
2307
-	out, _, err := runCommandWithOutput(cmd)
2306
+
2307
+	defer deleteAllContainers()
2308
+	cmd := exec.Command(dockerBinary, "run", "-i", "--rm", fmt.Sprintf("--mac-address=%s", mac), "busybox", "/bin/sh", "-c", "ip link show eth0 | tail -1 | awk '{print $2}'")
2309
+	out, ec, err := runCommandWithOutput(cmd)
2308 2310
 	if err != nil {
2309
-		t.Fatal(err)
2311
+		t.Fatalf("exec failed:\nexit code=%v\noutput=%s", ec, out)
2310 2312
 	}
2311 2313
 	actualMac := strings.TrimSpace(out)
2312 2314
 	if actualMac != mac {
2313 2315
 		t.Fatalf("Set MAC address with --mac-address failed. The container has an incorrect MAC address: %q, expected: %q", actualMac, mac)
2314 2316
 	}
2315 2317
 
2316
-	deleteAllContainers()
2317 2318
 	logDone("run - setting MAC address with --mac-address")
2318 2319
 }
2319 2320