增加自动测试框架&优化多arch支持

This commit is contained in:
zhangzheng
2024-09-17 11:38:12 +08:00
parent aaad929523
commit 354abcd569
72 changed files with 863 additions and 446 deletions

View File

@@ -11,6 +11,12 @@ export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/ar
export BOARD=STM32F205
export CROSS_COMPILE_NAME=arm-none-eabi-
set -e
if [ -z "$1" ]; then
export MKRTOS_TEST_MODE="normal"
else
export MKRTOS_TEST_MODE=$1
fi
set -e -x
cmake -G Ninja -B build/$KNL .
cd build/$KNL && ninja

View File

@@ -12,7 +12,12 @@ export TOOLCHAIN_LIB=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/li
# export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
export BOARD=aarch64_qemu
export CROSS_COMPILE_NAME=aarch64-none-elf-
if [ -z "$1" ]; then
export MKRTOS_TEST_MODE="normal"
else
export MKRTOS_TEST_MODE=$1
fi
set -e
set -e -x
cmake -G Ninja -B build/$KNL .
cd build/$KNL && ninja

49
mkrtos_script/build_test.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
set -e
# 定义超时时间(秒)
TIMEOUT=30
# 定义成功标志
SUCCESS_MSG="MKRTOS test ok."
# 运行命令并检查输出的函数
run_and_check() {
local cmd="$1"
local timeout="$2"
echo "Running: $cmd"
# 使用管道和 grep 来监听输出
timeout --preserve-status --foreground $timeout $cmd | while IFS= read -r line
do
echo "$line"
if [[ "$line" == *"$SUCCESS_MSG"* ]]; then
echo "Success message detected. Exiting..."
kill -INT $$
return 0;
fi
done
# 检查 timeout 命令的退出状态
if [ $? -eq 124 ]; then
echo "Test timed out: $cmd"
exit -1
fi
return 0
}
# 清理
./mkrtos_script/clean.sh
./mkrtos_script/build_qemu_aarch64.sh test
# 运行测试
run_and_check "./mkrtos_script/run_aarch64_qemu.sh" "$TIMEOUT"
./mkrtos_script/clean.sh
./mkrtos_script/build_f2.sh test
run_and_check "./mkrtos_script/run_m3.sh" "$TIMEOUT"
# ./mkrtos_script/clean.sh
# run_and_check "./mkrtos_script/build_swm34s.sh test" "$TIMEOUT"
echo "All tests completed."

View File

@@ -1,4 +1,4 @@
#!/bin/bash
set -e
# set -e
rm -r $PWD/build

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# netduino2
if [ -z "$1"]; then
if [ -z "$1" ]; then
echo "请输入板卡名字,使用默认板卡:"
echo "netduino2"
set $1 "netduino2"