test(test)修改测试脚本run.sh用于批量测试ir生成结果

mxr 1 month ago
parent e79d677644
commit f977583b6e

@ -21,6 +21,13 @@ if [ ! -f "$COMPILER" ]; then
exit 1
fi
# 检查 verify_ir.sh 是否存在(可选)
VERIFY_SCRIPT="./scripts/verify_ir.sh"
if [ ! -f "$VERIFY_SCRIPT" ]; then
echo "错误: 验证脚本 $VERIFY_SCRIPT 未找到"
exit 1
fi
# 如果指定了单个文件,检查文件是否存在
if [ -n "$1" ] && [ ! -f "$1" ]; then
echo "错误: 文件 $1 不存在"
@ -32,10 +39,11 @@ fi
# 计数器
total=0
emit_ir=0
passed=0
failed=0
echo "开始测试 ir out 解析..."
echo "开始测试 IR 生成与验证..."
echo "输出将保存到 $RESULT_FILE"
echo "------------------------"
@ -58,28 +66,43 @@ for file in "${TEST_FILES[@]}"; do
echo "========== $file ==========" >> "$RESULT_FILE"
# 1. 运行编译器生成 IR
if [ $VERBOSE -eq 1 ]; then
# "$COMPILER" --emit-parse-tree "$file" 2>&1 | tee -a "$RESULT_FILE"
"$COMPILER" --emit-ir "$file" 2>&1 | tee -a "$RESULT_FILE"
result=${PIPESTATUS[0]}
result1=${PIPESTATUS[0]}
else
# "$COMPILER" --emit-parse-tree "$file" >> "$RESULT_FILE" 2>&1
"$COMPILER" --emit-ir "$file" >> "$RESULT_FILE" 2>&1
result=$?
result1=$?
fi
echo "" >> "$RESULT_FILE"
# 2. 运行验证脚本
if [ $VERBOSE -eq 1 ]; then
"$VERIFY_SCRIPT" "$file" test/test_result/function/ir --run 2>&1 | tee -a "$RESULT_FILE"
result2=${PIPESTATUS[0]}
else
"$VERBOSE" "$VERIFY_SCRIPT" "$file" test/test_result/function/ir --run >> "$RESULT_FILE" 2>&1
result2=$?
fi
echo "" >> "$RESULT_FILE"
if [ $result -eq 0 ]; then
# 判断整体通过(两个命令都成功)
if [ $result1 -eq 0 ]; then
if [ $VERBOSE -eq 0 ]; then
echo "通过"
echo "生成ir"
fi
((passed++))
if [ $result2 -eq 0 ]; then
if [ $VERBOSE -eq 0 ]; then
echo "通过"
fi
((passed++))
fi
((emit_ir++))
else
if [ $VERBOSE -eq 0 ]; then
echo "失败"
else
echo ">>> 解析失败: $file"
echo ">>> 测试失败: $file (compiler exit: $result1, verify exit: $result2)"
fi
((failed++))
fi
@ -87,6 +110,7 @@ done
echo "------------------------"
echo "总计: $total"
echo "生成: $emit_ir"
echo "通过: $passed"
echo "失败: $failed"
echo "详细输出已保存至 $RESULT_FILE"
@ -95,4 +119,4 @@ if [ $failed -gt 0 ]; then
exit 1
else
exit 0
fi
fi
Loading…
Cancel
Save