(t *testing.T)
| 232 | } |
| 233 | |
| 234 | func TestProcessEnv(t *testing.T) { |
| 235 | if testing.Short() { |
| 236 | return |
| 237 | } |
| 238 | |
| 239 | config := newTemplateConfig(t, nil) |
| 240 | container, err := newContainer(t, config) |
| 241 | ok(t, err) |
| 242 | defer destroyContainer(container) |
| 243 | |
| 244 | var stdout strings.Builder |
| 245 | pconfig := libcontainer.Process{ |
| 246 | Cwd: "/", |
| 247 | Args: []string{"sh", "-c", "env"}, |
| 248 | Env: []string{ |
| 249 | "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", |
| 250 | "HOSTNAME=integration", |
| 251 | "TERM=xterm", |
| 252 | "FOO=BAR", |
| 253 | }, |
| 254 | Stdin: nil, |
| 255 | Stdout: &stdout, |
| 256 | Stderr: new(strings.Builder), |
| 257 | Init: true, |
| 258 | } |
| 259 | err = container.Run(&pconfig) |
| 260 | ok(t, err) |
| 261 | |
| 262 | // Wait for process |
| 263 | waitProcess(&pconfig, t) |
| 264 | |
| 265 | outputEnv := stdout.String() |
| 266 | |
| 267 | // Check that the environment has the key/value pair we added |
| 268 | if !strings.Contains(outputEnv, "FOO=BAR") { |
| 269 | t.Fatal("Environment doesn't have the expected FOO=BAR key/value pair: ", outputEnv) |
| 270 | } |
| 271 | |
| 272 | // Make sure that HOME is set |
| 273 | if !strings.Contains(outputEnv, "HOME=/root") { |
| 274 | t.Fatal("Environment doesn't have HOME set: ", outputEnv) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | func TestProcessEmptyCaps(t *testing.T) { |
| 279 | if testing.Short() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…