-
Notifications
You must be signed in to change notification settings - Fork 10
/
syscalls_test.go
81 lines (77 loc) · 2.03 KB
/
syscalls_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package manager
import (
"bytes"
"fmt"
"testing"
)
func TestGetSyscallFnNameWithKallsyms(t *testing.T) {
entries := []struct {
fnName string
kallsymsContent string
expected string
}{
{
fnName: "open",
kallsymsContent: `
0000000000000000 T do_fchownat
0000000000000000 T __arm64_sys_fchownat
0000000000000000 T __arm64_sys_chown
0000000000000000 T __arm64_sys_lchown
0000000000000000 T vfs_fchown
0000000000000000 T ksys_fchown
0000000000000000 T __arm64_sys_fchown
0000000000000000 T vfs_open
0000000000000000 T build_open_how
0000000000000000 T build_open_flags
0000000000000000 t do_sys_openat2
0000000000000000 t __do_sys_openat2
0000000000000000 T __arm64_sys_openat2
0000000000000000 T __arm64_sys_creat
0000000000000000 T __arm64_compat_sys_open
0000000000000000 T __arm64_compat_sys_openat
0000000000000000 T __arm64_sys_open
0000000000000000 T __arm64_sys_openat
0000000000000000 T file_open_name
0000000000000000 T do_sys_open
0000000000000000 T vfs_setpos
0000000000000000 T generic_file_llseek_size
0000000000000000 T generic_file_llseek
0000000000000000 T fixed_size_llseek
0000000000000000 T no_seek_end_llseek
0000000000000000 T no_seek_end_llseek_size
0000000000000000 T noop_llseek
0000000000000000 T vfs_llseek
0000000000000000 T default_llseek
0000000000000000 t arch_local_irq_save
`,
expected: "__arm64_sys_open",
},
{
fnName: "connect",
kallsymsContent: `
0000000000000000 T __sys_connect
0000000000000000 T __arm64_sys_connect
`,
expected: "__arm64_sys_connect",
},
{
fnName: "open",
kallsymsContent: `
0000000000000000 T __SyS_open
0000000000000000 T __sys_open
`,
expected: "__SyS_open",
},
}
for i, testEntry := range entries {
t.Run(fmt.Sprintf("%s_%d", testEntry.fnName, i), func(t *testing.T) {
res, err := getSyscallFnNameWithKallsyms(testEntry.fnName, bytes.NewBuffer([]byte(testEntry.kallsymsContent)), "arm64")
if err != nil {
t.Fatal(err)
}
if res != testEntry.expected {
t.Errorf("expected %s, got %s", testEntry.expected, res)
}
})
}
}