From 327e7198b6c8149f83fa2eb1cbe488ac3995179d Mon Sep 17 00:00:00 2001 From: mxr <> Date: Thu, 2 Apr 2026 12:10:22 +0800 Subject: [PATCH] =?UTF-8?q?test(test)=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=84=9A=E6=9C=ACrun.sh=E7=94=A8=E4=BA=8E=E6=B5=8B=E8=AF=95mir?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/run.sh b/run.sh index cc3bc5b..bf1a9d6 100755 --- a/run.sh +++ b/run.sh @@ -28,6 +28,12 @@ if [ ! -f "$VERIFY_SCRIPT" ]; then exit 1 fi +VERIFY_SCRIPT_ASM="./scripts/verify_asm.sh" +if [ ! -f "$VERIFY_SCRIPT_ASM" ]; then + echo "错误: 验证脚本 $VERIFY_SCRIPT_ASM 未找到" + exit 1 +fi + # 如果指定了单个文件,检查文件是否存在 if [ -n "$1" ] && [ ! -f "$1" ]; then echo "错误: 文件 $1 不存在" @@ -40,7 +46,9 @@ fi # 计数器 total=0 emit_ir=0 -passed=0 +ir_passed=0 +emit_asm=0 +asm_passed=0 failed=0 echo "开始测试 IR 生成与验证..." @@ -86,6 +94,26 @@ for file in "${TEST_FILES[@]}"; do fi echo "" >> "$RESULT_FILE" + # 3. 运行编译器生成 asm + if [ $VERBOSE -eq 1 ]; then + "$COMPILER" --emit-asm "$file" 2>&1 | tee -a "$RESULT_FILE" + result3=${PIPESTATUS[0]} + else + "$COMPILER" --emit-asm "$file" >> "$RESULT_FILE" 2>&1 + result3=$? + fi + echo "" >> "$RESULT_FILE" + + # 4. 运行验证脚本 + if [ $VERBOSE -eq 1 ]; then + "$VERIFY_SCRIPT_ASM" "$file" test/test_result/function/asm --run 2>&1 | tee -a "$RESULT_FILE" + result4=${PIPESTATUS[0]} + else + "$VERIFY_SCRIPT_ASM" "$file" test/test_result/function/asm --run >> "$RESULT_FILE" 2>&1 + result4=$? + fi + echo "" >> "$RESULT_FILE" + # 判断整体通过(两个命令都成功) if [ $result1 -eq 0 ]; then if [ $VERBOSE -eq 0 ]; then @@ -93,26 +121,37 @@ for file in "${TEST_FILES[@]}"; do fi if [ $result2 -eq 0 ]; then if [ $VERBOSE -eq 0 ]; then - echo "通过" + echo "ir通过" fi - ((passed++)) + ((ir_passed++)) fi ((emit_ir++)) else + echo "ir失败" + fi + + if [ $result3 -eq 0 ]; then if [ $VERBOSE -eq 0 ]; then - echo "失败" - else - echo ">>> 测试失败: $file (compiler exit: $result1, verify exit: $result2)" + echo "生成asm" fi - ((failed++)) + if [ $result4 -eq 0 ]; then + if [ $VERBOSE -eq 0 ]; then + echo "asm通过" + fi + ((asm_passed++)) + fi + ((emit_asm++)) + else + echo "asm失败" fi done echo "------------------------" echo "总计: $total" -echo "生成: $emit_ir" -echo "通过: $passed" -echo "失败: $failed" +echo "ir生成: $emit_ir" +echo "ir通过: $ir_passed" +echo "asm生成: $emit_asm" +echo "asm通过: $asm_passed" echo "详细输出已保存至 $RESULT_FILE" if [ $failed -gt 0 ]; then