mirror of
https://github.com/oneclickvirt/ecs.git
synced 2025-09-27 11:42:23 +08:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e523ca3c84 | ||
![]() |
42943370bb | ||
![]() |
7339f0336c | ||
![]() |
54bbe16563 | ||
![]() |
2a66452f40 | ||
![]() |
aab6bf197d | ||
![]() |
9206088bad |
84
.goreleaser.old
Normal file
84
.goreleaser.old
Normal file
@@ -0,0 +1,84 @@
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy -v
|
||||
builds:
|
||||
- id: universal
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
- freebsd
|
||||
goarch:
|
||||
- arm
|
||||
- arm64
|
||||
- 386
|
||||
- amd64
|
||||
- mips
|
||||
- mipsle
|
||||
- s390x
|
||||
- riscv64
|
||||
gomips:
|
||||
- softfloat
|
||||
ignore:
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
main: ./
|
||||
binary: goecs
|
||||
- id: darwin-amd64
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=o64-clang
|
||||
- CXX=o64-clang++
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
main: ./
|
||||
binary: goecs
|
||||
- id: darwin-arm64
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=oa64-clang
|
||||
- CXX=oa64-clang++
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- arm64
|
||||
main: ./
|
||||
binary: goecs
|
||||
universal_binaries:
|
||||
- name_template: "goecs"
|
||||
replace: false
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
snapshot:
|
||||
name_template: "goecs"
|
||||
archives:
|
||||
- name_template: "goecs_{{ .Os }}_{{ .Arch }}"
|
||||
format: zip
|
||||
files:
|
||||
- none*
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- "^docs:"
|
||||
- "^test:"
|
||||
- "^chore"
|
||||
- Merge pull request
|
||||
- Merge branch
|
||||
- go mod tidy
|
||||
- New translations
|
143
.goreleaser.yaml
143
.goreleaser.yaml
@@ -1,7 +1,64 @@
|
||||
project_name: goecs
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
- CGO_ENABLED=0
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy -v
|
||||
builds:
|
||||
- id: linux-cgo
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
- amd64
|
||||
- 386
|
||||
- arm64
|
||||
- riscv64
|
||||
- mips64
|
||||
- mips64le
|
||||
- ppc64le
|
||||
main: ./
|
||||
binary: goecs
|
||||
no_unique_dist_dir: true
|
||||
allow_different_binary_count: true
|
||||
- id: windows-cgo
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
- 386
|
||||
main: ./
|
||||
binary: goecs
|
||||
no_unique_dist_dir: true
|
||||
allow_different_binary_count: true
|
||||
- id: darwin-cgo
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
main: ./
|
||||
binary: goecs
|
||||
no_unique_dist_dir: true
|
||||
allow_different_binary_count: true
|
||||
- id: universal
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
@@ -13,57 +70,76 @@ builds:
|
||||
- linux
|
||||
- windows
|
||||
- freebsd
|
||||
- openbsd
|
||||
- netbsd
|
||||
goarch:
|
||||
- arm
|
||||
- arm64
|
||||
- 386
|
||||
- amd64
|
||||
- s390x
|
||||
- mips
|
||||
- mipsle
|
||||
- s390x
|
||||
- riscv64
|
||||
- ppc64
|
||||
goarm:
|
||||
- "5"
|
||||
- "6"
|
||||
- "7"
|
||||
gomips:
|
||||
- softfloat
|
||||
ignore:
|
||||
# 避免和 linux-cgo 重叠
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
- goos: linux
|
||||
goarch: 386
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
- goos: linux
|
||||
goarch: riscv64
|
||||
- goos: linux
|
||||
goarch: mips64
|
||||
- goos: linux
|
||||
goarch: mips64le
|
||||
- goos: linux
|
||||
goarch: ppc64le
|
||||
# 避免和 windows-cgo 重叠
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
- goos: windows
|
||||
goarch: 386
|
||||
# 避免和 darwin-cgo 重叠
|
||||
- goos: darwin
|
||||
goarch: amd64
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
# 原系统不支持的忽略规则
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: freebsd
|
||||
goarch: 386
|
||||
- goos: openbsd
|
||||
goarch: 386
|
||||
- goos: netbsd
|
||||
goarch: 386
|
||||
main: ./
|
||||
binary: goecs
|
||||
- id: darwin-amd64
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=o64-clang
|
||||
- CXX=o64-clang++
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
main: ./
|
||||
binary: goecs
|
||||
- id: darwin-arm64
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- CC=oa64-clang
|
||||
- CXX=oa64-clang++
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
|
||||
flags:
|
||||
- -trimpath
|
||||
goos:
|
||||
- darwin
|
||||
goarch:
|
||||
- arm64
|
||||
main: ./
|
||||
binary: goecs
|
||||
no_unique_dist_dir: true
|
||||
allow_different_binary_count: true
|
||||
universal_binaries:
|
||||
- name_template: "goecs"
|
||||
replace: false
|
||||
ids:
|
||||
- darwin-cgo
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
algorithm: sha256
|
||||
disable: false
|
||||
ids:
|
||||
- linux-cgo
|
||||
- windows-cgo
|
||||
- darwin-cgo
|
||||
- universal
|
||||
snapshot:
|
||||
name_template: "goecs"
|
||||
archives:
|
||||
@@ -71,6 +147,7 @@ archives:
|
||||
format: zip
|
||||
files:
|
||||
- none*
|
||||
allow_different_binary_count: true
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
@@ -81,4 +158,4 @@ changelog:
|
||||
- Merge pull request
|
||||
- Merge branch
|
||||
- go mod tidy
|
||||
- New translations
|
||||
- New translations
|
@@ -30,9 +30,9 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
|
||||
| 编译支持的架构 | 测试支持的架构 | 编译支持的系统 | 测试支持的系统 |
|
||||
|---------------------------|-----------|---------|-----------|
|
||||
| amd64 | amd64 | Linux | Linux |
|
||||
| arm | arm | Windows | Windows |
|
||||
| arm64 | arm64 | FreeBSD | FreeBSD |
|
||||
| 386 | 386 | OpenBSD | |
|
||||
| arm | | Windows | Windows |
|
||||
| arm64 | arm64 | FreeBSD | |
|
||||
| 386 | | OpenBSD | |
|
||||
| mips | | MacOS | MacOS |
|
||||
| mipsle | | | |
|
||||
| s390x | s390x | | |
|
||||
|
@@ -28,10 +28,10 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
|
||||
| Supported for Compilation | Tested on | Supported OS for Compilation | Tested OS |
|
||||
|---------------------------|-----------|------------------------------|-----------|
|
||||
| amd64 | amd64 | Linux | Linux |
|
||||
| arm | arm | Windows | Windows |
|
||||
| arm64 | arm64 | FreeBSD | FreeBSD |
|
||||
| 386 | 386 | OpenBSD | |
|
||||
| mips | | MacOS | MacOS |
|
||||
| arm | | Windows | Windows |
|
||||
| arm64 | arm64 | FreeBSD | |
|
||||
| 386 | | OpenBSD | |
|
||||
| mips | | MacOS(darwin) | MacOS |
|
||||
| mipsle | | | |
|
||||
| s390x | s390x | | |
|
||||
| riscv64 | | | |
|
||||
|
@@ -36,6 +36,7 @@ func CpuTest(language, testMethod, testThread string) (realTestMethod, res strin
|
||||
}
|
||||
default:
|
||||
res = "Invalid test method specified.\n"
|
||||
realTestMethod = "null"
|
||||
}
|
||||
}
|
||||
if !strings.Contains(res, "\n") && res != "" {
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package cputest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
CpuTest("zh", "sysbench", "1")
|
||||
_, res := CpuTest("zh", "sysbench", "1")
|
||||
fmt.Print(res)
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
package disktest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/oneclickvirt/disktest/disk"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/oneclickvirt/disktest/disk"
|
||||
)
|
||||
|
||||
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) {
|
||||
var res string
|
||||
func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChange bool) (realTestMethod, res string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
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)
|
||||
} else {
|
||||
@@ -19,24 +19,29 @@ func DiskTest(language, testMethod, testPath string, isMultiCheck bool, autoChan
|
||||
case "fio":
|
||||
res = disk.FioTest(language, isMultiCheck, testPath)
|
||||
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)
|
||||
realTestMethod = "dd"
|
||||
} else {
|
||||
realTestMethod = "fio"
|
||||
}
|
||||
case "dd":
|
||||
res = disk.DDTest(language, isMultiCheck, testPath)
|
||||
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)
|
||||
realTestMethod = "fio"
|
||||
} else {
|
||||
realTestMethod = "dd"
|
||||
}
|
||||
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)
|
||||
realTestMethod = "dd"
|
||||
}
|
||||
}
|
||||
//fmt.Println("--------------------------------------------------")
|
||||
if !strings.Contains(res, "\n") && res != "" {
|
||||
res += "\n"
|
||||
}
|
||||
fmt.Printf("%s", res)
|
||||
//fmt.Println("--------------------------------------------------")
|
||||
return
|
||||
}
|
||||
|
@@ -1,7 +1,11 @@
|
||||
package disktest
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDiskIoTest(t *testing.T) {
|
||||
DiskTest("zh", "sysbench", "", false, false)
|
||||
_, res := DiskTest("zh", "sysbench", "", false, false)
|
||||
fmt.Print(res)
|
||||
}
|
||||
|
8
go.mod
8
go.mod
@@ -1,8 +1,6 @@
|
||||
module github.com/oneclickvirt/ecs
|
||||
|
||||
go 1.24.1
|
||||
|
||||
toolchain go1.24.2
|
||||
go 1.24.5
|
||||
|
||||
require (
|
||||
github.com/imroc/req/v3 v3.50.0
|
||||
@@ -10,11 +8,11 @@ require (
|
||||
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053
|
||||
github.com/oneclickvirt/backtrace v0.0.5-20250629024536
|
||||
github.com/oneclickvirt/basics v0.0.15-20250714163009
|
||||
github.com/oneclickvirt/cputest v0.0.10-20250404151448
|
||||
github.com/oneclickvirt/cputest v0.0.11-20250716031513
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446
|
||||
github.com/oneclickvirt/disktest v0.0.8-20250701092629
|
||||
github.com/oneclickvirt/gostun v0.0.3-20250329105202
|
||||
github.com/oneclickvirt/memorytest v0.0.6-20250630141424.0.20250701113027-9edfc91f68e6
|
||||
github.com/oneclickvirt/memorytest v0.0.8-20250716133749
|
||||
github.com/oneclickvirt/nt3 v0.0.5-20250416131047
|
||||
github.com/oneclickvirt/pingtest v0.0.8-20250701125637
|
||||
github.com/oneclickvirt/portchecker v0.0.3-20250329125750
|
||||
|
8
go.sum
8
go.sum
@@ -105,8 +105,8 @@ github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxp
|
||||
github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI=
|
||||
github.com/oneclickvirt/basics v0.0.15-20250714163009 h1:7I1lU7N91kClw6Cb6o+vGfScc/HngrjhsaaW10AbBFs=
|
||||
github.com/oneclickvirt/basics v0.0.15-20250714163009/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ=
|
||||
github.com/oneclickvirt/cputest v0.0.10-20250404151448 h1:ovGtCwFXG0qmpyNDRqcNDIiAmhrtemCjIUXTJ1fPH0o=
|
||||
github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY=
|
||||
github.com/oneclickvirt/cputest v0.0.11-20250716031513 h1:6xP/QCxwI6jTLmarIY3UIgaeOL2u94hzjVyG4yNa4WM=
|
||||
github.com/oneclickvirt/cputest v0.0.11-20250716031513/go.mod h1:vjlH8tkPFft1tlLOpeNskXVvurxkHaJ3+dgFxQGLXY4=
|
||||
github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnqn1S31z1j0x3V4l0=
|
||||
github.com/oneclickvirt/dd v0.0.2-20250701085922/go.mod h1:tImu9sPTkLWo2tf1dEN1xQzrylWKauj9hbU8PHfyAeU=
|
||||
github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
|
||||
@@ -119,8 +119,8 @@ github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTj
|
||||
github.com/oneclickvirt/gostun v0.0.3-20250329105202/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA=
|
||||
github.com/oneclickvirt/mbw v0.0.1-20250630140849 h1:p6RMhOPBnQKAm9+VEQ2axAFsidrdSdrhXMyheIyv2a8=
|
||||
github.com/oneclickvirt/mbw v0.0.1-20250630140849/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y=
|
||||
github.com/oneclickvirt/memorytest v0.0.6-20250630141424.0.20250701113027-9edfc91f68e6 h1:78/eMk+FGeDxxpKgkTb4GF5KJe76y8UW7Htcwm2hF9I=
|
||||
github.com/oneclickvirt/memorytest v0.0.6-20250630141424.0.20250701113027-9edfc91f68e6/go.mod h1:7xMacjQobvFAtODht2hxTsB9hM2IFS7vZk3gxx+bsjo=
|
||||
github.com/oneclickvirt/memorytest v0.0.8-20250716133749 h1:/z5lfsxRo5MHPfTAAKLk9vD0sQ4JDw5aEe21u6rQdfw=
|
||||
github.com/oneclickvirt/memorytest v0.0.8-20250716133749/go.mod h1:7xMacjQobvFAtODht2hxTsB9hM2IFS7vZk3gxx+bsjo=
|
||||
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk=
|
||||
github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ=
|
||||
github.com/oneclickvirt/pingtest v0.0.8-20250701125637 h1:J28Ai5miTq1J0I4gdT8rewJSd3LwzD90L/bNiiaKfHM=
|
||||
|
112
goecs.go
112
goecs.go
@@ -39,7 +39,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ecsVersion = "v0.1.53"
|
||||
ecsVersion = "v0.1.56"
|
||||
menuMode bool
|
||||
onlyChinaTest bool
|
||||
input, choice string
|
||||
@@ -396,7 +396,7 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
||||
seconds := int(duration.Seconds()) % 60
|
||||
currentTime := time.Now().Format("Mon Jan 2 15:04:05 MST 2006")
|
||||
outputMutex.Lock()
|
||||
*output = utils.PrintAndCapture(func() {
|
||||
timeInfo := utils.PrintAndCapture(func() {
|
||||
utils.PrintCenteredTitle("", width)
|
||||
if language == "zh" {
|
||||
fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
|
||||
@@ -406,7 +406,8 @@ func handleSignalInterrupt(sig chan os.Signal, startTime *time.Time, output *str
|
||||
fmt.Printf("Current Time : %s\n", currentTime)
|
||||
}
|
||||
utils.PrintCenteredTitle("", width)
|
||||
}, tempOutput, *output)
|
||||
}, "", "")
|
||||
*output += timeInfo
|
||||
finalOutput := *output
|
||||
outputMutex.Unlock()
|
||||
resultChan := make(chan struct {
|
||||
@@ -461,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 {
|
||||
output = runBasicTests(preCheck, basicInfo, securityInfo, output, tempOutput, outputMutex)
|
||||
output = runCPUTest(output, tempOutput, outputMutex)
|
||||
output = runMemoryTest(output, tempOutput, outputMutex)
|
||||
output = runDiskTest(output, tempOutput, outputMutex)
|
||||
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 = runCPUTest(*output, tempOutput, outputMutex)
|
||||
*output = runMemoryTest(*output, tempOutput, outputMutex)
|
||||
*output = runDiskTest(*output, tempOutput, outputMutex)
|
||||
if (onlyChinaTest || pingTestStatus) && preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||
wg3.Add(1)
|
||||
go func() {
|
||||
@@ -488,24 +489,24 @@ func runChineseTests(preCheck utils.NetCheckResult, wg1, wg2, wg3 *sync.WaitGrou
|
||||
}()
|
||||
}
|
||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||
output = runStreamingTests(wg1, mediaInfo, output, tempOutput, outputMutex)
|
||||
output = runSecurityTests(*securityInfo, output, tempOutput, outputMutex)
|
||||
output = runEmailTests(wg2, emailInfo, output, tempOutput, outputMutex)
|
||||
*output = runStreamingTests(wg1, mediaInfo, *output, tempOutput, outputMutex)
|
||||
*output = runSecurityTests(*securityInfo, *output, tempOutput, outputMutex)
|
||||
*output = runEmailTests(wg2, emailInfo, *output, tempOutput, outputMutex)
|
||||
}
|
||||
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" {
|
||||
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 {
|
||||
output = runBasicTests(preCheck, basicInfo, securityInfo, output, tempOutput, outputMutex)
|
||||
output = runCPUTest(output, tempOutput, outputMutex)
|
||||
output = runMemoryTest(output, tempOutput, outputMutex)
|
||||
output = runDiskTest(output, tempOutput, outputMutex)
|
||||
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 = runCPUTest(*output, tempOutput, outputMutex)
|
||||
*output = runMemoryTest(*output, tempOutput, outputMutex)
|
||||
*output = runDiskTest(*output, tempOutput, outputMutex)
|
||||
if preCheck.Connected && preCheck.StackType != "" && preCheck.StackType != "None" {
|
||||
if utTestStatus {
|
||||
wg1.Add(1)
|
||||
@@ -521,16 +522,17 @@ func runEnglishTests(preCheck utils.NetCheckResult, wg1, wg2 *sync.WaitGroup, ba
|
||||
*emailInfo = email.EmailCheck()
|
||||
}()
|
||||
}
|
||||
output = runStreamingTests(wg1, mediaInfo, output, tempOutput, outputMutex) // 传递指针
|
||||
output = runSecurityTests(*securityInfo, output, tempOutput, outputMutex)
|
||||
output = runEmailTests(wg2, emailInfo, output, tempOutput, outputMutex)
|
||||
output = runEnglishSpeedTests(output, tempOutput, outputMutex)
|
||||
*output = runStreamingTests(wg1, mediaInfo, *output, tempOutput, outputMutex)
|
||||
*output = runSecurityTests(*securityInfo, *output, tempOutput, outputMutex)
|
||||
*output = runEmailTests(wg2, emailInfo, *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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
utils.PrintHead(language, width, ecsVersion)
|
||||
if basicStatus || securityTestStatus {
|
||||
@@ -567,7 +569,8 @@ func runBasicTests(preCheck utils.NetCheckResult, basicInfo, securityInfo *strin
|
||||
}
|
||||
|
||||
func runCPUTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if cpuTestStatus {
|
||||
realTestMethod, res := cputest.CpuTest(language, cpuTestMethod, cpuTestThreadMode)
|
||||
@@ -582,47 +585,56 @@ func runCPUTest(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() {
|
||||
if memoryTestStatus {
|
||||
realTestMethod, res := memorytest.MemoryTest(language, memoryTestMethod)
|
||||
if language == "zh" {
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", memoryTestMethod), width)
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", realTestMethod), width)
|
||||
} 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)
|
||||
}
|
||||
|
||||
func runDiskTest(output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if diskTestStatus && autoChangeDiskTestMethod {
|
||||
realTestMethod, res := disktest.DiskTest(language, diskTestMethod, diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||
if language == "zh" {
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", diskTestMethod), width)
|
||||
utils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", realTestMethod), width)
|
||||
} 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 {
|
||||
if language == "zh" {
|
||||
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)
|
||||
disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||
_, res = disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||
fmt.Print(res)
|
||||
} else {
|
||||
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)
|
||||
disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||
_, res = disktest.DiskTest(language, "fio", diskTestPath, diskMultiCheck, autoChangeDiskTestMethod)
|
||||
fmt.Print(res)
|
||||
}
|
||||
}
|
||||
}, tempOutput, output)
|
||||
}
|
||||
|
||||
func runStreamingTests(wg1 *sync.WaitGroup, mediaInfo *string, output, tempOutput string, outputMutex *sync.Mutex) string {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if language == "zh" {
|
||||
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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if securityTestStatus {
|
||||
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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if emailTestStatus {
|
||||
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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
output = utils.PrintAndCapture(func() {
|
||||
if backtraceStatus && !onlyChinaTest {
|
||||
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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if speedTestStatus {
|
||||
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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
return utils.PrintAndCapture(func() {
|
||||
if speedTestStatus {
|
||||
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 {
|
||||
_ = outputMutex
|
||||
outputMutex.Lock()
|
||||
defer outputMutex.Unlock()
|
||||
endTime := time.Now()
|
||||
duration := endTime.Sub(startTime)
|
||||
minutes := int(duration.Minutes())
|
||||
@@ -792,9 +810,9 @@ func main() {
|
||||
go handleSignalInterrupt(sig, &startTime, &output, tempOutput, uploadDone, &outputMutex)
|
||||
switch language {
|
||||
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":
|
||||
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:
|
||||
fmt.Println("Unsupported language")
|
||||
}
|
||||
|
6
goecs.sh
6
goecs.sh
@@ -143,7 +143,7 @@ goecs_check() {
|
||||
os=$(uname -s 2>/dev/null || echo "Unknown")
|
||||
arch=$(uname -m 2>/dev/null || echo "Unknown")
|
||||
check_china
|
||||
ECS_VERSION="0.1.52"
|
||||
ECS_VERSION="0.1.55"
|
||||
for api in \
|
||||
"https://api.github.com/repos/oneclickvirt/ecs/releases/latest" \
|
||||
"https://githubapi.spiritlhl.workers.dev/repos/oneclickvirt/ecs/releases/latest" \
|
||||
@@ -155,8 +155,8 @@ goecs_check() {
|
||||
sleep 1
|
||||
done
|
||||
if [ -z "$ECS_VERSION" ]; then
|
||||
_yellow "Unable to get version info, using default version 0.1.52"
|
||||
ECS_VERSION="0.1.52"
|
||||
_yellow "Unable to get version info, using default version 0.1.55"
|
||||
ECS_VERSION="0.1.55"
|
||||
fi
|
||||
version_output=""
|
||||
for cmd_path in "goecs" "./goecs" "/usr/bin/goecs" "/usr/local/bin/goecs"; do
|
||||
|
@@ -1,17 +1,17 @@
|
||||
package memorytest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/oneclickvirt/memorytest/memory"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/oneclickvirt/memorytest/memory"
|
||||
)
|
||||
|
||||
func MemoryTest(language, testMethod string) {
|
||||
var res string
|
||||
func MemoryTest(language, testMethod string) (realTestMethod, res string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
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)
|
||||
} else {
|
||||
@@ -19,18 +19,23 @@ func MemoryTest(language, testMethod string) {
|
||||
case "sysbench":
|
||||
res = memory.SysBenchTest(language)
|
||||
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)
|
||||
realTestMethod = "dd"
|
||||
} else {
|
||||
realTestMethod = "sysbench"
|
||||
}
|
||||
case "dd":
|
||||
res = memory.DDTest(language)
|
||||
realTestMethod = "dd"
|
||||
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)
|
||||
realTestMethod = "dd"
|
||||
}
|
||||
}
|
||||
if !strings.Contains(res, "\n") && res != "" {
|
||||
res += "\n"
|
||||
}
|
||||
fmt.Printf("%s", res)
|
||||
return
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package memorytest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) {
|
||||
MemoryTest("zh", "sysbench")
|
||||
_, res := MemoryTest("zh", "sysbench")
|
||||
fmt.Print(res)
|
||||
}
|
||||
|
Reference in New Issue
Block a user