Browse code

Merge pull request #8569 from jfrazelle/Cleanup-errorOut-resp

Cleanup: integration-cli (get rid of errorOut)

Tibor Vass authored on 2014/10/18 02:36:00
Showing 29 changed files
... ...
@@ -2,7 +2,6 @@ package main
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
-	"fmt"
6 5
 	"os/exec"
7 6
 	"testing"
8 7
 )
... ...
@@ -10,7 +9,9 @@ import (
10 10
 func TestInspectApiContainerResponse(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, fmt.Sprintf("failed to create a container: %v %v", out, err))
13
+	if err != nil {
14
+		t.Fatalf("failed to create a container: %s, %v", out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 
... ...
@@ -20,7 +20,9 @@ func TestBuildOnBuildForbiddenMaintainerInSourceImage(t *testing.T) {
20 20
 	defer deleteImages(name)
21 21
 	createCmd := exec.Command(dockerBinary, "create", "busybox", "true")
22 22
 	out, _, _, err := runCommandWithStdoutStderr(createCmd)
23
-	errorOut(err, t, out)
23
+	if err != nil {
24
+		t.Fatal(out, err)
25
+	}
24 26
 
25 27
 	cleanedContainerID := stripTrailingCharacters(out)
26 28
 
... ...
@@ -49,7 +51,9 @@ func TestBuildOnBuildForbiddenFromInSourceImage(t *testing.T) {
49 49
 	defer deleteImages(name)
50 50
 	createCmd := exec.Command(dockerBinary, "create", "busybox", "true")
51 51
 	out, _, _, err := runCommandWithStdoutStderr(createCmd)
52
-	errorOut(err, t, out)
52
+	if err != nil {
53
+		t.Fatal(out, err)
54
+	}
53 55
 
54 56
 	cleanedContainerID := stripTrailingCharacters(out)
55 57
 
... ...
@@ -78,7 +82,9 @@ func TestBuildOnBuildForbiddenChainedInSourceImage(t *testing.T) {
78 78
 	defer deleteImages(name)
79 79
 	createCmd := exec.Command(dockerBinary, "create", "busybox", "true")
80 80
 	out, _, _, err := runCommandWithStdoutStderr(createCmd)
81
-	errorOut(err, t, out)
81
+	if err != nil {
82
+		t.Fatal(out, err)
83
+	}
82 84
 
83 85
 	cleanedContainerID := stripTrailingCharacters(out)
84 86
 
... ...
@@ -299,11 +305,8 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio'
299 299
 
300 300
 func TestBuildCopyAddMultipleFiles(t *testing.T) {
301 301
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
302
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", "MultipleFiles")
303
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
304
-
305
-	if err != nil || exitCode != 0 {
306
-		t.Fatal("failed to build the image")
302
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", "MultipleFiles"); err != nil {
303
+		t.Fatalf("build failed to complete: %s, %v", out, err)
307 304
 	}
308 305
 
309 306
 	deleteImages("testaddimg")
... ...
@@ -620,11 +623,8 @@ func TestBuildCopySingleFileToRoot(t *testing.T) {
620 620
 		t.Fatal(err)
621 621
 	}
622 622
 	f.Close()
623
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", ".")
624
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
625
-
626
-	if err != nil || exitCode != 0 {
627
-		t.Fatal("failed to build the image")
623
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
624
+		t.Fatalf("build failed to complete: %s, %v", out, err)
628 625
 	}
629 626
 
630 627
 	deleteImages("testcopyimg")
... ...
@@ -650,9 +650,8 @@ func TestBuildCopySingleFileToWorkdir(t *testing.T) {
650 650
 		t.Fatal(err)
651 651
 	}
652 652
 	f.Close()
653
-	_, exitCode, err := dockerCmdInDirWithTimeout(5*time.Second, buildDirectory, "build", "-t", "testcopyimg", ".")
654
-	if err != nil || exitCode != 0 {
655
-		t.Fatalf("build failed: %s", err)
653
+	if out, _, err := dockerCmdInDirWithTimeout(5*time.Second, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
654
+		t.Fatalf("build failed to complete: %s, %v", out, err)
656 655
 	}
657 656
 
658 657
 	deleteImages("testcopyimg")
... ...
@@ -662,11 +661,8 @@ func TestBuildCopySingleFileToWorkdir(t *testing.T) {
662 662
 
663 663
 func TestBuildCopySingleFileToExistDir(t *testing.T) {
664 664
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
665
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "SingleFileToExistDir")
666
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
667
-
668
-	if err != nil || exitCode != 0 {
669
-		t.Fatal("failed to build the image")
665
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "SingleFileToExistDir"); err != nil {
666
+		t.Fatalf("build failed to complete: %s, %v", out, err)
670 667
 	}
671 668
 
672 669
 	deleteImages("testcopyimg")
... ...
@@ -676,11 +672,8 @@ func TestBuildCopySingleFileToExistDir(t *testing.T) {
676 676
 
677 677
 func TestBuildCopySingleFileToNonExistDir(t *testing.T) {
678 678
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
679
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "SingleFileToNonExistDir")
680
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
681
-
682
-	if err != nil || exitCode != 0 {
683
-		t.Fatal("failed to build the image")
679
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "SingleFileToNonExistDir"); err != nil {
680
+		t.Fatalf("build failed to complete: %s, %v", out, err)
684 681
 	}
685 682
 
686 683
 	deleteImages("testcopyimg")
... ...
@@ -690,11 +683,8 @@ func TestBuildCopySingleFileToNonExistDir(t *testing.T) {
690 690
 
691 691
 func TestBuildCopyDirContentToRoot(t *testing.T) {
692 692
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
693
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToRoot")
694
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
695
-
696
-	if err != nil || exitCode != 0 {
697
-		t.Fatal("failed to build the image")
693
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToRoot"); err != nil {
694
+		t.Fatalf("build failed to complete: %s, %v", out, err)
698 695
 	}
699 696
 
700 697
 	deleteImages("testcopyimg")
... ...
@@ -704,11 +694,8 @@ func TestBuildCopyDirContentToRoot(t *testing.T) {
704 704
 
705 705
 func TestBuildCopyDirContentToExistDir(t *testing.T) {
706 706
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
707
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToExistDir")
708
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
709
-
710
-	if err != nil || exitCode != 0 {
711
-		t.Fatal("failed to build the image")
707
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToExistDir"); err != nil {
708
+		t.Fatalf("build failed to complete: %s, %v", out, err)
712 709
 	}
713 710
 
714 711
 	deleteImages("testcopyimg")
... ...
@@ -737,11 +724,8 @@ func TestBuildCopyWholeDirToRoot(t *testing.T) {
737 737
 		t.Fatal(err)
738 738
 	}
739 739
 	f.Close()
740
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", ".")
741
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
742
-
743
-	if err != nil || exitCode != 0 {
744
-		t.Fatal("failed to build the image")
740
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
741
+		t.Fatalf("build failed to complete: %s, %v", out, err)
745 742
 	}
746 743
 
747 744
 	deleteImages("testcopyimg")
... ...
@@ -751,11 +735,8 @@ func TestBuildCopyWholeDirToRoot(t *testing.T) {
751 751
 
752 752
 func TestBuildCopyEtcToRoot(t *testing.T) {
753 753
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
754
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "EtcToRoot")
755
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
756
-
757
-	if err != nil || exitCode != 0 {
758
-		t.Fatal("failed to build the image")
754
+	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "EtcToRoot"); err != nil {
755
+		t.Fatalf("build failed to complete: %s, %v", out, err)
759 756
 	}
760 757
 
761 758
 	deleteImages("testcopyimg")
... ...
@@ -766,9 +747,7 @@ func TestBuildCopyDisallowRemote(t *testing.T) {
766 766
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
767 767
 	buildCmd := exec.Command(dockerBinary, "build", "-t", "testcopyimg", "DisallowRemote")
768 768
 	buildCmd.Dir = buildDirectory
769
-	out, exitCode, err := runCommandWithOutput(buildCmd)
770
-
771
-	if err == nil || exitCode == 0 {
769
+	if out, _, err := runCommandWithOutput(buildCmd); err == nil {
772 770
 		t.Fatalf("building the image should've failed; output: %s", out)
773 771
 	}
774 772
 
... ...
@@ -790,14 +769,16 @@ func TestBuildWithInaccessibleFilesInContext(t *testing.T) {
790 790
 		// This is used to ensure we detect inaccessible files early during build in the cli client
791 791
 		pathToFileWithoutReadAccess := filepath.Join(ctx.Dir, "fileWithoutReadAccess")
792 792
 
793
-		err = os.Chown(pathToFileWithoutReadAccess, 0, 0)
794
-		errorOut(err, t, fmt.Sprintf("failed to chown file to root: %s", err))
795
-		err = os.Chmod(pathToFileWithoutReadAccess, 0700)
796
-		errorOut(err, t, fmt.Sprintf("failed to chmod file to 700: %s", err))
793
+		if err = os.Chown(pathToFileWithoutReadAccess, 0, 0); err != nil {
794
+			t.Fatalf("failed to chown file to root: %s", err)
795
+		}
796
+		if err = os.Chmod(pathToFileWithoutReadAccess, 0700); err != nil {
797
+			t.Fatalf("failed to chmod file to 700: %s", err)
798
+		}
797 799
 		buildCmd := exec.Command("su", "unprivilegeduser", "-c", fmt.Sprintf("%s build -t %s .", dockerBinary, name))
798 800
 		buildCmd.Dir = ctx.Dir
799
-		out, exitCode, err := runCommandWithOutput(buildCmd)
800
-		if err == nil || exitCode == 0 {
801
+		out, _, err := runCommandWithOutput(buildCmd)
802
+		if err == nil {
801 803
 			t.Fatalf("build should have failed: %s %s", err, out)
802 804
 		}
803 805
 
... ...
@@ -822,17 +803,20 @@ func TestBuildWithInaccessibleFilesInContext(t *testing.T) {
822 822
 		pathToDirectoryWithoutReadAccess := filepath.Join(ctx.Dir, "directoryWeCantStat")
823 823
 		pathToFileInDirectoryWithoutReadAccess := filepath.Join(pathToDirectoryWithoutReadAccess, "bar")
824 824
 
825
-		err = os.Chown(pathToDirectoryWithoutReadAccess, 0, 0)
826
-		errorOut(err, t, fmt.Sprintf("failed to chown directory to root: %s", err))
827
-		err = os.Chmod(pathToDirectoryWithoutReadAccess, 0444)
828
-		errorOut(err, t, fmt.Sprintf("failed to chmod directory to 755: %s", err))
829
-		err = os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700)
830
-		errorOut(err, t, fmt.Sprintf("failed to chmod file to 444: %s", err))
825
+		if err = os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
826
+			t.Fatalf("failed to chown directory to root: %s", err)
827
+		}
828
+		if err = os.Chmod(pathToDirectoryWithoutReadAccess, 0444); err != nil {
829
+			t.Fatalf("failed to chmod directory to 755: %s", err)
830
+		}
831
+		if err = os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700); err != nil {
832
+			t.Fatalf("failed to chmod file to 444: %s", err)
833
+		}
831 834
 
832 835
 		buildCmd := exec.Command("su", "unprivilegeduser", "-c", fmt.Sprintf("%s build -t %s .", dockerBinary, name))
833 836
 		buildCmd.Dir = ctx.Dir
834
-		out, exitCode, err := runCommandWithOutput(buildCmd)
835
-		if err == nil || exitCode == 0 {
837
+		out, _, err := runCommandWithOutput(buildCmd)
838
+		if err == nil {
836 839
 			t.Fatalf("build should have failed: %s %s", err, out)
837 840
 		}
838 841
 
... ...
@@ -878,17 +862,19 @@ func TestBuildWithInaccessibleFilesInContext(t *testing.T) {
878 878
 		// This is used to ensure we don't try to add inaccessible files when they are ignored by a .dockerignore pattern
879 879
 		pathToDirectoryWithoutReadAccess := filepath.Join(ctx.Dir, "directoryWeCantStat")
880 880
 		pathToFileInDirectoryWithoutReadAccess := filepath.Join(pathToDirectoryWithoutReadAccess, "bar")
881
-		err = os.Chown(pathToDirectoryWithoutReadAccess, 0, 0)
882
-		errorOut(err, t, fmt.Sprintf("failed to chown directory to root: %s", err))
883
-		err = os.Chmod(pathToDirectoryWithoutReadAccess, 0444)
884
-		errorOut(err, t, fmt.Sprintf("failed to chmod directory to 755: %s", err))
885
-		err = os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700)
886
-		errorOut(err, t, fmt.Sprintf("failed to chmod file to 444: %s", err))
881
+		if err = os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
882
+			t.Fatalf("failed to chown directory to root: %s", err)
883
+		}
884
+		if err = os.Chmod(pathToDirectoryWithoutReadAccess, 0444); err != nil {
885
+			t.Fatalf("failed to chmod directory to 755: %s", err)
886
+		}
887
+		if err = os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700); err != nil {
888
+			t.Fatalf("failed to chmod file to 444: %s", err)
889
+		}
887 890
 
888 891
 		buildCmd := exec.Command("su", "unprivilegeduser", "-c", fmt.Sprintf("%s build -t %s .", dockerBinary, name))
889 892
 		buildCmd.Dir = ctx.Dir
890
-		out, exitCode, err := runCommandWithOutput(buildCmd)
891
-		if err != nil || exitCode != 0 {
893
+		if out, _, err := runCommandWithOutput(buildCmd); err != nil {
892 894
 			t.Fatalf("build should have worked: %s %s", err, out)
893 895
 		}
894 896
 
... ...
@@ -913,10 +899,8 @@ func TestBuildForceRm(t *testing.T) {
913 913
 
914 914
 	buildCmd := exec.Command(dockerBinary, "build", "-t", name, "--force-rm", ".")
915 915
 	buildCmd.Dir = ctx.Dir
916
-	_, exitCode, err := runCommandWithOutput(buildCmd)
917
-
918
-	if err == nil || exitCode == 0 {
919
-		t.Fatal("failed to build the image")
916
+	if out, _, err := runCommandWithOutput(buildCmd); err == nil {
917
+		t.Fatal("failed to build the image: %s, %v", out, err)
920 918
 	}
921 919
 
922 920
 	containerCountAfter, err := getContainerCount()
... ...
@@ -945,9 +929,9 @@ func TestBuildRm(t *testing.T) {
945 945
 			t.Fatalf("failed to get the container count: %s", err)
946 946
 		}
947 947
 
948
-		out, exitCode, err := dockerCmdInDir(t, ctx.Dir, "build", "--rm", "-t", name, ".")
948
+		out, _, err := dockerCmdInDir(t, ctx.Dir, "build", "--rm", "-t", name, ".")
949 949
 
950
-		if err != nil || exitCode != 0 {
950
+		if err != nil {
951 951
 			t.Fatal("failed to build the image", out)
952 952
 		}
953 953
 
... ...
@@ -968,9 +952,9 @@ func TestBuildRm(t *testing.T) {
968 968
 			t.Fatalf("failed to get the container count: %s", err)
969 969
 		}
970 970
 
971
-		out, exitCode, err := dockerCmdInDir(t, ctx.Dir, "build", "-t", name, ".")
971
+		out, _, err := dockerCmdInDir(t, ctx.Dir, "build", "-t", name, ".")
972 972
 
973
-		if err != nil || exitCode != 0 {
973
+		if err != nil {
974 974
 			t.Fatal("failed to build the image", out)
975 975
 		}
976 976
 
... ...
@@ -991,9 +975,9 @@ func TestBuildRm(t *testing.T) {
991 991
 			t.Fatalf("failed to get the container count: %s", err)
992 992
 		}
993 993
 
994
-		out, exitCode, err := dockerCmdInDir(t, ctx.Dir, "build", "--rm=false", "-t", name, ".")
994
+		out, _, err := dockerCmdInDir(t, ctx.Dir, "build", "--rm=false", "-t", name, ".")
995 995
 
996
-		if err != nil || exitCode != 0 {
996
+		if err != nil {
997 997
 			t.Fatal("failed to build the image", out)
998 998
 		}
999 999
 
... ...
@@ -1335,7 +1319,9 @@ func TestBuildOnBuildLimitedInheritence(t *testing.T) {
1335 1335
 		}
1336 1336
 
1337 1337
 		out1, _, err := dockerCmdInDir(t, ctx.Dir, "build", "-t", name1, ".")
1338
-		errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out1, err))
1338
+		if err != nil {
1339
+			t.Fatalf("build failed to complete: %s, %v", out1, err)
1340
+		}
1339 1341
 		defer deleteImages(name1)
1340 1342
 	}
1341 1343
 	{
... ...
@@ -1349,7 +1335,9 @@ func TestBuildOnBuildLimitedInheritence(t *testing.T) {
1349 1349
 		}
1350 1350
 
1351 1351
 		out2, _, err = dockerCmdInDir(t, ctx.Dir, "build", "-t", name2, ".")
1352
-		errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out2, err))
1352
+		if err != nil {
1353
+			t.Fatalf("build failed to complete: %s, %v", out2, err)
1354
+		}
1353 1355
 		defer deleteImages(name2)
1354 1356
 	}
1355 1357
 	{
... ...
@@ -1363,7 +1351,10 @@ func TestBuildOnBuildLimitedInheritence(t *testing.T) {
1363 1363
 		}
1364 1364
 
1365 1365
 		out3, _, err = dockerCmdInDir(t, ctx.Dir, "build", "-t", name3, ".")
1366
-		errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out3, err))
1366
+		if err != nil {
1367
+			t.Fatalf("build failed to complete: %s, %v", out3, err)
1368
+		}
1369
+
1367 1370
 		defer deleteImages(name3)
1368 1371
 	}
1369 1372
 
... ...
@@ -1763,8 +1754,7 @@ CMD ["cat", "/foo"]`,
1763 1763
 	defer deleteImages(name)
1764 1764
 	buildCmd.Stdin = context
1765 1765
 
1766
-	out, exitCode, err := runCommandWithOutput(buildCmd)
1767
-	if err != nil || exitCode != 0 {
1766
+	if out, _, err := runCommandWithOutput(buildCmd); err != nil {
1768 1767
 		t.Fatalf("build failed to complete: %v %v", out, err)
1769 1768
 	}
1770 1769
 	logDone(fmt.Sprintf("build - build an image with a context tar, compression: %v", compression))
... ...
@@ -1782,13 +1772,11 @@ func TestBuildNoContext(t *testing.T) {
1782 1782
 	buildCmd := exec.Command(dockerBinary, "build", "-t", "nocontext", "-")
1783 1783
 	buildCmd.Stdin = strings.NewReader("FROM busybox\nCMD echo ok\n")
1784 1784
 
1785
-	out, exitCode, err := runCommandWithOutput(buildCmd)
1786
-	if err != nil || exitCode != 0 {
1785
+	if out, _, err := runCommandWithOutput(buildCmd); err != nil {
1787 1786
 		t.Fatalf("build failed to complete: %v %v", out, err)
1788 1787
 	}
1789 1788
 
1790
-	out, exitCode, err = cmd(t, "run", "nocontext")
1791
-	if out != "ok\n" {
1789
+	if out, _, err := cmd(t, "run", "nocontext"); out != "ok\n" || err != nil {
1792 1790
 		t.Fatalf("run produced invalid output: %q, expected %q", out, "ok")
1793 1791
 	}
1794 1792
 
... ...
@@ -2717,7 +2705,7 @@ func TestBuildExoticShellInterpolation(t *testing.T) {
2717 2717
 
2718 2718
 	_, err := buildImage(name, `
2719 2719
 		FROM busybox
2720
-
2720
+		
2721 2721
 		ENV SOME_VAR a.b.c
2722 2722
 
2723 2723
 		RUN [ "$SOME_VAR"       = 'a.b.c' ]
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -10,23 +9,29 @@ import (
10 10
 func TestCommitAfterContainerIsDone(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
12 12
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
13
-	errorOut(err, t, fmt.Sprintf("failed to run container: %v %v", out, err))
13
+	if err != nil {
14
+		t.Fatalf("failed to run container: %s, %v", out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 
17 19
 	waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
18
-	_, _, err = runCommandWithOutput(waitCmd)
19
-	errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
20
+	if _, _, err = runCommandWithOutput(waitCmd); err != nil {
21
+		t.Fatalf("error thrown while waiting for container: %s, %v", out, err)
22
+	}
20 23
 
21 24
 	commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID)
22 25
 	out, _, err = runCommandWithOutput(commitCmd)
23
-	errorOut(err, t, fmt.Sprintf("failed to commit container to image: %v %v", out, err))
26
+	if err != nil {
27
+		t.Fatalf("failed to commit container to image: %s, %v", out, err)
28
+	}
24 29
 
25 30
 	cleanedImageID := stripTrailingCharacters(out)
26 31
 
27 32
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
28
-	out, _, err = runCommandWithOutput(inspectCmd)
29
-	errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
33
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
34
+		t.Fatalf("failed to inspect image: %s, %v", out, err)
35
+	}
30 36
 
31 37
 	deleteContainer(cleanedContainerID)
32 38
 	deleteImages(cleanedImageID)
... ...
@@ -37,23 +42,29 @@ func TestCommitAfterContainerIsDone(t *testing.T) {
37 37
 func TestCommitWithoutPause(t *testing.T) {
38 38
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
39 39
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
40
-	errorOut(err, t, fmt.Sprintf("failed to run container: %v %v", out, err))
40
+	if err != nil {
41
+		t.Fatalf("failed to run container: %s, %v", out, err)
42
+	}
41 43
 
42 44
 	cleanedContainerID := stripTrailingCharacters(out)
43 45
 
44 46
 	waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
45
-	_, _, err = runCommandWithOutput(waitCmd)
46
-	errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
47
+	if _, _, err = runCommandWithOutput(waitCmd); err != nil {
48
+		t.Fatalf("error thrown while waiting for container: %s, %v", out, err)
49
+	}
47 50
 
48 51
 	commitCmd := exec.Command(dockerBinary, "commit", "-p=false", cleanedContainerID)
49 52
 	out, _, err = runCommandWithOutput(commitCmd)
50
-	errorOut(err, t, fmt.Sprintf("failed to commit container to image: %v %v", out, err))
53
+	if err != nil {
54
+		t.Fatalf("failed to commit container to image: %s, %v", out, err)
55
+	}
51 56
 
52 57
 	cleanedImageID := stripTrailingCharacters(out)
53 58
 
54 59
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
55
-	out, _, err = runCommandWithOutput(inspectCmd)
56
-	errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
60
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
61
+		t.Fatalf("failed to inspect image: %s, %v", out, err)
62
+	}
57 63
 
58 64
 	deleteContainer(cleanedContainerID)
59 65
 	deleteImages(cleanedImageID)
... ...
@@ -81,7 +92,7 @@ func TestCommitNewFile(t *testing.T) {
81 81
 		t.Fatal(err, out)
82 82
 	}
83 83
 	if actual := strings.Trim(out, "\r\n"); actual != "koye" {
84
-		t.Fatalf("expected output koye received %s", actual)
84
+		t.Fatalf("expected output koye received %q", actual)
85 85
 	}
86 86
 
87 87
 	deleteAllContainers()
... ...
@@ -92,7 +103,6 @@ func TestCommitNewFile(t *testing.T) {
92 92
 
93 93
 func TestCommitTTY(t *testing.T) {
94 94
 	cmd := exec.Command(dockerBinary, "run", "-t", "--name", "tty", "busybox", "/bin/ls")
95
-
96 95
 	if _, err := runCommand(cmd); err != nil {
97 96
 		t.Fatal(err)
98 97
 	}
... ...
@@ -105,7 +115,6 @@ func TestCommitTTY(t *testing.T) {
105 105
 	imageID = strings.Trim(imageID, "\r\n")
106 106
 
107 107
 	cmd = exec.Command(dockerBinary, "run", "ttytest", "/bin/ls")
108
-
109 108
 	if _, err := runCommand(cmd); err != nil {
110 109
 		t.Fatal(err)
111 110
 	}
... ...
@@ -124,6 +133,7 @@ func TestCommitWithHostBindMount(t *testing.T) {
124 124
 	if err != nil {
125 125
 		t.Fatal(imageID, err)
126 126
 	}
127
+
127 128
 	imageID = strings.Trim(imageID, "\r\n")
128 129
 
129 130
 	cmd = exec.Command(dockerBinary, "run", "bindtest", "true")
... ...
@@ -2,7 +2,6 @@ package main
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
-	"fmt"
6 5
 	"os/exec"
7 6
 	"testing"
8 7
 	"time"
... ...
@@ -12,13 +11,17 @@ import (
12 12
 func TestCreateArgs(t *testing.T) {
13 13
 	runCmd := exec.Command(dockerBinary, "create", "busybox", "command", "arg1", "arg2", "arg with space")
14 14
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
15
-	errorOut(err, t, out)
15
+	if err != nil {
16
+		t.Fatal(out, err)
17
+	}
16 18
 
17 19
 	cleanedContainerID := stripTrailingCharacters(out)
18 20
 
19 21
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
20
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
21
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
22
+	out, _, err = runCommandWithOutput(inspectCmd)
23
+	if err != nil {
24
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
25
+	}
22 26
 
23 27
 	containers := []struct {
24 28
 		ID      string
... ...
@@ -27,7 +30,7 @@ func TestCreateArgs(t *testing.T) {
27 27
 		Args    []string
28 28
 		Image   string
29 29
 	}{}
30
-	if err := json.Unmarshal([]byte(inspectOut), &containers); err != nil {
30
+	if err := json.Unmarshal([]byte(out), &containers); err != nil {
31 31
 		t.Fatalf("Error inspecting the container: %s", err)
32 32
 	}
33 33
 	if len(containers) != 1 {
... ...
@@ -60,20 +63,24 @@ func TestCreateArgs(t *testing.T) {
60 60
 func TestCreateHostConfig(t *testing.T) {
61 61
 	runCmd := exec.Command(dockerBinary, "create", "-P", "busybox", "echo")
62 62
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
63
-	errorOut(err, t, out)
63
+	if err != nil {
64
+		t.Fatal(out, err)
65
+	}
64 66
 
65 67
 	cleanedContainerID := stripTrailingCharacters(out)
66 68
 
67 69
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
68
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
69
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
70
+	out, _, err = runCommandWithOutput(inspectCmd)
71
+	if err != nil {
72
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
73
+	}
70 74
 
71 75
 	containers := []struct {
72 76
 		HostConfig *struct {
73 77
 			PublishAllPorts bool
74 78
 		}
75 79
 	}{}
76
-	if err := json.Unmarshal([]byte(inspectOut), &containers); err != nil {
80
+	if err := json.Unmarshal([]byte(out), &containers); err != nil {
77 81
 		t.Fatalf("Error inspecting the container: %s", err)
78 82
 	}
79 83
 	if len(containers) != 1 {
... ...
@@ -98,13 +105,17 @@ func TestCreateHostConfig(t *testing.T) {
98 98
 func TestCreateEchoStdout(t *testing.T) {
99 99
 	runCmd := exec.Command(dockerBinary, "create", "busybox", "echo", "test123")
100 100
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
101
-	errorOut(err, t, out)
101
+	if err != nil {
102
+		t.Fatal(out, err)
103
+	}
102 104
 
103 105
 	cleanedContainerID := stripTrailingCharacters(out)
104 106
 
105 107
 	runCmd = exec.Command(dockerBinary, "start", "-ai", cleanedContainerID)
106 108
 	out, _, _, err = runCommandWithStdoutStderr(runCmd)
107
-	errorOut(err, t, out)
109
+	if err != nil {
110
+		t.Fatal(out, err)
111
+	}
108 112
 
109 113
 	if out != "test123\n" {
110 114
 		t.Errorf("container should've printed 'test123', got %q", out)
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -11,14 +10,18 @@ import (
11 11
 func TestDiffFilenameShownInOutput(t *testing.T) {
12 12
 	containerCmd := `echo foo > /root/bar`
13 13
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
14
-	cid, _, err := runCommandWithOutput(runCmd)
15
-	errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
14
+	out, _, err := runCommandWithOutput(runCmd)
15
+	if err != nil {
16
+		t.Fatalf("failed to start the container: %s, %v", out, err)
17
+	}
16 18
 
17
-	cleanCID := stripTrailingCharacters(cid)
19
+	cleanCID := stripTrailingCharacters(out)
18 20
 
19 21
 	diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
20
-	out, _, err := runCommandWithOutput(diffCmd)
21
-	errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err))
22
+	out, _, err = runCommandWithOutput(diffCmd)
23
+	if err != nil {
24
+		t.Fatalf("failed to run diff: %s %v", out, err)
25
+	}
22 26
 
23 27
 	found := false
24 28
 	for _, line := range strings.Split(out, "\n") {
... ...
@@ -44,14 +47,18 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
44 44
 	for i := 0; i < 20; i++ {
45 45
 		containerCmd := `echo foo > /root/bar`
46 46
 		runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
47
-		cid, _, err := runCommandWithOutput(runCmd)
48
-		errorOut(err, t, fmt.Sprintf("%s", err))
47
+		out, _, err := runCommandWithOutput(runCmd)
48
+		if err != nil {
49
+			t.Fatal(out, err)
50
+		}
49 51
 
50
-		cleanCID := stripTrailingCharacters(cid)
52
+		cleanCID := stripTrailingCharacters(out)
51 53
 
52 54
 		diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
53
-		out, _, err := runCommandWithOutput(diffCmd)
54
-		errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err))
55
+		out, _, err = runCommandWithOutput(diffCmd)
56
+		if err != nil {
57
+			t.Fatalf("failed to run diff: %s, %v", out, err)
58
+		}
55 59
 
56 60
 		deleteContainer(cleanCID)
57 61
 
... ...
@@ -67,13 +74,18 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) {
67 67
 
68 68
 func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) {
69 69
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep", "0")
70
-	cid, _, err := runCommandWithOutput(runCmd)
71
-	errorOut(err, t, fmt.Sprintf("%s", err))
72
-	cleanCID := stripTrailingCharacters(cid)
70
+	out, _, err := runCommandWithOutput(runCmd)
71
+	if err != nil {
72
+		t.Fatal(out, err)
73
+	}
74
+
75
+	cleanCID := stripTrailingCharacters(out)
73 76
 
74 77
 	diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
75
-	out, _, err := runCommandWithOutput(diffCmd)
76
-	errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err))
78
+	out, _, err = runCommandWithOutput(diffCmd)
79
+	if err != nil {
80
+		t.Fatalf("failed to run diff: %s, %v", out, err)
81
+	}
77 82
 	deleteContainer(cleanCID)
78 83
 
79 84
 	expected := map[string]bool{
... ...
@@ -10,13 +10,15 @@ import (
10 10
 
11 11
 func TestExec(t *testing.T) {
12 12
 	runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && sleep 100")
13
-	out, _, _, err := runCommandWithStdoutStderr(runCmd)
14
-	errorOut(err, t, out)
13
+	if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
14
+		t.Fatal(out, err)
15
+	}
15 16
 
16 17
 	execCmd := exec.Command(dockerBinary, "exec", "testing", "cat", "/tmp/file")
17
-
18
-	out, _, err = runCommandWithOutput(execCmd)
19
-	errorOut(err, t, out)
18
+	out, _, err := runCommandWithOutput(execCmd)
19
+	if err != nil {
20
+		t.Fatal(out, err)
21
+	}
20 22
 
21 23
 	out = strings.Trim(out, "\r\n")
22 24
 
... ...
@@ -31,8 +33,9 @@ func TestExec(t *testing.T) {
31 31
 
32 32
 func TestExecInteractive(t *testing.T) {
33 33
 	runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "testing", "busybox", "sh", "-c", "echo test > /tmp/file && sleep 100")
34
-	out, _, _, err := runCommandWithStdoutStderr(runCmd)
35
-	errorOut(err, t, out)
34
+	if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
35
+		t.Fatal(out, err)
36
+	}
36 37
 
37 38
 	execCmd := exec.Command(dockerBinary, "exec", "-i", "testing", "sh")
38 39
 	stdin, err := execCmd.StdinPipe()
... ...
@@ -84,17 +87,22 @@ func TestExecInteractive(t *testing.T) {
84 84
 func TestExecAfterContainerRestart(t *testing.T) {
85 85
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
86 86
 	out, _, err := runCommandWithOutput(runCmd)
87
-	errorOut(err, t, out)
87
+	if err != nil {
88
+		t.Fatal(out, err)
89
+	}
88 90
 
89 91
 	cleanedContainerID := stripTrailingCharacters(out)
90 92
 
91 93
 	runCmd = exec.Command(dockerBinary, "restart", cleanedContainerID)
92
-	out, _, err = runCommandWithOutput(runCmd)
93
-	errorOut(err, t, out)
94
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
95
+		t.Fatal(out, err)
96
+	}
94 97
 
95 98
 	runCmd = exec.Command(dockerBinary, "exec", cleanedContainerID, "echo", "hello")
96 99
 	out, _, err = runCommandWithOutput(runCmd)
97
-	errorOut(err, t, out)
100
+	if err != nil {
101
+		t.Fatal(out, err)
102
+	}
98 103
 
99 104
 	outStr := strings.TrimSpace(out)
100 105
 	if outStr != "hello" {
... ...
@@ -26,19 +26,23 @@ func TestExportContainerAndImportImage(t *testing.T) {
26 26
 	exportCmdTemplate := `%v export %v > /tmp/testexp.tar`
27 27
 	exportCmdFinal := fmt.Sprintf(exportCmdTemplate, dockerBinary, cleanedContainerID)
28 28
 	exportCmd := exec.Command("bash", "-c", exportCmdFinal)
29
-	out, _, err = runCommandWithOutput(exportCmd)
30
-	errorOut(err, t, fmt.Sprintf("failed to export container: %v %v", out, err))
29
+	if out, _, err = runCommandWithOutput(exportCmd); err != nil {
30
+		t.Fatalf("failed to export container: %s, %v", out, err)
31
+	}
31 32
 
32 33
 	importCmdFinal := `cat /tmp/testexp.tar | docker import - repo/testexp:v1`
33 34
 	importCmd := exec.Command("bash", "-c", importCmdFinal)
34 35
 	out, _, err = runCommandWithOutput(importCmd)
35
-	errorOut(err, t, fmt.Sprintf("failed to import image: %v %v", out, err))
36
+	if err != nil {
37
+		t.Fatalf("failed to import image: %s, %v", out, err)
38
+	}
36 39
 
37 40
 	cleanedImageID := stripTrailingCharacters(out)
38 41
 
39 42
 	inspectCmd = exec.Command(dockerBinary, "inspect", cleanedImageID)
40
-	out, _, err = runCommandWithOutput(inspectCmd)
41
-	errorOut(err, t, fmt.Sprintf("output should've been an image id: %v %v", out, err))
43
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
44
+		t.Fatalf("output should've been an image id: %s, %v", out, err)
45
+	}
42 46
 
43 47
 	deleteContainer(cleanedContainerID)
44 48
 	deleteImages("repo/testexp:v1")
... ...
@@ -46,9 +46,8 @@ RUN echo "Z"`,
46 46
 	}
47 47
 
48 48
 	out, exitCode, err := runCommandWithOutput(exec.Command(dockerBinary, "history", "testbuildhistory"))
49
-	errorOut(err, t, fmt.Sprintf("image history failed: %v %v", out, err))
50 49
 	if err != nil || exitCode != 0 {
51
-		t.Fatal("failed to get image history")
50
+		t.Fatal("failed to get image history: %s, %v", out, err)
52 51
 	}
53 52
 
54 53
 	actualValues := strings.Split(out, "\n")[1:27]
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -11,7 +10,9 @@ import (
11 11
 func TestImagesEnsureImageIsListed(t *testing.T) {
12 12
 	imagesCmd := exec.Command(dockerBinary, "images")
13 13
 	out, _, err := runCommandWithOutput(imagesCmd)
14
-	errorOut(err, t, fmt.Sprintf("listing images failed with errors: %v", err))
14
+	if err != nil {
15
+		t.Fatalf("listing images failed with errors: %s, %v", out, err)
16
+	}
15 17
 
16 18
 	if !strings.Contains(out, "busybox") {
17 19
 		t.Fatal("images should've listed busybox")
... ...
@@ -46,7 +47,9 @@ func TestImagesOrderedByCreationDate(t *testing.T) {
46 46
 	}
47 47
 
48 48
 	out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "images", "-q", "--no-trunc"))
49
-	errorOut(err, t, fmt.Sprintf("listing images failed with errors: %v", err))
49
+	if err != nil {
50
+		t.Fatalf("listing images failed with errors: %s, %v", out, err)
51
+	}
50 52
 	imgs := strings.Split(out, "\n")
51 53
 	if imgs[0] != id3 {
52 54
 		t.Fatalf("First image must be %s, got %s", id3, imgs[0])
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -11,10 +10,8 @@ import (
11 11
 func TestInfoEnsureSucceeds(t *testing.T) {
12 12
 	versionCmd := exec.Command(dockerBinary, "info")
13 13
 	out, exitCode, err := runCommandWithOutput(versionCmd)
14
-	errorOut(err, t, fmt.Sprintf("encountered error while running docker info: %v", err))
15
-
16 14
 	if err != nil || exitCode != 0 {
17
-		t.Fatal("failed to execute docker info")
15
+		t.Fatal("failed to execute docker info: %s, %v", out, err)
18 16
 	}
19 17
 
20 18
 	stringsToCheck := []string{"Containers:", "Execution Driver:", "Kernel Version:"}
... ...
@@ -10,13 +10,14 @@ func TestInspectImage(t *testing.T) {
10 10
 	imageTest := "scratch"
11 11
 	imageTestID := "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158"
12 12
 	imagesCmd := exec.Command(dockerBinary, "inspect", "--format='{{.Id}}'", imageTest)
13
-
14 13
 	out, exitCode, err := runCommandWithOutput(imagesCmd)
15 14
 	if exitCode != 0 || err != nil {
16
-		t.Fatalf("failed to inspect image")
15
+		t.Fatalf("failed to inspect image: %s, %v", out, err)
17 16
 	}
17
+
18 18
 	if id := strings.TrimSuffix(out, "\n"); id != imageTestID {
19 19
 		t.Fatalf("Expected id: %s for image: %s but received id: %s", imageTestID, imageTest, id)
20 20
 	}
21
+
21 22
 	logDone("inspect - inspect an image")
22 23
 }
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -10,21 +9,27 @@ import (
10 10
 func TestKillContainer(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 10")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
13
+	if err != nil {
14
+		t.Fatal(out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 
17 19
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
18
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
19
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
20
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
21
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
22
+	}
20 23
 
21 24
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
22
-	out, _, err = runCommandWithOutput(killCmd)
23
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v %v", out, err))
25
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
26
+		t.Fatalf("failed to kill container: %s, %v", out, err)
27
+	}
24 28
 
25 29
 	listRunningContainersCmd := exec.Command(dockerBinary, "ps", "-q")
26 30
 	out, _, err = runCommandWithOutput(listRunningContainersCmd)
27
-	errorOut(err, t, fmt.Sprintf("failed to list running containers: %v", err))
31
+	if err != nil {
32
+		t.Fatalf("failed to list running containers: %s, %v", out, err)
33
+	}
28 34
 
29 35
 	if strings.Contains(out, cleanedContainerID) {
30 36
 		t.Fatal("killed container is still running")
... ...
@@ -38,21 +43,27 @@ func TestKillContainer(t *testing.T) {
38 38
 func TestKillDifferentUserContainer(t *testing.T) {
39 39
 	runCmd := exec.Command(dockerBinary, "run", "-u", "daemon", "-d", "busybox", "sh", "-c", "sleep 10")
40 40
 	out, _, err := runCommandWithOutput(runCmd)
41
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
41
+	if err != nil {
42
+		t.Fatal(out, err)
43
+	}
42 44
 
43 45
 	cleanedContainerID := stripTrailingCharacters(out)
44 46
 
45 47
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
46
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
47
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
48
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
49
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
50
+	}
48 51
 
49 52
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
50
-	out, _, err = runCommandWithOutput(killCmd)
51
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v %v", out, err))
53
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
54
+		t.Fatalf("failed to kill container: %s, %v", out, err)
55
+	}
52 56
 
53 57
 	listRunningContainersCmd := exec.Command(dockerBinary, "ps", "-q")
54 58
 	out, _, err = runCommandWithOutput(listRunningContainersCmd)
55
-	errorOut(err, t, fmt.Sprintf("failed to list running containers: %v", err))
59
+	if err != nil {
60
+		t.Fatalf("failed to list running containers: %s, %v", out, err)
61
+	}
56 62
 
57 63
 	if strings.Contains(out, cleanedContainerID) {
58 64
 		t.Fatal("killed container is still running")
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"io/ioutil"
6 5
 	"os"
7 6
 	"os/exec"
... ...
@@ -14,7 +13,9 @@ import (
14 14
 func TestLinksEtcHostsRegularFile(t *testing.T) {
15 15
 	runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts")
16 16
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
17
-	errorOut(err, t, out)
17
+	if err != nil {
18
+		t.Fatal(out, err)
19
+	}
18 20
 
19 21
 	if !strings.HasPrefix(out, "-") {
20 22
 		t.Errorf("/etc/hosts should be a regular file")
... ...
@@ -28,7 +29,9 @@ func TestLinksEtcHostsRegularFile(t *testing.T) {
28 28
 func TestLinksEtcHostsContentMatch(t *testing.T) {
29 29
 	runCmd := exec.Command(dockerBinary, "run", "--net=host", "busybox", "cat", "/etc/hosts")
30 30
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
31
-	errorOut(err, t, out)
31
+	if err != nil {
32
+		t.Fatal(out, err)
33
+	}
32 34
 
33 35
 	hosts, err := ioutil.ReadFile("/etc/hosts")
34 36
 	if os.IsNotExist(err) {
... ...
@@ -51,7 +54,7 @@ func TestLinksPingUnlinkedContainers(t *testing.T) {
51 51
 	if exitCode == 0 {
52 52
 		t.Fatal("run ping did not fail")
53 53
 	} else if exitCode != 1 {
54
-		errorOut(err, t, fmt.Sprintf("run ping failed with errors: %v", err))
54
+		t.Fatalf("run ping failed with errors: %v", err)
55 55
 	}
56 56
 
57 57
 	logDone("links - ping unlinked container")
... ...
@@ -16,14 +16,18 @@ func TestLogsContainerSmallerThanPage(t *testing.T) {
16 16
 	testLen := 32767
17 17
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen))
18 18
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
19
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
19
+	if err != nil {
20
+		t.Fatalf("run failed with errors: %s, %v", out, err)
21
+	}
20 22
 
21 23
 	cleanedContainerID := stripTrailingCharacters(out)
22 24
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
23 25
 
24 26
 	logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
25 27
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
26
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
28
+	if err != nil {
29
+		t.Fatalf("failed to log container: %s, %v", out, err)
30
+	}
27 31
 
28 32
 	if len(out) != testLen+1 {
29 33
 		t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
... ...
@@ -39,14 +43,18 @@ func TestLogsContainerBiggerThanPage(t *testing.T) {
39 39
 	testLen := 32768
40 40
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen))
41 41
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
42
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
42
+	if err != nil {
43
+		t.Fatalf("run failed with errors: %s, %v", out, err)
44
+	}
43 45
 
44 46
 	cleanedContainerID := stripTrailingCharacters(out)
45 47
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
46 48
 
47 49
 	logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
48 50
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
49
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
51
+	if err != nil {
52
+		t.Fatalf("failed to log container: %s, %v", out, err)
53
+	}
50 54
 
51 55
 	if len(out) != testLen+1 {
52 56
 		t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
... ...
@@ -62,14 +70,18 @@ func TestLogsContainerMuchBiggerThanPage(t *testing.T) {
62 62
 	testLen := 33000
63 63
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen))
64 64
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
65
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
65
+	if err != nil {
66
+		t.Fatalf("run failed with errors: %s, %v", out, err)
67
+	}
66 68
 
67 69
 	cleanedContainerID := stripTrailingCharacters(out)
68 70
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
69 71
 
70 72
 	logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
71 73
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
72
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
74
+	if err != nil {
75
+		t.Fatalf("failed to log container: %s, %v", out, err)
76
+	}
73 77
 
74 78
 	if len(out) != testLen+1 {
75 79
 		t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
... ...
@@ -85,14 +97,18 @@ func TestLogsTimestamps(t *testing.T) {
85 85
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen))
86 86
 
87 87
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
88
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
88
+	if err != nil {
89
+		t.Fatalf("run failed with errors: %s, %v", out, err)
90
+	}
89 91
 
90 92
 	cleanedContainerID := stripTrailingCharacters(out)
91 93
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
92 94
 
93 95
 	logsCmd := exec.Command(dockerBinary, "logs", "-t", cleanedContainerID)
94 96
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
95
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
97
+	if err != nil {
98
+		t.Fatalf("failed to log container: %s, %v", out, err)
99
+	}
96 100
 
97 101
 	lines := strings.Split(out, "\n")
98 102
 
... ...
@@ -124,14 +140,18 @@ func TestLogsSeparateStderr(t *testing.T) {
124 124
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg))
125 125
 
126 126
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
127
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
127
+	if err != nil {
128
+		t.Fatalf("run failed with errors: %s, %v", out, err)
129
+	}
128 130
 
129 131
 	cleanedContainerID := stripTrailingCharacters(out)
130 132
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
131 133
 
132 134
 	logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
133 135
 	stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd)
134
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
136
+	if err != nil {
137
+		t.Fatalf("failed to log container: %s, %v", out, err)
138
+	}
135 139
 
136 140
 	if stdout != "" {
137 141
 		t.Fatalf("Expected empty stdout stream, got %v", stdout)
... ...
@@ -152,14 +172,18 @@ func TestLogsStderrInStdout(t *testing.T) {
152 152
 	runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg))
153 153
 
154 154
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
155
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
155
+	if err != nil {
156
+		t.Fatalf("run failed with errors: %s, %v", out, err)
157
+	}
156 158
 
157 159
 	cleanedContainerID := stripTrailingCharacters(out)
158 160
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
159 161
 
160 162
 	logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
161 163
 	stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd)
162
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
164
+	if err != nil {
165
+		t.Fatalf("failed to log container: %s, %v", out, err)
166
+	}
163 167
 
164 168
 	if stderr != "" {
165 169
 		t.Fatalf("Expected empty stderr stream, got %v", stdout)
... ...
@@ -180,14 +204,18 @@ func TestLogsTail(t *testing.T) {
180 180
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen))
181 181
 
182 182
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
183
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
183
+	if err != nil {
184
+		t.Fatalf("run failed with errors: %s, %v", out, err)
185
+	}
184 186
 
185 187
 	cleanedContainerID := stripTrailingCharacters(out)
186 188
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
187 189
 
188 190
 	logsCmd := exec.Command(dockerBinary, "logs", "--tail", "5", cleanedContainerID)
189 191
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
190
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
192
+	if err != nil {
193
+		t.Fatalf("failed to log container: %s, %v", out, err)
194
+	}
191 195
 
192 196
 	lines := strings.Split(out, "\n")
193 197
 
... ...
@@ -197,7 +225,9 @@ func TestLogsTail(t *testing.T) {
197 197
 
198 198
 	logsCmd = exec.Command(dockerBinary, "logs", "--tail", "all", cleanedContainerID)
199 199
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
200
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
200
+	if err != nil {
201
+		t.Fatalf("failed to log container: %s, %v", out, err)
202
+	}
201 203
 
202 204
 	lines = strings.Split(out, "\n")
203 205
 
... ...
@@ -207,7 +237,9 @@ func TestLogsTail(t *testing.T) {
207 207
 
208 208
 	logsCmd = exec.Command(dockerBinary, "logs", "--tail", "random", cleanedContainerID)
209 209
 	out, _, _, err = runCommandWithStdoutStderr(logsCmd)
210
-	errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
210
+	if err != nil {
211
+		t.Fatalf("failed to log container: %s, %v", out, err)
212
+	}
211 213
 
212 214
 	lines = strings.Split(out, "\n")
213 215
 
... ...
@@ -223,7 +255,9 @@ func TestLogsFollowStopped(t *testing.T) {
223 223
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello")
224 224
 
225 225
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
226
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
226
+	if err != nil {
227
+		t.Fatalf("run failed with errors: %s, %v", out, err)
228
+	}
227 229
 
228 230
 	cleanedContainerID := stripTrailingCharacters(out)
229 231
 	exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
... ...
@@ -26,17 +26,24 @@ func TestNetworkNat(t *testing.T) {
26 26
 
27 27
 	runCmd := exec.Command(dockerBinary, "run", "-dt", "-p", "8080:8080", "busybox", "nc", "-lp", "8080")
28 28
 	out, _, err := runCommandWithOutput(runCmd)
29
-	errorOut(err, t, fmt.Sprintf("run1 failed with errors: %v (%s)", err, out))
29
+	if err != nil {
30
+		t.Fatal(out, err)
31
+	}
30 32
 
31 33
 	cleanedContainerID := stripTrailingCharacters(out)
32 34
 
33 35
 	runCmd = exec.Command(dockerBinary, "run", "busybox", "sh", "-c", fmt.Sprintf("echo hello world | nc -w 30 %s 8080", ifaceIP))
34 36
 	out, _, err = runCommandWithOutput(runCmd)
35
-	errorOut(err, t, fmt.Sprintf("run2 failed with errors: %v (%s)", err, out))
37
+	if err != nil {
38
+		t.Fatal(out, err)
39
+	}
36 40
 
37 41
 	runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID)
38 42
 	out, _, err = runCommandWithOutput(runCmd)
39
-	errorOut(err, t, fmt.Sprintf("failed to retrieve logs for container: %v %v", cleanedContainerID, err))
43
+	if err != nil {
44
+		t.Fatalf("failed to retrieve logs for container: %s, %v", out, err)
45
+	}
46
+
40 47
 	out = strings.Trim(out, "\r\n")
41 48
 
42 49
 	if expected := "hello world"; out != expected {
... ...
@@ -44,8 +51,9 @@ func TestNetworkNat(t *testing.T) {
44 44
 	}
45 45
 
46 46
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
47
-	out, _, err = runCommandWithOutput(killCmd)
48
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v %v", out, err))
47
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
48
+		t.Fatalf("failed to kill container: %s, %v", out, err)
49
+	}
49 50
 	deleteAllContainers()
50 51
 
51 52
 	logDone("network - make sure nat works through the host")
... ...
@@ -11,12 +11,16 @@ func TestPortList(t *testing.T) {
11 11
 	// one port
12 12
 	runCmd := exec.Command(dockerBinary, "run", "-d", "-p", "9876:80", "busybox", "top")
13 13
 	out, _, err := runCommandWithOutput(runCmd)
14
-	errorOut(err, t, out)
14
+	if err != nil {
15
+		t.Fatal(out, err)
16
+	}
15 17
 	firstID := stripTrailingCharacters(out)
16 18
 
17 19
 	runCmd = exec.Command(dockerBinary, "port", firstID, "80")
18 20
 	out, _, err = runCommandWithOutput(runCmd)
19
-	errorOut(err, t, out)
21
+	if err != nil {
22
+		t.Fatal(out, err)
23
+	}
20 24
 
21 25
 	if !assertPortList(t, out, []string{"0.0.0.0:9876"}) {
22 26
 		t.Error("Port list is not correct")
... ...
@@ -24,14 +28,17 @@ func TestPortList(t *testing.T) {
24 24
 
25 25
 	runCmd = exec.Command(dockerBinary, "port", firstID)
26 26
 	out, _, err = runCommandWithOutput(runCmd)
27
-	errorOut(err, t, out)
27
+	if err != nil {
28
+		t.Fatal(out, err)
29
+	}
28 30
 
29 31
 	if !assertPortList(t, out, []string{"80/tcp -> 0.0.0.0:9876"}) {
30 32
 		t.Error("Port list is not correct")
31 33
 	}
32 34
 	runCmd = exec.Command(dockerBinary, "rm", "-f", firstID)
33
-	out, _, err = runCommandWithOutput(runCmd)
34
-	errorOut(err, t, out)
35
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
36
+		t.Fatal(out, err)
37
+	}
35 38
 
36 39
 	// three port
37 40
 	runCmd = exec.Command(dockerBinary, "run", "-d",
... ...
@@ -40,12 +47,16 @@ func TestPortList(t *testing.T) {
40 40
 		"-p", "9878:82",
41 41
 		"busybox", "top")
42 42
 	out, _, err = runCommandWithOutput(runCmd)
43
-	errorOut(err, t, out)
43
+	if err != nil {
44
+		t.Fatal(out, err)
45
+	}
44 46
 	ID := stripTrailingCharacters(out)
45 47
 
46 48
 	runCmd = exec.Command(dockerBinary, "port", ID, "80")
47 49
 	out, _, err = runCommandWithOutput(runCmd)
48
-	errorOut(err, t, out)
50
+	if err != nil {
51
+		t.Fatal(out, err)
52
+	}
49 53
 
50 54
 	if !assertPortList(t, out, []string{"0.0.0.0:9876"}) {
51 55
 		t.Error("Port list is not correct")
... ...
@@ -53,7 +64,9 @@ func TestPortList(t *testing.T) {
53 53
 
54 54
 	runCmd = exec.Command(dockerBinary, "port", ID)
55 55
 	out, _, err = runCommandWithOutput(runCmd)
56
-	errorOut(err, t, out)
56
+	if err != nil {
57
+		t.Fatal(out, err)
58
+	}
57 59
 
58 60
 	if !assertPortList(t, out, []string{
59 61
 		"80/tcp -> 0.0.0.0:9876",
... ...
@@ -63,7 +76,9 @@ func TestPortList(t *testing.T) {
63 63
 	}
64 64
 	runCmd = exec.Command(dockerBinary, "rm", "-f", ID)
65 65
 	out, _, err = runCommandWithOutput(runCmd)
66
-	errorOut(err, t, out)
66
+	if err != nil {
67
+		t.Fatal(out, err)
68
+	}
67 69
 
68 70
 	// more and one port mapped to the same container port
69 71
 	runCmd = exec.Command(dockerBinary, "run", "-d",
... ...
@@ -73,12 +88,16 @@ func TestPortList(t *testing.T) {
73 73
 		"-p", "9878:82",
74 74
 		"busybox", "top")
75 75
 	out, _, err = runCommandWithOutput(runCmd)
76
-	errorOut(err, t, out)
76
+	if err != nil {
77
+		t.Fatal(out, err)
78
+	}
77 79
 	ID = stripTrailingCharacters(out)
78 80
 
79 81
 	runCmd = exec.Command(dockerBinary, "port", ID, "80")
80 82
 	out, _, err = runCommandWithOutput(runCmd)
81
-	errorOut(err, t, out)
83
+	if err != nil {
84
+		t.Fatal(out, err)
85
+	}
82 86
 
83 87
 	if !assertPortList(t, out, []string{"0.0.0.0:9876", "0.0.0.0:9999"}) {
84 88
 		t.Error("Port list is not correct")
... ...
@@ -86,7 +105,9 @@ func TestPortList(t *testing.T) {
86 86
 
87 87
 	runCmd = exec.Command(dockerBinary, "port", ID)
88 88
 	out, _, err = runCommandWithOutput(runCmd)
89
-	errorOut(err, t, out)
89
+	if err != nil {
90
+		t.Fatal(out, err)
91
+	}
90 92
 
91 93
 	if !assertPortList(t, out, []string{
92 94
 		"80/tcp -> 0.0.0.0:9876",
... ...
@@ -96,8 +117,9 @@ func TestPortList(t *testing.T) {
96 96
 		t.Error("Port list is not correct\n", out)
97 97
 	}
98 98
 	runCmd = exec.Command(dockerBinary, "rm", "-f", ID)
99
-	out, _, err = runCommandWithOutput(runCmd)
100
-	errorOut(err, t, out)
99
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
100
+		t.Fatal(out, err)
101
+	}
101 102
 
102 103
 	deleteAllContainers()
103 104
 
... ...
@@ -10,34 +10,45 @@ import (
10 10
 func TestPsListContainers(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, out)
13
+	if err != nil {
14
+		t.Fatal(out, err)
15
+	}
14 16
 	firstID := stripTrailingCharacters(out)
15 17
 
16 18
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top")
17 19
 	out, _, err = runCommandWithOutput(runCmd)
18
-	errorOut(err, t, out)
20
+	if err != nil {
21
+		t.Fatal(out, err)
22
+	}
19 23
 	secondID := stripTrailingCharacters(out)
20 24
 
21 25
 	// not long running
22 26
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "true")
23 27
 	out, _, err = runCommandWithOutput(runCmd)
24
-	errorOut(err, t, out)
28
+	if err != nil {
29
+		t.Fatal(out, err)
30
+	}
25 31
 	thirdID := stripTrailingCharacters(out)
26 32
 
27 33
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top")
28 34
 	out, _, err = runCommandWithOutput(runCmd)
29
-	errorOut(err, t, out)
35
+	if err != nil {
36
+		t.Fatal(out, err)
37
+	}
30 38
 	fourthID := stripTrailingCharacters(out)
31 39
 
32 40
 	// make sure third one is not running
33 41
 	runCmd = exec.Command(dockerBinary, "wait", thirdID)
34
-	out, _, err = runCommandWithOutput(runCmd)
35
-	errorOut(err, t, out)
42
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
43
+		t.Fatal(out, err)
44
+	}
36 45
 
37 46
 	// all
38 47
 	runCmd = exec.Command(dockerBinary, "ps", "-a")
39 48
 	out, _, err = runCommandWithOutput(runCmd)
40
-	errorOut(err, t, out)
49
+	if err != nil {
50
+		t.Fatal(out, err)
51
+	}
41 52
 
42 53
 	if !assertContainerList(out, []string{fourthID, thirdID, secondID, firstID}) {
43 54
 		t.Error("Container list is not in the correct order")
... ...
@@ -46,7 +57,9 @@ func TestPsListContainers(t *testing.T) {
46 46
 	// running
47 47
 	runCmd = exec.Command(dockerBinary, "ps")
48 48
 	out, _, err = runCommandWithOutput(runCmd)
49
-	errorOut(err, t, out)
49
+	if err != nil {
50
+		t.Fatal(out, err)
51
+	}
50 52
 
51 53
 	if !assertContainerList(out, []string{fourthID, secondID, firstID}) {
52 54
 		t.Error("Container list is not in the correct order")
... ...
@@ -57,7 +70,9 @@ func TestPsListContainers(t *testing.T) {
57 57
 	// limit
58 58
 	runCmd = exec.Command(dockerBinary, "ps", "-n=2", "-a")
59 59
 	out, _, err = runCommandWithOutput(runCmd)
60
-	errorOut(err, t, out)
60
+	if err != nil {
61
+		t.Fatal(out, err)
62
+	}
61 63
 	expected := []string{fourthID, thirdID}
62 64
 
63 65
 	if !assertContainerList(out, expected) {
... ...
@@ -66,7 +81,9 @@ func TestPsListContainers(t *testing.T) {
66 66
 
67 67
 	runCmd = exec.Command(dockerBinary, "ps", "-n=2")
68 68
 	out, _, err = runCommandWithOutput(runCmd)
69
-	errorOut(err, t, out)
69
+	if err != nil {
70
+		t.Fatal(out, err)
71
+	}
70 72
 
71 73
 	if !assertContainerList(out, expected) {
72 74
 		t.Error("Container list is not in the correct order")
... ...
@@ -75,7 +92,9 @@ func TestPsListContainers(t *testing.T) {
75 75
 	// since
76 76
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-a")
77 77
 	out, _, err = runCommandWithOutput(runCmd)
78
-	errorOut(err, t, out)
78
+	if err != nil {
79
+		t.Fatal(out, err)
80
+	}
79 81
 	expected = []string{fourthID, thirdID, secondID}
80 82
 
81 83
 	if !assertContainerList(out, expected) {
... ...
@@ -84,7 +103,9 @@ func TestPsListContainers(t *testing.T) {
84 84
 
85 85
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID)
86 86
 	out, _, err = runCommandWithOutput(runCmd)
87
-	errorOut(err, t, out)
87
+	if err != nil {
88
+		t.Fatal(out, err)
89
+	}
88 90
 
89 91
 	if !assertContainerList(out, expected) {
90 92
 		t.Error("Container list is not in the correct order")
... ...
@@ -93,7 +114,9 @@ func TestPsListContainers(t *testing.T) {
93 93
 	// before
94 94
 	runCmd = exec.Command(dockerBinary, "ps", "--before", thirdID, "-a")
95 95
 	out, _, err = runCommandWithOutput(runCmd)
96
-	errorOut(err, t, out)
96
+	if err != nil {
97
+		t.Fatal(out, err)
98
+	}
97 99
 	expected = []string{secondID, firstID}
98 100
 
99 101
 	if !assertContainerList(out, expected) {
... ...
@@ -102,7 +125,9 @@ func TestPsListContainers(t *testing.T) {
102 102
 
103 103
 	runCmd = exec.Command(dockerBinary, "ps", "--before", thirdID)
104 104
 	out, _, err = runCommandWithOutput(runCmd)
105
-	errorOut(err, t, out)
105
+	if err != nil {
106
+		t.Fatal(out, err)
107
+	}
106 108
 
107 109
 	if !assertContainerList(out, expected) {
108 110
 		t.Error("Container list is not in the correct order")
... ...
@@ -111,7 +136,9 @@ func TestPsListContainers(t *testing.T) {
111 111
 	// since & before
112 112
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-a")
113 113
 	out, _, err = runCommandWithOutput(runCmd)
114
-	errorOut(err, t, out)
114
+	if err != nil {
115
+		t.Fatal(out, err)
116
+	}
115 117
 	expected = []string{thirdID, secondID}
116 118
 
117 119
 	if !assertContainerList(out, expected) {
... ...
@@ -120,7 +147,9 @@ func TestPsListContainers(t *testing.T) {
120 120
 
121 121
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID)
122 122
 	out, _, err = runCommandWithOutput(runCmd)
123
-	errorOut(err, t, out)
123
+	if err != nil {
124
+		t.Fatal(out, err)
125
+	}
124 126
 	if !assertContainerList(out, expected) {
125 127
 		t.Error("Container list is not in the correct order")
126 128
 	}
... ...
@@ -128,7 +157,9 @@ func TestPsListContainers(t *testing.T) {
128 128
 	// since & limit
129 129
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-n=2", "-a")
130 130
 	out, _, err = runCommandWithOutput(runCmd)
131
-	errorOut(err, t, out)
131
+	if err != nil {
132
+		t.Fatal(out, err)
133
+	}
132 134
 	expected = []string{fourthID, thirdID}
133 135
 
134 136
 	if !assertContainerList(out, expected) {
... ...
@@ -137,7 +168,9 @@ func TestPsListContainers(t *testing.T) {
137 137
 
138 138
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-n=2")
139 139
 	out, _, err = runCommandWithOutput(runCmd)
140
-	errorOut(err, t, out)
140
+	if err != nil {
141
+		t.Fatal(out, err)
142
+	}
141 143
 
142 144
 	if !assertContainerList(out, expected) {
143 145
 		t.Error("Container list is not in the correct order")
... ...
@@ -146,7 +179,9 @@ func TestPsListContainers(t *testing.T) {
146 146
 	// before & limit
147 147
 	runCmd = exec.Command(dockerBinary, "ps", "--before", fourthID, "-n=1", "-a")
148 148
 	out, _, err = runCommandWithOutput(runCmd)
149
-	errorOut(err, t, out)
149
+	if err != nil {
150
+		t.Fatal(out, err)
151
+	}
150 152
 	expected = []string{thirdID}
151 153
 
152 154
 	if !assertContainerList(out, expected) {
... ...
@@ -155,7 +190,9 @@ func TestPsListContainers(t *testing.T) {
155 155
 
156 156
 	runCmd = exec.Command(dockerBinary, "ps", "--before", fourthID, "-n=1")
157 157
 	out, _, err = runCommandWithOutput(runCmd)
158
-	errorOut(err, t, out)
158
+	if err != nil {
159
+		t.Fatal(out, err)
160
+	}
159 161
 
160 162
 	if !assertContainerList(out, expected) {
161 163
 		t.Error("Container list is not in the correct order")
... ...
@@ -164,7 +201,9 @@ func TestPsListContainers(t *testing.T) {
164 164
 	// since & before & limit
165 165
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-n=1", "-a")
166 166
 	out, _, err = runCommandWithOutput(runCmd)
167
-	errorOut(err, t, out)
167
+	if err != nil {
168
+		t.Fatal(out, err)
169
+	}
168 170
 	expected = []string{thirdID}
169 171
 
170 172
 	if !assertContainerList(out, expected) {
... ...
@@ -173,7 +212,9 @@ func TestPsListContainers(t *testing.T) {
173 173
 
174 174
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-n=1")
175 175
 	out, _, err = runCommandWithOutput(runCmd)
176
-	errorOut(err, t, out)
176
+	if err != nil {
177
+		t.Fatal(out, err)
178
+	}
177 179
 
178 180
 	if !assertContainerList(out, expected) {
179 181
 		t.Error("Container list is not in the correct order")
... ...
@@ -205,7 +246,9 @@ func TestPsListContainersSize(t *testing.T) {
205 205
 	name := "test_size"
206 206
 	runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "sh", "-c", "echo 1 > test")
207 207
 	out, _, err := runCommandWithOutput(runCmd)
208
-	errorOut(err, t, out)
208
+	if err != nil {
209
+		t.Fatal(out, err)
210
+	}
209 211
 	id, err := getIDByName(name)
210 212
 	if err != nil {
211 213
 		t.Fatal(err)
... ...
@@ -222,7 +265,9 @@ func TestPsListContainersSize(t *testing.T) {
222 222
 	case <-time.After(3 * time.Second):
223 223
 		t.Fatalf("Calling \"docker ps -s\" timed out!")
224 224
 	}
225
-	errorOut(err, t, out)
225
+	if err != nil {
226
+		t.Fatal(out, err)
227
+	}
226 228
 	lines := strings.Split(strings.Trim(out, "\n "), "\n")
227 229
 	sizeIndex := strings.Index(lines[0], "SIZE")
228 230
 	idIndex := strings.Index(lines[0], "CONTAINER ID")
... ...
@@ -247,24 +292,31 @@ func TestPsListContainersFilterStatus(t *testing.T) {
247 247
 	// start exited container
248 248
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox")
249 249
 	out, _, err := runCommandWithOutput(runCmd)
250
-	errorOut(err, t, out)
250
+	if err != nil {
251
+		t.Fatal(out, err)
252
+	}
251 253
 	firstID := stripTrailingCharacters(out)
252 254
 
253 255
 	// make sure the exited cintainer is not running
254 256
 	runCmd = exec.Command(dockerBinary, "wait", firstID)
255
-	out, _, err = runCommandWithOutput(runCmd)
256
-	errorOut(err, t, out)
257
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
258
+		t.Fatal(out, err)
259
+	}
257 260
 
258 261
 	// start running container
259 262
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 360")
260 263
 	out, _, err = runCommandWithOutput(runCmd)
261
-	errorOut(err, t, out)
264
+	if err != nil {
265
+		t.Fatal(out, err)
266
+	}
262 267
 	secondID := stripTrailingCharacters(out)
263 268
 
264 269
 	// filter containers by exited
265 270
 	runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--filter=status=exited")
266 271
 	out, _, err = runCommandWithOutput(runCmd)
267
-	errorOut(err, t, out)
272
+	if err != nil {
273
+		t.Fatal(out, err)
274
+	}
268 275
 	containerOut := strings.TrimSpace(out)
269 276
 	if containerOut != firstID[:12] {
270 277
 		t.Fatalf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out)
... ...
@@ -272,7 +324,9 @@ func TestPsListContainersFilterStatus(t *testing.T) {
272 272
 
273 273
 	runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--filter=status=running")
274 274
 	out, _, err = runCommandWithOutput(runCmd)
275
-	errorOut(err, t, out)
275
+	if err != nil {
276
+		t.Fatal(out, err)
277
+	}
276 278
 	containerOut = strings.TrimSpace(out)
277 279
 	if containerOut != secondID[:12] {
278 280
 		t.Fatalf("Expected id %s, got %s for running filter, output: %q", secondID[:12], containerOut, out)
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"testing"
7 6
 )
... ...
@@ -11,11 +10,8 @@ import (
11 11
 // pulling an image from the central registry should work
12 12
 func TestPullImageFromCentralRegistry(t *testing.T) {
13 13
 	pullCmd := exec.Command(dockerBinary, "pull", "scratch")
14
-	out, exitCode, err := runCommandWithOutput(pullCmd)
15
-	errorOut(err, t, fmt.Sprintf("%s %s", out, err))
16
-
17
-	if err != nil || exitCode != 0 {
18
-		t.Fatal("pulling the scratch image from the registry has failed")
14
+	if out, _, err := runCommandWithOutput(pullCmd); err != nil {
15
+		t.Fatal("pulling the scratch image from the registry has failed: %s, %v", out, err)
19 16
 	}
20 17
 	logDone("pull - pull scratch")
21 18
 }
... ...
@@ -23,10 +19,8 @@ func TestPullImageFromCentralRegistry(t *testing.T) {
23 23
 // pulling a non-existing image from the central registry should return a non-zero exit code
24 24
 func TestPullNonExistingImage(t *testing.T) {
25 25
 	pullCmd := exec.Command(dockerBinary, "pull", "fooblahblah1234")
26
-	_, exitCode, err := runCommandWithOutput(pullCmd)
27
-
28
-	if err == nil || exitCode == 0 {
29
-		t.Fatal("expected non-zero exit status when pulling non-existing image")
26
+	if out, _, err := runCommandWithOutput(pullCmd); err == nil {
27
+		t.Fatal("expected non-zero exit status when pulling non-existing image: %s", out)
30 28
 	}
31 29
 	logDone("pull - pull fooblahblah1234 (non-existing image)")
32 30
 }
... ...
@@ -15,22 +15,17 @@ func TestPushBusyboxImage(t *testing.T) {
15 15
 	// tag the image to upload it tot he private registry
16 16
 	repoName := fmt.Sprintf("%v/busybox", privateRegistryURL)
17 17
 	tagCmd := exec.Command(dockerBinary, "tag", "busybox", repoName)
18
-	out, exitCode, err := runCommandWithOutput(tagCmd)
19
-	errorOut(err, t, fmt.Sprintf("%v %v", out, err))
20
-
21
-	if err != nil || exitCode != 0 {
22
-		t.Fatal("image tagging failed")
18
+	if out, _, err := runCommandWithOutput(tagCmd); err != nil {
19
+		t.Fatal("image tagging failed: %s, %v", out, err)
23 20
 	}
24 21
 
25 22
 	pushCmd := exec.Command(dockerBinary, "push", repoName)
26
-	out, exitCode, err = runCommandWithOutput(pushCmd)
27
-	errorOut(err, t, fmt.Sprintf("%v %v", out, err))
23
+	if out, _, err := runCommandWithOutput(pushCmd); err != nil {
24
+		t.Fatal("pushing the image to the private registry has failed: %s, %v", out, err)
25
+	}
28 26
 
29 27
 	deleteImages(repoName)
30 28
 
31
-	if err != nil || exitCode != 0 {
32
-		t.Fatal("pushing the image to the private registry has failed")
33
-	}
34 29
 	logDone("push - push busybox to private registry")
35 30
 }
36 31
 
... ...
@@ -39,10 +34,8 @@ func TestPushUnprefixedRepo(t *testing.T) {
39 39
 	// skip this test until we're able to use a registry
40 40
 	t.Skip()
41 41
 	pushCmd := exec.Command(dockerBinary, "push", "busybox")
42
-	_, exitCode, err := runCommandWithOutput(pushCmd)
43
-
44
-	if err == nil || exitCode == 0 {
45
-		t.Fatal("pushing an unprefixed repo didn't result in a non-zero exit status")
42
+	if out, _, err := runCommandWithOutput(pushCmd); err == nil {
43
+		t.Fatal("pushing an unprefixed repo didn't result in a non-zero exit status: %s", out)
46 44
 	}
47 45
 	logDone("push - push unprefixed busybox repo --> must fail")
48 46
 }
... ...
@@ -10,29 +10,37 @@ import (
10 10
 func TestRestartStoppedContainer(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "foobar")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, out)
13
+	if err != nil {
14
+		t.Fatal(out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 
17 19
 	runCmd = exec.Command(dockerBinary, "wait", cleanedContainerID)
18
-	out, _, err = runCommandWithOutput(runCmd)
19
-	errorOut(err, t, out)
20
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
21
+		t.Fatal(out, err)
22
+	}
20 23
 
21 24
 	runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID)
22 25
 	out, _, err = runCommandWithOutput(runCmd)
23
-	errorOut(err, t, out)
26
+	if err != nil {
27
+		t.Fatal(out, err)
28
+	}
24 29
 
25 30
 	if out != "foobar\n" {
26 31
 		t.Errorf("container should've printed 'foobar'")
27 32
 	}
28 33
 
29 34
 	runCmd = exec.Command(dockerBinary, "restart", cleanedContainerID)
30
-	out, _, err = runCommandWithOutput(runCmd)
31
-	errorOut(err, t, out)
35
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
36
+		t.Fatal(out, err)
37
+	}
32 38
 
33 39
 	runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID)
34 40
 	out, _, err = runCommandWithOutput(runCmd)
35
-	errorOut(err, t, out)
41
+	if err != nil {
42
+		t.Fatal(out, err)
43
+	}
36 44
 
37 45
 	if out != "foobar\nfoobar\n" {
38 46
 		t.Errorf("container should've printed 'foobar' twice")
... ...
@@ -46,7 +54,9 @@ func TestRestartStoppedContainer(t *testing.T) {
46 46
 func TestRestartRunningContainer(t *testing.T) {
47 47
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'")
48 48
 	out, _, err := runCommandWithOutput(runCmd)
49
-	errorOut(err, t, out)
49
+	if err != nil {
50
+		t.Fatal(out, err)
51
+	}
50 52
 
51 53
 	cleanedContainerID := stripTrailingCharacters(out)
52 54
 
... ...
@@ -54,19 +64,24 @@ func TestRestartRunningContainer(t *testing.T) {
54 54
 
55 55
 	runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID)
56 56
 	out, _, err = runCommandWithOutput(runCmd)
57
-	errorOut(err, t, out)
57
+	if err != nil {
58
+		t.Fatal(out, err)
59
+	}
58 60
 
59 61
 	if out != "foobar\n" {
60 62
 		t.Errorf("container should've printed 'foobar'")
61 63
 	}
62 64
 
63 65
 	runCmd = exec.Command(dockerBinary, "restart", "-t", "1", cleanedContainerID)
64
-	out, _, err = runCommandWithOutput(runCmd)
65
-	errorOut(err, t, out)
66
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
67
+		t.Fatal(out, err)
68
+	}
66 69
 
67 70
 	runCmd = exec.Command(dockerBinary, "logs", cleanedContainerID)
68 71
 	out, _, err = runCommandWithOutput(runCmd)
69
-	errorOut(err, t, out)
72
+	if err != nil {
73
+		t.Fatal(out, err)
74
+	}
70 75
 
71 76
 	time.Sleep(1 * time.Second)
72 77
 
... ...
@@ -83,13 +98,17 @@ func TestRestartRunningContainer(t *testing.T) {
83 83
 func TestRestartWithVolumes(t *testing.T) {
84 84
 	runCmd := exec.Command(dockerBinary, "run", "-d", "-v", "/test", "busybox", "top")
85 85
 	out, _, err := runCommandWithOutput(runCmd)
86
-	errorOut(err, t, out)
86
+	if err != nil {
87
+		t.Fatal(out, err)
88
+	}
87 89
 
88 90
 	cleanedContainerID := stripTrailingCharacters(out)
89 91
 
90 92
 	runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ len .Volumes }}", cleanedContainerID)
91 93
 	out, _, err = runCommandWithOutput(runCmd)
92
-	errorOut(err, t, out)
94
+	if err != nil {
95
+		t.Fatal(out, err)
96
+	}
93 97
 
94 98
 	if out = strings.Trim(out, " \n\r"); out != "1" {
95 99
 		t.Errorf("expect 1 volume received %s", out)
... ...
@@ -97,15 +116,20 @@ func TestRestartWithVolumes(t *testing.T) {
97 97
 
98 98
 	runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ .Volumes }}", cleanedContainerID)
99 99
 	volumes, _, err := runCommandWithOutput(runCmd)
100
-	errorOut(err, t, volumes)
100
+	if err != nil {
101
+		t.Fatal(volumes, err)
102
+	}
101 103
 
102 104
 	runCmd = exec.Command(dockerBinary, "restart", cleanedContainerID)
103
-	out, _, err = runCommandWithOutput(runCmd)
104
-	errorOut(err, t, out)
105
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
106
+		t.Fatal(out, err)
107
+	}
105 108
 
106 109
 	runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ len .Volumes }}", cleanedContainerID)
107 110
 	out, _, err = runCommandWithOutput(runCmd)
108
-	errorOut(err, t, out)
111
+	if err != nil {
112
+		t.Fatal(out, err)
113
+	}
109 114
 
110 115
 	if out = strings.Trim(out, " \n\r"); out != "1" {
111 116
 		t.Errorf("expect 1 volume after restart received %s", out)
... ...
@@ -113,7 +137,9 @@ func TestRestartWithVolumes(t *testing.T) {
113 113
 
114 114
 	runCmd = exec.Command(dockerBinary, "inspect", "--format", "{{ .Volumes }}", cleanedContainerID)
115 115
 	volumesAfterRestart, _, err := runCommandWithOutput(runCmd)
116
-	errorOut(err, t, volumesAfterRestart)
116
+	if err != nil {
117
+		t.Fatal(volumesAfterRestart, err)
118
+	}
117 119
 
118 120
 	if volumes != volumesAfterRestart {
119 121
 		volumes = strings.Trim(volumes, " \n\r")
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -13,7 +12,9 @@ func TestRmiWithContainerFails(t *testing.T) {
13 13
 	// create a container
14 14
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
15 15
 	out, _, err := runCommandWithOutput(runCmd)
16
-	errorOut(err, t, fmt.Sprintf("failed to create a container: %v %v", out, err))
16
+	if err != nil {
17
+		t.Fatalf("failed to create a container: %s, %v", out, err)
18
+	}
17 19
 
18 20
 	cleanedContainerID := stripTrailingCharacters(out)
19 21
 
... ...
@@ -141,8 +141,6 @@ func TestRunPingGoogle(t *testing.T) {
141 141
 		t.Fatalf("failed to run container: %v, output: %q", err, out)
142 142
 	}
143 143
 
144
-	errorOut(err, t, "container should've been able to ping 8.8.8.8")
145
-
146 144
 	deleteAllContainers()
147 145
 
148 146
 	logDone("run - ping 8.8.8.8")
... ...
@@ -152,11 +150,8 @@ func TestRunPingGoogle(t *testing.T) {
152 152
 // some versions of lxc might make this test fail
153 153
 func TestRunExitCodeZero(t *testing.T) {
154 154
 	runCmd := exec.Command(dockerBinary, "run", "busybox", "true")
155
-	exitCode, err := runCommand(runCmd)
156
-	errorOut(err, t, fmt.Sprintf("%s", err))
157
-
158
-	if exitCode != 0 {
159
-		t.Errorf("container should've exited with exit code 0")
155
+	if out, _, err := runCommandWithOutput(runCmd); err != nil {
156
+		t.Errorf("container should've exited with exit code 0: %s, %v", out, err)
160 157
 	}
161 158
 
162 159
 	deleteAllContainers()
... ...
@@ -193,26 +188,31 @@ func TestRunStdinPipe(t *testing.T) {
193 193
 	out = stripTrailingCharacters(out)
194 194
 
195 195
 	inspectCmd := exec.Command(dockerBinary, "inspect", out)
196
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
197
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %s %s", out, inspectOut))
196
+	if out, _, err := runCommandWithOutput(inspectCmd); err != nil {
197
+		t.Fatalf("out should've been a container id: %s %v", out, err)
198
+	}
198 199
 
199 200
 	waitCmd := exec.Command(dockerBinary, "wait", out)
200
-	_, _, err = runCommandWithOutput(waitCmd)
201
-	errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
201
+	if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
202
+		t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
203
+	}
202 204
 
203 205
 	logsCmd := exec.Command(dockerBinary, "logs", out)
204
-	containerLogs, _, err := runCommandWithOutput(logsCmd)
205
-	errorOut(err, t, fmt.Sprintf("error thrown while trying to get container logs: %s", err))
206
+	logsOut, _, err := runCommandWithOutput(logsCmd)
207
+	if err != nil {
208
+		t.Fatalf("error thrown while trying to get container logs: %s, %v", logsOut, err)
209
+	}
206 210
 
207
-	containerLogs = stripTrailingCharacters(containerLogs)
211
+	containerLogs := stripTrailingCharacters(logsOut)
208 212
 
209 213
 	if containerLogs != "blahblah" {
210 214
 		t.Errorf("logs didn't print the container's logs %s", containerLogs)
211 215
 	}
212 216
 
213 217
 	rmCmd := exec.Command(dockerBinary, "rm", out)
214
-	_, _, err = runCommandWithOutput(rmCmd)
215
-	errorOut(err, t, fmt.Sprintf("rm failed to remove container %s", err))
218
+	if out, _, err = runCommandWithOutput(rmCmd); err != nil {
219
+		t.Fatalf("rm failed to remove container: %s, %v", out, err)
220
+	}
216 221
 
217 222
 	deleteAllContainers()
218 223
 
... ...
@@ -230,16 +230,20 @@ func TestRunDetachedContainerIDPrinting(t *testing.T) {
230 230
 	out = stripTrailingCharacters(out)
231 231
 
232 232
 	inspectCmd := exec.Command(dockerBinary, "inspect", out)
233
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
234
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %s %s", out, inspectOut))
233
+	if inspectOut, _, err := runCommandWithOutput(inspectCmd); err != nil {
234
+		t.Fatalf("out should've been a container id: %s %v", inspectOut, err)
235
+	}
235 236
 
236 237
 	waitCmd := exec.Command(dockerBinary, "wait", out)
237
-	_, _, err = runCommandWithOutput(waitCmd)
238
-	errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
238
+	if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil {
239
+		t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err)
240
+	}
239 241
 
240 242
 	rmCmd := exec.Command(dockerBinary, "rm", out)
241 243
 	rmOut, _, err := runCommandWithOutput(rmCmd)
242
-	errorOut(err, t, "rm failed to remove container")
244
+	if err != nil {
245
+		t.Fatalf("rm failed to remove container: %s, %v", rmOut, err)
246
+	}
243 247
 
244 248
 	rmOut = stripTrailingCharacters(rmOut)
245 249
 	if rmOut != out {
... ...
@@ -267,7 +271,9 @@ func TestRunWorkingDirectory(t *testing.T) {
267 267
 
268 268
 	runCmd = exec.Command(dockerBinary, "run", "--workdir", "/root", "busybox", "pwd")
269 269
 	out, _, _, err = runCommandWithStdoutStderr(runCmd)
270
-	errorOut(err, t, out)
270
+	if err != nil {
271
+		t.Fatal(out, err)
272
+	}
271 273
 
272 274
 	out = stripTrailingCharacters(out)
273 275
 
... ...
@@ -14,40 +14,50 @@ import (
14 14
 func TestSaveAndLoadRepoStdout(t *testing.T) {
15 15
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
16 16
 	out, _, err := runCommandWithOutput(runCmd)
17
-	errorOut(err, t, fmt.Sprintf("failed to create a container: %v %v", out, err))
17
+	if err != nil {
18
+		t.Fatalf("failed to create a container: %s, %v", out, err)
19
+	}
18 20
 
19 21
 	cleanedContainerID := stripTrailingCharacters(out)
20 22
 
21 23
 	repoName := "foobar-save-load-test"
22 24
 
23 25
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
24
-	out, _, err = runCommandWithOutput(inspectCmd)
25
-	errorOut(err, t, fmt.Sprintf("output should've been a container id: %v %v", cleanedContainerID, err))
26
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
27
+		t.Fatalf("output should've been a container id: %s, %v", out, err)
28
+	}
26 29
 
27 30
 	commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
28
-	out, _, err = runCommandWithOutput(commitCmd)
29
-	errorOut(err, t, fmt.Sprintf("failed to commit container: %v %v", out, err))
31
+	if out, _, err = runCommandWithOutput(commitCmd); err != nil {
32
+		t.Fatalf("failed to commit container: %s, %v", out, err)
33
+	}
30 34
 
31 35
 	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
32 36
 	before, _, err := runCommandWithOutput(inspectCmd)
33
-	errorOut(err, t, fmt.Sprintf("the repo should exist before saving it: %v %v", before, err))
37
+	if err != nil {
38
+		t.Fatalf("the repo should exist before saving it: %s, %v", before, err)
39
+	}
34 40
 
35 41
 	saveCmdTemplate := `%v save %v > /tmp/foobar-save-load-test.tar`
36 42
 	saveCmdFinal := fmt.Sprintf(saveCmdTemplate, dockerBinary, repoName)
37 43
 	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
38
-	out, _, err = runCommandWithOutput(saveCmd)
39
-	errorOut(err, t, fmt.Sprintf("failed to save repo: %v %v", out, err))
44
+	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
45
+		t.Fatalf("failed to save repo: %s, %v", out, err)
46
+	}
40 47
 
41 48
 	deleteImages(repoName)
42 49
 
43 50
 	loadCmdFinal := `cat /tmp/foobar-save-load-test.tar | docker load`
44 51
 	loadCmd := exec.Command("bash", "-c", loadCmdFinal)
45
-	out, _, err = runCommandWithOutput(loadCmd)
46
-	errorOut(err, t, fmt.Sprintf("failed to load repo: %v %v", out, err))
52
+	if out, _, err = runCommandWithOutput(loadCmd); err != nil {
53
+		t.Fatalf("failed to load repo: %s, %v", out, err)
54
+	}
47 55
 
48 56
 	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
49 57
 	after, _, err := runCommandWithOutput(inspectCmd)
50
-	errorOut(err, t, fmt.Sprintf("the repo should exist after loading it: %v %v", after, err))
58
+	if err != nil {
59
+		t.Fatalf("the repo should exist after loading it: %s %v", after, err)
60
+	}
51 61
 
52 62
 	if before != after {
53 63
 		t.Fatalf("inspect is not the same after a save / load")
... ...
@@ -67,20 +77,24 @@ func TestSaveSingleTag(t *testing.T) {
67 67
 
68 68
 	tagCmdFinal := fmt.Sprintf("%v tag busybox:latest %v:latest", dockerBinary, repoName)
69 69
 	tagCmd := exec.Command("bash", "-c", tagCmdFinal)
70
-	out, _, err := runCommandWithOutput(tagCmd)
71
-	errorOut(err, t, fmt.Sprintf("failed to tag repo: %v %v", out, err))
70
+	if out, _, err := runCommandWithOutput(tagCmd); err != nil {
71
+		t.Fatalf("failed to tag repo: %s, %v", out, err)
72
+	}
72 73
 
73 74
 	idCmdFinal := fmt.Sprintf("%v images -q --no-trunc %v", dockerBinary, repoName)
74 75
 	idCmd := exec.Command("bash", "-c", idCmdFinal)
75
-	out, _, err = runCommandWithOutput(idCmd)
76
-	errorOut(err, t, fmt.Sprintf("failed to get repo ID: %v %v", out, err))
76
+	out, _, err := runCommandWithOutput(idCmd)
77
+	if err != nil {
78
+		t.Fatalf("failed to get repo ID: %s, %v", out, err)
79
+	}
77 80
 
78 81
 	cleanedImageID := stripTrailingCharacters(out)
79 82
 
80 83
 	saveCmdFinal := fmt.Sprintf("%v save %v:latest | tar t | grep -E '(^repositories$|%v)'", dockerBinary, repoName, cleanedImageID)
81 84
 	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
82
-	out, _, err = runCommandWithOutput(saveCmd)
83
-	errorOut(err, t, fmt.Sprintf("failed to save repo with image ID and 'repositories' file: %v %v", out, err))
85
+	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
86
+		t.Fatalf("failed to save repo with image ID and 'repositories' file: %s, %v", out, err)
87
+	}
84 88
 
85 89
 	deleteImages(repoName)
86 90
 
... ...
@@ -92,27 +106,33 @@ func TestSaveImageId(t *testing.T) {
92 92
 
93 93
 	tagCmdFinal := fmt.Sprintf("%v tag scratch:latest %v:latest", dockerBinary, repoName)
94 94
 	tagCmd := exec.Command("bash", "-c", tagCmdFinal)
95
-	out, _, err := runCommandWithOutput(tagCmd)
96
-	errorOut(err, t, fmt.Sprintf("failed to tag repo: %v %v", out, err))
95
+	if out, _, err := runCommandWithOutput(tagCmd); err != nil {
96
+		t.Fatalf("failed to tag repo: %s, %v", out, err)
97
+	}
97 98
 
98 99
 	idLongCmdFinal := fmt.Sprintf("%v images -q --no-trunc %v", dockerBinary, repoName)
99 100
 	idLongCmd := exec.Command("bash", "-c", idLongCmdFinal)
100
-	out, _, err = runCommandWithOutput(idLongCmd)
101
-	errorOut(err, t, fmt.Sprintf("failed to get repo ID: %v %v", out, err))
101
+	out, _, err := runCommandWithOutput(idLongCmd)
102
+	if err != nil {
103
+		t.Fatalf("failed to get repo ID: %s, %v", out, err)
104
+	}
102 105
 
103 106
 	cleanedLongImageID := stripTrailingCharacters(out)
104 107
 
105 108
 	idShortCmdFinal := fmt.Sprintf("%v images -q %v", dockerBinary, repoName)
106 109
 	idShortCmd := exec.Command("bash", "-c", idShortCmdFinal)
107 110
 	out, _, err = runCommandWithOutput(idShortCmd)
108
-	errorOut(err, t, fmt.Sprintf("failed to get repo short ID: %v %v", out, err))
111
+	if err != nil {
112
+		t.Fatalf("failed to get repo short ID: %s, %v", out, err)
113
+	}
109 114
 
110 115
 	cleanedShortImageID := stripTrailingCharacters(out)
111 116
 
112 117
 	saveCmdFinal := fmt.Sprintf("%v save %v | tar t | grep %v", dockerBinary, cleanedShortImageID, cleanedLongImageID)
113 118
 	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
114
-	out, _, err = runCommandWithOutput(saveCmd)
115
-	errorOut(err, t, fmt.Sprintf("failed to save repo with image ID: %v %v", out, err))
119
+	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
120
+		t.Fatalf("failed to save repo with image ID: %s, %v", out, err)
121
+	}
116 122
 
117 123
 	deleteImages(repoName)
118 124
 
... ...
@@ -123,40 +143,50 @@ func TestSaveImageId(t *testing.T) {
123 123
 func TestSaveAndLoadRepoFlags(t *testing.T) {
124 124
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
125 125
 	out, _, err := runCommandWithOutput(runCmd)
126
-	errorOut(err, t, fmt.Sprintf("failed to create a container: %v %v", out, err))
126
+	if err != nil {
127
+		t.Fatalf("failed to create a container: %s, %v", out, err)
128
+	}
127 129
 
128 130
 	cleanedContainerID := stripTrailingCharacters(out)
129 131
 
130 132
 	repoName := "foobar-save-load-test"
131 133
 
132 134
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
133
-	out, _, err = runCommandWithOutput(inspectCmd)
134
-	errorOut(err, t, fmt.Sprintf("output should've been a container id: %v %v", cleanedContainerID, err))
135
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
136
+		t.Fatalf("output should've been a container id: %s, %v", out, err)
137
+	}
135 138
 
136 139
 	commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID, repoName)
137
-	out, _, err = runCommandWithOutput(commitCmd)
138
-	errorOut(err, t, fmt.Sprintf("failed to commit container: %v %v", out, err))
140
+	if out, _, err = runCommandWithOutput(commitCmd); err != nil {
141
+		t.Fatalf("failed to commit container: %s, %v", out, err)
142
+	}
139 143
 
140 144
 	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
141 145
 	before, _, err := runCommandWithOutput(inspectCmd)
142
-	errorOut(err, t, fmt.Sprintf("the repo should exist before saving it: %v %v", before, err))
146
+	if err != nil {
147
+		t.Fatalf("the repo should exist before saving it: %s, %v", before, err)
148
+	}
143 149
 
144 150
 	saveCmdTemplate := `%v save -o /tmp/foobar-save-load-test.tar %v`
145 151
 	saveCmdFinal := fmt.Sprintf(saveCmdTemplate, dockerBinary, repoName)
146 152
 	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
147
-	out, _, err = runCommandWithOutput(saveCmd)
148
-	errorOut(err, t, fmt.Sprintf("failed to save repo: %v %v", out, err))
153
+	if out, _, err = runCommandWithOutput(saveCmd); err != nil {
154
+		t.Fatalf("failed to save repo: %s, %v", out, err)
155
+	}
149 156
 
150 157
 	deleteImages(repoName)
151 158
 
152 159
 	loadCmdFinal := `docker load -i /tmp/foobar-save-load-test.tar`
153 160
 	loadCmd := exec.Command("bash", "-c", loadCmdFinal)
154
-	out, _, err = runCommandWithOutput(loadCmd)
155
-	errorOut(err, t, fmt.Sprintf("failed to load repo: %v %v", out, err))
161
+	if out, _, err = runCommandWithOutput(loadCmd); err != nil {
162
+		t.Fatalf("failed to load repo: %s, %v", out, err)
163
+	}
156 164
 
157 165
 	inspectCmd = exec.Command(dockerBinary, "inspect", repoName)
158 166
 	after, _, err := runCommandWithOutput(inspectCmd)
159
-	errorOut(err, t, fmt.Sprintf("the repo should exist after loading it: %v %v", after, err))
167
+	if err != nil {
168
+		t.Fatalf("the repo should exist after loading it: %s, %v", after, err)
169
+	}
160 170
 
161 171
 	if before != after {
162 172
 		t.Fatalf("inspect is not the same after a save / load")
... ...
@@ -177,18 +207,21 @@ func TestSaveMultipleNames(t *testing.T) {
177 177
 	// Make one image
178 178
 	tagCmdFinal := fmt.Sprintf("%v tag scratch:latest %v-one:latest", dockerBinary, repoName)
179 179
 	tagCmd := exec.Command("bash", "-c", tagCmdFinal)
180
-	out, _, err := runCommandWithOutput(tagCmd)
181
-	errorOut(err, t, fmt.Sprintf("failed to tag repo: %v %v", out, err))
180
+	if out, _, err := runCommandWithOutput(tagCmd); err != nil {
181
+		t.Fatalf("failed to tag repo: %s, %v", out, err)
182
+	}
182 183
 	// Make two images
183 184
 	tagCmdFinal = fmt.Sprintf("%v tag scratch:latest %v-two:latest", dockerBinary, repoName)
184 185
 	tagCmd = exec.Command("bash", "-c", tagCmdFinal)
185
-	out, _, err = runCommandWithOutput(tagCmd)
186
-	errorOut(err, t, fmt.Sprintf("failed to tag repo: %v %v", out, err))
186
+	if out, _, err := runCommandWithOutput(tagCmd); err != nil {
187
+		t.Fatalf("failed to tag repo: %s, %v", out, err)
188
+	}
187 189
 
188 190
 	saveCmdFinal := fmt.Sprintf("%v save %v-one %v-two:latest | tar xO repositories | grep -q -E '(-one|-two)'", dockerBinary, repoName, repoName)
189 191
 	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
190
-	out, _, err = runCommandWithOutput(saveCmd)
191
-	errorOut(err, t, fmt.Sprintf("failed to save multiple repos: %v %v", out, err))
192
+	if out, _, err := runCommandWithOutput(saveCmd); err != nil {
193
+		t.Fatalf("failed to save multiple repos: %s, %v", out, err)
194
+	}
192 195
 
193 196
 	deleteImages(repoName)
194 197
 
... ...
@@ -202,12 +235,12 @@ func TestSaveDirectoryPermissions(t *testing.T) {
202 202
 
203 203
 	name := "save-directory-permissions"
204 204
 	tmpDir, err := ioutil.TempDir("", "save-layers-with-directories")
205
-	extractionDirectory := filepath.Join(tmpDir, "image-extraction-dir")
206
-	os.Mkdir(extractionDirectory, 0777)
207
-
208 205
 	if err != nil {
209 206
 		t.Errorf("failed to create temporary directory: %s", err)
210 207
 	}
208
+	extractionDirectory := filepath.Join(tmpDir, "image-extraction-dir")
209
+	os.Mkdir(extractionDirectory, 0777)
210
+
211 211
 	defer os.RemoveAll(tmpDir)
212 212
 	defer deleteImages(name)
213 213
 	_, err = buildImage(name,
... ...
@@ -221,8 +254,7 @@ func TestSaveDirectoryPermissions(t *testing.T) {
221 221
 
222 222
 	saveCmdFinal := fmt.Sprintf("%s save %s | tar -xf - -C %s", dockerBinary, name, extractionDirectory)
223 223
 	saveCmd := exec.Command("bash", "-c", saveCmdFinal)
224
-	out, _, err := runCommandWithOutput(saveCmd)
225
-	if err != nil {
224
+	if out, _, err := runCommandWithOutput(saveCmd); err != nil {
226 225
 		t.Errorf("failed to save and extract image: %s", out)
227 226
 	}
228 227
 
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -11,10 +10,8 @@ import (
11 11
 func TestSearchOnCentralRegistry(t *testing.T) {
12 12
 	searchCmd := exec.Command(dockerBinary, "search", "busybox")
13 13
 	out, exitCode, err := runCommandWithOutput(searchCmd)
14
-	errorOut(err, t, fmt.Sprintf("encountered error while searching: %v", err))
15
-
16 14
 	if err != nil || exitCode != 0 {
17
-		t.Fatal("failed to search on the central registry")
15
+		t.Fatal("failed to search on the central registry: %s, %v", out, err)
18 16
 	}
19 17
 
20 18
 	if !strings.Contains(out, "Busybox base image.") {
... ...
@@ -13,8 +13,9 @@ func TestTagUnprefixedRepoByName(t *testing.T) {
13 13
 	}
14 14
 
15 15
 	tagCmd := exec.Command(dockerBinary, "tag", "busybox:latest", "testfoobarbaz")
16
-	out, _, err := runCommandWithOutput(tagCmd)
17
-	errorOut(err, t, fmt.Sprintf("%v %v", out, err))
16
+	if out, _, err := runCommandWithOutput(tagCmd); err != nil {
17
+		t.Fatal(out, err)
18
+	}
18 19
 
19 20
 	deleteImages("testfoobarbaz")
20 21
 
... ...
@@ -25,12 +26,15 @@ func TestTagUnprefixedRepoByName(t *testing.T) {
25 25
 func TestTagUnprefixedRepoByID(t *testing.T) {
26 26
 	getIDCmd := exec.Command(dockerBinary, "inspect", "-f", "{{.Id}}", "busybox")
27 27
 	out, _, err := runCommandWithOutput(getIDCmd)
28
-	errorOut(err, t, fmt.Sprintf("failed to get the image ID of busybox: %v", err))
28
+	if err != nil {
29
+		t.Fatalf("failed to get the image ID of busybox: %s, %v", out, err)
30
+	}
29 31
 
30 32
 	cleanedImageID := stripTrailingCharacters(out)
31 33
 	tagCmd := exec.Command(dockerBinary, "tag", cleanedImageID, "testfoobarbaz")
32
-	out, _, err = runCommandWithOutput(tagCmd)
33
-	errorOut(err, t, fmt.Sprintf("%s %s", out, err))
34
+	if out, _, err = runCommandWithOutput(tagCmd); err != nil {
35
+		t.Fatal(out, err)
36
+	}
34 37
 
35 38
 	deleteImages("testfoobarbaz")
36 39
 
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -10,17 +9,21 @@ import (
10 10
 func TestTopMultipleArgs(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
13
+	if err != nil {
14
+		t.Fatalf("failed to start the container: %s, %v", out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 	defer deleteContainer(cleanedContainerID)
17 19
 
18 20
 	topCmd := exec.Command(dockerBinary, "top", cleanedContainerID, "-o", "pid")
19 21
 	out, _, err = runCommandWithOutput(topCmd)
20
-	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
22
+	if err != nil {
23
+		t.Fatalf("failed to run top: %s, %v", out, err)
24
+	}
21 25
 
22 26
 	if !strings.Contains(out, "PID") {
23
-		errorOut(nil, t, fmt.Sprintf("did not see PID after top -o pid"))
27
+		t.Fatalf("did not see PID after top -o pid: %s", out)
24 28
 	}
25 29
 
26 30
 	logDone("top - multiple arguments")
... ...
@@ -29,27 +32,34 @@ func TestTopMultipleArgs(t *testing.T) {
29 29
 func TestTopNonPrivileged(t *testing.T) {
30 30
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
31 31
 	out, _, err := runCommandWithOutput(runCmd)
32
-	errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
32
+	if err != nil {
33
+		t.Fatalf("failed to start the container: %s, %v", out, err)
34
+	}
33 35
 
34 36
 	cleanedContainerID := stripTrailingCharacters(out)
35 37
 
36 38
 	topCmd := exec.Command(dockerBinary, "top", cleanedContainerID)
37
-	out, _, err = runCommandWithOutput(topCmd)
38
-	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
39
+	out1, _, err := runCommandWithOutput(topCmd)
40
+	if err != nil {
41
+		t.Fatalf("failed to run top: %s, %v", out1, err)
42
+	}
39 43
 
40 44
 	topCmd = exec.Command(dockerBinary, "top", cleanedContainerID)
41
-	out2, _, err2 := runCommandWithOutput(topCmd)
42
-	errorOut(err2, t, fmt.Sprintf("failed to run top: %v %v", out2, err2))
45
+	out2, _, err := runCommandWithOutput(topCmd)
46
+	if err != nil {
47
+		t.Fatalf("failed to run top: %s, %v", out2, err)
48
+	}
43 49
 
44 50
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
45
-	_, err = runCommand(killCmd)
46
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v", err))
51
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
52
+		t.Fatalf("failed to kill container: %s, %v", out, err)
53
+	}
47 54
 
48 55
 	deleteContainer(cleanedContainerID)
49 56
 
50
-	if !strings.Contains(out, "sleep 20") && !strings.Contains(out2, "sleep 20") {
57
+	if !strings.Contains(out1, "sleep 20") && !strings.Contains(out2, "sleep 20") {
51 58
 		t.Fatal("top should've listed `sleep 20` in the process list, but failed twice")
52
-	} else if !strings.Contains(out, "sleep 20") {
59
+	} else if !strings.Contains(out1, "sleep 20") {
53 60
 		t.Fatal("top should've listed `sleep 20` in the process list, but failed the first time")
54 61
 	} else if !strings.Contains(out2, "sleep 20") {
55 62
 		t.Fatal("top should've listed `sleep 20` in the process list, but failed the second itime")
... ...
@@ -61,27 +71,34 @@ func TestTopNonPrivileged(t *testing.T) {
61 61
 func TestTopPrivileged(t *testing.T) {
62 62
 	runCmd := exec.Command(dockerBinary, "run", "--privileged", "-i", "-d", "busybox", "sleep", "20")
63 63
 	out, _, err := runCommandWithOutput(runCmd)
64
-	errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
64
+	if err != nil {
65
+		t.Fatalf("failed to start the container: %s, %v", out, err)
66
+	}
65 67
 
66 68
 	cleanedContainerID := stripTrailingCharacters(out)
67 69
 
68 70
 	topCmd := exec.Command(dockerBinary, "top", cleanedContainerID)
69
-	out, _, err = runCommandWithOutput(topCmd)
70
-	errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
71
+	out1, _, err := runCommandWithOutput(topCmd)
72
+	if err != nil {
73
+		t.Fatalf("failed to run top: %s, %v", out1, err)
74
+	}
71 75
 
72 76
 	topCmd = exec.Command(dockerBinary, "top", cleanedContainerID)
73
-	out2, _, err2 := runCommandWithOutput(topCmd)
74
-	errorOut(err2, t, fmt.Sprintf("failed to run top: %v %v", out2, err2))
77
+	out2, _, err := runCommandWithOutput(topCmd)
78
+	if err != nil {
79
+		t.Fatalf("failed to run top: %s, %v", out2, err)
80
+	}
75 81
 
76 82
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
77
-	_, err = runCommand(killCmd)
78
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v", err))
83
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
84
+		t.Fatalf("failed to kill container: %s, %v", out, err)
85
+	}
79 86
 
80 87
 	deleteContainer(cleanedContainerID)
81 88
 
82
-	if !strings.Contains(out, "sleep 20") && !strings.Contains(out2, "sleep 20") {
89
+	if !strings.Contains(out1, "sleep 20") && !strings.Contains(out2, "sleep 20") {
83 90
 		t.Fatal("top should've listed `sleep 20` in the process list, but failed twice")
84
-	} else if !strings.Contains(out, "sleep 20") {
91
+	} else if !strings.Contains(out1, "sleep 20") {
85 92
 		t.Fatal("top should've listed `sleep 20` in the process list, but failed the first time")
86 93
 	} else if !strings.Contains(out2, "sleep 20") {
87 94
 		t.Fatal("top should've listed `sleep 20` in the process list, but failed the second itime")
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -10,11 +9,9 @@ import (
10 10
 // ensure docker version works
11 11
 func TestVersionEnsureSucceeds(t *testing.T) {
12 12
 	versionCmd := exec.Command(dockerBinary, "version")
13
-	out, exitCode, err := runCommandWithOutput(versionCmd)
14
-	errorOut(err, t, fmt.Sprintf("encountered error while running docker version: %v", err))
15
-
16
-	if err != nil || exitCode != 0 {
17
-		t.Fatal("failed to execute docker version")
13
+	out, _, err := runCommandWithOutput(versionCmd)
14
+	if err != nil {
15
+		t.Fatal("failed to execute docker version: %s, %v", out, err)
18 16
 	}
19 17
 
20 18
 	stringsToCheck := []string{
... ...
@@ -341,7 +341,9 @@ func cmd(t *testing.T, args ...string) (string, int, error) {
341 341
 
342 342
 func dockerCmd(t *testing.T, args ...string) (string, int, error) {
343 343
 	out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...))
344
-	errorOut(err, t, fmt.Sprintf("%q failed with errors: %v (%v)", strings.Join(args, " "), err, out))
344
+	if err != nil {
345
+		t.Fatalf("%q failed with errors: %s, %v", strings.Join(args, " "), out, err)
346
+	}
345 347
 	return out, status, err
346 348
 }
347 349
 
... ...
@@ -13,7 +13,6 @@ import (
13 13
 	"reflect"
14 14
 	"strings"
15 15
 	"syscall"
16
-	"testing"
17 16
 	"time"
18 17
 
19 18
 	"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
... ...
@@ -113,18 +112,6 @@ func stripTrailingCharacters(target string) string {
113 113
 	return target
114 114
 }
115 115
 
116
-func errorOut(err error, t *testing.T, message string) {
117
-	if err != nil {
118
-		t.Fatal(message)
119
-	}
120
-}
121
-
122
-func errorOutOnNonNilError(err error, t *testing.T, message string) {
123
-	if err == nil {
124
-		t.Fatalf(message)
125
-	}
126
-}
127
-
128 116
 func nLines(s string) int {
129 117
 	return strings.Count(s, "\n")
130 118
 }