49 lines
1.6 KiB
Bash
49 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
# 定义输入目录
|
|
input_dir="."
|
|
|
|
# 获取当前目录下的所有符合条件的可执行文件,并按前缀数字升序排序
|
|
executable_files=$(ls "$input_dir" | grep -E '^[0-9]+_.*' | grep -E '_clang$|_sysyc$' | sort -t '_' -k1,1n)
|
|
|
|
# 用于存储前缀数字和返回值
|
|
declare -A clang_results
|
|
declare -A sysyc_results
|
|
|
|
# 遍历所有符合条件的可执行文件
|
|
for file in $executable_files; do
|
|
# 提取文件名前缀和后缀
|
|
prefix=$(echo "$file" | cut -d '_' -f 1)
|
|
suffix=$(echo "$file" | cut -d '_' -f 2)
|
|
|
|
# 检查是否已经处理过该前缀的两个文件
|
|
if [[ ${clang_results["$prefix"]} && ${sysyc_results["$prefix"]} ]]; then
|
|
continue
|
|
fi
|
|
|
|
# 执行可执行文件并捕获返回值
|
|
echo "Executing: $file"
|
|
"./$file"
|
|
ret_code=$?
|
|
|
|
# 明确记录返回值
|
|
echo "Return code for $file: $ret_code"
|
|
|
|
# 根据后缀存储返回值
|
|
if [[ "$suffix" == "clang" ]]; then
|
|
clang_results["$prefix"]=$ret_code
|
|
elif [[ "$suffix" == "sysyc" ]]; then
|
|
sysyc_results["$prefix"]=$ret_code
|
|
fi
|
|
|
|
# 如果同一个前缀的两个文件都已执行,比较它们的返回值
|
|
if [[ ${clang_results["$prefix"]} && ${sysyc_results["$prefix"]} ]]; then
|
|
clang_ret=${clang_results["$prefix"]}
|
|
sysyc_ret=${sysyc_results["$prefix"]}
|
|
if [[ "$clang_ret" -ne "$sysyc_ret" ]]; then
|
|
echo -e "\e[31mWARNING: Return codes differ for prefix $prefix: _clang=$clang_ret, _sysyc=$sysyc_ret\e[0m"
|
|
else
|
|
echo "Return codes match for prefix $prefix: $clang_ret"
|
|
fi
|
|
fi
|
|
done |