MCPcopy Index your code
hub / github.com/docker/cli / TestProcessTermination

Function TestProcessTermination

e2e/container/run_test.go:194–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

192}
193
194func TestProcessTermination(t *testing.T) {
195 var out bytes.Buffer
196 cmd := icmd.Command("docker", "run", "--rm", "-i", fixtures.AlpineImage,
197 "sh", "-c", "echo 'starting trap'; trap 'echo got signal; exit 0;' TERM; while true; do sleep 10; done")
198 cmd.Stdout = &out
199 cmd.Stderr = &out
200
201 result := icmd.StartCmd(cmd).Assert(t, icmd.Success)
202
203 poll.WaitOn(t, func(t poll.LogT) poll.Result {
204 if strings.Contains(result.Stdout(), "starting trap") {
205 return poll.Success()
206 }
207 return poll.Continue("waiting for process to trap signal")
208 }, poll.WithDelay(1*time.Second), poll.WithTimeout(5*time.Second))
209
210 assert.NilError(t, result.Cmd.Process.Signal(syscall.SIGTERM))
211
212 icmd.WaitOnCmd(time.Second*10, result).Assert(t, icmd.Expected{
213 ExitCode: 0,
214 })
215}
216
217// Adapted from https://github.com/docker/for-mac/issues/7632#issue-2932169772
218// Thanks [@almet](https://github.com/almet)!

Callers

nothing calls this directly

Calls 2

ContainsMethod · 0.80
CommandMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…