mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
3bc606e9d3
1. Use t.TempDir instead of ioutil.TempDir. This means no need for an explicit cleanup, which removes some code, including newTestBundle and newTestRoot. 2. Move newRootfs invocation down to newTemplateConfig, removing a need for explicit rootfs creation. Also, remove rootfs from tParam as it is no longer needed (there was a since test case in which two containers shared the same rootfs, but it does not look like it's required for the test). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
38 lines
792 B
Go
38 lines
792 B
Go
package integration
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/opencontainers/runc/libcontainer"
|
|
_ "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
|
|
func init() {
|
|
if len(os.Args) < 2 || os.Args[1] != "init" {
|
|
return
|
|
}
|
|
runtime.GOMAXPROCS(1)
|
|
runtime.LockOSThread()
|
|
factory, err := libcontainer.New("")
|
|
if err != nil {
|
|
logrus.Fatalf("unable to initialize for container: %s", err)
|
|
}
|
|
if err := factory.StartInitialization(); err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestMain(m *testing.M) {
|
|
logrus.SetOutput(os.Stderr)
|
|
logrus.SetLevel(logrus.InfoLevel)
|
|
|
|
ret := m.Run()
|
|
os.Exit(ret)
|
|
}
|