...
Source file
src/os/exec_unix_test.go
Documentation: os
1
2
3
4
5
6
7 package os_test
8
9 import (
10 "internal/testenv"
11 . "os"
12 "syscall"
13 "testing"
14 )
15
16 func TestErrProcessDone(t *testing.T) {
17 testenv.MustHaveGoBuild(t)
18 t.Parallel()
19
20 p, err := StartProcess(testenv.GoToolPath(t), []string{"go"}, &ProcAttr{})
21 if err != nil {
22 t.Fatalf("starting test process: %v", err)
23 }
24 p.Wait()
25 if got := p.Signal(Kill); got != ErrProcessDone {
26 t.Errorf("got %v want %v", got, ErrProcessDone)
27 }
28 }
29
30 func TestUNIXProcessAlive(t *testing.T) {
31 testenv.MustHaveGoBuild(t)
32 t.Parallel()
33
34 p, err := StartProcess(testenv.GoToolPath(t), []string{"sleep", "1"}, &ProcAttr{})
35 if err != nil {
36 t.Skipf("starting test process: %v", err)
37 }
38 defer p.Kill()
39
40 proc, _ := FindProcess(p.Pid)
41 err = proc.Signal(syscall.Signal(0))
42 if err != nil {
43 t.Errorf("OS reported error for running process: %v", err)
44 }
45 }
46
View as plain text