aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2022-10-20 18:25:46 +0200
committerGitHub <noreply@github.com>2022-10-20 18:25:46 +0200
commita0fd4dab4eac71d7b3237bb1000352206a6a82f5 (patch)
tree5118188dc0be56188a812db8cc05c3abaee8b1c1 /pkg
parentb31320fc8f3519e40494f64ebf77c13d16284bfd (diff)
pkg/host: increase token size to enable 128+core CPUs (#3453)
Default maxTokenSize is 64k. On 128 cores, I experienced 120k long token (len(flags * 128)). + check for scanner errors
Diffstat (limited to 'pkg')
-rw-r--r--pkg/host/machine_info_linux_test.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/host/machine_info_linux_test.go b/pkg/host/machine_info_linux_test.go
index 755b792f7..4782a1aac 100644
--- a/pkg/host/machine_info_linux_test.go
+++ b/pkg/host/machine_info_linux_test.go
@@ -7,6 +7,7 @@ import (
"bufio"
"bytes"
"fmt"
+ "io"
"path/filepath"
"runtime"
"strings"
@@ -15,6 +16,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/sys/targets"
+ "github.com/stretchr/testify/assert"
)
func TestCollectMachineInfo(t *testing.T) {
@@ -46,7 +48,8 @@ func TestCannedCPUInfoLinux(t *testing.T) {
func checkCPUInfo(t *testing.T, data []byte, arch string) {
t.Logf("input data:\n%s", data)
keys := make(map[string]bool)
- for s := bufio.NewScanner(bytes.NewReader(data)); s.Scan(); {
+ s := longScanner(bytes.NewReader(data))
+ for s.Scan() {
splitted := strings.Split(s.Text(), ":")
if len(splitted) != 2 {
t.Fatalf("the format of line %q is not correct", s.Text())
@@ -54,6 +57,8 @@ func checkCPUInfo(t *testing.T, data []byte, arch string) {
key := strings.TrimSpace(splitted[0])
keys[key] = true
}
+ assert.Nil(t, s.Err(), "scanner failed reading the CpuInfo: %v", s.Err())
+
importantKeys := map[string][]string{
targets.PPC64LE: {"cpu", "revision", "platform", "model", "machine"},
targets.AMD64: {"vendor_id", "model", "flags"},
@@ -413,3 +418,10 @@ func TestGetGlobsInfo(t *testing.T) {
t.Fatal(diff)
}
}
+
+func longScanner(r io.Reader) *bufio.Scanner {
+ const newMaxTokenSize = 1 * 1024 * 1024
+ s := bufio.NewScanner(r)
+ s.Buffer(nil, newMaxTokenSize)
+ return s
+}