MCPcopy Create free account
hub / github.com/docker/cli / TestIgnoredSignals

Function TestIgnoredSignals

cli/command/container/signals_unix_test.go:17–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestIgnoredSignals(t *testing.T) {
18 ignoredSignals := []syscall.Signal{unix.SIGPIPE, unix.SIGCHLD, unix.SIGURG}
19
20 for _, s := range ignoredSignals {
21 t.Run(unix.SignalName(s), func(t *testing.T) {
22 ctx, cancel := context.WithCancel(context.Background())
23 defer cancel()
24
25 var called bool
26 apiClient := &fakeClient{containerKillFunc: func(ctx context.Context, container string, options client.ContainerKillOptions) (client.ContainerKillResult, error) {
27 called = true
28 return client.ContainerKillResult{}, nil
29 }}
30
31 sigc := make(chan os.Signal)
32 defer close(sigc)
33
34 done := make(chan struct{})
35 go func() {
36 ForwardAllSignals(ctx, apiClient, t.Name(), sigc)
37 close(done)
38 }()
39
40 timer := time.NewTimer(30 * time.Second)
41 defer timer.Stop()
42
43 select {
44 case <-timer.C:
45 t.Fatal("timeout waiting to send signal")
46 case sigc <- s:
47 case <-done:
48 }
49
50 // cancel the context so ForwardAllSignals will exit after it has processed the signal we sent.
51 // This is how we know the signal was actually processed and are not introducing a flakey test.
52 cancel()
53 <-done
54
55 assert.Assert(t, !called, "kill was called")
56 })
57 }
58}

Callers

nothing calls this directly

Calls 2

ForwardAllSignalsFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…