blob: d2dc217f857fd62187df83ffb15ccac29565dad6 [file] [log] [blame]
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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()