Skip to content

Commit 48e1500

Browse files
committed
fix: 在CPU测试自动切换测试类型的时候头部测试方式自动替换测试说明
1 parent 486b767 commit 48e1500

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

cputest/cputest.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
package cputest
22

33
import (
4-
"fmt"
5-
"github.com/oneclickvirt/cputest/cpu"
64
"runtime"
75
"strings"
6+
7+
"github.com/oneclickvirt/cputest/cpu"
88
)
99

10-
func CpuTest(language, testMethod, testThread string) {
11-
var res string
10+
func CpuTest(language, testMethod, testThread string) (realTestMethod, res string) {
1211
if runtime.GOOS == "windows" {
1312
if testMethod != "winsat" && testMethod != "" {
14-
res = "Detected host is Windows, using Winsat for testing.\n"
13+
// res = "Detected host is Windows, using Winsat for testing.\n"
14+
realTestMethod = "winsat"
1515
}
1616
res += cpu.WinsatTest(language, testThread)
1717
} else {
1818
switch testMethod {
1919
case "sysbench":
2020
res = cpu.SysBenchTest(language, testThread)
2121
if res == "" {
22-
res = "Sysbench test failed, switching to Geekbench for testing.\n"
22+
// res = "Sysbench test failed, switching to Geekbench for testing.\n"
23+
realTestMethod = "geekbench"
2324
res += cpu.GeekBenchTest(language, testThread)
25+
} else {
26+
realTestMethod = "sysbench"
2427
}
2528
case "geekbench":
2629
res = cpu.GeekBenchTest(language, testThread)
2730
if res == "" {
28-
res = "Geekbench test failed, switching to Sysbench for testing.\n"
31+
// res = "Geekbench test failed, switching to Sysbench for testing.\n"
32+
realTestMethod = "sysbench"
2933
res += cpu.SysBenchTest(language, testThread)
34+
} else {
35+
realTestMethod = "geekbench"
3036
}
3137
default:
3238
res = "Invalid test method specified.\n"
@@ -35,5 +41,5 @@ func CpuTest(language, testMethod, testThread string) {
3541
if !strings.Contains(res, "\n") && res != "" {
3642
res += "\n"
3743
}
38-
fmt.Print(res)
44+
return
3945
}

goecs.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
)
4040

4141
var (
42-
ecsVersion = "v0.1.52"
42+
ecsVersion = "v0.1.53"
4343
menuMode bool
4444
onlyChinaTest bool
4545
input, choice string
@@ -570,12 +570,13 @@ func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
570570
_ = outputMutex
571571
return utils.PrintAndCapture(func() {
572572
if cpuTestStatus {
573+
realTestMethod, res := cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
573574
if language == "zh" {
574-
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
575+
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), width)
575576
} else {
576-
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", cpuTestMethod), width)
577+
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", realTestMethod), width)
577578
}
578-
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
579+
fmt.Print(res)
579580
}
580581
}, tempOutput, output)
581582
}

0 commit comments

Comments
 (0)