summaryrefslogtreecommitdiff
path: root/misc/cgo/testtls
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2014-06-19 09:22:53 +0200
committerMichael Stapelberg <stapelberg@debian.org>2014-06-19 09:22:53 +0200
commit8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch)
tree4449f2036cccf162e8417cc5841a35815b3e7ac5 /misc/cgo/testtls
parentc8bf49ef8a92e2337b69c14b9b88396efe498600 (diff)
downloadgolang-8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1.tar.gz
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'misc/cgo/testtls')
-rw-r--r--misc/cgo/testtls/tls.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/misc/cgo/testtls/tls.go b/misc/cgo/testtls/tls.go
index a9546a61c..8e9ee7003 100644
--- a/misc/cgo/testtls/tls.go
+++ b/misc/cgo/testtls/tls.go
@@ -15,14 +15,16 @@ import (
)
func testTLS(t *testing.T) {
- var keyVal C.int = 1234
-
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- C.setTLS(C.int(keyVal))
- storedVal := C.getTLS()
- if storedVal != keyVal {
- t.Fatalf("stored %d want %d", storedVal, keyVal)
+ if val := C.getTLS(); val != 0 {
+ t.Fatalf("at start, C.getTLS() = %#x, want 0", val)
+ }
+
+ const keyVal = 0x1234
+ C.setTLS(keyVal)
+ if val := C.getTLS(); val != keyVal {
+ t.Fatalf("at end, C.getTLS() = %#x, want %#x", val, keyVal)
}
}