diff options
author | David Crawshaw <crawshaw@tailscale.com> | 2020-04-07 14:52:17 +1000 |
---|---|---|
committer | David Crawshaw <crawshaw@tailscale.com> | 2020-04-07 15:55:53 +1000 |
commit | a4657f996d98378c06cc7da4d2c69539c19dae32 (patch) | |
tree | e07249243098c8435543660b5cae76927d2b55c6 /device/peer_test.go | |
parent | f6020a2085d9a6b911c00875752bb40bfe629e00 (diff) | |
download | wireguard-go-a4657f996d98378c06cc7da4d2c69539c19dae32.tar.gz wireguard-go-a4657f996d98378c06cc7da4d2c69539c19dae32.zip |
device: move stats fields back down and add test diagnostics
This reverts the movement of fields from d49f4e9.
That commit was cherry-picked from another branch where a field
had changed and misaligned the atomic fields. After cherry-picking,
moving the fields was no longer necessary but got dragged along.
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
Diffstat (limited to 'device/peer_test.go')
-rw-r--r-- | device/peer_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/device/peer_test.go b/device/peer_test.go index de87ab6..b389f1e 100644 --- a/device/peer_test.go +++ b/device/peer_test.go @@ -6,6 +6,7 @@ package device import ( + "reflect" "testing" "unsafe" ) @@ -24,6 +25,19 @@ func checkAlignment(t *testing.T, name string, offset uintptr) { // hard segfault at runtime. func TestPeerAlignment(t *testing.T) { var p Peer + + typ := reflect.TypeOf(p) + t.Logf("Peer type size: %d, with fields:", typ.Size()) + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + t.Logf("\t%30s\toffset=%3v\t(type size=%3d, align=%d)", + field.Name, + field.Offset, + field.Type.Size(), + field.Type.Align(), + ) + } + checkAlignment(t, "Peer.stats", unsafe.Offsetof(p.stats)) checkAlignment(t, "Peer.isRunning", unsafe.Offsetof(p.isRunning)) } |