Skip to content

Commit f850a69

Browse files
committed
get tests passing on s390x
1 parent 0494d7f commit f850a69

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ build_test: ## test only buildable
1818
GOOS=linux GOARCH=arm go test ./... | $(BUILD_FAIL_PATTERN)
1919
GOOS=linux GOARCH=arm64 go test ./... | $(BUILD_FAIL_PATTERN)
2020
GOOS=linux GOARCH=riscv64 go test ./... | $(BUILD_FAIL_PATTERN)
21+
GOOS=linux GOARCH=s390x go test ./... | $(BUILD_FAIL_PATTERN)
2122
GOOS=freebsd GOARCH=amd64 go test ./... | $(BUILD_FAIL_PATTERN)
2223
GOOS=freebsd GOARCH=386 go test ./... | $(BUILD_FAIL_PATTERN)
2324
GOOS=freebsd GOARCH=arm go test ./... | $(BUILD_FAIL_PATTERN)

cpu/cpu_linux.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
190190
switch key {
191191
case "Processor":
192192
processorName = value
193-
case "processor":
193+
case "processor", "cpu number":
194194
if c.CPU >= 0 {
195195
finishCPUInfo(&c)
196196
ret = append(ret, c)
@@ -203,6 +203,9 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
203203
c.CPU = int32(t)
204204
case "vendorId", "vendor_id":
205205
c.VendorID = value
206+
if strings.Contains(value, "S390") {
207+
processorName = "S390"
208+
}
206209
case "CPU implementer":
207210
if v, err := strconv.ParseUint(value, 0, 8); err == nil {
208211
switch v {
@@ -273,7 +276,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
273276
return ret, err
274277
}
275278
c.Stepping = int32(t)
276-
case "cpu MHz", "clock":
279+
case "cpu MHz", "clock", "cpu MHz dynamic":
277280
// treat this as the fallback value, thus we ignore error
278281
if t, err := strconv.ParseFloat(strings.Replace(value, "MHz", "", 1), 64); err == nil {
279282
c.Mhz = t

cpu/cpu_linux_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ func TestCPUCountsAgainstLscpu(t *testing.T) {
4848
}
4949
t.Errorf("error executing lscpu: %v", err)
5050
}
51-
var threadsPerCore, coresPerSocket, sockets int
51+
var threadsPerCore, coresPerSocket, sockets, books, drawers int
52+
books = 1
53+
drawers = 1
5254
lines := strings.Split(string(out), "\n")
5355
for _, line := range lines {
5456
fields := strings.Split(line, ":")
@@ -60,14 +62,18 @@ func TestCPUCountsAgainstLscpu(t *testing.T) {
6062
threadsPerCore, _ = strconv.Atoi(strings.TrimSpace(fields[1]))
6163
case "Core(s) per socket":
6264
coresPerSocket, _ = strconv.Atoi(strings.TrimSpace(fields[1]))
63-
case "Socket(s)":
65+
case "Socket(s)", "Socket(s) per book":
6466
sockets, _ = strconv.Atoi(strings.TrimSpace(fields[1]))
67+
case "Book(s) per drawer":
68+
books, _ = strconv.Atoi(strings.TrimSpace(fields[1]))
69+
case "Drawer(s)":
70+
drawers, _ = strconv.Atoi(strings.TrimSpace(fields[1]))
6571
}
6672
}
6773
if threadsPerCore == 0 || coresPerSocket == 0 || sockets == 0 {
6874
t.Errorf("missing info from lscpu: threadsPerCore=%d coresPerSocket=%d sockets=%d", threadsPerCore, coresPerSocket, sockets)
6975
}
70-
expectedPhysical := coresPerSocket * sockets
76+
expectedPhysical := coresPerSocket * sockets * books * drawers
7177
expectedLogical := expectedPhysical * threadsPerCore
7278
physical, err := Counts(false)
7379
skipIfNotImplementedErr(t, err)

0 commit comments

Comments
 (0)