Update nodeloc_vps_autotest_response.sh

This commit is contained in:
Jensfrank 2024-06-28 00:19:00 +08:00 committed by GitHub
parent 4d0f5572ae
commit 981b538434
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,14 +91,7 @@ show_welcome() {
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "1. Yabs"
echo "2. 融合怪"
echo "3. IP质量"
echo "4. 流媒体解锁"
echo "5. 响应测试"
echo "6. 多线程测试"
echo "7. 单线程测试"
echo "8. 回程路由"
echo "响应测试"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
@ -108,12 +101,6 @@ show_welcome() {
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 去除响应板块ANSI转义码
response_process_output() {
local input="$1"
echo "$input" | sed 's/\x1b\[[0-9;]*m//g'
}
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
@ -122,6 +109,12 @@ run_and_capture() {
echo "$command_output"
}
# 去除响应板块ANSI转义码
response_process_output() {
local input="$1"
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g'
}
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
@ -137,9 +130,11 @@ run_all_tests() {
# 格式化结果为 Markdown
format_results() {
# 处理响应测试结果
local processed_response_result
processed_response_result=$(response_process_output "$response_result")
# 处理响应测试结果
local processed_response_result
processed_response_result=$(response_process_output "$response_result")
result="[tabs]
[tab=\"响应\"]
\`\`\`
@ -149,7 +144,7 @@ $processed_response_result
[/tabs]"
echo "$result" > results.md
echo -e "${GREEN}结果已保存到 results.md 文件中。${NC}"
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
@ -157,9 +152,9 @@ main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${GREEN}所有测试完成。点击屏幕任意位置复制结果${NC}"
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用${NC}"
read -n 1 -s
echo "最终结果文件内容:" >&2
echo "最终测试结果如下:" >&2
cat results.md >&2
}