github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/ipc/ipc_priv_test.go (about)

     1  // Copyright 2022 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package ipc
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func TestOutputDeadline(t *testing.T) {
    11  	// Run the command that leaks stderr to a child process.
    12  	env := &Env{
    13  		bin: []string{
    14  			"sh",
    15  			"-c",
    16  			"exec 1>&2; ( sleep 100; echo fail ) & echo done",
    17  		},
    18  		pid:    1,
    19  		config: &Config{},
    20  	}
    21  	c, err := env.makeCommand(&ExecOpts{}, t.TempDir())
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	c.wait()
    26  	out := <-c.readDone
    27  	if string(out) != "done\n" {
    28  		t.Errorf("unexpected output: '%s'", out)
    29  	}
    30  }