File tree Expand file tree Collapse file tree 2 files changed +2
-9
lines changed Expand file tree Collapse file tree 2 files changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"os"
23
23
"path"
24
24
"path/filepath"
25
- "regexp"
26
25
"strconv"
27
26
"strings"
28
27
@@ -341,7 +340,7 @@ func (fs *realSysFs) IsCPUOnline(dir string) bool {
341
340
if err != nil {
342
341
pathErr , ok := err .(* os.PathError )
343
342
if ok {
344
- if errors .Is (pathErr .Unwrap (), os .ErrNotExist ) && isZeroCPU ( dir ) {
343
+ if errors .Is (pathErr .Unwrap (), os .ErrNotExist ) {
345
344
return true
346
345
}
347
346
}
@@ -351,9 +350,3 @@ func (fs *realSysFs) IsCPUOnline(dir string) bool {
351
350
trimmed := bytes .TrimSpace (content )
352
351
return len (trimmed ) == 1 && trimmed [0 ] == 49
353
352
}
354
-
355
- func isZeroCPU (dir string ) bool {
356
- regex := regexp .MustCompile ("cpu([0-9]*)" )
357
- matches := regex .FindStringSubmatch (dir )
358
- return len (matches ) == 2 && matches [1 ] == "0"
359
- }
Original file line number Diff line number Diff line change @@ -139,5 +139,5 @@ func TestIsCPUOnlineNoFileAndCPU0MustBeOnline(t *testing.T) {
139
139
assert .True (t , online )
140
140
141
141
online = sysFs .IsCPUOnline ("./testdata/missing_online/node0/cpu33" )
142
- assert .False (t , online )
142
+ assert .True (t , online )
143
143
}
You can’t perform that action at this time.
0 commit comments