File: parent_test.go

package info (click to toggle)
golang-github-cloudflare-tableflip 1.2.1~git20200514.4baec98-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: makefile: 2
file content (32 lines) | stat: -rw-r--r-- 548 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package tableflip

import (
	"testing"
)

func TestParentExit(t *testing.T) {
	env, procs := testEnv()
	child, err := startChild(env, nil)
	if err != nil {
		t.Fatal(err)
	}

	proc := <-procs
	_, exited, err := proc.notify()
	if err != nil {
		t.Fatal(err)
	}

	readyFile := <-child.ready
	if _, err = readyFile.Write([]byte{1}); err != nil {
		t.Fatal("Can't inject garbage from parent")
	}
	if err := readyFile.Close(); err != nil {
		t.Fatal(err)
	}

	err = <-exited
	if err == nil {
		t.Fatal("Expect child to detect garbage from parent")
	}
}