package main import ( "os" "path/filepath" "testing" ) func TestCPUModel(t *testing.T) { path := filepath.Join(t.TempDir(), "cpuinfo") content := `processor : 0 model name : Test CPU 1234 @ 2.40GHz physical id : 0 core id : 0 processor : 1 model name : Test CPU 1234 @ 2.40GHz physical id : 0 core id : 0 ` if err := os.WriteFile(path, []byte(content), 0o600); err != nil { t.Fatal(err) } model, err := cpuModel(path) if err != nil { t.Fatal(err) } if model != "Test CPU 1234 @ 2.40GHz" { t.Fatalf("получена неожиданная модель CPU: %q", model) } } func TestCPUStatic(t *testing.T) { path := filepath.Join(t.TempDir(), "cpuinfo") content := `processor : 0 model name : Test CPU physical id : 0 core id : 0 processor : 1 model name : Test CPU physical id : 0 core id : 1 ` if err := os.WriteFile(path, []byte(content), 0o600); err != nil { t.Fatal(err) } info, err := readCPUStatic(path) if err != nil { t.Fatal(err) } if info.Sockets != 1 || info.PhysicalCores != 2 || info.LogicalCPUs != 2 { t.Fatalf("неожиданная топология CPU: %+v", info) } }