blob: 87278cac8e39373196b2ee3eeb3cc68fc9fd6167 [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 30)
else()
set(_TIMEOUT ${_RULE_TIMEOUT})
endif()
if(DEFINED TEST_RUNNER)
find_program(QEMU_RV32 qemu-system-riscv32 HINTS $ENV{OUT}/host/qemu)
if(QEMU_RV32)
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_BIN renode HINTS $ENV{CACHE}/renode)
if(RENODE_BIN)
add_test(
NAME
"renode_${_RULE_NAME}"
COMMAND
${TEST_RUNNER} renode $<TARGET_FILE:${_RULE_NAME}.elf> --renode-path ${RENODE_BIN} --quick_test --timeout=${_TIMEOUT}
)
set_tests_properties("renode_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
else()
message(WARNING "renode doesn't exist. Make sure you build renode first and start a clean build to enable the renode test")
endif()
endif(DEFINED TEST_RUNNER)
endfunction()