adds test harness
This commit is contained in:
@@ -5,19 +5,19 @@ set(TX_CMAKE_DIR
|
||||
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/cmake
|
||||
)
|
||||
|
||||
# This time patch a test. Since we use a patched trap vector, we need the function test_interrupt_dispatch(void) to exist
|
||||
# As this test is not using testcontrol.c to provide the symbol, we do so in this workaround
|
||||
# This test needs a local test_interrupt_dispatch() because it does not link testcontrol.c.
|
||||
set(TX_KERNEL_SETUP_TEST_SOURCE_INPUT ${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/regression/threadx_initialize_kernel_setup_test.c)
|
||||
set(TX_KERNEL_SETUP_TEST_SOURCE ${CMAKE_BINARY_DIR}/generated/threadx_initialize_kernel_setup_test.c)
|
||||
execute_process(
|
||||
add_custom_command(
|
||||
OUTPUT ${TX_KERNEL_SETUP_TEST_SOURCE}
|
||||
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_kernel_setup_test_file.sh
|
||||
${TX_KERNEL_SETUP_TEST_SOURCE_INPUT}
|
||||
${TX_KERNEL_SETUP_TEST_SOURCE}
|
||||
RESULT_VARIABLE TX_KERNEL_SETUP_TEST_GENERATE_RESULT
|
||||
${TX_KERNEL_SETUP_TEST_SOURCE_INPUT}
|
||||
${TX_KERNEL_SETUP_TEST_SOURCE}
|
||||
DEPENDS ${TX_KERNEL_SETUP_TEST_SOURCE_INPUT}
|
||||
${CMAKE_CURRENT_LIST_DIR}/generate_kernel_setup_test_file.sh
|
||||
VERBATIM
|
||||
)
|
||||
if(NOT TX_KERNEL_SETUP_TEST_GENERATE_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to generate patched kernel setup test source")
|
||||
endif()
|
||||
set_source_files_properties(${TX_KERNEL_SETUP_TEST_SOURCE} PROPERTIES GENERATED TRUE)
|
||||
|
||||
set(TX_REGRESSION_CASES
|
||||
${TX_REGRESSION_DIR}/threadx_block_memory_basic_test.c
|
||||
@@ -153,8 +153,26 @@ function(add_threadx_regression_test TEST_SOURCE)
|
||||
list(APPEND TX_REGRESSION_TARGETS ${TEST_NAME})
|
||||
set(TX_REGRESSION_TARGETS ${TX_REGRESSION_TARGETS} PARENT_SCOPE)
|
||||
|
||||
# The executable is embedded and not directly host-runnable.
|
||||
# Add a real add_test() command here once a QEMU or board runner exists.
|
||||
if(TEST_NAME STREQUAL "threadx_initialize_kernel_setup_test")
|
||||
add_test(
|
||||
NAME ${TEST_NAME}
|
||||
COMMAND ${CMAKE_CURRENT_LIST_DIR}/run_threadx_simple_test.sh
|
||||
${THREADX_TEST_SIMULATOR}
|
||||
${THREADX_TEST_ISA}
|
||||
$<TARGET_FILE:${TEST_NAME}>
|
||||
"Running Initialize Kernel Setup Test................................ SUCCESS!"
|
||||
"Running Initialize Kernel Setup Test................................ ERROR!"
|
||||
)
|
||||
else()
|
||||
add_test(
|
||||
NAME ${TEST_NAME}
|
||||
COMMAND ${CMAKE_CURRENT_LIST_DIR}/run_threadx_test.sh
|
||||
${THREADX_TEST_SIMULATOR}
|
||||
${THREADX_TEST_ISA}
|
||||
$<TARGET_FILE:${TEST_NAME}>
|
||||
)
|
||||
endif()
|
||||
set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT 5)
|
||||
endfunction()
|
||||
|
||||
foreach(test_case ${TX_REGRESSION_CASES})
|
||||
|
||||
40
test/threadx/run_threadx_simple_test.sh
Executable file
40
test/threadx/run_threadx_simple_test.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
simulator="$1"
|
||||
isa="$2"
|
||||
elf="$3"
|
||||
pass_pattern="$4"
|
||||
fail_pattern="$5"
|
||||
|
||||
if [ ! -x "$simulator" ]; then
|
||||
echo "Simulator not found or not executable: $simulator" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f "$elf" ]; then
|
||||
echo "ELF not found: $elf" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log_file=$(mktemp)
|
||||
trap 'rm -f "$log_file"' EXIT
|
||||
|
||||
"$simulator" \
|
||||
--isa="$isa" \
|
||||
-f "$elf" \
|
||||
-p tb.top.core.finish_condition=1 \
|
||||
-m 10s \
|
||||
| tee "$log_file"
|
||||
|
||||
if grep -Fq "$fail_pattern" "$log_file"; then
|
||||
echo "ThreadX regression reported failure pattern: $fail_pattern" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -Fq "$pass_pattern" "$log_file"; then
|
||||
echo "Missing expected success pattern in simulator output: $pass_pattern" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
48
test/threadx/run_threadx_test.sh
Executable file
48
test/threadx/run_threadx_test.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
simulator="$1"
|
||||
isa="$2"
|
||||
elf="$3"
|
||||
|
||||
if [ ! -x "$simulator" ]; then
|
||||
echo "Simulator not found or not executable: $simulator" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f "$elf" ]; then
|
||||
echo "ELF not found: $elf" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log_file=$(mktemp)
|
||||
trap 'rm -f "$log_file"' EXIT
|
||||
|
||||
"$simulator" \
|
||||
--isa="$isa" \
|
||||
-f "$elf" \
|
||||
-p tb.top.core.finish_condition=1 \
|
||||
-m 10s \
|
||||
| tee "$log_file"
|
||||
|
||||
summary_line=$(grep -F "**** Test Summary:" "$log_file" | tail -n 1 || true)
|
||||
if [ -z "$summary_line" ]; then
|
||||
echo "Missing ThreadX test summary in simulator output" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -r passed failed errors <<EOF_SUMMARY
|
||||
$(echo "$summary_line" | sed -n 's/.*Tests Passed:[[:space:]]*\([0-9][0-9]*\)[[:space:]]*Tests Failed:[[:space:]]*\([0-9][0-9]*\)[[:space:]]*System Errors:[[:space:]]*\([0-9][0-9]*\).*/\1 \2 \3/p')
|
||||
EOF_SUMMARY
|
||||
|
||||
if [ -z "${passed:-}" ] || [ -z "${failed:-}" ] || [ -z "${errors:-}" ]; then
|
||||
echo "Could not parse ThreadX test summary: $summary_line" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$failed" -ne 0 ] || [ "$errors" -ne 0 ]; then
|
||||
echo "ThreadX regression reported failure: passed=$passed failed=$failed errors=$errors" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user