summaryrefslogtreecommitdiffhomepage
path: root/pkg/state/tests
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2021-01-05 18:13:18 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-05 18:15:27 -0800
commitab32fa2481d84e3f390f2cd81e25c537756b7aa1 (patch)
treef193f68f63571edfe85104a8b2c583e33b2804a9 /pkg/state/tests
parentb9b99d3d26b0d4907e8d24b4a842b31a91151aab (diff)
Make type sanity checking happen only in race builds.
This adds significant costs to startup, since it is done for every type in the system. Since the state package already saves sanity checks for race builds, use this for type registration. PiperOrigin-RevId: 350259336
Diffstat (limited to 'pkg/state/tests')
-rw-r--r--pkg/state/tests/register_test.go11
-rw-r--r--pkg/state/tests/struct_test.go11
2 files changed, 11 insertions, 11 deletions
diff --git a/pkg/state/tests/register_test.go b/pkg/state/tests/register_test.go
index c829753cc..75bdbfc6e 100644
--- a/pkg/state/tests/register_test.go
+++ b/pkg/state/tests/register_test.go
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// +build race
+
package tests
import (
@@ -165,3 +167,12 @@ func TestRegisterBad(t *testing.T) {
}
}
+
+func TestRegisterTypeOnlyStruct(t *testing.T) {
+ defer func() {
+ if r := recover(); r == nil {
+ t.Errorf("Register did not panic")
+ }
+ }()
+ state.Register((*typeOnlyEmptyStruct)(nil))
+}
diff --git a/pkg/state/tests/struct_test.go b/pkg/state/tests/struct_test.go
index c91c2c032..9826f1ee9 100644
--- a/pkg/state/tests/struct_test.go
+++ b/pkg/state/tests/struct_test.go
@@ -17,8 +17,6 @@ package tests
import (
"math/rand"
"testing"
-
- "gvisor.dev/gvisor/pkg/state"
)
func TestEmptyStruct(t *testing.T) {
@@ -58,15 +56,6 @@ func TestEmptyStruct(t *testing.T) {
})
}
-func TestRegisterTypeOnlyStruct(t *testing.T) {
- defer func() {
- if r := recover(); r == nil {
- t.Errorf("Register did not panic")
- }
- }()
- state.Register((*typeOnlyEmptyStruct)(nil))
-}
-
func TestEmbeddedPointers(t *testing.T) {
// Give each int64 a random value to prevent Go from using
// runtime.staticuint64s, which confounds tests for struct duplication.