github.com/lrita/numa@v1.0.2/vdso_linux_amd64_test.go (about) 1 package numa 2 3 import "testing" 4 5 func TestELFHash(t *testing.T) { 6 var tt = []struct { 7 s string 8 h uint32 9 g uint32 10 }{ 11 {s: "__vdso_gettimeofday", h: 0x315ca59, g: 0xb01bca00}, 12 {s: "__vdso_clock_gettime", h: 0xd35ec75, g: 0x6e43a318}, 13 {s: "__vdso_getcpu", h: 0xb01045, g: 0x6562b026}, 14 } 15 for _, v := range tt { 16 h := elfHash(v.s) 17 if h != v.h { 18 t.Errorf("%s got 0x%x", v.s, h) 19 } 20 g := elfGNUHash(v.s) 21 if g != v.g { 22 t.Errorf("%s got 0x%x", v.s, g) 23 } 24 } 25 } 26 27 func TestVdsoSym(t *testing.T) { 28 var tt = []struct { 29 s string 30 v bool 31 }{ 32 {"__vdso_gettimeofday", true}, 33 {"__vdso_clock_gettime", true}, 34 {"__vdso_time", true}, 35 {"__vdso_getcpu", true}, 36 {"__abc", false}, 37 } 38 39 for _, v := range tt { 40 p := vdsoSym(v.s) 41 if x := p != 0; x != v.v { 42 t.Errorf("vdsoSym %v got 0x%x", v.s, p) 43 } 44 } 45 }