Compare commits

...

49 Commits

Author SHA1 Message Date
spiritlhl
df6d1236cc fix: 暂时注释调freebsd进行编译 2025-07-17 03:12:06 +00:00
spiritlhl
7c64102581 fix: 修复头文件导入 2025-07-17 03:07:18 +00:00
spiritlhl
58cb4f3831 fix: 修复头文件导入 2025-07-17 03:04:13 +00:00
spiritlhl
20bddae048 fix: 更新版本 2025-07-17 02:49:04 +00:00
spiritlhl
3c0590ca8d fix: 删除暂不适配的freebsd-arm 2025-07-17 02:43:28 +00:00
spiritlhl
a752eeeeb0 fix: 修复配置错配 2025-07-17 02:26:32 +00:00
spiritlhl
630a28f2f2 fix: 编译顺序执行避免报错无法溯源 2025-07-17 02:14:19 +00:00
spiritlhl
cfd70e100b fix: 编译顺序执行避免报错无法溯源 2025-07-17 02:02:59 +00:00
spiritlhl
9114f5b97a fix: linux的amd64架构无需额外设置gcc 2025-07-17 01:36:26 +00:00
spiritlhl
8c0fc16384 fix: 升级默认编译容器的版本 2025-07-17 01:25:15 +00:00
spiritlhl
2ded570639 fix: 去除暂不支持的系统 2025-07-16 16:52:34 +00:00
spiritlhl
42f0cb3399 fix: 去除暂不支持的系统 2025-07-16 16:35:48 +00:00
spiritlhl
14adbddeb9 fix: 添加错误追踪 2025-07-16 16:19:21 +00:00
spiritlhl
27fd06b007 fix: 无法去除默认验证 2025-07-16 16:08:41 +00:00
spiritlhl
88db8df827 fix: 重构编译逻辑避免全部任务失败 2025-07-16 16:03:46 +00:00
spiritlhl
ec728796f4 fix: 修复缺失的前置依赖 2025-07-16 15:44:40 +00:00
spiritlhl
147e8c1113 fix: 修复缺失的前置依赖 2025-07-16 15:27:55 +00:00
spiritlhl
b9b1d5ca76 fix: 删除goreleaser的部分无效参数 2025-07-16 15:00:35 +00:00
spiritlhl
1500c8342e fix: 更新goreleaser的yaml版本 2025-07-16 14:54:49 +00:00
spiritlhl
e523ca3c84 fix: 修复cputest和memorytest的C重构,尽量使用CGO编译嵌入依赖,拓展编译支持的系统和架构,增加容错机制 2025-07-16 14:47:11 +00:00
github-actions[bot]
42943370bb chore: update ECS_VERSION to 0.1.55 in goecs.sh 2025-07-15 12:48:33 +00:00
spiritlhl
7339f0336c fix: 修复传递过程中非指针传递导致的写入丢失 2025-07-15 12:44:24 +00:00
github-actions[bot]
54bbe16563 chore: update ECS_VERSION to 0.1.54 in goecs.sh 2025-07-15 12:27:50 +00:00
spiritlhl
2a66452f40 fix: 更新版本号 2025-07-15 12:23:20 +00:00
spiritlhl
aab6bf197d fix: 修复测试项目自动切换了测试方式在测试项头部同步更改说明 2025-07-15 12:22:51 +00:00
github-actions[bot]
9206088bad chore: update ECS_VERSION to 0.1.53 in goecs.sh 2025-07-15 11:55:49 +00:00
spiritlhl
48e150036d fix: 在CPU测试自动切换测试类型的时候头部测试方式自动替换测试说明 2025-07-15 11:51:30 +00:00
spiritlhl
486b767a25 fix: 修复文本赋值顺序错位 2025-07-15 19:29:13 +08:00
spiritlhl
5a2e68bf92 fix: 修复文本赋值顺序错位 2025-07-15 19:27:11 +08:00
github-actions[bot]
97d05f4b57 chore: update ECS_VERSION to 0.1.52 in goecs.sh 2025-07-15 11:12:52 +00:00
spiritlhl
4f08a33de8 fix: 离线环境下不再尝试结果分享链接的生成 2025-07-15 10:58:40 +00:00
spiritlhl
ff8712a743 fix: 修复中途退出文本内容未正常保存并生成分享链接的问题 2025-07-15 10:51:55 +00:00
spiritlhl
abd38554b6 fix: 更新basics模块支持多盘智能检测同时显示boot和mount路径 2025-07-15 10:29:41 +00:00
github-actions[bot]
918a9b3a46 chore: update ECS_VERSION to 0.1.51 in goecs.sh 2025-07-10 08:15:00 +00:00
spiritlhl
d9dac50487 fix: 更新basics支持多盘检测,更新security数据库来源,增加maxmind数据库获取IP信息 2025-07-10 08:02:54 +00:00
spiritlhl
cd65f04433 fix: 添加测试环境类型说明 2025-07-01 13:36:18 +00:00
github-actions[bot]
8b5193eca1 chore: update ECS_VERSION to 0.1.50 in goecs.sh 2025-07-01 13:14:04 +00:00
spiritlhl
4797ff0b34 fix: 优化pingtest的日志记录 2025-07-01 13:02:39 +00:00
github-actions[bot]
9886cad73e chore: update ECS_VERSION to 0.1.49 in goecs.sh 2025-07-01 12:18:04 +00:00
spiritlhl
ca0470f01a fix: 修复pingtest和speedtest在无root权限环境下的鉴权问题 2025-07-01 12:06:59 +00:00
github-actions[bot]
5a6d6845c1 chore: update ECS_VERSION to 0.1.48 in goecs.sh 2025-07-01 09:57:47 +00:00
spiritlhl
487dd7c1d2 fix: 测试修复无权限下硬盘测试引擎选择的问题 2025-07-01 09:37:56 +00:00
spiritlhl
2dbf97de8c fix: 测试修复无权限下硬盘测试引擎选择的问题 2025-07-01 09:35:56 +00:00
github-actions[bot]
97e7cae2c2 chore: update ECS_VERSION to 0.1.47 in goecs.sh 2025-07-01 08:44:22 +00:00
spiritlhl
d61a1879f5 fix: 修复macos上无权限时的测试路径选择 2025-07-01 08:33:30 +00:00
github-actions[bot]
29dd4ac57e chore: update ECS_VERSION to 0.1.46 in goecs.sh 2025-07-01 03:30:58 +00:00
spiritlhl
dc3eff1fe3 fix: 更新版本 2025-07-01 11:20:24 +08:00
spiritlhl
0a0f2199bc fix: 修复内存和硬盘测试的权限校验问题 2025-07-01 03:19:07 +00:00
github-actions[bot]
91004d87f5 chore: update ECS_VERSION to 0.1.45 in goecs.sh 2025-06-30 14:30:04 +00:00
18 changed files with 894 additions and 251 deletions

