-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsiginfo_test.go
38 lines (32 loc) · 1.21 KB
/
siginfo_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//SPDX-License-Identifier: Beerware
package siginfo
import (
"testing"
"unsafe"
. "github.com/xdu-icpc/siginfo/testaux"
)
func assertEqual(t *testing.T, expect uintptr, get uintptr) {
t.Helper()
if expect != get {
t.Errorf("result mismatch: expect %v, get %v", expect, get)
}
}
func TestSize(t *testing.T) {
assertEqual(t, unsafe.Sizeof(SiginfoKill{}), 128)
assertEqual(t, unsafe.Sizeof(SiginfoTimer{}), 128)
assertEqual(t, unsafe.Sizeof(SiginfoQueue{}), 128)
assertEqual(t, unsafe.Sizeof(SiginfoSync{}), 128)
assertEqual(t, unsafe.Sizeof(SiginfoPoll{}), 128)
assertEqual(t, unsafe.Sizeof(SiginfoSys{}), 128)
}
func TestABI(t *testing.T) {
assertEqual(t, unsafe.Offsetof(SiginfoKill{}.Pid), OffsetPid)
assertEqual(t, unsafe.Offsetof(SiginfoKill{}.Uid), OffsetUid)
assertEqual(t, unsafe.Offsetof(SiginfoChild{}.Status), OffsetStatus)
assertEqual(t, unsafe.Offsetof(SiginfoTimer{}.Timer), OffsetTimer)
assertEqual(t, unsafe.Offsetof(SiginfoTimer{}.Value), OffsetValue)
assertEqual(t, unsafe.Offsetof(SiginfoTimer{}.Overrun), OffsetOverrun)
assertEqual(t, unsafe.Offsetof(SiginfoChild{}.Utime), OffsetUtime)
assertEqual(t, unsafe.Offsetof(SiginfoChild{}.Stime), OffsetStime)
t.Logf("SI_TIMER = %d", SI_TIMER)
}