(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func TestNumCoresAmongOfflineCPUs(t *testing.T) { |
| 135 | if _, ok := os.LookupEnv("GHW_TESTING_SKIP_CPU"); ok { |
| 136 | t.Skip("Skipping CPU tests.") |
| 137 | } |
| 138 | |
| 139 | testdataPath, err := testdata.SnapshotsDirectory() |
| 140 | if err != nil { |
| 141 | t.Fatalf("Expected nil err, but got %v", err) |
| 142 | } |
| 143 | |
| 144 | offlineCPUSnapshot := filepath.Join(testdataPath, "linux-amd64-offlineCPUs.tar.gz") |
| 145 | |
| 146 | // Capture stderr |
| 147 | rErr, wErr, err := os.Pipe() |
| 148 | if err != nil { |
| 149 | t.Fatalf("Cannot pipe the StdErr. %v", err) |
| 150 | } |
| 151 | unpackDir := t.TempDir() |
| 152 | err = snapshot.UnpackInto(offlineCPUSnapshot, unpackDir) |
| 153 | if err != nil { |
| 154 | t.Fatal(err) |
| 155 | } |
| 156 | |
| 157 | info, err := topology.New(ghw.WithChroot(unpackDir)) |
| 158 | if err != nil { |
| 159 | t.Fatalf("Error determining node topology. %v", err) |
| 160 | } |
| 161 | |
| 162 | if len(info.Nodes) < 1 { |
| 163 | t.Fatal("No nodes found. Must contain one or more nodes") |
| 164 | } |
| 165 | for _, node := range info.Nodes { |
| 166 | if len(node.Cores) < 1 { |
| 167 | t.Fatal("No cores found. Must contain one or more cores") |
| 168 | } |
| 169 | } |
| 170 | wErr.Close() |
| 171 | var bufErr bytes.Buffer |
| 172 | if _, err := io.Copy(&bufErr, rErr); err != nil { |
| 173 | t.Fatalf("Failed to copy data to buffer: %v", err) |
| 174 | } |
| 175 | errorOutput := bufErr.String() |
| 176 | if strings.Contains(errorOutput, "WARNING: failed to read int from file:") { |
| 177 | t.Fatalf("Unexpected warnings related to missing files under topology directory was raised") |
| 178 | } |
| 179 | } |
| 180 | func TestS390xCPU(t *testing.T) { |
| 181 | if _, ok := os.LookupEnv("GHW_TESTING_SKIP_CPU"); ok { |
| 182 | t.Skip("Skipping CPU tests.") |
nothing calls this directly
no test coverage detected
searching dependent graphs…