소스 검색

busybox: Fix `ls` compatible issue

BusyBox v1.26.2 (2017-03-09 00:04:38 UTC) supports `-le` option
to get the full date and time information, while BusyBox v1.27.2
(2017-11-01 23:22:25 UTC, which is used by the official multi-arch
image, uses `--full-time` instead of `-e` to get the same data. As
a result, we will get below error for the `DockerSuite.TestBuildLastModified`
test case in case of multi-arch image used:

> docker_cli_build_test.go:446:
>     out2 = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined()
>   o/src/github.com/docker/docker/vendor/github.com/gotestyourself/gotestyourself/icmd/command.go:61:
>     t.Fatalf("at %s:%d - %s\n", filepath.Base(file), line, err.Error())
> ... Error: at cli.go:33 -
> Command:  /usr/local/bin/docker run testbuildlastmodified ls -le /file
> ExitCode: 1
> Error:    exit status 1
> Stdout:
> Stderr:   ls: invalid option -- e
> BusyBox v1.27.2 (2017-11-01 23:22:25 UTC) multi-call binary.

This PR tries to fix the above compatible issue for busybox image.

Signed-off-by: Dennis Chen <dennis.chen@arm.com>
Dennis Chen 7 년 전
부모
커밋
f88c2c04ef
1개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 3
      integration-cli/docker_cli_build_test.go

+ 10 - 3
integration-cli/docker_cli_build_test.go

@@ -400,20 +400,27 @@ func (s *DockerSuite) TestBuildLastModified(c *check.C) {
 	defer server.Close()
 	defer server.Close()
 
 
 	var out, out2 string
 	var out, out2 string
+	var args []string
+	// Temopray workaround for #35963. Will remove this when that issue fixed
+	if runtime.GOARCH == "amd64" {
+		args = []string{"run", name, "ls", "-le", "/file"}
+	} else {
+		args = []string{"run", name, "ls", "-l", "--full-time", "/file"}
+	}
 
 
 	dFmt := `FROM busybox
 	dFmt := `FROM busybox
 ADD %s/file /`
 ADD %s/file /`
 	dockerfile := fmt.Sprintf(dFmt, server.URL())
 	dockerfile := fmt.Sprintf(dFmt, server.URL())
 
 
 	cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile))
 	cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile))
-	out = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined()
+	out = cli.DockerCmd(c, args...).Combined()
 
 
 	// Build it again and make sure the mtime of the file didn't change.
 	// Build it again and make sure the mtime of the file didn't change.
 	// Wait a few seconds to make sure the time changed enough to notice
 	// Wait a few seconds to make sure the time changed enough to notice
 	time.Sleep(2 * time.Second)
 	time.Sleep(2 * time.Second)
 
 
 	cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile))
 	cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile))
-	out2 = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined()
+	out2 = cli.DockerCmd(c, args...).Combined()
 
 
 	if out != out2 {
 	if out != out2 {
 		c.Fatalf("MTime changed:\nOrigin:%s\nNew:%s", out, out2)
 		c.Fatalf("MTime changed:\nOrigin:%s\nNew:%s", out, out2)
@@ -428,7 +435,7 @@ ADD %s/file /`
 
 
 	dockerfile = fmt.Sprintf(dFmt, server.URL())
 	dockerfile = fmt.Sprintf(dFmt, server.URL())
 	cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile))
 	cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile))
-	out2 = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined()
+	out2 = cli.DockerCmd(c, args...).Combined()
 
 
 	if out == out2 {
 	if out == out2 {
 		c.Fatalf("MTime didn't change:\nOrigin:%s\nNew:%s", out, out2)
 		c.Fatalf("MTime didn't change:\nOrigin:%s\nNew:%s", out, out2)