veyron/runtimes/google/ipc/benchmark: fix a broken benchmark

Fix a broken benchmark by a recent change in initializing
principal via the environment variables.

Change-Id: I72d7768a1fa0ce28a9653df1d0a7d916e7afc5d6
diff --git a/runtimes/google/ipc/benchmark/benchmark_test.go b/runtimes/google/ipc/benchmark/benchmark_test.go
index 941a22d..b51ae42 100644
--- a/runtimes/google/ipc/benchmark/benchmark_test.go
+++ b/runtimes/google/ipc/benchmark/benchmark_test.go
@@ -9,17 +9,17 @@
 	"v.io/core/veyron/profiles"
 
 	"v.io/core/veyron2"
-	"v.io/core/veyron2/rt"
+	"v.io/core/veyron2/context"
 )
 
 var (
-	vrt        veyron2.Runtime
 	serverAddr string
+	ctx        *context.T
 )
 
 // Benchmarks for non-streaming RPC.
 func runEcho(b *testing.B, payloadSize int) {
-	CallEcho(b, vrt.NewContext(), serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
+	CallEcho(b, ctx, serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
 }
 
 func Benchmark____1B(b *testing.B) { runEcho(b, 1) }
@@ -31,7 +31,7 @@
 
 // Benchmarks for streaming RPC.
 func runEchoStream(b *testing.B, chunkCnt, payloadSize int) {
-	CallEchoStream(b, vrt.NewContext(), serverAddr, b.N, chunkCnt, payloadSize, benchmark.AddStats(b, 16))
+	CallEchoStream(b, ctx, serverAddr, b.N, chunkCnt, payloadSize, benchmark.AddStats(b, 16))
 }
 
 func Benchmark____1_chunk_____1B(b *testing.B) { runEchoStream(b, 1, 1) }
@@ -61,7 +61,7 @@
 
 // Benchmarks for per-chunk throughput in streaming RPC.
 func runPerChunk(b *testing.B, payloadSize int) {
-	CallEchoStream(b, vrt.NewContext(), serverAddr, 1, b.N, payloadSize, benchmark.NewStats(1))
+	CallEchoStream(b, ctx, serverAddr, 1, b.N, payloadSize, benchmark.NewStats(1))
 }
 
 func Benchmark__per_chunk____1B(b *testing.B) { runPerChunk(b, 1) }
@@ -73,8 +73,8 @@
 
 // Benchmarks for non-streaming RPC while running streaming RPC in background.
 func runMux(b *testing.B, payloadSize, chunkCntB, payloadSizeB int) {
-	_, stop := StartEchoStream(&testing.B{}, vrt.NewContext(), serverAddr, 0, chunkCntB, payloadSizeB, benchmark.NewStats(1))
-	CallEcho(b, vrt.NewContext(), serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
+	_, stop := StartEchoStream(&testing.B{}, ctx, serverAddr, 0, chunkCntB, payloadSizeB, benchmark.NewStats(1))
+	CallEcho(b, ctx, serverAddr, b.N, payloadSize, benchmark.AddStats(b, 16))
 	stop()
 }
 
@@ -101,15 +101,16 @@
 func TestNoOp(t *testing.T) {}
 
 func TestMain(m *testing.M) {
+	// We do not use defer here since this program will exit at the end of
+	// this function through os.Exit().
+	var shutdown veyron2.Shutdown
+	ctx, shutdown = veyron2.Init()
+
 	var err error
-	vrt, err = rt.New()
+	ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing"))
 	if err != nil {
 		panic(err)
 	}
-	ctx := vrt.NewContext()
-	if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
-		panic(err)
-	}
 
 	var serverStop func()
 	serverAddr, serverStop = StartServer(ctx, profiles.LocalListenSpec)
@@ -120,7 +121,7 @@
 	r := benchmark.RunTestMain(m)
 
 	serverStop()
-	vrt.Cleanup()
+	shutdown()
 
 	os.Exit(r)
 }