From e3c2bd51a1a970991cce71d6994bb053c546e538 Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Fri, 17 Jul 2020 16:13:44 -0700 Subject: Move main methods for benchmark packages main package file. PiperOrigin-RevId: 321875119 --- test/benchmarks/fs/BUILD | 7 +++---- test/benchmarks/fs/bazel_test.go | 9 --------- test/benchmarks/fs/fs.go | 15 +++++++++++++++ test/benchmarks/network/BUILD | 1 + test/benchmarks/network/iperf_test.go | 9 --------- test/benchmarks/network/network.go | 15 +++++++++++++++ 6 files changed, 34 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/benchmarks/fs/BUILD b/test/benchmarks/fs/BUILD index 606331895..2874cdbb3 100644 --- a/test/benchmarks/fs/BUILD +++ b/test/benchmarks/fs/BUILD @@ -4,7 +4,9 @@ package(licenses = ["notice"]) go_library( name = "fs", + testonly = 1, srcs = ["fs.go"], + deps = ["//test/benchmarks/harness"], ) go_test( @@ -17,8 +19,5 @@ go_test( "local", "manual", ], - deps = [ - "//pkg/test/dockerutil", - "//test/benchmarks/harness", - ], + deps = ["//pkg/test/dockerutil"], ) diff --git a/test/benchmarks/fs/bazel_test.go b/test/benchmarks/fs/bazel_test.go index b7915e19d..fdcac1a7a 100644 --- a/test/benchmarks/fs/bazel_test.go +++ b/test/benchmarks/fs/bazel_test.go @@ -15,16 +15,12 @@ package fs import ( "context" - "os" "strings" "testing" "gvisor.dev/gvisor/pkg/test/dockerutil" - "gvisor.dev/gvisor/test/benchmarks/harness" ) -var h harness.Harness - // Note: CleanCache versions of this test require running with root permissions. func BenchmarkABSL(b *testing.B) { // Get a machine from the Harness on which to run. @@ -97,8 +93,3 @@ func BenchmarkABSL(b *testing.B) { }) } } - -func TestMain(m *testing.M) { - h.Init() - os.Exit(m.Run()) -} diff --git a/test/benchmarks/fs/fs.go b/test/benchmarks/fs/fs.go index 27eb6c56a..e5ca28c3b 100644 --- a/test/benchmarks/fs/fs.go +++ b/test/benchmarks/fs/fs.go @@ -14,3 +14,18 @@ // Package fs holds benchmarks around filesystem performance. package fs + +import ( + "os" + "testing" + + "gvisor.dev/gvisor/test/benchmarks/harness" +) + +var h harness.Harness + +// TestMain is the main method for package fs. +func TestMain(m *testing.M) { + h.Init() + os.Exit(m.Run()) +} diff --git a/test/benchmarks/network/BUILD b/test/benchmarks/network/BUILD index ea78416cf..16d267bc8 100644 --- a/test/benchmarks/network/BUILD +++ b/test/benchmarks/network/BUILD @@ -6,6 +6,7 @@ go_library( name = "network", testonly = 1, srcs = ["network.go"], + deps = ["//test/benchmarks/harness"], ) go_test( diff --git a/test/benchmarks/network/iperf_test.go b/test/benchmarks/network/iperf_test.go index 48cc9dd8f..664e0797e 100644 --- a/test/benchmarks/network/iperf_test.go +++ b/test/benchmarks/network/iperf_test.go @@ -16,7 +16,6 @@ package network import ( "context" "fmt" - "os" "regexp" "strconv" "strings" @@ -26,8 +25,6 @@ import ( "gvisor.dev/gvisor/test/benchmarks/harness" ) -var h harness.Harness - func BenchmarkIperf(b *testing.B) { // Get two machines @@ -144,10 +141,4 @@ TCP window size: 45.0 KByte (default) if err != nil || bandwidth != 45900 { t.Fatalf("failed with: %v and %f", err, bandwidth) } - -} - -func TestMain(m *testing.M) { - h.Init() - os.Exit(m.Run()) } diff --git a/test/benchmarks/network/network.go b/test/benchmarks/network/network.go index f480b5bcd..ce17ddb94 100644 --- a/test/benchmarks/network/network.go +++ b/test/benchmarks/network/network.go @@ -14,3 +14,18 @@ // Package network holds benchmarks around raw network performance. package network + +import ( + "os" + "testing" + + "gvisor.dev/gvisor/test/benchmarks/harness" +) + +var h harness.Harness + +// TestMain is the main method for package network. +func TestMain(m *testing.M) { + h.Init() + os.Exit(m.Run()) +} -- cgit v1.2.3