blob: 8a84f3d03aa06bf52f0b6271f88f50b400e974a3 [file] [log] [blame]
Jiri Simsa5293dcb2014-05-10 09:56:38 -07001package rt_test
2
3import (
4 "fmt"
5 "syscall"
6 "testing"
7
8 "veyron/lib/testutil/blackbox"
9 "veyron/runtimes/google/rt"
10)
11
12func init() {
13 blackbox.CommandTable["withRuntime"] = withRuntime
14 blackbox.CommandTable["withoutRuntime"] = withoutRuntime
15}
16
17func simpleEchoProgram() {
18 fmt.Println("ready")
19 fmt.Println(blackbox.ReadLineFromStdin())
20 blackbox.WaitForEOFOnStdin()
21}
22
23func withRuntime([]string) {
24 rt.Init()
25 simpleEchoProgram()
26}
27
28func withoutRuntime([]string) {
29 simpleEchoProgram()
30}
31
32func TestWithRuntime(t *testing.T) {
33 c := blackbox.HelperCommand(t, "withRuntime")
34 defer c.Cleanup()
35 c.Cmd.Start()
36 c.Expect("ready")
37 syscall.Kill(c.Cmd.Process.Pid, syscall.SIGHUP)
38 c.WriteLine("foo")
39 c.Expect("foo")
40 c.CloseStdin()
41 c.ExpectEOFAndWait()
42}
43
44func TestWithoutRuntime(t *testing.T) {
45 c := blackbox.HelperCommand(t, "withoutRuntime")
46 defer c.Cleanup()
47 c.Cmd.Start()
48 c.Expect("ready")
49 syscall.Kill(c.Cmd.Process.Pid, syscall.SIGHUP)
50 c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status 2"))
51}