Home | History | Annotate | Download | only in runtime
      1 // Copyright 2012 The Go Authors.  All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package runtime_test
      6 
      7 import (
      8 	. "runtime"
      9 	"syscall"
     10 	"testing"
     11 )
     12 
     13 var pid, tid int
     14 
     15 func init() {
     16 	// Record pid and tid of init thread for use during test.
     17 	// The call to LockOSThread is just to exercise it;
     18 	// we can't test that it does anything.
     19 	// Instead we're testing that the conditions are good
     20 	// for how it is used in init (must be on main thread).
     21 	pid, tid = syscall.Getpid(), syscall.Gettid()
     22 	LockOSThread()
     23 }
     24 
     25 func TestLockOSThread(t *testing.T) {
     26 	if pid != tid {
     27 		t.Fatalf("pid=%d but tid=%d", pid, tid)
     28 	}
     29 }
     30