Skip to content

Commit c0b4453

Browse files
committed
without bin file
1 parent 0c52eb1 commit c0b4453

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

util/exec/exec_test.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package exec
22

33
import (
4-
"os"
54
"os/exec"
6-
"path/filepath"
75
"regexp"
86
"syscall"
97
"testing"
@@ -219,51 +217,3 @@ func TestRunCaptureStderr(t *testing.T) {
219217
assert.Equal(t, "hello world\nmy-error", output)
220218
assert.NoError(t, err)
221219
}
222-
223-
// This test demonstrates that when a process group is signaled, all child processes are also terminated and file locks released.
224-
func TestProcessGroupSignalRemovesChildLock(t *testing.T) {
225-
hook := test.NewGlobal()
226-
log.SetLevel(log.DebugLevel)
227-
defer log.SetLevel(log.InfoLevel)
228-
229-
dir := t.TempDir()
230-
lockFile := filepath.Join(dir, "lockfile")
231-
childScript := filepath.Join(dir, "child.sh")
232-
parentScript := filepath.Join(dir, "parent.sh")
233-
234-
// Child: create lock file; on SIGTERM remove it and exit
235-
child := "#!/bin/sh\n" +
236-
"trap 'rm -f lockfile; exit 0' TERM\n" +
237-
"touch lockfile\n" +
238-
"sleep 100\n"
239-
require.NoError(t, os.WriteFile(childScript, []byte(child), 0o755))
240-
241-
// Parent: start child in background and sleep
242-
parent := "#!/bin/sh\n" +
243-
"./child.sh &\n" +
244-
"sleep 100\n"
245-
require.NoError(t, os.WriteFile(parentScript, []byte(parent), 0o755))
246-
247-
// Run parent with a short timeout; our implementation signals the process group
248-
opts := CmdOpts{
249-
Timeout: 500 * time.Millisecond,
250-
FatalTimeout: 500 * time.Millisecond,
251-
TimeoutBehavior: TimeoutBehavior{
252-
Signal: syscall.SIGTERM,
253-
ShouldWait: true,
254-
},
255-
}
256-
_, err := RunCommand("sh", opts, "-c", "cd "+dir+" && ./parent.sh")
257-
require.Error(t, err)
258-
259-
// Give a bit of time for traps to run and for the process tree to settle
260-
time.Sleep(200 * time.Millisecond)
261-
262-
// Because the process group was signaled, the child should have removed the lock
263-
_, statErr := os.Stat(lockFile)
264-
require.Error(t, statErr, "expected lock file to be removed when process group is signaled")
265-
assert.True(t, os.IsNotExist(statErr))
266-
267-
// basic sanity: logs produced
268-
require.GreaterOrEqual(t, len(hook.Entries), 1)
269-
}

0 commit comments

Comments
 (0)