Add full automotive RTOS project
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers, middleware (CAN stack, diagnostics, safety), applications, board support, build/test tooling, and documentation.
This commit is contained in:
Executable
+169
@@ -0,0 +1,169 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
# Run tests for Automotive RTOS
|
||||
#==============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test directories
|
||||
TEST_DIR="${PROJECT_ROOT}/tests"
|
||||
BUILD_TEST_DIR="${PROJECT_ROOT}/build/tests"
|
||||
|
||||
# Test results
|
||||
PASSED=0
|
||||
FAILED=0
|
||||
TOTAL=0
|
||||
|
||||
# Print banner
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Automotive RTOS Test Runner${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Function to compile and run a test
|
||||
run_test_file() {
|
||||
local test_file=$1
|
||||
local test_name=$(basename "${test_file}" .c)
|
||||
local test_binary="${BUILD_TEST_DIR}/${test_name}"
|
||||
|
||||
TOTAL=$((TOTAL + 1))
|
||||
|
||||
echo -e "${YELLOW}Compiling ${test_name}...${NC}"
|
||||
|
||||
# Try to compile
|
||||
if gcc \
|
||||
-I"${PROJECT_ROOT}/kernel/include" \
|
||||
-I"${PROJECT_ROOT}/drivers/include" \
|
||||
-I"${PROJECT_ROOT}/middleware" \
|
||||
-I"${PROJECT_ROOT}/config" \
|
||||
-I"${PROJECT_ROOT}/tests" \
|
||||
"${test_file}" \
|
||||
-o "${test_binary}" \
|
||||
-Wall -Wextra -g -O0 2>"${BUILD_TEST_DIR}/${test_name}_compile.log"; then
|
||||
|
||||
echo -e "${GREEN}✓ Compilation successful${NC}"
|
||||
echo -e "${YELLOW}Running ${test_name}...${NC}"
|
||||
|
||||
# Run test
|
||||
if timeout 30 "${test_binary}" >"${BUILD_TEST_DIR}/${test_name}_run.log" 2>&1; then
|
||||
echo -e "${GREEN}✓ ${test_name} passed${NC}"
|
||||
PASSED=$((PASSED + 1))
|
||||
else
|
||||
echo -e "${RED}✗ ${test_name} failed${NC}"
|
||||
echo -e "${YELLOW} See log: ${BUILD_TEST_DIR}/${test_name}_run.log${NC}"
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ ${test_name} compilation failed${NC}"
|
||||
echo -e "${YELLOW} See log: ${BUILD_TEST_DIR}/${test_name}_compile.log${NC}"
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to run all tests in a directory
|
||||
run_test_directory() {
|
||||
local dir=$1
|
||||
local dir_name=$2
|
||||
|
||||
echo -e "${BLUE}Running ${dir_name}${NC}"
|
||||
echo -e "${BLUE}----------------------------------------${NC}"
|
||||
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo -e "${YELLOW}No ${dir_name} found${NC}"
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
|
||||
for test_file in "$dir"/test_*.c; do
|
||||
if [ -f "$test_file" ]; then
|
||||
run_test_file "$test_file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
# Parse arguments
|
||||
local run_unit=true
|
||||
local run_integration=true
|
||||
local run_system=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--unit)
|
||||
run_integration=false
|
||||
shift
|
||||
;;
|
||||
--integration)
|
||||
run_unit=false
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
run_system=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo " --unit Run unit tests only"
|
||||
echo " --integration Run integration tests only"
|
||||
echo " --all Run all tests"
|
||||
echo " -h, --help Show this help"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Create build test directory
|
||||
mkdir -p "${BUILD_TEST_DIR}"
|
||||
|
||||
# Run tests
|
||||
if [ "$run_unit" = true ]; then
|
||||
run_test_directory "${TEST_DIR}/unit" "Unit Tests"
|
||||
fi
|
||||
|
||||
if [ "$run_integration" = true ]; then
|
||||
run_test_directory "${TEST_DIR}/integration" "Integration Tests"
|
||||
fi
|
||||
|
||||
if [ "$run_system" = true ]; then
|
||||
run_test_directory "${TEST_DIR}/system" "System Tests"
|
||||
fi
|
||||
|
||||
# Print summary
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Test Summary${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
echo -e " Total: ${TOTAL}"
|
||||
echo -e " ${GREEN}Passed: ${PASSED}${NC}"
|
||||
echo -e " ${RED}Failed: ${FAILED}${NC}"
|
||||
echo ""
|
||||
|
||||
if [ ${FAILED} -gt 0 ]; then
|
||||
echo -e "${RED}Some tests failed${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}All tests passed${NC}"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user