core: Remove testutil.Init in init and use v23 test generate
to generate proper TestMains.
Next step, remove remaining TestHelperProcesses. This proved to cause
issues on TestAppLifeCycle, where converting to the generated TestMain
didn't work. Will look into that in another CL.
Change-Id: I804dfcf4760a899642705d7da98f07e85e37a594
diff --git a/lib/filelocker/locker_test.go b/lib/filelocker/locker_test.go
index cf483a7..46f7bb6 100644
--- a/lib/filelocker/locker_test.go
+++ b/lib/filelocker/locker_test.go
@@ -14,13 +14,7 @@
"v.io/core/veyron/lib/modules"
)
-func init() {
- modules.RegisterChild("testLockChild", "", testLockChild)
-}
-
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
+//go:generate v23 test generate
func newFile() string {
file, err := ioutil.TempFile("", "test_lock_file")
diff --git a/lib/filelocker/v23_internal_test.go b/lib/filelocker/v23_internal_test.go
new file mode 100644
index 0000000..9f46669
--- /dev/null
+++ b/lib/filelocker/v23_internal_test.go
@@ -0,0 +1,26 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package filelocker
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("testLockChild", ``, testLockChild)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/lib/modules/core/core_test.go b/lib/modules/core/core_test.go
index 9f2b0b5..b775c1c 100644
--- a/lib/modules/core/core_test.go
+++ b/lib/modules/core/core_test.go
@@ -20,6 +20,20 @@
_ "v.io/core/veyron/profiles"
)
+// We create our own TestMain here because v23 test generate currently does not
+// recognize that this requires modules.Dispatch().
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
+
func TestCommands(t *testing.T) {
sh, fn := newShell(t)
defer fn()
@@ -30,10 +44,6 @@
}
}
-func init() {
- testutil.Init()
-}
-
// TODO(cnicolaou): add test for proxyd
func newShell(t *testing.T) (*modules.Shell, func()) {
@@ -229,7 +239,3 @@
t.Fatalf("unexpected output: got %v, want %v", got, want)
}
}
-
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
diff --git a/lib/modules/modules_test.go b/lib/modules/modules_test.go
index f6d3230..a482125 100644
--- a/lib/modules/modules_test.go
+++ b/lib/modules/modules_test.go
@@ -26,7 +26,6 @@
const credentialsEnvPrefix = "\"" + consts.VeyronCredentials + "="
func init() {
- testutil.Init()
modules.RegisterChild("envtest", "envtest: <variables to print>...", PrintFromEnv)
modules.RegisterChild("printenv", "printenv", PrintEnv)
modules.RegisterChild("printblessing", "printblessing", PrintBlessing)
@@ -39,6 +38,20 @@
modules.RegisterFunction("errortestFunc", "", ErrorMain)
}
+// We must call Testmain ourselves because using v23 test generate
+// creates an import cycle for this package.
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
+
func ignoresStdin(io.Reader, io.Writer, io.Writer, map[string]string, ...string) error {
<-time.After(time.Minute)
return nil
@@ -263,7 +276,7 @@
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
- if got, want := h.Shutdown(nil, nil), "exit status 255"; got == nil || got.Error() != want {
+ if got, want := h.Shutdown(nil, nil), "exit status 1"; got == nil || got.Error() != want {
t.Errorf("got %q, want %q", got, want)
}
}
@@ -514,8 +527,4 @@
}
}
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
-
// TODO(cnicolaou): test for error return from cleanup
diff --git a/lib/modules/queue_rw_test.go b/lib/modules/queue_rw_test.go
index 98be7db..e6bc984 100644
--- a/lib/modules/queue_rw_test.go
+++ b/lib/modules/queue_rw_test.go
@@ -9,11 +9,6 @@
"v.io/core/veyron/lib/testutil"
)
-func init() {
- if !modules.IsModulesProcess() {
- testutil.Init()
- }
-}
func TestQueueRW(t *testing.T) {
q := modules.NewRW()
size := testutil.Rand.Intn(1000)
diff --git a/lib/signals/signals_test.go b/lib/signals/signals_test.go
index 69c47fd..e427ca9 100644
--- a/lib/signals/signals_test.go
+++ b/lib/signals/signals_test.go
@@ -27,18 +27,7 @@
"v.io/core/veyron/services/mgmt/device"
)
-// TestHelperProcess is boilerplate for the modules setup.
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
-
-func init() {
- testutil.Init()
- modules.RegisterChild("handleDefaults", "", handleDefaults)
- modules.RegisterChild("handleCustom", "", handleCustom)
- modules.RegisterChild("handleCustomWithStop", "", handleCustomWithStop)
- modules.RegisterChild("handleDefaultsIgnoreChan", "", handleDefaultsIgnoreChan)
-}
+//go:generate v23 test generate
func stopLoop(stop func(), stdin io.Reader, ch chan<- struct{}) {
scanner := bufio.NewScanner(stdin)
diff --git a/lib/signals/v23_internal_test.go b/lib/signals/v23_internal_test.go
new file mode 100644
index 0000000..516b493
--- /dev/null
+++ b/lib/signals/v23_internal_test.go
@@ -0,0 +1,29 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package signals
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("handleDefaults", ``, handleDefaults)
+ modules.RegisterChild("handleCustom", ``, handleCustom)
+ modules.RegisterChild("handleCustomWithStop", ``, handleCustomWithStop)
+ modules.RegisterChild("handleDefaultsIgnoreChan", ``, handleDefaultsIgnoreChan)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/lib/testutil/init.go b/lib/testutil/init.go
index 9dd4630..277d1b3 100644
--- a/lib/testutil/init.go
+++ b/lib/testutil/init.go
@@ -3,7 +3,10 @@
// Configures logging, random number generators and other global state.
// Typical usage in _test.go files:
// import "v.io/core/veyron/lib/testutil"
-// func init() { testutil.Init() }
+// func TestMain(m *testing.M) {
+// testutil.Init()
+// os.Exit(m.Run())
+// }
package testutil
import (
diff --git a/lib/websocket/util_test.go b/lib/websocket/util_test.go
index cb8df27..fe06ec1 100644
--- a/lib/websocket/util_test.go
+++ b/lib/websocket/util_test.go
@@ -12,14 +12,13 @@
"time"
"v.io/core/veyron2/ipc"
-
- "v.io/core/veyron/lib/testutil"
)
+//go:generate v23 test generate
+
var crcTable *crc64.Table
func init() {
- testutil.Init()
crcTable = crc64.MakeTable(crc64.ISO)
}
diff --git a/lib/websocket/v23_internal_test.go b/lib/websocket/v23_internal_test.go
new file mode 100644
index 0000000..00e5713
--- /dev/null
+++ b/lib/websocket/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package websocket
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 2fc49da..61d7773 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -6,7 +6,6 @@
"fmt"
"io"
"net"
- "os"
"path/filepath"
"reflect"
"runtime"
@@ -43,6 +42,8 @@
ivtrace "v.io/core/veyron/runtimes/google/vtrace"
)
+//go:generate v23 test generate
+
var (
errMethod = verror.New(verror.ErrAborted, nil)
clock = new(fakeClock)
@@ -1854,13 +1855,11 @@
}
}
-func TestMain(m *testing.M) {
- testutil.Init()
+func init() {
security.RegisterCaveatValidator(fakeTimeCaveat, func(_ security.Context, t int64) error {
if now := clock.Now(); now > int(t) {
return fmt.Errorf("fakeTimeCaveat expired: now=%d > then=%d", now, t)
}
return nil
})
- os.Exit(m.Run())
}
diff --git a/runtimes/google/ipc/proxy_test.go b/runtimes/google/ipc/proxy_test.go
index 0795737..3606d46 100644
--- a/runtimes/google/ipc/proxy_test.go
+++ b/runtimes/google/ipc/proxy_test.go
@@ -325,7 +325,3 @@
t.Errorf("%s not supposed to be found in mounttable; got %d servers instead: %v", name, len(names), names)
}
}
-
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
diff --git a/runtimes/google/ipc/stream/manager/manager_test.go b/runtimes/google/ipc/stream/manager/manager_test.go
index 17a03c2..cd8ac68 100644
--- a/runtimes/google/ipc/stream/manager/manager_test.go
+++ b/runtimes/google/ipc/stream/manager/manager_test.go
@@ -34,13 +34,26 @@
}
func init() {
+ modules.RegisterChild("runServer", "", runServer)
+}
+
+// We write our own TestMain here instead of relying on v23 test generate because
+// we need to set runtime.GOMAXPROCS.
+func TestMain(m *testing.M) {
testutil.Init()
// testutil.Init sets GOMAXPROCS to NumCPU. We want to force
// GOMAXPROCS to remain at 1, in order to trigger a particular race
- // condition tht occurs when closing the server; also, using 1 cpu
+ // condition that occurs when closing the server; also, using 1 cpu
// introduces less variance in the behavior of the test.
runtime.GOMAXPROCS(1)
- modules.RegisterChild("runServer", "", runServer)
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
}
func testSimpleFlow(t *testing.T, protocol string) {
@@ -549,11 +562,6 @@
}
}
-// Needed by modules framework
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
-
func runServer(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
server := InternalNew(naming.FixedRoutingID(0x55555555))
_, ep, err := server.Listen(args[0], args[1])
diff --git a/runtimes/google/ipc/stream/proxy/proxy_test.go b/runtimes/google/ipc/stream/proxy/proxy_test.go
index 5469e25..86920f7 100644
--- a/runtimes/google/ipc/stream/proxy/proxy_test.go
+++ b/runtimes/google/ipc/stream/proxy/proxy_test.go
@@ -4,7 +4,6 @@
"bytes"
"fmt"
"io"
- "os"
"reflect"
"strings"
"testing"
@@ -12,7 +11,6 @@
"v.io/core/veyron/runtimes/google/ipc/stream"
"v.io/core/veyron2/naming"
- "v.io/core/veyron/lib/testutil"
tsecurity "v.io/core/veyron/lib/testutil/security"
_ "v.io/core/veyron/profiles"
"v.io/core/veyron/runtimes/google/ipc/stream/manager"
@@ -20,10 +18,7 @@
"v.io/core/veyron/runtimes/google/ipc/stream/vc"
)
-func TestMain(m *testing.M) {
- testutil.Init()
- os.Exit(m.Run())
-}
+//go:generate v23 test generate
func TestProxy(t *testing.T) {
proxy, err := proxy.New(naming.FixedRoutingID(0xbbbbbbbbbbbbbbbb), nil, "tcp", "127.0.0.1:0", "")
diff --git a/runtimes/google/ipc/stream/proxy/v23_internal_test.go b/runtimes/google/ipc/stream/proxy/v23_internal_test.go
new file mode 100644
index 0000000..2f412c7
--- /dev/null
+++ b/runtimes/google/ipc/stream/proxy/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package proxy
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/ipc/stream/vc/v23_internal_test.go b/runtimes/google/ipc/stream/vc/v23_internal_test.go
new file mode 100644
index 0000000..f314781
--- /dev/null
+++ b/runtimes/google/ipc/stream/vc/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package vc
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/ipc/stream/vc/vc_test.go b/runtimes/google/ipc/stream/vc/vc_test.go
index a8499bc..a27a0ed 100644
--- a/runtimes/google/ipc/stream/vc/vc_test.go
+++ b/runtimes/google/ipc/stream/vc/vc_test.go
@@ -7,7 +7,6 @@
"fmt"
"io"
"net"
- "os"
"reflect"
"runtime"
"strings"
@@ -30,10 +29,7 @@
"v.io/core/veyron2/security"
)
-func TestMain(m *testing.M) {
- testutil.Init()
- os.Exit(m.Run())
-}
+//go:generate v23 test generate
const (
// Convenience alias to avoid conflicts between the package name "vc" and variables called "vc".
diff --git a/runtimes/google/ipc/stream/vif/v23_internal_test.go b/runtimes/google/ipc/stream/vif/v23_internal_test.go
new file mode 100644
index 0000000..cd832a8
--- /dev/null
+++ b/runtimes/google/ipc/stream/vif/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package vif
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/ipc/stream/vif/vif_test.go b/runtimes/google/ipc/stream/vif/vif_test.go
index ed21c70..8b7a06d 100644
--- a/runtimes/google/ipc/stream/vif/vif_test.go
+++ b/runtimes/google/ipc/stream/vif/vif_test.go
@@ -9,7 +9,6 @@
"fmt"
"io"
"net"
- "os"
"reflect"
"runtime"
"sort"
@@ -28,10 +27,7 @@
"v.io/core/veyron2/naming"
)
-func TestMain(m *testing.M) {
- testutil.Init()
- os.Exit(m.Run())
-}
+//go:generate v23 test generate
func newPrincipal(defaultBlessing string) vc.LocalPrincipal {
return vc.LocalPrincipal{tsecurity.NewPrincipal("defaultBlessing")}
diff --git a/runtimes/google/ipc/v23_test.go b/runtimes/google/ipc/v23_test.go
new file mode 100644
index 0000000..1eb8e5c
--- /dev/null
+++ b/runtimes/google/ipc/v23_test.go
@@ -0,0 +1,26 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package ipc_test
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("childPing", ``, childPing)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/lib/deque/deque_test.go b/runtimes/google/lib/deque/deque_test.go
index ae0d4d3..50a3078 100644
--- a/runtimes/google/lib/deque/deque_test.go
+++ b/runtimes/google/lib/deque/deque_test.go
@@ -6,7 +6,7 @@
"v.io/core/veyron/lib/testutil"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
func TestBasic(t *testing.T) {
var q T
diff --git a/runtimes/google/lib/deque/v23_internal_test.go b/runtimes/google/lib/deque/v23_internal_test.go
new file mode 100644
index 0000000..d1ae75c
--- /dev/null
+++ b/runtimes/google/lib/deque/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package deque
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/lib/pcqueue/pcqueue_test.go b/runtimes/google/lib/pcqueue/pcqueue_test.go
index cfd60f0..bf88179 100644
--- a/runtimes/google/lib/pcqueue/pcqueue_test.go
+++ b/runtimes/google/lib/pcqueue/pcqueue_test.go
@@ -6,11 +6,10 @@
"testing"
"time"
- "v.io/core/veyron/lib/testutil"
"v.io/core/veyron2/vlog"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
const (
queueSize = 10
diff --git a/runtimes/google/lib/pcqueue/v23_internal_test.go b/runtimes/google/lib/pcqueue/v23_internal_test.go
new file mode 100644
index 0000000..ed4f14e
--- /dev/null
+++ b/runtimes/google/lib/pcqueue/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package pcqueue
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/lib/publisher/publisher_test.go b/runtimes/google/lib/publisher/publisher_test.go
index a70d1e2..3143d26 100644
--- a/runtimes/google/lib/publisher/publisher_test.go
+++ b/runtimes/google/lib/publisher/publisher_test.go
@@ -12,15 +12,12 @@
"v.io/core/veyron2/vtrace"
"v.io/core/veyron/lib/flags"
- "v.io/core/veyron/lib/testutil"
"v.io/core/veyron/runtimes/google/lib/publisher"
tnaming "v.io/core/veyron/runtimes/google/testing/mocks/naming"
ivtrace "v.io/core/veyron/runtimes/google/vtrace"
)
-func init() {
- testutil.Init()
-}
+//go:generate v23 test generate
func testContext() *context.T {
ctx, _ := context.RootContext()
diff --git a/runtimes/google/lib/publisher/v23_internal_test.go b/runtimes/google/lib/publisher/v23_internal_test.go
new file mode 100644
index 0000000..e1a855f
--- /dev/null
+++ b/runtimes/google/lib/publisher/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package publisher
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/lib/sync/semaphore_test.go b/runtimes/google/lib/sync/semaphore_test.go
index 4660ee1..8fc9f87 100644
--- a/runtimes/google/lib/sync/semaphore_test.go
+++ b/runtimes/google/lib/sync/semaphore_test.go
@@ -4,11 +4,9 @@
"sync"
"sync/atomic"
"testing"
-
- "v.io/core/veyron/lib/testutil"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
func TestSemaphore(t *testing.T) {
s1 := NewSemaphore()
diff --git a/runtimes/google/lib/sync/v23_internal_test.go b/runtimes/google/lib/sync/v23_internal_test.go
new file mode 100644
index 0000000..fe6cd24
--- /dev/null
+++ b/runtimes/google/lib/sync/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package sync
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/lib/sync/wait_group_test.go b/runtimes/google/lib/sync/wait_group_test.go
index 44738a9..a41665d 100644
--- a/runtimes/google/lib/sync/wait_group_test.go
+++ b/runtimes/google/lib/sync/wait_group_test.go
@@ -5,7 +5,7 @@
"v.io/core/veyron/lib/testutil"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
// TestRandom tests Wait after a random sequence of TryAdd's and Done's that
// leaves the counter at 0.
diff --git a/runtimes/google/lib/upcqueue/upcqueue_test.go b/runtimes/google/lib/upcqueue/upcqueue_test.go
index 2ac6982..0ffad94 100644
--- a/runtimes/google/lib/upcqueue/upcqueue_test.go
+++ b/runtimes/google/lib/upcqueue/upcqueue_test.go
@@ -6,12 +6,11 @@
"testing"
"time"
- "v.io/core/veyron/lib/testutil"
vsync "v.io/core/veyron/runtimes/google/lib/sync"
"v.io/core/veyron2/vlog"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
const (
elementCount = 100
diff --git a/runtimes/google/lib/upcqueue/v23_internal_test.go b/runtimes/google/lib/upcqueue/v23_internal_test.go
new file mode 100644
index 0000000..2716851
--- /dev/null
+++ b/runtimes/google/lib/upcqueue/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package upcqueue
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 5790aef..39cc398 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -25,9 +25,7 @@
service "v.io/core/veyron/services/mounttable/lib"
)
-func init() {
- testutil.Init()
-}
+//go:generate v23 test generate
func createContexts(t *testing.T) (sc, c *context.T, cleanup func()) {
ctx, shutdown := testutil.InitForTest()
diff --git a/runtimes/google/naming/namespace/v23_internal_test.go b/runtimes/google/naming/namespace/v23_internal_test.go
new file mode 100644
index 0000000..16b2cdf
--- /dev/null
+++ b/runtimes/google/naming/namespace/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package namespace
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/rt/ipc_test.go b/runtimes/google/rt/ipc_test.go
index c985e04..3758881 100644
--- a/runtimes/google/rt/ipc_test.go
+++ b/runtimes/google/rt/ipc_test.go
@@ -18,7 +18,7 @@
"v.io/core/veyron2/verror"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
type testService struct{}
diff --git a/runtimes/google/rt/mgmt_test.go b/runtimes/google/rt/mgmt_test.go
index 41271ef..cb825d9 100644
--- a/runtimes/google/rt/mgmt_test.go
+++ b/runtimes/google/rt/mgmt_test.go
@@ -24,19 +24,14 @@
"v.io/core/veyron/services/mgmt/device"
)
+//go:generate v23 test generate
+
const (
noWaitersCmd = "noWaiters"
forceStopCmd = "forceStop"
appCmd = "app"
)
-func init() {
- testutil.Init()
- modules.RegisterChild(noWaitersCmd, "", noWaiters)
- modules.RegisterChild(forceStopCmd, "", forceStop)
- modules.RegisterChild(appCmd, "", app)
-}
-
// TestBasic verifies that the basic plumbing works: LocalStop calls result in
// stop messages being sent on the channel passed to WaitForStop.
func TestBasic(t *testing.T) {
diff --git a/runtimes/google/rt/rt_test.go b/runtimes/google/rt/rt_test.go
index 567b6c8..6610a7c 100644
--- a/runtimes/google/rt/rt_test.go
+++ b/runtimes/google/rt/rt_test.go
@@ -20,16 +20,7 @@
vsecurity "v.io/core/veyron/security"
)
-func init() {
- testutil.Init()
- modules.RegisterChild("child", "", child)
- modules.RegisterChild("principal", "", principal)
- modules.RegisterChild("runner", "", runner)
-}
-
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
+//go:generate v23 test generate
func TestInit(t *testing.T) {
testutil.UnsetPrincipalEnvVars()
diff --git a/runtimes/google/rt/shutdown_test.go b/runtimes/google/rt/shutdown_test.go
index 8c7c20a..eeec6e0 100644
--- a/runtimes/google/rt/shutdown_test.go
+++ b/runtimes/google/rt/shutdown_test.go
@@ -13,13 +13,13 @@
"v.io/core/veyron/lib/expect"
"v.io/core/veyron/lib/modules"
"v.io/core/veyron/lib/signals"
- "v.io/core/veyron/lib/testutil"
)
+//go:generate v23 test generate
+
var cstderr io.Writer
func init() {
- testutil.Init()
if testing.Verbose() {
cstderr = os.Stderr
}
diff --git a/runtimes/google/rt/v23_test.go b/runtimes/google/rt/v23_test.go
new file mode 100644
index 0000000..0dad003
--- /dev/null
+++ b/runtimes/google/rt/v23_test.go
@@ -0,0 +1,42 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package rt_test
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("noWaiters", ``, noWaiters)
+ modules.RegisterChild("forceStop", ``, forceStop)
+ modules.RegisterChild("app", ``, app)
+ modules.RegisterChild("child", ``, child)
+ modules.RegisterChild("principal", ``, principal)
+ modules.RegisterChild("runner", `Runner runs a principal as a subprocess and reports back with its
+own security info and it's childs.`, runner)
+ modules.RegisterChild("complexServerProgram", `complexServerProgram demonstrates the recommended way to write a more
+complex server application (with several servers, a mix of interruptible
+and blocking cleanup, and parallel and sequential cleanup execution).
+For a more typical server, see simpleServerProgram.`, complexServerProgram)
+ modules.RegisterChild("simpleServerProgram", `simpleServerProgram demonstrates the recommended way to write a typical
+simple server application (with one server and a clean shutdown triggered by
+a signal or a stop command). For an example of something more involved, see
+complexServerProgram.`, simpleServerProgram)
+ modules.RegisterChild("withRuntime", ``, withRuntime)
+ modules.RegisterChild("withoutRuntime", ``, withoutRuntime)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/runtimes/google/testing/concurrency/clock_test.go b/runtimes/google/testing/concurrency/clock_test.go
index 0d6b243..e3e4714 100644
--- a/runtimes/google/testing/concurrency/clock_test.go
+++ b/runtimes/google/testing/concurrency/clock_test.go
@@ -6,7 +6,7 @@
"v.io/core/veyron/lib/testutil"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
// TestClone checks the clone() method of a clock.
func TestClone(t *testing.T) {
diff --git a/runtimes/google/testing/concurrency/v23_internal_test.go b/runtimes/google/testing/concurrency/v23_internal_test.go
new file mode 100644
index 0000000..6b4587c
--- /dev/null
+++ b/runtimes/google/testing/concurrency/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package concurrency
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/security/flag/flag_test.go b/security/flag/flag_test.go
index 2416001..8419343 100644
--- a/security/flag/flag_test.go
+++ b/security/flag/flag_test.go
@@ -13,13 +13,10 @@
"v.io/core/veyron2/services/security/access"
"v.io/core/veyron/lib/modules"
- "v.io/core/veyron/lib/testutil"
tsecurity "v.io/core/veyron/lib/testutil/security"
)
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
+//go:generate v23 test generate
var (
acl1 = access.TaggedACLMap{}
@@ -38,11 +35,6 @@
}
)
-func init() {
- testutil.Init()
- modules.RegisterChild("tamFromFlag", "", tamFromFlag)
-}
-
func auth(a security.Authorizer, err error) security.Authorizer {
if err != nil {
panic(err)
diff --git a/security/flag/v23_internal_test.go b/security/flag/v23_internal_test.go
new file mode 100644
index 0000000..8b3fa7c
--- /dev/null
+++ b/security/flag/v23_internal_test.go
@@ -0,0 +1,26 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package flag
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("tamFromFlag", ``, tamFromFlag)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/security/serialization/serialization_test.go b/security/serialization/serialization_test.go
index bda4c95..b280f0c 100644
--- a/security/serialization/serialization_test.go
+++ b/security/serialization/serialization_test.go
@@ -9,6 +9,7 @@
"io"
"io/ioutil"
mrand "math/rand"
+ "os"
"reflect"
"strings"
"testing"
@@ -19,7 +20,12 @@
"v.io/core/veyron2/security"
)
-func init() { testutil.Init() }
+// We call our own TestMain here because v23 test generate causes an import cycle
+// in this package.
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
type bufferCloser struct {
bytes.Buffer
diff --git a/services/mgmt/application/impl/acl_test.go b/services/mgmt/application/impl/acl_test.go
index c8e5b96..c86b6ff 100644
--- a/services/mgmt/application/impl/acl_test.go
+++ b/services/mgmt/application/impl/acl_test.go
@@ -17,7 +17,6 @@
"v.io/core/veyron2/verror"
"v.io/core/veyron2/vlog"
- "v.io/core/veyron/lib/modules"
"v.io/core/veyron/lib/signals"
"v.io/core/veyron/lib/testutil"
tsecurity "v.io/core/veyron/lib/testutil/security"
@@ -26,21 +25,12 @@
"v.io/core/veyron/services/mgmt/repository"
)
+//go:generate v23 test generate
+
const (
- repoCmd = "repository"
+ repoCmd = "appRepository"
)
-func init() {
- modules.RegisterChild(repoCmd, "", appRepository)
- testutil.Init()
-}
-
-// TestHelperProcess is the entrypoint for the modules commands in a
-// a test subprocess.
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
-
func appRepository(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
if len(args) < 2 {
vlog.Fatalf("repository expected at least name and store arguments and optionally ACL flags per TaggedACLMapFromFlag")
diff --git a/services/mgmt/application/impl/v23_test.go b/services/mgmt/application/impl/v23_test.go
new file mode 100644
index 0000000..b3506a9
--- /dev/null
+++ b/services/mgmt/application/impl/v23_test.go
@@ -0,0 +1,26 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package impl_test
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("appRepository", ``, appRepository)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/services/mgmt/binary/impl/acl_test.go b/services/mgmt/binary/impl/acl_test.go
index 0d8ea78..7f0be51 100644
--- a/services/mgmt/binary/impl/acl_test.go
+++ b/services/mgmt/binary/impl/acl_test.go
@@ -16,7 +16,6 @@
"v.io/core/veyron2/verror"
"v.io/core/veyron2/vlog"
- "v.io/core/veyron/lib/modules"
"v.io/core/veyron/lib/signals"
"v.io/core/veyron/lib/testutil"
tsecurity "v.io/core/veyron/lib/testutil/security"
@@ -24,21 +23,12 @@
mgmttest "v.io/core/veyron/services/mgmt/lib/testutil"
)
+//go:generate v23 test generate
+
const (
binaryCmd = "binaryd"
)
-func init() {
- modules.RegisterChild(binaryCmd, "", binaryd)
- testutil.Init()
-}
-
-// TestHelperProcess is the entrypoint for the modules commands in
-// a test subprocess.
-func TestHelperProcess(t *testing.T) {
- modules.DispatchInTest()
-}
-
func binaryd(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
if len(args) < 2 {
vlog.Fatalf("binaryd expected at least name and store arguments and optionally ACL flags per TaggedACLMapFromFlag")
diff --git a/services/mgmt/binary/impl/v23_test.go b/services/mgmt/binary/impl/v23_test.go
new file mode 100644
index 0000000..b59cd64
--- /dev/null
+++ b/services/mgmt/binary/impl/v23_test.go
@@ -0,0 +1,26 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package impl_test
+
+import "fmt"
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/modules"
+import "v.io/core/veyron/lib/testutil"
+
+func init() {
+ modules.RegisterChild("binaryd", ``, binaryd)
+}
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ if modules.IsModulesProcess() {
+ if err := modules.Dispatch(); err != nil {
+ fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
+ os.Exit(1)
+ }
+ return
+ }
+ os.Exit(m.Run())
+}
diff --git a/services/mgmt/build/impl/impl_test.go b/services/mgmt/build/impl/impl_test.go
index 6cdb33e..29edf2a 100644
--- a/services/mgmt/build/impl/impl_test.go
+++ b/services/mgmt/build/impl/impl_test.go
@@ -16,9 +16,7 @@
_ "v.io/core/veyron/profiles"
)
-func init() {
- testutil.Init()
-}
+//go:generate v23 test generate
// findGoBinary returns the path to the given Go binary and
// the GOROOT environment variable to use.
diff --git a/services/mgmt/build/impl/v23_internal_test.go b/services/mgmt/build/impl/v23_internal_test.go
new file mode 100644
index 0000000..b4e1708
--- /dev/null
+++ b/services/mgmt/build/impl/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package impl
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/services/mgmt/lib/binary/impl_test.go b/services/mgmt/lib/binary/impl_test.go
index 3857994..8dbd554 100644
--- a/services/mgmt/lib/binary/impl_test.go
+++ b/services/mgmt/lib/binary/impl_test.go
@@ -20,14 +20,12 @@
"v.io/core/veyron/services/mgmt/binary/impl"
)
+//go:generate v23 test generate
+
const (
veyronPrefix = "veyron_binary_repository"
)
-func init() {
- testutil.Init()
-}
-
func setupRepository(t *testing.T, ctx *context.T) (string, func()) {
// Setup the root of the binary repository.
rootDir, err := ioutil.TempDir("", veyronPrefix)
diff --git a/services/mgmt/lib/binary/v23_internal_test.go b/services/mgmt/lib/binary/v23_internal_test.go
new file mode 100644
index 0000000..9d97c2c
--- /dev/null
+++ b/services/mgmt/lib/binary/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package binary
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}
diff --git a/services/mounttable/lib/neighborhood_test.go b/services/mounttable/lib/neighborhood_test.go
index 5bfa810..05f6b0a 100644
--- a/services/mounttable/lib/neighborhood_test.go
+++ b/services/mounttable/lib/neighborhood_test.go
@@ -16,7 +16,7 @@
_ "v.io/core/veyron/profiles"
)
-func init() { testutil.Init() }
+//go:generate v23 test generate
func protocolAndAddress(e naming.Endpoint) (string, string, error) {
addr := e.Addr()
diff --git a/services/mounttable/lib/v23_internal_test.go b/services/mounttable/lib/v23_internal_test.go
new file mode 100644
index 0000000..cb1edda
--- /dev/null
+++ b/services/mounttable/lib/v23_internal_test.go
@@ -0,0 +1,13 @@
+// This file was auto-generated via go generate.
+// DO NOT UPDATE MANUALLY
+package mounttable
+
+import "testing"
+import "os"
+
+import "v.io/core/veyron/lib/testutil"
+
+func TestMain(m *testing.M) {
+ testutil.Init()
+ os.Exit(m.Run())
+}