diff --git a/libcontainer/integration/execin_test.go b/libcontainer/integration/execin_test.go index f8a6a9c69..58519a419 100644 --- a/libcontainer/integration/execin_test.go +++ b/libcontainer/integration/execin_test.go @@ -215,12 +215,10 @@ func TestExecInError(t *testing.T) { ok(t, err) for i := 0; i < 42; i++ { - var out bytes.Buffer unexistent := &libcontainer.Process{ - Cwd: "/", - Args: []string{"unexistent"}, - Env: standardEnvironment, - Stderr: &out, + Cwd: "/", + Args: []string{"unexistent"}, + Env: standardEnvironment, } err = container.Run(unexistent) if err == nil { @@ -229,9 +227,6 @@ func TestExecInError(t *testing.T) { if !strings.Contains(err.Error(), "executable file not found") { t.Fatalf("Should be error about not found executable, got %s", err) } - if !bytes.Contains(out.Bytes(), []byte("executable file not found")) { - t.Fatalf("executable file not found error not delivered to stdio:\n%s", out.String()) - } } } diff --git a/libcontainer/integration/init_test.go b/libcontainer/integration/init_test.go index 76638ffc7..efcbe72b0 100644 --- a/libcontainer/integration/init_test.go +++ b/libcontainer/integration/init_test.go @@ -1,6 +1,7 @@ package integration import ( + "fmt" "os" "runtime" "testing" @@ -9,27 +10,27 @@ import ( //nolint:revive // Enable cgroup manager to manage devices _ "github.com/opencontainers/runc/libcontainer/cgroups/devices" _ "github.com/opencontainers/runc/libcontainer/nsenter" - - "github.com/sirupsen/logrus" ) -// init runs the libcontainer initialization code because of the busybox style needs -// to work around the go runtime and the issues with forking +// Same as ../../init.go but for libcontainer/integration. func init() { if len(os.Args) < 2 || os.Args[1] != "init" { return } + // This is the golang entry point for runc init, executed + // before TestMain() but after libcontainer/nsenter's nsexec(). runtime.GOMAXPROCS(1) runtime.LockOSThread() if err := libcontainer.StartInitialization(); err != nil { - logrus.Fatal(err) + // logrus is not initialized + fmt.Fprintln(os.Stderr, err) } + // Normally, StartInitialization() never returns, meaning + // if we are here, it had failed. + os.Exit(1) } func TestMain(m *testing.M) { - logrus.SetOutput(os.Stderr) - logrus.SetLevel(logrus.InfoLevel) - ret := m.Run() os.Exit(ret) }