mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-28 04:02:12 +08:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7339f0336c | ||
![]() |
54bbe16563 | ||
![]() |
2a66452f40 | ||
![]() |
aab6bf197d | ||
![]() |
9206088bad | ||
![]() |
48e150036d | ||
![]() |
486b767a25 | ||
![]() |
5a2e68bf92 | ||
![]() |
97d05f4b57 |
@@ -1,17 +1,17 @@
|
|||||||
package cputest
|
package cputest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/cputest/cpu"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/oneclickvirt/cputest/cpu"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CpuTest(language, testMethod, testThread string) {
|
func CpuTest(language, testMethod, testThread string) (realTestMethod, res string) {
|
||||||
var res string
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if testMethod != "winsat" && testMethod != "" {
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
realTestMethod = "winsat"
|
||||||
}
|
}
|
||||||
res += cpu.WinsatTest(language, testThread)
|
res += cpu.WinsatTest(language, testThread)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,21 +19,28 @@ func CpuTest(language, testMethod, testThread string) {
|
|||||||
case "sysbench":
|
case "sysbench":
|
||||||
res = cpu.SysBenchTest(language, testThread)
|
res = cpu.SysBenchTest(language, testThread)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
// res = "Sysbench test failed, switching to Geekbench for testing.\n"
|
||||||
|
realTestMethod = "geekbench"
|
||||||
res += cpu.GeekBenchTest(language, testThread)
|
res += cpu.GeekBenchTest(language, testThread)
|
||||||
|
} else {
|
||||||
|
realTestMethod = "sysbench"
|
||||||
}
|
}
|
||||||
case "geekbench":
|
case "geekbench":
|
||||||
res = cpu.GeekBenchTest(language, testThread)
|
res = cpu.GeekBenchTest(language, testThread)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
// res = "Geekbench test failed, switching to Sysbench for testing.\n"
|
||||||
|
realTestMethod = "sysbench"
|
||||||
res += cpu.SysBenchTest(language, testThread)
|
res += cpu.SysBenchTest(language, testThread)
|
||||||
|
} else {
|
||||||
|
realTestMethod = "geekbench"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = "Invalid test method specified.\n"
|
res = "Invalid test method specified.\n"
|
||||||
|
realTestMethod = "null"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(res, "\n") && res != "" {
|
if !strings.Contains(res, "\n") && res != "" {
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
fmt.Print(res)
|
return
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package cputest
|
package cputest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
CpuTest("zh", "sysbench", "1")
|
_, res := CpuTest("zh", "sysbench", "1")
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
package disktest
|
package disktest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/disktest/disk"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/oneclickvirt/disktest/disk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) {
|
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) (realTestMethod, res string) {
|
||||||
var res string
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if testMethod != "winsat" && testMethod != "" {
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
realTestMethod = "winsat"
|
||||||
}
|
}
|
||||||
res = disk.WinsatTest(language, isMultiCheck, testPath)
|
res = disk.WinsatTest(language, isMultiCheck, testPath)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,24 +19,29 @@ func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChan
|
|||||||
case "fio":
|
case "fio":
|
||||||
res = disk.FioTest(language, isMultiCheck, testPath)
|
res = disk.FioTest(language, isMultiCheck, testPath)
|
||||||
if res == "" && autoChange {
|
if res == "" && autoChange {
|
||||||
res = "Fio test failed, switching to DD for testing.\n"
|
// res = "Fio test failed, switching to DD for testing.\n"
|
||||||
res += disk.DDTest(language, isMultiCheck, testPath)
|
res += disk.DDTest(language, isMultiCheck, testPath)
|
||||||
|
realTestMethod = "dd"
|
||||||
|
} else {
|
||||||
|
realTestMethod = "fio"
|
||||||
}
|
}
|
||||||
case "dd":
|
case "dd":
|
||||||
res = disk.DDTest(language, isMultiCheck, testPath)
|
res = disk.DDTest(language, isMultiCheck, testPath)
|
||||||
if res == "" && autoChange {
|
if res == "" && autoChange {
|
||||||
res = "DD test failed, switching to Fio for testing.\n"
|
// res = "DD test failed, switching to Fio for testing.\n"
|
||||||
res += disk.FioTest(language, isMultiCheck, testPath)
|
res += disk.FioTest(language, isMultiCheck, testPath)
|
||||||
|
realTestMethod = "fio"
|
||||||
|
} else {
|
||||||
|
realTestMethod = "dd"
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
res = "Unsupported test method specified, switching to DD for testing.\n"
|
// res = "Unsupported test method specified, switching to DD for testing.\n"
|
||||||
res += disk.DDTest(language, isMultiCheck, testPath)
|
res += disk.DDTest(language, isMultiCheck, testPath)
|
||||||
|
realTestMethod = "dd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fmt.Println("--------------------------------------------------")
|
|
||||||
if !strings.Contains(res, "\n") && res != "" {
|
if !strings.Contains(res, "\n") && res != "" {
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
fmt.Printf("%s", res)
|
return
|
||||||
//fmt.Println("--------------------------------------------------")
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
package disktest
|
package disktest
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestDiskIoTest(t *testing.T) {
|
func TestDiskIoTest(t *testing.T) {
|
||||||
DiskTest("zh", "sysbench", "", false, false)
|
_, res := DiskTest("zh", "sysbench", "", false, false)
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
122
goecs.go
122
goecs.go
@@ -39,7 +39,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ecsVersion = "v0.1.52"
|
ecsVersion = "v0.1.55"
|
||||||
menuMode bool
|
menuMode bool
|
||||||
onlyChinaTest bool
|
onlyChinaTest bool
|
||||||
input, choice string
|
input, choice string
|
||||||
@@ -396,8 +396,7 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
|||||||
seconds := int(duration.Seconds()) % 60
|
seconds := int(duration.Seconds()) % 60
|
||||||
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
||||||
outputMutex.Lock()
|
outputMutex.Lock()
|
||||||
finalOutput := *output
|
timeInfo := utils.PrintAndCapture(func() {
|
||||||
*output = utils.PrintAndCapture(func() {
|
|
||||||
utils.PrintCenteredTitle("", width)
|
utils.PrintCenteredTitle("", width)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
|
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
|
||||||
@@ -407,8 +406,9 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
|||||||
fmt.Printf("Current Time : %s\n", currentTime)
|
fmt.Printf("Current Time : %s\n", currentTime)
|
||||||
}
|
}
|
||||||
utils.PrintCenteredTitle("", width)
|
utils.PrintCenteredTitle("", width)
|
||||||
}, tempOutput, finalOutput)
|
}, "", "")
|
||||||
finalOutput = *output
|
*output += timeInfo
|
||||||
|
finalOutput := *output
|
||||||
outputMutex.Unlock()
|
outputMutex.Unlock()
|
||||||
resultChan := make(chan struct {
|
resultChan := make(chan struct {
|
||||||
httpURL string
|
httpURL string
|
||||||
@@ -462,11 +462,11 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo *string, output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo *string, output *string, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) {
|
||||||
output = runBasicTests(preCheck, basicInfo, securityInfo, output, tempOutput, outputMutex)
|
*output = runBasicTests(preCheck, basicInfo, securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runCPUTest(output, tempOutput, outputMutex)
|
*output = runCPUTest(*output, tempOutput, outputMutex)
|
||||||
output = runMemoryTest(output, tempOutput, outputMutex)
|
*output = runMemoryTest(*output, tempOutput, outputMutex)
|
||||||
output = runDiskTest(output, tempOutput, outputMutex)
|
*output = runDiskTest(*output, tempOutput, outputMutex)
|
||||||
if (onlyChinaTest || pingTestStatus) && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if (onlyChinaTest || pingTestStatus) && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
wg3.Add(1)
|
wg3.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -489,24 +489,24 @@ func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGrou
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
output = runStreamingTests(wg1, mediaInfo, output, tempOutput, outputMutex)
|
*output = runStreamingTests(wg1, mediaInfo, *output, tempOutput, outputMutex)
|
||||||
output = runSecurityTests(*securityInfo, output, tempOutput, outputMutex)
|
*output = runSecurityTests(*securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runEmailTests(wg2, emailInfo, output, tempOutput, outputMutex)
|
*output = runEmailTests(wg2, emailInfo, *output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if runtime.GOOS != "windows" && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
output = runNetworkTests(wg3, ptInfo, output, tempOutput, outputMutex)
|
*output = runNetworkTests(wg3, ptInfo, *output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
output = runSpeedTests(output, tempOutput, outputMutex)
|
*output = runSpeedTests(*output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
return appendTimeInfo(output, tempOutput, startTime, outputMutex)
|
*output = appendTimeInfo(*output, tempOutput, startTime, outputMutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo *string, output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, basicInfo, securityInfo, emailInfo, mediaInfo *string, output *string, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) {
|
||||||
output = runBasicTests(preCheck, basicInfo, securityInfo, output, tempOutput, outputMutex)
|
*output = runBasicTests(preCheck, basicInfo, securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runCPUTest(output, tempOutput, outputMutex)
|
*output = runCPUTest(*output, tempOutput, outputMutex)
|
||||||
output = runMemoryTest(output, tempOutput, outputMutex)
|
*output = runMemoryTest(*output, tempOutput, outputMutex)
|
||||||
output = runDiskTest(output, tempOutput, outputMutex)
|
*output = runDiskTest(*output, tempOutput, outputMutex)
|
||||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||||
if utTestStatus {
|
if utTestStatus {
|
||||||
wg1.Add(1)
|
wg1.Add(1)
|
||||||
@@ -522,16 +522,17 @@ func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, ba
|
|||||||
*emailInfo = email.EmailCheck()
|
*emailInfo = email.EmailCheck()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
output = runStreamingTests(wg1, mediaInfo, output, tempOutput, outputMutex) // 传递指针
|
*output = runStreamingTests(wg1, mediaInfo, *output, tempOutput, outputMutex)
|
||||||
output = runSecurityTests(*securityInfo, output, tempOutput, outputMutex)
|
*output = runSecurityTests(*securityInfo, *output, tempOutput, outputMutex)
|
||||||
output = runEmailTests(wg2, emailInfo, output, tempOutput, outputMutex)
|
*output = runEmailTests(wg2, emailInfo, *output, tempOutput, outputMutex)
|
||||||
output = runEnglishSpeedTests(output, tempOutput, outputMutex)
|
*output = runEnglishSpeedTests(*output, tempOutput, outputMutex)
|
||||||
}
|
}
|
||||||
return appendTimeInfo(output, tempOutput, startTime, outputMutex)
|
*output = appendTimeInfo(*output, tempOutput, startTime, outputMutex)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
utils.PrintHead(language, width, ecsVersion)
|
utils.PrintHead(language, width, ecsVersion)
|
||||||
if basicStatus || securityTestStatus {
|
if basicStatus || securityTestStatus {
|
||||||
@@ -568,61 +569,72 @@ func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if cpuTestStatus {
|
if cpuTestStatus {
|
||||||
|
realTestMethod, res := cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", cpuTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), width)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", cpuTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("CPU-Test--%s-Method", realTestMethod), width)
|
||||||
}
|
}
|
||||||
cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runMemoryTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if memoryTestStatus {
|
if memoryTestStatus {
|
||||||
|
realTestMethod, res := memorytest.MemoryTest(language, memoryTestMethod)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", memoryTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", realTestMethod), width)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Memory-Test--%s-Method", memoryTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Memory-Test--%s-Method", realTestMethod), width)
|
||||||
}
|
}
|
||||||
memorytest.MemoryTest(language, memoryTestMethod)
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if diskTestStatus && autoChangeDiskTestMethod {
|
if diskTestStatus && autoChangeDiskTestMethod {
|
||||||
|
realTestMethod, res := disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", realTestMethod), width)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", diskTestMethod), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", realTestMethod), width)
|
||||||
}
|
}
|
||||||
disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
fmt.Print(res)
|
||||||
} else if diskTestStatus && !autoChangeDiskTestMethod {
|
} else if diskTestStatus && !autoChangeDiskTestMethod {
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "dd"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "dd"), width)
|
||||||
disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res := disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "fio"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", "fio"), width)
|
||||||
disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res = disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
} else {
|
} else {
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "dd"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "dd"), width)
|
||||||
disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res := disktest.DiskTest(language, "dd", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "fio"), width)
|
utils.PrintCenteredTitle(fmt.Sprintf("Disk-Test--%s-Method", "fio"), width)
|
||||||
disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
_, res = disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, tempOutput, output)
|
}, tempOutput, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
if commTestStatus && !onlyChinaTest {
|
if commTestStatus && !onlyChinaTest {
|
||||||
@@ -643,7 +655,8 @@ func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if securityTestStatus {
|
if securityTestStatus {
|
||||||
if language == "zh" {
|
if language == "zh" {
|
||||||
@@ -657,7 +670,8 @@ func runSecurityTests(securityInfo, output, tempOutput string, outputMutex *sync
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if emailTestStatus {
|
if emailTestStatus {
|
||||||
wg2.Wait()
|
wg2.Wait()
|
||||||
@@ -672,7 +686,8 @@ func runEmailTests(wg2 *sync.WaitGroup, emailInfo *string, output, tempOutput st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
output = utils.PrintAndCapture(func() {
|
output = utils.PrintAndCapture(func() {
|
||||||
if backtraceStatus && !onlyChinaTest {
|
if backtraceStatus && !onlyChinaTest {
|
||||||
utils.PrintCenteredTitle("三网回程线路检测", width)
|
utils.PrintCenteredTitle("三网回程线路检测", width)
|
||||||
@@ -699,7 +714,8 @@ func runNetworkTests(wg3 *sync.WaitGroup, ptInfo *string, output, tempOutput str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if speedTestStatus {
|
if speedTestStatus {
|
||||||
utils.PrintCenteredTitle("就近节点测速", width)
|
utils.PrintCenteredTitle("就近节点测速", width)
|
||||||
@@ -720,7 +736,8 @@ func runSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
return utils.PrintAndCapture(func() {
|
return utils.PrintAndCapture(func() {
|
||||||
if speedTestStatus {
|
if speedTestStatus {
|
||||||
utils.PrintCenteredTitle("Speed-Test", width)
|
utils.PrintCenteredTitle("Speed-Test", width)
|
||||||
@@ -732,7 +749,8 @@ func runEnglishSpeedTests(output, tempOutput string, outputMutex *sync.Mutex) st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func appendTimeInfo(output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
func appendTimeInfo(output, tempOutput string, startTime time.Time, outputMutex *sync.Mutex) string {
|
||||||
_ = outputMutex
|
outputMutex.Lock()
|
||||||
|
defer outputMutex.Unlock()
|
||||||
endTime := time.Now()
|
endTime := time.Now()
|
||||||
duration := endTime.Sub(startTime)
|
duration := endTime.Sub(startTime)
|
||||||
minutes := int(duration.Minutes())
|
minutes := int(duration.Minutes())
|
||||||
@@ -792,9 +810,9 @@ func main() {
|
|||||||
go handleSignalInterrupt(sig, &startTime, &output, tempOutput, uploadDone, &outputMutex)
|
go handleSignalInterrupt(sig, &startTime, &output, tempOutput, uploadDone, &outputMutex)
|
||||||
switch language {
|
switch language {
|
||||||
case "zh":
|
case "zh":
|
||||||
output = runChineseTests(preCheck, &wg1, &wg2, &wg3, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, &ptInfo, output, tempOutput, startTime, &outputMutex)
|
runChineseTests(preCheck, &wg1, &wg2, &wg3, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, &ptInfo, &output, tempOutput, startTime, &outputMutex)
|
||||||
case "en":
|
case "en":
|
||||||
output = runEnglishTests(preCheck, &wg1, &wg2, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, output, tempOutput, startTime, &outputMutex)
|
runEnglishTests(preCheck, &wg1, &wg2, &basicInfo, &securityInfo, &emailInfo, &mediaInfo, &output, tempOutput, startTime, &outputMutex)
|
||||||
default:
|
default:
|
||||||
fmt.Println("Unsupported language")
|
fmt.Println("Unsupported language")
|
||||||
}
|
}
|
||||||
|
6
goecs.sh
6
goecs.sh
@@ -143,7 +143,7 @@ goecs_check() {
|
|||||||
os=$(uname -s 2>/dev/null || echo "Unknown")
|
os=$(uname -s 2>/dev/null || echo "Unknown")
|
||||||
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
||||||
check_china
|
check_china
|
||||||
ECS_VERSION="0.1.51"
|
ECS_VERSION="0.1.54"
|
||||||
for api in \
|
for api in \
|
||||||
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
||||||
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
||||||
@@ -155,8 +155,8 @@ goecs_check() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
if [ -z "$ECS_VERSION" ]; then
|
if [ -z "$ECS_VERSION" ]; then
|
||||||
_yellow "Unable to get version info, using default version 0.1.51"
|
_yellow "Unable to get version info, using default version 0.1.54"
|
||||||
ECS_VERSION="0.1.51"
|
ECS_VERSION="0.1.54"
|
||||||
fi
|
fi
|
||||||
version_output=""
|
version_output=""
|
||||||
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
package memorytest
|
package memorytest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/oneclickvirt/memorytest/memory"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/oneclickvirt/memorytest/memory"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MemoryTest(language, testMethod string) {
|
func MemoryTest(language, testMethod string) (realTestMethod, res string) {
|
||||||
var res string
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if testMethod != "winsat" && testMethod != "" {
|
if testMethod != "winsat" && testMethod != "" {
|
||||||
res = "Detected host is Windows, using Winsat for testing.\n"
|
// res = "Detected host is Windows, using Winsat for testing.\n"
|
||||||
|
realTestMethod = "winsat"
|
||||||
}
|
}
|
||||||
res += memory.WinsatTest(language)
|
res += memory.WinsatTest(language)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,18 +19,23 @@ func MemoryTest(language, testMethod string) {
|
|||||||
case "sysbench":
|
case "sysbench":
|
||||||
res = memory.SysBenchTest(language)
|
res = memory.SysBenchTest(language)
|
||||||
if res == "" {
|
if res == "" {
|
||||||
res = "sysbench test failed, switch to use dd test.\n"
|
// res = "sysbench test failed, switch to use dd test.\n"
|
||||||
res += memory.DDTest(language)
|
res += memory.DDTest(language)
|
||||||
|
realTestMethod = "dd"
|
||||||
|
} else {
|
||||||
|
realTestMethod = "sysbench"
|
||||||
}
|
}
|
||||||
case "dd":
|
case "dd":
|
||||||
res = memory.DDTest(language)
|
res = memory.DDTest(language)
|
||||||
|
realTestMethod = "dd"
|
||||||
default:
|
default:
|
||||||
res = "Unsupported test method, switch to use dd test.\n"
|
// res = "Unsupported test method, switch to use dd test.\n"
|
||||||
res += memory.DDTest(language)
|
res += memory.DDTest(language)
|
||||||
|
realTestMethod = "dd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(res, "\n") && res != "" {
|
if !strings.Contains(res, "\n") && res != "" {
|
||||||
res += "\n"
|
res += "\n"
|
||||||
}
|
}
|
||||||
fmt.Printf("%s", res)
|
return
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package memorytest
|
package memorytest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
MemoryTest("zh", "sysbench")
|
_, res := MemoryTest("zh", "sysbench")
|
||||||
|
fmt.Print(res)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user