#!/bin/bash
set -e
ST_DIR="test/st"
if [[ $(basename $(pwd)) != "msmonitor" ]]; then
if [[ -d "msmonitor" ]]; then
echo "进入msmonitor目录"
cd msmonitor
else
echo "错误: 请在msmonitor目录或其父目录下运行此脚本"
exit 1
fi
fi
export LD_LIBRARY_PATH=third_party/dynolog/third_party/prometheus-cpp/_build/lib:$LD_LIBRARY_PATH
echo "执行系统测试 (test/st 目录)"
if [[ ! -d "$ST_DIR" ]]; then
echo "错误: 系统测试目录 $ST_DIR 不存在"
exit 1
fi
st_files=$(find $ST_DIR -name "test*.py")
if [[ -z "$st_files" ]]; then
echo "错误: 没有找到测试文件"
exit 1
fi
for test_file in $st_files; do
echo "==============================================="
echo "执行测试: $test_file"
python "$test_file"
result=$?
if [ $result -eq 0 ]; then
echo "[通过] 测试成功: $test_file"
else
echo "[失败] 测试失败: $test_file"
echo "==============================================="
echo "测试执行中止: 发现失败的测试"
exit 1
fi
done
echo "==============================================="
echo "系统测试执行完毕"
echo "[成功] 所有测试通过"
exit 0