mirror of
				https://github.com/opencontainers/runc.git
				synced 2025-10-31 11:06:21 +08:00 
			
		
		
		
	 883aef789b
			
		
	
	883aef789b
	
	
	
		
			
			This commit does two things: 1. Consolidate StartInitialization calling logic into Init(). 2. Fix init error handling logic. The main issues at hand are: - the "unable to convert _LIBCONTAINER_INITPIPE" error from StartInitialization is never shown; - errors from WriteSync and WriteJSON are never shown; - the StartInit calling code is triplicated; - using panic is questionable. Generally, our goals are: - if there's any error, do our best to show it; - but only show each error once; - simplify the code, unify init implementations. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
		
			
				
	
	
		
			24 lines
		
	
	
		
			490 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			490 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package integration
 | |
| 
 | |
| import (
 | |
| 	"os"
 | |
| 	"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) > 1 && os.Args[1] == "init" {
 | |
| 		libcontainer.Init()
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func TestMain(m *testing.M) {
 | |
| 	ret := m.Run()
 | |
| 	os.Exit(ret)
 | |
| }
 |