1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/fixtures_linux_daemon_test.go
Sebastiaan van Stijn 67e4d36e46
integration-cli: remove unused functions and enable disabled tests
```
14:26:43 integration-cli/docker_cli_pull_local_test.go:64:6: U1000: func `testConcurrentPullWholeRepo` is unused (unused)
14:26:43 func testConcurrentPullWholeRepo(c *check.C) {
14:26:43      ^
14:26:43 integration-cli/docker_cli_pull_local_test.go:111:31: U1000: func `(*DockerRegistrySuite).testConcurrentPullWholeRepo` is unused (unused)
14:26:43 func (s *DockerRegistrySuite) testConcurrentPullWholeRepo(c *check.C) {
14:26:43                               ^
14:26:43 integration-cli/docker_cli_pull_local_test.go:115:38: U1000: func `(*DockerSchema1RegistrySuite).testConcurrentPullWholeRepo` is unused (unused)
14:26:43 func (s *DockerSchema1RegistrySuite) testConcurrentPullWholeRepo(c *check.C) {
14:26:43                                      ^
14:26:43 integration-cli/docker_cli_pull_local_test.go:120:6: U1000: func `testConcurrentFailingPull` is unused (unused)
14:26:43 func testConcurrentFailingPull(c *check.C) {
14:26:43      ^
14:26:43 integration-cli/docker_cli_pull_local_test.go:142:31: U1000: func `(*DockerRegistrySuite).testConcurrentFailingPull` is unused (unused)
14:26:43 func (s *DockerRegistrySuite) testConcurrentFailingPull(c *check.C) {
14:26:43                               ^
14:26:43 integration-cli/docker_cli_pull_local_test.go:146:38: U1000: func `(*DockerSchema1RegistrySuite).testConcurrentFailingPull` is unused (unused)
14:26:43 func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *check.C) {

14:26:43 integration-cli/docker_utils_test.go:170:6: U1000: func `inspectImage` is unused (unused)
14:26:43 func inspectImage(c *check.C, name, filter string) string {
14:26:43      ^
14:26:43 integration-cli/events_utils_test.go:196:6: U1000: func `parseEventsWithID` is unused (unused)
14:26:43 func parseEventsWithID(c *check.C, out, match, id string) {
14:26:43      ^
14:26:43 integration-cli/fixtures_linux_daemon_test.go:17:6: U1000: type `testingT` is unused (unused)
14:26:43 type testingT interface {
14:26:43      ^
14:26:43 integration-cli/fixtures_linux_daemon_test.go:19:2: U1000: func `testingT.Fatalf` is unused (unused)
14:26:43 	Fatalf(string, ...interface{})
14:26:43 	^
14:26:43 integration-cli/fixtures_linux_daemon_test.go:22:6: U1000: type `logT` is unused (unused)
14:26:43 type logT interface {
14:26:43      ^
14:26:43 integration-cli/fixtures_linux_daemon_test.go:23:2: U1000: func `logT.Logf` is unused (unused)
14:26:43 	Logf(string, ...interface{})
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:56:59 +02:00

133 lines
4 KiB
Go

package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/docker/docker/testutil/fixtures/load"
"gotest.tools/assert"
)
func ensureSyscallTest(c *testing.T) {
defer testEnv.ProtectImage(c, "syscall-test:latest")
// If the image already exists, there's nothing left to do.
if testEnv.HasExistingImage(c, "syscall-test:latest") {
return
}
// if no match, must build in docker, which is significantly slower
// (slower mostly because of the vfs graphdriver)
if testEnv.OSType != runtime.GOOS {
ensureSyscallTestBuild(c)
return
}
tmp, err := ioutil.TempDir("", "syscall-test-build")
assert.NilError(c, err, "couldn't create temp dir")
defer os.RemoveAll(tmp)
gcc, err := exec.LookPath("gcc")
assert.NilError(c, err, "could not find gcc")
tests := []string{"userns", "ns", "acct", "setuid", "setgid", "socket", "raw"}
for _, test := range tests {
out, err := exec.Command(gcc, "-g", "-Wall", "-static", fmt.Sprintf("../contrib/syscall-test/%s.c", test), "-o", fmt.Sprintf("%s/%s-test", tmp, test)).CombinedOutput()
assert.NilError(c, err, string(out))
}
if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" {
out, err := exec.Command(gcc, "-s", "-m32", "-nostdlib", "-static", "../contrib/syscall-test/exit32.s", "-o", tmp+"/"+"exit32-test").CombinedOutput()
assert.NilError(c, err, string(out))
}
dockerFile := filepath.Join(tmp, "Dockerfile")
content := []byte(`
FROM debian:jessie
COPY . /usr/bin/
`)
err = ioutil.WriteFile(dockerFile, content, 0600)
assert.NilError(c, err)
var buildArgs []string
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
buildArgs = strings.Split(arg, " ")
}
buildArgs = append(buildArgs, []string{"-q", "-t", "syscall-test", tmp}...)
buildArgs = append([]string{"build"}, buildArgs...)
dockerCmd(c, buildArgs...)
}
func ensureSyscallTestBuild(c *testing.T) {
err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie")
assert.NilError(c, err)
var buildArgs []string
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
buildArgs = strings.Split(arg, " ")
}
buildArgs = append(buildArgs, []string{"-q", "-t", "syscall-test", "../contrib/syscall-test"}...)
buildArgs = append([]string{"build"}, buildArgs...)
dockerCmd(c, buildArgs...)
}
func ensureNNPTest(c *testing.T) {
defer testEnv.ProtectImage(c, "nnp-test:latest")
// If the image already exists, there's nothing left to do.
if testEnv.HasExistingImage(c, "nnp-test:latest") {
return
}
// if no match, must build in docker, which is significantly slower
// (slower mostly because of the vfs graphdriver)
if testEnv.OSType != runtime.GOOS {
ensureNNPTestBuild(c)
return
}
tmp, err := ioutil.TempDir("", "docker-nnp-test")
assert.NilError(c, err)
gcc, err := exec.LookPath("gcc")
assert.NilError(c, err, "could not find gcc")
out, err := exec.Command(gcc, "-g", "-Wall", "-static", "../contrib/nnp-test/nnp-test.c", "-o", filepath.Join(tmp, "nnp-test")).CombinedOutput()
assert.NilError(c, err, string(out))
dockerfile := filepath.Join(tmp, "Dockerfile")
content := `
FROM debian:jessie
COPY . /usr/bin
RUN chmod +s /usr/bin/nnp-test
`
err = ioutil.WriteFile(dockerfile, []byte(content), 0600)
assert.NilError(c, err, "could not write Dockerfile for nnp-test image")
var buildArgs []string
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
buildArgs = strings.Split(arg, " ")
}
buildArgs = append(buildArgs, []string{"-q", "-t", "nnp-test", tmp}...)
buildArgs = append([]string{"build"}, buildArgs...)
dockerCmd(c, buildArgs...)
}
func ensureNNPTestBuild(c *testing.T) {
err := load.FrozenImagesLinux(testEnv.APIClient(), "buildpack-deps:jessie")
assert.NilError(c, err)
var buildArgs []string
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
buildArgs = strings.Split(arg, " ")
}
buildArgs = append(buildArgs, []string{"-q", "-t", "npp-test", "../contrib/nnp-test"}...)
buildArgs = append([]string{"build"}, buildArgs...)
dockerCmd(c, buildArgs...)
}