mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
7e481ee2eb
Currently, TestInit sets up logrus, and init uses it to log an error from StartInitialization(). This is solely used by TestExecInError to check that error returned from StartInitialization is the one it expects. Note that the very same error is communicated to the runc init parent and is ultimately returned by container.Run(), so checking what StartInitialization returned is redundant. Remove logrus setup and use from TestMain/init. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
37 lines
897 B
Go
37 lines
897 B
Go
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/opencontainers/runc/libcontainer"
|
|
//nolint:revive // Enable cgroup manager to manage devices
|
|
_ "github.com/opencontainers/runc/libcontainer/cgroups/devices"
|
|
_ "github.com/opencontainers/runc/libcontainer/nsenter"
|
|
)
|
|
|
|
// 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 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) {
|
|
ret := m.Run()
|
|
os.Exit(ret)
|
|
}
|