121
.github/workflows/build.yaml vendored Normal file
View File

@@ -0,0 +1,121 @@
name: Goreleaser
on:
workflow_dispatch:
tags:
- "v*.*.*"
jobs:
goreleaser:
runs-on: ubuntu-latest
container:
# 1.20 是 Windows 7/8 Server 2008/2012 最后一个支持版本
image: goreleaser/goreleaser-cross:v1.20
steps:
- name: Configure git safe directory
run: |
git config --global --add safe.directory /__w/ecs/ecs
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.4
- name: Configure Git for Private Modules
run: |
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
git config --global url."git@github.com:".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ secrets.GHT }}
- name: Install missing cross-compilation tools
run: |
echo "Installing missing cross-compilation tools..."
apt-get update
apt-get install -y gcc-multilib g++-multilib
dpkg --add-architecture i386
apt-get update
apt-get install -y \
linux-libc-dev \
gcc-aarch64-linux-gnu \
gcc-riscv64-linux-gnu \
gcc-mips64-linux-gnuabi64 \
gcc-mips64el-linux-gnuabi64 \
gcc-powerpc64le-linux-gnu \
gcc-mingw-w64-x86-64 \
gcc-mingw-w64-i686 \
libc6-dev-i386 \
|| echo "Some packages may already be installed"
- name: Verify cross-compilation tools
run: |
echo "Checking available cross-compilation tools..."
echo "=== GCC compilers ==="
which gcc || echo "gcc not found"
which x86_64-linux-gnu-gcc || echo "x86_64-linux-gnu-gcc not found"
which aarch64-linux-gnu-gcc || echo "aarch64-linux-gnu-gcc not found"
which riscv64-linux-gnu-gcc || echo "riscv64-linux-gnu-gcc not found"
which mips64-linux-gnuabi64-gcc || echo "mips64-linux-gnuabi64-gcc not found"
which mips64el-linux-gnuabi64-gcc || echo "mips64el-linux-gnuabi64-gcc not found"
which powerpc64le-linux-gnu-gcc || echo "powerpc64le-linux-gnu-gcc not found"
echo "=== MinGW compilers ==="
which x86_64-w64-mingw32-gcc || echo "x86_64-w64-mingw32-gcc not found"
which i686-w64-mingw32-gcc || echo "i686-w64-mingw32-gcc not found"
echo "=== OSXCross compilers ==="
which o64-clang || echo "o64-clang not found"
which oa64-clang || echo "oa64-clang not found"
which o64-clang++ || echo "o64-clang++ not found"
which oa64-clang++ || echo "oa64-clang++ not found"
echo "=== Clang compilers ==="
which clang || echo "clang not found"
echo "=== Available gcc binaries ==="
ls -la /usr/bin/*gcc* | head -20
echo "=== Available clang binaries ==="
ls -la /usr/bin/*clang* | head -10
echo "=== OSXCross directory ==="
ls -la /usr/osxcross/bin/ 2>/dev/null || echo "OSXCross not found in /usr/osxcross/bin/"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --parallelism 1 --verbose
env:
GITHUB_TOKEN: ${{ secrets.GHT }}
GOPRIVATE: github.com/oneclickvirt/security
- name: Update goecs.sh with new version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.1.37")
fi
echo "Using version: $VERSION"
FILE="goecs.sh"
BRANCH="master"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global --unset url."git@github.com:".insteadOf || true
git fetch origin $BRANCH
git checkout $BRANCH
if [ ! -f "$FILE" ]; then
echo "Error: $FILE not found"
exit 1
fi
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "$FILE"
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "$FILE"
if git diff --quiet "$FILE"; then
echo "No changes detected in $FILE"
exit 0
fi
git add "$FILE"
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
git push origin $BRANCH
env:
GITHUB_TOKEN: ${{ secrets.GHT }}

View File

@@ -1,73 +0,0 @@
name: goreleaser
on:
workflow_dispatch:
tags:
- "v*.*.*"
jobs:
goreleaser:
runs-on: ubuntu-latest
container:
# 1.20 是 Windows 7/8 Server 2008/2012 最后一个支持版本
image: goreleaser/goreleaser-cross:v1.20
steps:
- run: |
git config --global --add safe.directory /__w/ecs/ecs
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.4
- name: Configure Git for Private Modules
run: |
git config --global url."https://${{ secrets.GHT }}@github.com/".insteadOf "https://github.com/"
git config --global url."git@github.com:".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ secrets.GHT }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GHT }}
GOPRIVATE: github.com/oneclickvirt/security
- name: Update goecs.sh with new version
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.1.37")
fi
echo "Using version: $VERSION"
FILE="goecs.sh"
BRANCH="master"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global --unset url."git@github.com:".insteadOf || true
git fetch origin $BRANCH
git checkout $BRANCH
if [ ! -f "$FILE" ]; then
echo "Error: $FILE not found"
exit 1
fi
sed -i "s/\(_yellow \"Unable to get version info, using default version \).*\(\".*\)/\1$VERSION\2/" "$FILE"
sed -i "s/\(ECS_VERSION=\"\).*\(\"\)/\1$VERSION\2/" "$FILE"
if git diff --quiet "$FILE"; then
echo "No changes detected in $FILE"
exit 0
fi
git add "$FILE"
git commit -m "chore: update ECS_VERSION to $VERSION in goecs.sh"
git push origin $BRANCH
env:
GITHUB_TOKEN: ${{ secrets.GHT }}

View File

@@ -1,39 +1,146 @@
version: 2
project_name: goecs
env:
- GO111MODULE=on
before: before:
hooks: hooks:
- go mod tidy -v - go mod tidy -v
builds: builds:
- id: universal # Linux AMD64 with CGO
- id: linux-amd64-cgo
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=1
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
- CGO_CFLAGS=-O2 -static -fno-stack-protector -Wl,--gc-sections
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags: flags:
- -trimpath - -trimpath
goos: goos:
- linux - linux
- windows
- freebsd
goarch: goarch:
- arm
- arm64
- 386
- amd64 - amd64
- mips
- mipsle
- s390x
- riscv64
gomips:
- softfloat
ignore:
- goos: windows
goarch: arm
main: ./ main: ./
binary: goecs binary: goecs
- id: darwin-amd64 no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/amd64 (CGO)"
post:
- echo "Successfully built linux/amd64 (CGO)"
- echo "---"
# Linux 386 with CGO
- id: linux-386-cgo
env:
- CGO_ENABLED=1
- CC=gcc -m32
- CGO_CFLAGS=-m32 -static -O1 -march=i686 -mtune=generic -fno-stack-protector
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- linux
goarch:
- 386
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/386 (CGO)"
post:
- echo "Successfully built linux/386 (CGO)"
- echo "---"
# Linux ARM64 with CGO
- id: linux-arm64-cgo
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-gcc
- CGO_CFLAGS=-static -O1 -fno-stack-protector
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- linux
goarch:
- arm64
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/arm64 (CGO)"
post:
- echo "Successfully built linux/arm64 (CGO)"
- echo "---"
# Windows AMD64 with CGO
- id: windows-amd64-cgo
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CGO_CFLAGS=-O2 -static -static-libgcc -static-libstdc++
- CGO_LDFLAGS=-static -static-libgcc -static-libstdc++
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- windows
goarch:
- amd64
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for windows/amd64 (CGO)"
post:
- echo "Successfully built windows/amd64 (CGO)"
- echo "---"
# Windows 386 with CGO
- id: windows-386-cgo
env:
- CGO_ENABLED=1
- CC=gcc-mingw-w64-i686
- CGO_CFLAGS=-O2 -static -static-libgcc -static-libstdc++
- CGO_LDFLAGS=-static -static-libgcc -static-libstdc++
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- windows
goarch:
- 386
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for windows/386 (CGO)"
post:
- echo "Successfully built windows/386 (CGO)"
- echo "---"
# Darwin AMD64 with CGO
- id: darwin-amd64-cgo
env: env:
- CGO_ENABLED=1 - CGO_ENABLED=1
- CC=o64-clang - CC=o64-clang
- CXX=o64-clang++ - CXX=o64-clang++
- CGO_CFLAGS=-O2 -arch x86_64 -mmacosx-version-min=10.12
- CGO_LDFLAGS=-arch x86_64 -mmacosx-version-min=10.12
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags: flags:
@@ -44,11 +151,25 @@ builds:
- amd64 - amd64
main: ./ main: ./
binary: goecs binary: goecs
- id: darwin-arm64 no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for darwin/amd64 (CGO)"
- echo "Checking osxcross tools..."
- which o64-clang || echo "o64-clang not found"
- which o64-clang++ || echo "o64-clang++ not found"
post:
- echo "Successfully built darwin/amd64 (CGO)"
- echo "---"
# Darwin ARM64 with CGO
- id: darwin-arm64-cgo
env: env:
- CGO_ENABLED=1 - CGO_ENABLED=1
- CC=oa64-clang - CC=oa64-clang
- CXX=oa64-clang++ - CXX=oa64-clang++
- CGO_CFLAGS=-O2 -arch arm64 -mmacosx-version-min=11.0
- CGO_LDFLAGS=-arch arm64 -mmacosx-version-min=11.0
ldflags: ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags: flags:
@@ -59,18 +180,338 @@ builds:
- arm64 - arm64
main: ./ main: ./
binary: goecs binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for darwin/arm64 (CGO)"
- echo "Checking osxcross tools..."
- which oa64-clang || echo "oa64-clang not found"
- which oa64-clang++ || echo "oa64-clang++ not found"
post:
- echo "Successfully built darwin/arm64 (CGO)"
- echo "---"
# Linux RISC-V 64 with CGO
- id: linux-riscv64-cgo
env:
- CGO_ENABLED=1
- CC=riscv64-linux-gnu-gcc
- CGO_CFLAGS=-static -O1 -fno-stack-protector
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- linux
goarch:
- riscv64
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/riscv64 (CGO)"
post:
- echo "Successfully built linux/riscv64 (CGO)"
- echo "---"
# Linux MIPS64 with CGO
- id: linux-mips64-cgo
env:
- CGO_ENABLED=1
- CC=mips64-linux-gnuabi64-gcc
- CGO_CFLAGS=-static -O1 -fno-stack-protector
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- linux
goarch:
- mips64
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/mips64 (CGO)"
post:
- echo "Successfully built linux/mips64 (CGO)"
- echo "---"
# Linux MIPS64LE with CGO
- id: linux-mips64le-cgo
env:
- CGO_ENABLED=1
- CC=mips64el-linux-gnuabi64-gcc
- CGO_CFLAGS=-static -O1 -fno-stack-protector
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- linux
goarch:
- mips64le
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/mips64le (CGO)"
post:
- echo "Successfully built linux/mips64le (CGO)"
- echo "---"
# Linux PPC64LE with CGO
- id: linux-ppc64le-cgo
env:
- CGO_ENABLED=1
- CC=powerpc64le-linux-gnu-gcc
- CGO_CFLAGS=-static -O1 -fno-stack-protector
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0 -extldflags=-static
flags:
- -trimpath
goos:
- linux
goarch:
- ppc64le
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/ppc64le (CGO)"
post:
- echo "Successfully built linux/ppc64le (CGO)"
- echo "---"
# Linux ARM (no CGO)
- id: linux-arm-nocgo
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos:
- linux
goarch:
- arm
goarm:
- "5"
- "6"
- "7"
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/arm (no CGO)"
post:
- echo "Successfully built linux/arm (no CGO)"
- echo "---"
# Linux S390X (no CGO)
- id: linux-s390x-nocgo
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos:
- linux
goarch:
- s390x
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/s390x (no CGO)"
post:
- echo "Successfully built linux/s390x (no CGO)"
- echo "---"
# Linux MIPS (no CGO)
- id: linux-mips-nocgo
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos:
- linux
goarch:
- mips
gomips:
- softfloat
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/mips (no CGO)"
post:
- echo "Successfully built linux/mips (no CGO)"
- echo "---"
# Linux MIPSLE (no CGO)
- id: linux-mipsle-nocgo
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos:
- linux
goarch:
- mipsle
gomips:
- softfloat
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/mipsle (no CGO)"
post:
- echo "Successfully built linux/mipsle (no CGO)"
- echo "---"
# Linux PPC64 (no CGO)
- id: linux-ppc64-nocgo
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
flags:
- -trimpath
goos:
- linux
goarch:
- ppc64
main: ./
binary: goecs
no_unique_dist_dir: true
hooks:
pre:
- echo "Starting build for linux/ppc64 (no CGO)"
post:
- echo "Successfully built linux/ppc64 (no CGO)"
- echo "---"
# # FreeBSD AMD64 (no CGO)
# - id: freebsd-amd64-nocgo
# env:
# - CGO_ENABLED=0
# ldflags:
# - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
# flags:
# - -trimpath
# goos:
# - freebsd
# goarch:
# - amd64
# main: ./
# binary: goecs
# no_unique_dist_dir: true
# hooks:
# pre:
# - echo "Starting build for freebsd/amd64 (no CGO)"
# post:
# - echo "Successfully built freebsd/amd64 (no CGO)"
# - echo "---"
# # FreeBSD ARM64 (no CGO)
# - id: freebsd-arm64-nocgo
# env:
# - CGO_ENABLED=0
# ldflags:
# - -s -w -X main.version={{.Version}} -X main.arch={{.Arch}} -checklinkname=0
# flags:
# - -trimpath
# goos:
# - freebsd
# goarch:
# - arm64
# main: ./
# binary: goecs
# no_unique_dist_dir: true
# hooks:
# pre:
# - echo "Starting build for freebsd/arm64 (no CGO)"
# post:
# - echo "Successfully built freebsd/arm64 (no CGO)"
# - echo "---"
universal_binaries: universal_binaries:
- name_template: "goecs" - name_template: "goecs"
replace: false replace: false
ids:
- darwin-amd64-cgo
- darwin-arm64-cgo
checksum: checksum:
name_template: "checksums.txt" name_template: "checksums.txt"
algorithm: sha256
disable: false
ids:
- linux-amd64-cgo
- linux-386-cgo
- linux-arm64-cgo
- linux-riscv64-cgo
- linux-mips64-cgo
- linux-mips64le-cgo
- linux-ppc64le-cgo
- windows-amd64-cgo
- windows-386-cgo
- darwin-amd64-cgo
- darwin-arm64-cgo
- linux-arm-nocgo
- linux-s390x-nocgo
- linux-mips-nocgo
- linux-mipsle-nocgo
- linux-ppc64-nocgo
# - freebsd-amd64-nocgo
# - freebsd-arm64-nocgo
extra_files:
- glob: "./goecs.sh"
snapshot: snapshot:
name_template: "goecs" name_template: "goecs"
archives: archives:
- name_template: "goecs_{{ .Os }}_{{ .Arch }}" - id: default
name_template: "goecs_{{ .Os }}_{{ .Arch }}"
format: zip format: zip
files: files:
- none* - none*
allow_different_binary_count: true
builds:
- linux-amd64-cgo
- linux-386-cgo
- linux-arm64-cgo
- linux-riscv64-cgo
- linux-mips64-cgo
- linux-mips64le-cgo
- linux-ppc64le-cgo
- windows-amd64-cgo
- windows-386-cgo
- darwin-amd64-cgo
- darwin-arm64-cgo
- linux-arm-nocgo
- linux-s390x-nocgo
- linux-mips-nocgo
- linux-mipsle-nocgo
- linux-ppc64-nocgo
# - freebsd-amd64-nocgo
# - freebsd-arm64-nocgo
changelog: changelog:
sort: asc sort: asc
filters: filters:
@@ -81,4 +522,4 @@ changelog:
- Merge pull request - Merge pull request
- Merge branch - Merge branch
- go mod tidy - go mod tidy
- New translations - New translations

View File

@@ -30,10 +30,10 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
| 编译支持的架构 | 测试支持的架构 | 编译支持的系统 | 测试支持的系统 | | 编译支持的架构 | 测试支持的架构 | 编译支持的系统 | 测试支持的系统 |
|---------------------------|-----------|---------|-----------| |---------------------------|-----------|---------|-----------|
| amd64 | amd64 | Linux | Linux | | amd64 | amd64 | Linux | Linux |
| arm | arm | Windows | Windows | | arm | | Windows | Windows |
| arm64 | arm64 | FreeBSD | FreeBSD | | arm64 | arm64 | FreeBSD | |
| 386 | 386 | OpenBSD | | | 386 | | OpenBSD | |
| mips | | MacOS | | | mips | | MacOS | MacOS |
| mipsle | | | | | mipsle | | | |
| s390x | s390x | | | | s390x | s390x | | |
| riscv64 | | | | | riscv64 | | | |
@@ -44,7 +44,6 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
### **待支持的系统** ### **待支持的系统**
| 系统 | 说明 | | 系统 | 说明 |
|-----|---------------------------| |-----|---------------------------|
| MacOS | 存在硬件测试 BUG 未修复,存在环境依赖未修复 |
| Android(arm64) | 存在权限问题未修复非安卓系统的ARM架构无问题 | | Android(arm64) | 存在权限问题未修复非安卓系统的ARM架构无问题 |
--- ---
@@ -63,6 +62,7 @@ Shell 版本:[https://github.com/spiritLHLS/ecs](https://github.com/spiritLHLS
- 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3) - 三网路由测试:基于 [NTrace-core](https://github.com/nxtrace/NTrace-core),二次开发至 [nt3](https://github.com/oneclickvirt/nt3)
- 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest) - 网速测试:基于 [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) 和 [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID) 数据,开发至 [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
- 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest) - 三网 Ping 值测试:借鉴 [ecsspeed](https://github.com/spiritLHLS/ecsspeed),二次开发至 [pingtest](https://github.com/oneclickvirt/pingtest)
- 支持root或admin环境下测试也支持非root或非admin环境下测试半支持离线环境下进行测试未支持无DNS环境下进行测试
**本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)** **本项目初次使用建议查看说明:[跳转](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
@@ -369,7 +369,7 @@ GOOS=darwin GOARCH=amd64 go build -o goecs_darwin
## 致谢 ## 致谢
感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) 等网站提供的API进行检测感谢互联网各网站提供的查询资源 感谢 [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [maxmind.com](https://www.maxmind.com/en/home) [cloudflare.com](https://www.cloudflare.com/) [ip.sb](https://ip.sb) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) [dkly.net](https://data.dkly.net) [virustotal.com](https://www.virustotal.com/) 等网站提供的API进行检测感谢互联网各网站提供的查询资源
感谢 感谢

View File

@@ -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 | | Supported for Compilation | Tested on | Supported OS for Compilation | Tested OS |
|---------------------------|-----------|------------------------------|-----------| |---------------------------|-----------|------------------------------|-----------|
| amd64 | amd64 | Linux | Linux | | amd64 | amd64 | Linux | Linux |
| arm | arm | Windows | Windows | | arm | | Windows | Windows |
| arm64 | arm64 | FreeBSD | FreeBSD | | arm64 | arm64 | FreeBSD | |
| 386 | 386 | OpenBSD | | | 386 | | OpenBSD | |
| mips | | MacOS | | | mips | | MacOS(darwin) | MacOS |
| mipsle | | | | | mipsle | | | |
| s390x | s390x | | | | s390x | s390x | | |
| riscv64 | | | | | riscv64 | | | |
@@ -41,7 +41,6 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
### **Systems Pending Support** ### **Systems Pending Support**
| OS | Notes | | OS | Notes |
|--------|-------------------------------------------------------------------------------------------------| |--------|-------------------------------------------------------------------------------------------------|
| MacOS | Hardware testing bugs and environment dependencies unresolved |
| Android(arm64) | Permission issues that are not fixed, no problems with ARM architecture for non-Android systems | | Android(arm64) | Permission issues that are not fixed, no problems with ARM architecture for non-Android systems |
--- ---
@@ -59,6 +58,7 @@ Shell version: [https://github.com/spiritLHLS/ecs/blob/main/README_EN.md](https:
- Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3) - Three-network route test: Modified from [NTrace-core](https://github.com/nxtrace/NTrace-core) to [nt3](https://github.com/oneclickvirt/nt3)
- Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest) - Speed test: Based on data from [speedtest.net](https://github.com/spiritLHLS/speedtest.net-CN-ID) and [speedtest.cn](https://github.com/spiritLHLS/speedtest.cn-CN-ID), developed to [oneclickvirt/speedtest](https://github.com/oneclickvirt/speedtest)
- Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest) - Three-network Ping test: Modified from [ecsspeed](https://github.com/spiritLHLS/ecsspeed) to [pingtest](https://github.com/oneclickvirt/pingtest)
- Support root or admin environment testing, also support non-root or non-admin environment testing, semi-support offline environment for testing, not support no DNS environment for testing
**For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)** **For first-time users of this project, it is recommended to check the instructions: [Jump to](https://github.com/oneclickvirt/ecs/blob/master/README_NEW_USER.md)**
@@ -363,7 +363,7 @@ Note that `goecs` allows you to specify CPU test method via parameters. The defa
## Thanks ## Thanks
Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [ip.sb](https://ip.sb) [cheervision.co](https://cheervision.co) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [virustotal.com](https://www.virustotal.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources. Thank [he.net](https://he.net) [bgp.tools](https://bgp.tools) [ipinfo.io](https://ipinfo.io) [maxmind.com](https://www.maxmind.com/en/home) [cloudflare.com](https://www.cloudflare.com/) [ip.sb](https://ip.sb) [scamalytics.com](https://scamalytics.com) [abuseipdb.com](https://www.abuseipdb.com/) [ip2location.com](https://ip2location.com/) [ip-api.com](https://ip-api.com) [ipregistry.co](https://ipregistry.co/) [ipdata.co](https://ipdata.co/) [ipgeolocation.io](https://ipgeolocation.io) [ipwhois.io](https://ipwhois.io) [ipapi.com](https://ipapi.com/) [ipapi.is](https://ipapi.is/) [ipqualityscore.com](https://www.ipqualityscore.com/) [bigdatacloud.com](https://www.bigdatacloud.com/) [dkly.net](https://data.dkly.net) [virustotal.com](https://www.virustotal.com/) and others for providing APIs for testing, and thanks to various websites on the Internet for providing query resources.
Thank Thank

View File

@@ -250,9 +250,9 @@ Load: Displays system load.
Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow. Virtualization Architecture: Shows what virtualization architecture the host machine uses. Generally speaking, the recommended order is `Dedicated > KVM > Xen` virtualization. Other virtualization will have performance losses, leading to shared/degraded performance during use. However, this is not definitive. Only dedicated servers have completely independent resource usage; other virtualization methods basically all have resource sharing, depending on whether the host machine seller has a conscience. The specific performance merits still depend on the specialized tests that follow.
NAT Type: Displays NAT type. Specifically recommended in order: `Full Cone > Restricted Cone > Port Restricted Cone > Symmetric`. When not detectable, it will show `Inconclusive`. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric. NAT Type: Displays NAT type. Specifically recommended in order: ```Full Cone > Restricted Cone > Port Restricted Cone > Symmetric```. When not detectable, it will show ```Inconclusive```. Generally speaking, if you're not using it for special purposes (related to special proxy and real-time communication needs), you don't need to pay attention to this metric.
TCP Acceleration Method: Generally this is the `cubic/bbr` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator. TCP Acceleration Method: Generally this is the ```cubic/bbr``` congestion control protocol. Generally speaking, using bbr for proxy servers can improve network speed; for ordinary purposes, you don't need to pay attention to this indicator.
IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool. IPv4/IPv6 ASN: Displays the ASN organization ID and name that the host machine's IP belongs to. The same IDC may have multiple ASNs, and an ASN may have multiple vendors selling servers with different IP segments. The specific upstream and downstream relationships are complex and can be further viewed using bgp.tool.
@@ -273,17 +273,17 @@ Supports selecting `GeekBench` and `Sysbench` for testing through command line p
| Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice | | Test Content | Only tests computational performance, based on prime number calculation | Covers multiple performance tests, weighted score calculation, but some tests are not commonly used in practice |
| Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing | | Applicable Scenarios | Suitable for quick testing, only tests computational performance | Suitable for comprehensive testing |
By default, `Sysbench` is used for testing, with the baseline roughly as follows: By default, ```Sysbench``` is used for testing, with the baseline roughly as follows:
CPU test single-core `Sysbench` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points. CPU test single-core ```Sysbench``` scores above 5000 can be considered first tier, 4000 to 5000 points second tier, with roughly one tier per 1000 points.
AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance. AMD's 7950x single-core full performance score is around 6500, AMD's 5950x single-core full performance score is around 5700, Intel's ordinary CPUs (E5 series, etc.) are around 1000~800, and single-core CPUs scoring below 500 can be said to have relatively poor performance.
Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud. Sometimes multi-core scores are the same as single-core scores, proving that the vendor is limiting program concurrent use of CPU, a typical example being Tencent Cloud.
Benchmarks for ```Sysbench`` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested. Benchmarks for ```Sysbench``` can be found in the [CPU Performance Ladder For Sysbench](https://sysbench.spiritlhl.net/) ladder chart, with specific scores regardless of the version of sysbench tested.
For `GeekBench` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each `GeekBench` version, so note which `GeekBench` version is being used when testing. For ```GeekBench``` baselines, see the [official website](https://browser.geekbench.com/processor-benchmarks/) ladder chart. Specific scores differ for each ```GeekBench``` version, so note which ```GeekBench``` version is being used when testing.
As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance. As an additional note, many things tested by `GeekBench` are not actually used in server usage processes, so the test is for reference only. Of course, `Sysbench` is very incomplete, but it can roughly compare CPU performance based on the most basic computational performance.

84
back/.goreleaser.old Normal file
View 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

View File

@@ -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
} }

View File

@@ -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)
} }

View File

@@ -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,23 +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.\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 != "" { if !strings.Contains(res, "\n") && res != "" {
res += "\n" res += "\n"
} }
fmt.Printf("%s", res) return
//fmt.Println("--------------------------------------------------")
} }

View File

@@ -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)
} }

22
go.mod
View File

@@ -1,25 +1,23 @@
module github.com/oneclickvirt/ecs module github.com/oneclickvirt/ecs
go 1.24.1 go 1.24.5
toolchain go1.24.2
require ( require (
github.com/imroc/req/v3 v3.50.0 github.com/imroc/req/v3 v3.50.0
github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841 github.com/oneclickvirt/CommonMediaTests v0.0.4-20250329123841
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053 github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053
github.com/oneclickvirt/backtrace v0.0.5-20250629024536 github.com/oneclickvirt/backtrace v0.0.5-20250629024536
github.com/oneclickvirt/basics v0.0.13-20250629023612 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/defaultset v0.0.2-20240624082446
github.com/oneclickvirt/disktest v0.0.8-20250425015826 github.com/oneclickvirt/disktest v0.0.8-20250701092629
github.com/oneclickvirt/gostun v0.0.3-20250329105202 github.com/oneclickvirt/gostun v0.0.3-20250329105202
github.com/oneclickvirt/memorytest v0.0.6-20250630141424 github.com/oneclickvirt/memorytest v0.0.8-20250716133749
github.com/oneclickvirt/nt3 v0.0.5-20250416131047 github.com/oneclickvirt/nt3 v0.0.5-20250416131047
github.com/oneclickvirt/pingtest v0.0.7-20250413051539 github.com/oneclickvirt/pingtest v0.0.8-20250701125637
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 github.com/oneclickvirt/portchecker v0.0.3-20250329125750
github.com/oneclickvirt/security v0.0.4-20250629033626 github.com/oneclickvirt/security v0.0.6-20250715102027
github.com/oneclickvirt/speedtest v0.0.9-20250521034111 github.com/oneclickvirt/speedtest v0.0.10-20250701123931
) )
require ( require (
@@ -61,8 +59,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nxtrace/NTrace-core v1.4.0 // indirect github.com/nxtrace/NTrace-core v1.4.0 // indirect
github.com/oneclickvirt/dd v0.0.1-20250406062523 // indirect github.com/oneclickvirt/dd v0.0.2-20250701085922 // indirect
github.com/oneclickvirt/fio v0.0.1-20250406060851 // indirect github.com/oneclickvirt/fio v0.0.2-20250701085933 // indirect
github.com/oneclickvirt/mbw v0.0.1-20250630140849 // indirect github.com/oneclickvirt/mbw v0.0.1-20250630140849 // indirect
github.com/onsi/ginkgo/v2 v2.22.1 // indirect github.com/onsi/ginkgo/v2 v2.22.1 // indirect
github.com/oschwald/maxminddb-golang v1.13.1 // indirect github.com/oschwald/maxminddb-golang v1.13.1 // indirect

36
go.sum
View File

@@ -103,34 +103,34 @@ github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053 h1:Ug8kySZR1weRUcsnGO
github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc= github.com/oneclickvirt/UnlockTests v0.0.27-20250628125053/go.mod h1:yXWIZB6iLS88pEd9m4QJi1GENn+7I91zA72y5ONz2Oc=
github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs= github.com/oneclickvirt/backtrace v0.0.5-20250629024536 h1:caHCa0DHmbYWBFN1bqKxpvPnN0wOxDEqJv1VDvDdLWs=
github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI= github.com/oneclickvirt/backtrace v0.0.5-20250629024536/go.mod h1:5AH00bo41hH3d2/JVuCTlBkZUs3AXX4nlKVXb6piZcI=
github.com/oneclickvirt/basics v0.0.13-20250629023612 h1:cQg+cGBt2NMRrjhJPH+CbevZrwtMU8pIZIY2Lp6zmt4= github.com/oneclickvirt/basics v0.0.15-20250714163009 h1:7I1lU7N91kClw6Cb6o+vGfScc/HngrjhsaaW10AbBFs=
github.com/oneclickvirt/basics v0.0.13-20250629023612/go.mod h1:yN1IEOXN6v/GJqJSA70Pooo6nXBI/6rq72vTY72wJMQ= 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.11-20250716031513 h1:6xP/QCxwI6jTLmarIY3UIgaeOL2u94hzjVyG4yNa4WM=
github.com/oneclickvirt/cputest v0.0.10-20250404151448/go.mod h1:MmaHN9+XMntI3rLycwj8Ne31fG18IfNoa8N2utDK1CY= github.com/oneclickvirt/cputest v0.0.11-20250716031513/go.mod h1:vjlH8tkPFft1tlLOpeNskXVvurxkHaJ3+dgFxQGLXY4=
github.com/oneclickvirt/dd v0.0.1-20250406062523 h1:jegTww4fuoFEqwFozvGJEqUNI/5ew3QJ0XcKZZ/zuTs= github.com/oneclickvirt/dd v0.0.2-20250701085922 h1:WiWZwcnCPhRc8hLZdvkjD2kOEpnqn1S31z1j0x3V4l0=
github.com/oneclickvirt/dd v0.0.1-20250406062523/go.mod h1:tImu9sPTkLWo2tf1dEN1xQzrylWKauj9hbU8PHfyAeU= 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= github.com/oneclickvirt/defaultset v0.0.2-20240624082446 h1:5Pg3mK/u/vQvSz7anu0nxzrNdELi/AcDAU1mMsmPzyc=
github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E= github.com/oneclickvirt/defaultset v0.0.2-20240624082446/go.mod h1:e9Jt4tf2sbemCtc84/XgKcHy9EZ2jkc5x2sW1NiJS+E=
github.com/oneclickvirt/disktest v0.0.8-20250425015826 h1:bwVg0zysB3uCwQV+KIIQpuq2IJXWdIcdjD2+FiKPo5w= github.com/oneclickvirt/disktest v0.0.8-20250701092629 h1:B/gA6SOr4qL5pQmVpHl9m5bn3paDcL7wJ1SZ7aY66M8=
github.com/oneclickvirt/disktest v0.0.8-20250425015826/go.mod h1:sqVu6HwbnLmbnRj4389Xn08c301IhLnWCcbaEk2WzEc= github.com/oneclickvirt/disktest v0.0.8-20250701092629/go.mod h1:6YCvGr+Z0tvcP4Ue8bezZqm/GqS/dSyEnSUhvS3Q03o=
github.com/oneclickvirt/fio v0.0.1-20250406060851 h1:b7xHKpPmU4q0NmvigRCEr3tQuAV/83ZIAGtHycLegw8= github.com/oneclickvirt/fio v0.0.2-20250701085933 h1:4P7QcOTxbqyx5DhHdFvyeRSsdNajSo9l/H2XK0vICIc=
github.com/oneclickvirt/fio v0.0.1-20250406060851/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE= github.com/oneclickvirt/fio v0.0.2-20250701085933/go.mod h1:NIq+XYTey68KNERGIy/oRDlzpwLzBVoHOCiqX8didsE=
github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTjqOOaWvufr5oras6cFtM= github.com/oneclickvirt/gostun v0.0.3-20250329105202 h1:aJ6E91Lp94lq8iWRcCaxpXTjqOOaWvufr5oras6cFtM=
github.com/oneclickvirt/gostun v0.0.3-20250329105202/go.mod h1:f7DPEXAxbmwXSW33dbxtb0/KzqvOBWhTs2Or5xBerQA= 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 h1:p6RMhOPBnQKAm9+VEQ2axAFsidrdSdrhXMyheIyv2a8=
github.com/oneclickvirt/mbw v0.0.1-20250630140849/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y= github.com/oneclickvirt/mbw v0.0.1-20250630140849/go.mod h1:0Vq6NRpyLmGUdfHfL3uDcFsuZhi7KlG+OCs5ky2757Y=
github.com/oneclickvirt/memorytest v0.0.6-20250630141424 h1:nFDaWWr9BR7uGrpDBVNhzIbQDqy0VFzSMboE8yIZFXY= github.com/oneclickvirt/memorytest v0.0.8-20250716133749 h1:/z5lfsxRo5MHPfTAAKLk9vD0sQ4JDw5aEe21u6rQdfw=
github.com/oneclickvirt/memorytest v0.0.6-20250630141424/go.mod h1:7xMacjQobvFAtODht2hxTsB9hM2IFS7vZk3gxx+bsjo= 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 h1:KL0xowq19cW+FMBGMJxdqpRNoeyR+eEmb+jYSubmlTk=
github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ= github.com/oneclickvirt/nt3 v0.0.5-20250416131047/go.mod h1:CVsDJEaIdyyZHn3WKbhU8Wn6GOfmBNvJlC/dDLRqcSQ=
github.com/oneclickvirt/pingtest v0.0.7-20250413051539 h1:mYOsEmMtwKr40hwM2NimVLpnbR2cjwuOh1c/9fQr2Dw= github.com/oneclickvirt/pingtest v0.0.8-20250701125637 h1:J28Ai5miTq1J0I4gdT8rewJSd3LwzD90L/bNiiaKfHM=
github.com/oneclickvirt/pingtest v0.0.7-20250413051539/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8= github.com/oneclickvirt/pingtest v0.0.8-20250701125637/go.mod h1:d3Ntx5m9lMll3a/k3+2B+5emj//vgDh4/NHTxs2qQE8=
github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk= github.com/oneclickvirt/portchecker v0.0.3-20250329125750 h1:TTNL0pnQlRsn046kW59I/9UWRpihttFHWnU7Ixycggk=
github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k= github.com/oneclickvirt/portchecker v0.0.3-20250329125750/go.mod h1:HQxSTrqM8/QFqHMTBZ7S8H9eEO5FkUXU1eb7ZX5Mk+k=
github.com/oneclickvirt/security v0.0.4-20250629033626 h1:DEchQ7WKKz4CzQpMlweoqA993BGncvmp1rL1ICNDJ2g= github.com/oneclickvirt/security v0.0.6-20250715102027 h1:lOaFxORBT/9nBlof7EU36YP+ZIbqkhCLGyOpYQTY1qs=
github.com/oneclickvirt/security v0.0.4-20250629033626/go.mod h1:/5eVnZLvP7RUjwhoI6d8iIMP7msbkHC5So3ZxM+A7Zg= github.com/oneclickvirt/security v0.0.6-20250715102027/go.mod h1:SDFBXV0sDo8pSIcGaaJ2gfCCW+NKy4pO1q9i4SIX2jc=
github.com/oneclickvirt/speedtest v0.0.9-20250521034111 h1:yygDk+s5qFhPMDRzdMfyopm1xU512peNqY6WYyvYcfY= github.com/oneclickvirt/speedtest v0.0.10-20250701123931 h1:IMUM0F3trrlCdl9JTO+FBIJ9zc8mbi+oyd66IkO/8mI=
github.com/oneclickvirt/speedtest v0.0.9-20250521034111/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI= github.com/oneclickvirt/speedtest v0.0.10-20250701123931/go.mod h1:zd5ZgIGslmtQLQehEfRjyumlvgDHTpCSMchKfKXoASI=
github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM= github.com/onsi/ginkgo/v2 v2.22.1 h1:QW7tbJAUDyVDVOM5dFa7qaybo+CRfR7bemlQUN6Z8aM=
github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM= github.com/onsi/ginkgo/v2 v2.22.1/go.mod h1:S6aTpoRsSq2cZOd+pssHAlKW/Q/jZt6cPrPlnj4a1xM=
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw= github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=

197
goecs.go
View File

@@ -39,7 +39,7 @@ import (
) )
var ( var (
ecsVersion = "v0.1.45" ecsVersion = "v0.1.58"
menuMode bool menuMode bool
onlyChinaTest bool onlyChinaTest bool
input, choice string input, choice string
@@ -347,14 +347,13 @@ func setUnlockOnlyTestStatus() {
} }
func setHardwareOnlyTestStatus(preCheck utils.NetCheckResult) { func setHardwareOnlyTestStatus(preCheck utils.NetCheckResult) {
_ = preCheck
basicStatus = true basicStatus = true
cpuTestStatus = true cpuTestStatus = true
memoryTestStatus = true memoryTestStatus = true
diskTestStatus = true diskTestStatus = true
if preCheck.Connected { securityTestStatus = false
securityTestStatus = false autoChangeDiskTestMethod = false
autoChangeDiskTestMethod = false
}
} }
func setIPQualityTestStatus() { func setIPQualityTestStatus() {
@@ -397,65 +396,77 @@ 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()
*output = utils.PrintAndCapture(func() { timeInfo := utils.PrintAndCapture(func() {
utils.PrintCenteredTitle("", width) utils.PrintCenteredTitle("", width)
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds) if language == "zh" {
fmt.Printf("Current Time : %s\n", currentTime) fmt.Printf("花费 : %d 分 %d 秒\n", minutes, seconds)
fmt.Printf("时间 : %s\n", currentTime)
} else {
fmt.Printf("Cost Time : %d min %d sec\n", minutes, seconds)
fmt.Printf("Current Time : %s\n", currentTime)
}
utils.PrintCenteredTitle("", width) utils.PrintCenteredTitle("", width)
}, tempOutput, *output) }, "", "")
*output += timeInfo
finalOutput := *output
outputMutex.Unlock() outputMutex.Unlock()
resultChan := make(chan struct { resultChan := make(chan struct {
httpURL string httpURL string
httpsURL string httpsURL string
}, 1) }, 1)
go func() { if enabelUpload {
outputMutex.Lock() go func() {
finalOutput := *output httpURL, httpsURL := utils.ProcessAndUpload(finalOutput, filePath, enabelUpload)
outputMutex.Unlock() resultChan <- struct {
httpURL, httpsURL := utils.ProcessAndUpload(finalOutput, filePath, enabelUpload) httpURL string
resultChan <- struct { httpsURL string
httpURL string }{httpURL, httpsURL}
httpsURL string uploadDone <- true
}{httpURL, httpsURL} }()
uploadDone <- true select {
}() case result := <-resultChan:
select { if result.httpURL != "" || result.httpsURL != "" {
case result := <-resultChan: if language == "en" {
if result.httpURL != "" || result.httpsURL != "" { fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
if language == "en" { } else {
fmt.Printf("Upload successfully!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL) fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
} else { }
fmt.Printf("上传成功!\nHttp URL: %s\nHttps URL: %s\n", result.httpURL, result.httpsURL)
} }
time.Sleep(100 * time.Millisecond)
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
os.Exit(0)
case <-time.After(30 * time.Second):
if language == "en" {
fmt.Println("Upload timeout, program exit")
} else {
fmt.Println("上传超时,程序退出")
}
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
os.Exit(1)
} }
time.Sleep(100 * time.Millisecond) } else {
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...") fmt.Println("Press Enter to exit...")
fmt.Scanln() fmt.Scanln()
} }
os.Exit(0) os.Exit(0)
case <-time.After(30 * time.Second):
if language == "en" {
fmt.Println("Upload timeout, program exit")
} else {
fmt.Println("上传超时,程序退出")
}
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...")
fmt.Scanln()
}
os.Exit(1)
} }
} }
os.Exit(0) os.Exit(0)
} }
} }
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() {
@@ -478,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)
@@ -511,15 +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.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 {
@@ -556,57 +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.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.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.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.Lock()
defer outputMutex.Unlock()
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if language == "zh" { if language == "zh" {
if commTestStatus && !onlyChinaTest { if commTestStatus && !onlyChinaTest {
@@ -627,6 +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.Lock()
defer outputMutex.Unlock()
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if securityTestStatus { if securityTestStatus {
if language == "zh" { if language == "zh" {
@@ -640,6 +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.Lock()
defer outputMutex.Unlock()
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if emailTestStatus { if emailTestStatus {
wg2.Wait() wg2.Wait()
@@ -654,6 +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.Lock()
defer outputMutex.Unlock()
output = utils.PrintAndCapture(func() { output = utils.PrintAndCapture(func() {
if backtraceStatus && !onlyChinaTest { if backtraceStatus && !onlyChinaTest {
utils.PrintCenteredTitle("三网回程线路检测", width) utils.PrintCenteredTitle("三网回程线路检测", width)
@@ -680,6 +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.Lock()
defer outputMutex.Unlock()
return utils.PrintAndCapture(func() { return utils.PrintAndCapture(func() {
if speedTestStatus { if speedTestStatus {
utils.PrintCenteredTitle("就近节点测速", width) utils.PrintCenteredTitle("就近节点测速", width)
@@ -700,6 +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.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)
@@ -711,6 +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.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())
@@ -754,6 +794,9 @@ func main() {
handleMenuMode(preCheck) handleMenuMode(preCheck)
} }
handleLanguageSpecificSettings() handleLanguageSpecificSettings()
if !preCheck.Connected {
enabelUpload = false
}
var ( var (
wg1, wg2, wg3 sync.WaitGroup wg1, wg2, wg3 sync.WaitGroup
basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string basicInfo, securityInfo, emailInfo, mediaInfo, ptInfo string
@@ -767,13 +810,15 @@ 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")
} }
handleUploadResults(output) if preCheck.Connected {
handleUploadResults(output)
}
finish = true finish = true
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
fmt.Println("Press Enter to exit...") fmt.Println("Press Enter to exit...")

View File

@@ -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.44" ECS_VERSION="0.1.55"
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.44" _yellow "Unable to get version info, using default version 0.1.55"
ECS_VERSION="0.1.44" ECS_VERSION="0.1.55"
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

View File

@@ -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,17 +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" // res = "Unsupported test method, switch to use dd test.\n"
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
} }

View File

@@ -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)
} }