-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstat_linux_test.go
More file actions
61 lines (49 loc) · 1.12 KB
/
stat_linux_test.go
File metadata and controls
61 lines (49 loc) · 1.12 KB
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
//go:build linux
package clistat
import (
_ "embed"
"testing"
"github.com/stretchr/testify/require"
)
func TestLinuxNumCPU(t *testing.T) {
t.Parallel()
tests := []struct {
name string
cpuInfo string
expectedCount int
}{
{
name: "Raspberry Pi 5 (4 CPU)",
cpuInfo: procCPUInfoRaspberryPi5,
expectedCount: 4,
},
{
name: "EU Coder Workspace (96 CPU)",
cpuInfo: procCPUInfoCoderWorkspaceEU,
expectedCount: 96,
},
{
name: "UpCloud Cloud Server (1 CPU)",
cpuInfo: procCPUInfoUpCloud,
expectedCount: 1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
fs := initFS(t, map[string]string{
"/proc/cpuinfo": tt.cpuInfo,
})
s, err := New(WithFS(fs))
require.NoError(t, err)
cpuCount := s.numCPU()
require.Equal(t, tt.expectedCount, cpuCount)
})
}
}
//go:embed testdata/cpuinfo/raspberrypi5
var procCPUInfoRaspberryPi5 string
//go:embed testdata/cpuinfo/coderworkspaceeu
var procCPUInfoCoderWorkspaceEU string
//go:embed testdata/cpuinfo/upcloud
var procCPUInfoUpCloud string