You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#!/bin/bash
PROJECT_ROOT = $( cd " $( dirname " $0 " ) /.. " ; pwd )
COMPILER = " $PROJECT_ROOT /build/bin/compiler "
TEST_CASE_DIR = " $PROJECT_ROOT /test/test_case "
TEST_RESULT_DIR = " $PROJECT_ROOT /test/test_result/ir "
if [ ! -x " $COMPILER " ] ; then
echo " 错误:编译器不存在或不可执行: $COMPILER "
echo "请先构建项目: cmake --build build -j\$(nproc)"
exit 1
fi
mkdir -p " $TEST_RESULT_DIR "
pass_count = 0
fail_count = 0
failed_cases = ( )
echo "=== 开始测试 IR 生成 ==="
echo ""
while IFS = read -r test_file; do
relative_path = $( realpath --relative-to= " $TEST_CASE_DIR " " $test_file " )
output_file = " $TEST_RESULT_DIR / ${ relative_path %.sy } .ll "
mkdir -p " $( dirname " $output_file " ) "
echo -n " 测试: $relative_path ... "
" $COMPILER " --emit-ir " $test_file " > " $output_file " 2>& 1
exit_code = $?
if [ $exit_code -eq 0 ] && [ -s " $output_file " ] && ! grep -q '\[error\]' " $output_file " ; then
echo "通过"
pass_count = $(( pass_count + 1 ))
else
echo "失败"
fail_count = $(( fail_count + 1 ))
failed_cases += ( " $relative_path " )
echo " 错误信息已保存到: $output_file "
fi
done < <( find " $TEST_CASE_DIR " -name "*.sy" | sort)
echo ""
echo "=== 测试完成 ==="
echo " 通过: $pass_count "
echo " 失败: $fail_count "
echo " 结果保存在: $TEST_RESULT_DIR "
if [ ${# failed_cases [@] } -gt 0 ] ; then
echo ""
echo "=== 失败的用例 ==="
for f in " ${ failed_cases [@] } " ; do
echo " - $f "
done
exit 1
fi