blob: 5e21a70e16fcadc313918d10d4397f81d72953fc [file] [log] [blame]
# vec_cc_generated_test()
#
# CMake function to generate vector test from a given template.
#
# Parameters:
# NAME: Name of the op_code the test will verify
# TEMPLATE: mako template to use in generating the CPP file
# PREFIX: prefix to add to the target
# LINKOPTS: additional link options
# TIMEOUT: test specific timeout
#
# Note:
# This will generate an elf file that can be executed on target
# It also adds a test that can be run via CTest
function(vec_cc_generated_test)
cmake_parse_arguments(
_RULE
""
"NAME"
"TEMPLATE;PREFIX;LINKOPTS;TIMEOUT"
${ARGN}
)
set(_TEST_NAME "${_RULE_PREFIX}${_RULE_NAME}_test")
set(_OP_CODE ${_RULE_NAME})
string(REPLACE ".tpl" "" _TEST_SRC_FILENAME ${_RULE_TEMPLATE})
set(_TEST_SRC ${CMAKE_CURRENT_BINARY_DIR}/generated/${_OP_CODE}/${_TEST_SRC_FILENAME})
find_file(_GEN_VEC_SCRIPT generate_vector_tests.py ${CMAKE_SOURCE_DIR}/scripts)
file(GLOB_RECURSE TEMPLATES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.tpl")
add_custom_command(
OUTPUT
${_TEST_SRC}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/templates/${_RULE_TEMPLATE}
${TEMPLATES}
COMMAND python3 ${_GEN_VEC_SCRIPT}
--template-path=${CMAKE_CURRENT_SOURCE_DIR}/templates/
--template=${_RULE_TEMPLATE}
--out-path=${CMAKE_CURRENT_BINARY_DIR}/generated/${_OP_CODE}
--op=${_OP_CODE}
)
vec_cc_test(
NAME
${_TEST_NAME}
SRCS
${_TEST_SRC}
DEPS
softrvv
LINKOPTS
${_RULE_LINKOPTS}
TIMEOUT
${_RULE_TIMEOUT}
)
endfunction()
function(softrvv_vec_cc_generated_test)
cmake_parse_arguments(
_RULE
""
"NAME"
"TEMPLATE;LINKOPTS;TIMEOUT"
${ARGN}
)
vec_cc_generated_test(
NAME
${_RULE_NAME}
PREFIX
softrvv_
TEMPLATE
${_RULE_TEMPLATE}
LINKOPTS
${_RULE_LINKOPTS}
TIMEOUT
${_RULE_TIMEOUT}
)
endfunction()