MCPcopy
hub / github.com/apptainer/apptainer / TestStartContainer

Function TestStartContainer

internal/app/starter/master_linux_test.go:75–116  ·  view source on GitHub ↗

nolint:dupl

(t *testing.T)

Source from the content-addressed store, hash-verified

73
74//nolint:dupl
75func TestStartContainer(t *testing.T) {
76 test.DropPrivilege(t)
77 defer test.ResetPrivilege(t)
78
79 var fatal error
80 fatalChan := make(chan error, 1)
81
82 tests := []struct {
83 name string
84 masterSocket int
85 containerPid int
86 engine *engine.Engine
87 shallPass bool
88 }{
89 {
90 name: "nil engine; bad masterSocket",
91 masterSocket: -1,
92 containerPid: -1,
93 engine: nil,
94 shallPass: false,
95 },
96 {
97 name: "nil engine; wrong socket",
98 masterSocket: 2,
99 containerPid: -1,
100 engine: nil,
101 shallPass: false,
102 },
103 }
104
105 for _, tt := range tests {
106 t.Run(tt.name, func(t *testing.T) {
107 go startContainer(t.Context(), tt.masterSocket, tt.containerPid, tt.engine, fatalChan)
108 fatal = <-fatalChan
109 if tt.shallPass && fatal != nil {
110 t.Fatalf("test %s expected to succeed but failed: %s", tt.name, fatal)
111 } else if !tt.shallPass && fatal == nil {
112 t.Fatalf("test %s expected to fail but succeeded", tt.name)
113 }
114 })
115 }
116}

Callers

nothing calls this directly

Calls 4

DropPrivilegeFunction · 0.92
ResetPrivilegeFunction · 0.92
startContainerFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected