blob: d7d5951908a9929657ba1eea343ab3db34e6bdb9 [file] [log] [blame]
function(vec_cc_test)
cmake_parse_arguments(
_RULE
""
"NAME"
"SRCS;COPTS;DEFINES;LINKOPTS;DATA;DEPS;LABELS;TIMEOUT"
${ARGN}
)
set(_NAME "${_RULE_NAME}")
project(${_RULE_NAME})
set (CMAKE_CXX_STANDARD 17)
vec_cc_binary(
NAME
${_RULE_NAME}
SRCS
${_RULE_SRCS}
DEPS
pw_unit_test
pw_unit_test.main
pw_assert_basic
test_v_helpers
softrvv
${_RULE_DEPS}
LINKOPTS
${_RULE_LINKOPTS}
)
if("${_RULE_TIMEOUT}" STREQUAL "")
set(_TIMEOUT 20)
else()
set(_TIMEOUT ${_RULE_TIMEOUT})
endif()
find_file(TEST_RUNNER test_runner.py HINTS ${CMAKE_BINARY_DIR})
find_program(QEMU_RV32 qemu-system-riscv32 HINTS $ENV{OUT}/host/qemu)
if(QEMU_RV32 AND TEST_RUNNER)
add_test(
NAME
"qemu_${_RULE_NAME}"
COMMAND
${TEST_RUNNER} qemu $<TARGET_FILE:${_RULE_NAME}.elf> --qemu-path ${QEMU_RV32} --timeout=${_TIMEOUT}
)
set_tests_properties("qemu_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
else()
message(WARNING "qemu-system-riscv32 doesn't exist. Make sure you build qemu first and start a clean build to enable the qemu test")
endif()
find_program(RENODE_EXE Renode.exe HINTS $ENV{OUT}/host/renode)
if(RENODE_EXE AND TEST_RUNNER)
add_test(
NAME
"renode_${_RULE_NAME}"
COMMAND
${TEST_RUNNER} renode $<TARGET_FILE:${_RULE_NAME}.elf> --renode-path ${RENODE_EXE}
)
set_tests_properties("renode_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
else()
message(WARNING "Renode.exe doesn't exist. Make sure you build renode first and start a clean build to enable the renode test")
endif()
endfunction()