From a0fd4dab4eac71d7b3237bb1000352206a6a82f5 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Thu, 20 Oct 2022 18:25:46 +0200 Subject: 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 --- pkg/host/machine_info_linux_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'pkg/host/machine_info_linux_test.go') 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 +} -- cgit mrf-deployment