64a928a3d4
sed -E -i 's#\bcheck\.C\b#testing.T#g' \
-- "integration-cli/check_test.go" "integration-cli/daemon/daemon.go" "integration-cli/daemon/daemon_swarm.go" "integration-cli/daemon_swarm_hack_test.go" "integration-cli/docker_api_attach_test.go" "integration-cli/docker_api_build_test.go" "integration-cli/docker_api_build_windows_test.go" "integration-cli/docker_api_containers_test.go" "integration-cli/docker_api_containers_windows_test.go" "integration-cli/docker_api_exec_resize_test.go" "integration-cli/docker_api_exec_test.go" "integration-cli/docker_api_images_test.go" "integration-cli/docker_api_inspect_test.go" "integration-cli/docker_api_logs_test.go" "integration-cli/docker_api_network_test.go" "integration-cli/docker_api_stats_test.go" "integration-cli/docker_api_swarm_node_test.go" "integration-cli/docker_api_swarm_service_test.go" "integration-cli/docker_api_swarm_test.go" "integration-cli/docker_api_test.go" "integration-cli/docker_cli_attach_test.go" "integration-cli/docker_cli_attach_unix_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_build_unix_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_cp_from_container_test.go" "integration-cli/docker_cli_cp_test.go" "integration-cli/docker_cli_cp_to_container_test.go" "integration-cli/docker_cli_cp_to_container_unix_test.go" "integration-cli/docker_cli_cp_utils_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_plugins_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_events_test.go" "integration-cli/docker_cli_events_unix_test.go" "integration-cli/docker_cli_exec_test.go" "integration-cli/docker_cli_exec_unix_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_health_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_import_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_info_unix_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_login_test.go" "integration-cli/docker_cli_logout_test.go" "integration-cli/docker_cli_logs_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_logdriver_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_proxy_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_pull_test.go" "integration-cli/docker_cli_push_test.go" "integration-cli/docker_cli_registry_user_agent_test.go" "integration-cli/docker_cli_restart_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_save_load_unix_test.go" "integration-cli/docker_cli_search_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_service_logs_test.go" "integration-cli/docker_cli_service_scale_test.go" "integration-cli/docker_cli_sni_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_stats_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_swarm_unix_test.go" "integration-cli/docker_cli_top_test.go" "integration-cli/docker_cli_update_unix_test.go" "integration-cli/docker_cli_userns_test.go" "integration-cli/docker_cli_v2_only_test.go" "integration-cli/docker_cli_volume_test.go" "integration-cli/docker_deprecated_api_v124_test.go" "integration-cli/docker_deprecated_api_v124_unix_test.go" "integration-cli/docker_hub_pull_suite_test.go" "integration-cli/docker_utils_test.go" "integration-cli/events_utils_test.go" "integration-cli/fixtures_linux_daemon_test.go" "integration-cli/utils_test.go" "pkg/discovery/discovery_test.go" "pkg/discovery/file/file_test.go" "pkg/discovery/generator_test.go" "pkg/discovery/kv/kv_test.go" "pkg/discovery/memory/memory_test.go" "pkg/discovery/nodes/nodes_test.go"
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 1d92789b4f
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
142 lines
4.2 KiB
Go
142 lines
4.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/internal/test/fixtures/load"
|
|
"github.com/go-check/check"
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
type testingT interface {
|
|
logT
|
|
Fatalf(string, ...interface{})
|
|
}
|
|
|
|
type logT interface {
|
|
Logf(string, ...interface{})
|
|
}
|
|
|
|
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, 600)
|
|
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), 600)
|
|
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...)
|
|
}
|