...

Source file src/github.com/opencontainers/runc/libcontainer/integration/init_test.go

Documentation: github.com/opencontainers/runc/libcontainer/integration

     1  package integration
     2  
     3  import (
     4  	"os"
     5  	"runtime"
     6  	"testing"
     7  
     8  	"github.com/opencontainers/runc/libcontainer"
     9  	_ "github.com/opencontainers/runc/libcontainer/nsenter"
    10  
    11  	"github.com/sirupsen/logrus"
    12  )
    13  
    14  // init runs the libcontainer initialization code because of the busybox style needs
    15  // to work around the go runtime and the issues with forking
    16  func init() {
    17  	if len(os.Args) < 2 || os.Args[1] != "init" {
    18  		return
    19  	}
    20  	runtime.GOMAXPROCS(1)
    21  	runtime.LockOSThread()
    22  	factory, err := libcontainer.New("")
    23  	if err != nil {
    24  		logrus.Fatalf("unable to initialize for container: %s", err)
    25  	}
    26  	if err := factory.StartInitialization(); err != nil {
    27  		logrus.Fatal(err)
    28  	}
    29  }
    30  
    31  func TestMain(m *testing.M) {
    32  	logrus.SetOutput(os.Stderr)
    33  	logrus.SetLevel(logrus.InfoLevel)
    34  
    35  	ret := m.Run()
    36  	os.Exit(ret)
    37  }
    38  

View as plain text