veyron/lib/testutil: fixing a bug in blackbox
Change-Id: I83b7b2373ccea9dbfa8ed22109e9a81f93f2c9fa
diff --git a/lib/exec/parent.go b/lib/exec/parent.go
index eecc198..1e147ad 100644
--- a/lib/exec/parent.go
+++ b/lib/exec/parent.go
@@ -93,7 +93,7 @@
// Start starts the child process, sharing a secret with it and
// setting up a communication channel over which to read its status.
func (p *ParentHandle) Start() error {
- if parent.BlackboxTest(p.c.Env) {
+ if parent.BlackboxTest() {
if err := parent.InitBlackboxParent(p.c); err != nil {
return err
}
diff --git a/lib/testutil/blackbox/parent/parent.go b/lib/testutil/blackbox/parent/parent.go
index 7e991d1..fe24135 100644
--- a/lib/testutil/blackbox/parent/parent.go
+++ b/lib/testutil/blackbox/parent/parent.go
@@ -10,16 +10,10 @@
"sync"
)
-// BlackboxTest returns true if the environment variables passed to
-// it contain the variable (GO_WANT_HELPER_PROCESS_BLACKBOX=1) indicating that
-// a blackbox test is configured.
-func BlackboxTest(env []string) bool {
- for _, v := range env {
- if v == "GO_WANT_HELPER_PROCESS_BLACKBOX=1" {
- return true
- }
- }
- return false
+// BlackboxTest returns true if the current process has been spawned
+// using the blackbox testing framework.
+func BlackboxTest() bool {
+ return os.Getenv("VEYRON_BLACKBOX_TEST") == "1"
}
type pipeList struct {
@@ -29,12 +23,13 @@
var pipes pipeList
-// InitBlacboxParent initializes the exec.Command instance passed in for
-// use with a process that is to be run as blackbox test. This is needed
-// for processes, such as the node manager, which want to run subprocesses
-// from within blackbox tests but are not themselves test code.
-// It must be called before any changes are made to ExtraFiles since it will
-// use the first entry for itself, overwriting anything that's there.
+// InitBlackboxParent initializes the exec.Command instance passed in
+// for use with a process that is to be run as blackbox test. This is
+// needed for processes, such as the node manager, which want to run
+// subprocesses from within blackbox tests but are not themselves test
+// code. It must be called before any changes are made to ExtraFiles
+// since it will use the first entry for itself, overwriting anything
+// that's there.
func InitBlackboxParent(cmd *exec.Cmd) error {
reader, writer, err := os.Pipe()
if err != nil {
diff --git a/lib/testutil/blackbox/subprocess.go b/lib/testutil/blackbox/subprocess.go
index 116b51f..9de1a90 100644
--- a/lib/testutil/blackbox/subprocess.go
+++ b/lib/testutil/blackbox/subprocess.go
@@ -64,7 +64,7 @@
if err != nil {
return nil, err
}
- cmd.Env = append([]string{"GO_WANT_HELPER_PROCESS_BLACKBOX=1"}, os.Environ()...)
+ cmd.Env = append([]string{"VEYRON_BLACKBOX_TEST=1"}, os.Environ()...)
cmd.ExtraFiles = []*os.File{reader}
return writer, nil
}
@@ -127,7 +127,7 @@
func HelperProcess(t *testing.T) {
// Return immediately if this is not run as the child helper
// for the other tests.
- if os.Getenv("GO_WANT_HELPER_PROCESS_BLACKBOX") != "1" {
+ if os.Getenv("VEYRON_BLACKBOX_TEST") != "1" {
return
}
if len(subcommand) == 0 {
diff --git a/lib/testutil/init.go b/lib/testutil/init.go
index 2315551..3b130d7 100644
--- a/lib/testutil/init.go
+++ b/lib/testutil/init.go
@@ -44,7 +44,7 @@
if seedString != "" {
var err error
base, bitSize := 0, 64
- seed, err = strconv.ParseInt(seedString, 0, 64)
+ seed, err = strconv.ParseInt(seedString, base, bitSize)
if err != nil {
vlog.Fatalf("ParseInt(%v, %v, %v) failed: %v", seedString, base, bitSize, err)
}