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>
| ... | ... |
@@ -400,20 +400,27 @@ func (s *DockerSuite) TestBuildLastModified(c *check.C) {
|
| 400 | 400 |
defer server.Close() |
| 401 | 401 |
|
| 402 | 402 |
var out, out2 string |
| 403 |
+ var args []string |
|
| 404 |
+ // Temopray workaround for #35963. Will remove this when that issue fixed |
|
| 405 |
+ if runtime.GOARCH == "amd64" {
|
|
| 406 |
+ args = []string{"run", name, "ls", "-le", "/file"}
|
|
| 407 |
+ } else {
|
|
| 408 |
+ args = []string{"run", name, "ls", "-l", "--full-time", "/file"}
|
|
| 409 |
+ } |
|
| 403 | 410 |
|
| 404 | 411 |
dFmt := `FROM busybox |
| 405 | 412 |
ADD %s/file /` |
| 406 | 413 |
dockerfile := fmt.Sprintf(dFmt, server.URL()) |
| 407 | 414 |
|
| 408 | 415 |
cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
| 409 |
- out = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined() |
|
| 416 |
+ out = cli.DockerCmd(c, args...).Combined() |
|
| 410 | 417 |
|
| 411 | 418 |
// Build it again and make sure the mtime of the file didn't change. |
| 412 | 419 |
// Wait a few seconds to make sure the time changed enough to notice |
| 413 | 420 |
time.Sleep(2 * time.Second) |
| 414 | 421 |
|
| 415 | 422 |
cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
| 416 |
- out2 = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined() |
|
| 423 |
+ out2 = cli.DockerCmd(c, args...).Combined() |
|
| 417 | 424 |
|
| 418 | 425 |
if out != out2 {
|
| 419 | 426 |
c.Fatalf("MTime changed:\nOrigin:%s\nNew:%s", out, out2)
|
| ... | ... |
@@ -428,7 +435,7 @@ ADD %s/file /` |
| 428 | 428 |
|
| 429 | 429 |
dockerfile = fmt.Sprintf(dFmt, server.URL()) |
| 430 | 430 |
cli.BuildCmd(c, name, build.WithoutCache, build.WithDockerfile(dockerfile)) |
| 431 |
- out2 = cli.DockerCmd(c, "run", name, "ls", "-le", "/file").Combined() |
|
| 431 |
+ out2 = cli.DockerCmd(c, args...).Combined() |
|
| 432 | 432 |
|
| 433 | 433 |
if out == out2 {
|
| 434 | 434 |
c.Fatalf("MTime didn't change:\nOrigin:%s\nNew:%s", out, out2)
|