summaryrefslogtreecommitdiff
path: root/cmd/ioworkload/scenario_pidfd_test.go
blob: 5ee100273ee1de9fea1d837f38c3494306727eeb (plain)
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
package main

import "testing"

func TestPidfdOpenSyscallNrForArch(t *testing.T) {
	for _, tc := range []struct {
		name    string
		arch    string
		want    uintptr
		wantErr bool
	}{
		{name: "amd64", arch: "amd64", want: 434},
		{name: "arm64", arch: "arm64", want: 434},
		{name: "unsupported", arch: "riscv64", wantErr: true},
	} {
		got, err := pidfdOpenSyscallNrForArch(tc.arch)
		if tc.wantErr {
			if err == nil {
				t.Fatalf("%s: expected error", tc.name)
			}
			continue
		}
		if err != nil {
			t.Fatalf("%s: unexpected error: %v", tc.name, err)
		}
		if got != tc.want {
			t.Fatalf("%s: got %d, want %d", tc.name, got, tc.want)
		}
	}
}

func TestPidfdGetfdSyscallNrForArch(t *testing.T) {
	for _, tc := range []struct {
		name    string
		arch    string
		want    uintptr
		wantErr bool
	}{
		{name: "amd64", arch: "amd64", want: 438},
		{name: "arm64", arch: "arm64", want: 438},
		{name: "unsupported", arch: "riscv64", wantErr: true},
	} {
		got, err := pidfdGetfdSyscallNrForArch(tc.arch)
		if tc.wantErr {
			if err == nil {
				t.Fatalf("%s: expected error", tc.name)
			}
			continue
		}
		if err != nil {
			t.Fatalf("%s: unexpected error: %v", tc.name, err)
		}
		if got != tc.want {
			t.Fatalf("%s: got %d, want %d", tc.name, got, tc.want)
		}
	}
}