Merge pull request #45523 from thaJeztah/24.0_backport_cleanup_reexec_inits

[24.0 backport] [chore] clean up reexec.Init() calls
This commit is contained in:
Sebastiaan van Stijn 2023-05-11 19:00:48 +02:00 committed by GitHub
commit ed0c147c8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 10 additions and 66 deletions

View file

@ -21,8 +21,11 @@ type dispatchTestCase struct {
files map[string]string
}
func init() {
reexec.Init()
func TestMain(m *testing.M) {
if reexec.Init() {
return
}
os.Exit(m.Run())
}
func TestDispatch(t *testing.T) {

View file

@ -17,8 +17,11 @@ const (
contents = "contents test"
)
func init() {
reexec.Init()
func TestMain(m *testing.M) {
if reexec.Init() {
return
}
os.Exit(m.Run())
}
func TestCloseRootDirectory(t *testing.T) {

View file

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/daemon/graphdriver/graphtest"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/reexec"
)
func init() {
@ -17,8 +16,6 @@ func init() {
// errors or hangs to be debugged directly from the test process.
untar = archive.UntarUncompressed
graphdriver.ApplyUncompressedLayer = archive.ApplyUncompressedLayer
reexec.Init()
}
// This avoids creating a new driver for each test if all tests are run

View file

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/daemon/graphdriver/graphtest"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/reexec"
)
func init() {
@ -18,8 +17,6 @@ func init() {
// errors or hangs to be debugged directly from the test process.
untar = archive.UntarUncompressed
graphdriver.ApplyUncompressedLayer = archive.ApplyUncompressedLayer
reexec.Init()
}
func skipIfNaive(t *testing.T) {

View file

@ -7,14 +7,8 @@ import (
"testing"
"github.com/docker/docker/daemon/graphdriver/graphtest"
"github.com/docker/docker/pkg/reexec"
)
func init() {
reexec.Init()
}
// This avoids creating a new driver for each test if all tests are run
// Make sure to put new tests between TestVfsSetup and TestVfsTeardown
func TestVfsSetup(t *testing.T) {

View file

@ -18,7 +18,6 @@ import (
"github.com/docker/docker/integration-cli/daemon"
"github.com/docker/docker/integration-cli/environment"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/reexec"
testdaemon "github.com/docker/docker/testutil/daemon"
ienv "github.com/docker/docker/testutil/environment"
"github.com/docker/docker/testutil/fakestorage"
@ -50,8 +49,6 @@ var (
func init() {
var err error
reexec.Init() // This is required for external graphdriver tests
testEnv, err = environment.New()
if err != nil {
panic(err)

View file

@ -5,16 +5,12 @@ import (
"os"
"testing"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/testutil/environment"
)
var testEnv *environment.Execution
func TestMain(m *testing.M) {
if reexec.Init() {
return
}
var err error
testEnv, err = environment.New()
if err != nil {

View file

@ -5,7 +5,6 @@ import (
"os"
"testing"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/testutil/environment"
)
@ -13,10 +12,6 @@ var (
testEnv *environment.Execution
)
func init() {
reexec.Init() // This is required for external graphdriver tests
}
func TestMain(m *testing.M) {
var err error
testEnv, err = environment.New()

View file

@ -8,14 +8,9 @@ import (
"github.com/docker/docker/libnetwork/config"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/options"
"github.com/docker/docker/pkg/reexec"
)
func main() {
if reexec.Init() {
return
}
// Select and configure the network driver
networkType := "bridge"

View file

@ -4,23 +4,14 @@
package bridge
import (
"os"
"testing"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/ns"
"github.com/docker/docker/libnetwork/testutils"
"github.com/docker/docker/libnetwork/types"
"github.com/docker/docker/pkg/reexec"
)
func TestMain(m *testing.M) {
if reexec.Init() {
return
}
os.Exit(m.Run())
}
func TestPortMappingConfig(t *testing.T) {
defer testutils.SetupTestOSContext(t)()
d := newDriver()

View file

@ -10,7 +10,6 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"testing"
"github.com/docker/docker/libnetwork"
@ -23,19 +22,9 @@ import (
"github.com/docker/docker/libnetwork/testutils"
"github.com/docker/docker/libnetwork/types"
"github.com/docker/docker/pkg/plugins"
"github.com/docker/docker/pkg/reexec"
"github.com/sirupsen/logrus"
)
func TestMain(m *testing.M) {
if runtime.GOOS == "windows" {
logrus.Info("Test suite does not currently support windows")
os.Exit(0)
}
if reexec.Init() {
return
}
// Cleanup local datastore file
_ = os.Remove(datastore.DefaultScope("").Client.Address)

View file

@ -15,7 +15,6 @@ import (
"github.com/docker/docker/libnetwork/ns"
"github.com/docker/docker/libnetwork/testutils"
"github.com/docker/docker/libnetwork/types"
"github.com/docker/docker/pkg/reexec"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netlink/nl"
"github.com/vishvananda/netns"
@ -382,13 +381,6 @@ func TestLiveRestore(t *testing.T) {
}
}
func TestMain(m *testing.M) {
if reexec.Init() {
return
}
os.Exit(m.Run())
}
func TestSandboxCreate(t *testing.T) {
defer testutils.SetupTestOSContext(t)()

View file

@ -14,14 +14,9 @@ import (
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/reexec"
"gotest.tools/v3/skip"
)
func init() {
reexec.Init()
}
var chrootArchiver = NewArchiver(idtools.IdentityMapping{})
func TarUntar(src, dst string) error {