2016-03-17 02:43:31 +00:00
|
|
|
# Copyright (c) 2015-2016 The Khronos Group Inc.
|
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# 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
|
2016-03-17 02:43:31 +00:00
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2016-03-17 02:43:31 +00:00
|
|
|
#
|
2016-09-01 19:33:59 +00:00
|
|
|
# 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.
|
2016-03-17 02:43:31 +00:00
|
|
|
|
2016-06-21 22:29:36 +00:00
|
|
|
# Add a SPIR-V Tools unit test. Signature:
|
|
|
|
# add_spvtools_unittest(
|
|
|
|
# TARGET target_name
|
|
|
|
# SRCS src_file.h src_file.cpp
|
|
|
|
# LIBS lib1 lib2
|
|
|
|
# )
|
2016-05-22 17:48:08 +00:00
|
|
|
|
2016-08-05 17:46:45 +00:00
|
|
|
if (NOT "${SPIRV_SKIP_TESTS}")
|
|
|
|
if (TARGET gmock_main)
|
2016-03-17 02:43:31 +00:00
|
|
|
message(STATUS "Found Google Mock, building tests.")
|
|
|
|
else()
|
2017-12-05 15:55:00 +00:00
|
|
|
message(STATUS "Did not find googletest, tests will not be built. "
|
2016-03-17 02:43:31 +00:00
|
|
|
"To enable tests place googletest in '<spirv-dir>/external/googletest'.")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-08-05 17:46:45 +00:00
|
|
|
|
|
|
|
function(add_spvtools_unittest)
|
|
|
|
if (NOT "${SPIRV_SKIP_TESTS}" AND TARGET gmock_main)
|
|
|
|
set(one_value_args TARGET)
|
2018-02-02 22:37:14 +00:00
|
|
|
set(multi_value_args SRCS LIBS ENVIRONMENT)
|
2016-08-05 17:46:45 +00:00
|
|
|
cmake_parse_arguments(
|
|
|
|
ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
2016-09-07 21:26:18 +00:00
|
|
|
set(target test_${ARG_TARGET})
|
|
|
|
add_executable(${target} ${ARG_SRCS})
|
|
|
|
spvtools_default_compile_options(${target})
|
2016-08-05 17:46:45 +00:00
|
|
|
if(${COMPILER_IS_LIKE_GNU})
|
2016-09-07 21:26:18 +00:00
|
|
|
target_compile_options(${target} PRIVATE -Wno-undef)
|
2017-11-08 05:23:42 +00:00
|
|
|
# Effcee and RE2 headers exhibit shadowing.
|
|
|
|
target_compile_options(${target} PRIVATE -Wno-shadow)
|
2016-08-05 17:46:45 +00:00
|
|
|
endif()
|
2016-08-08 02:49:00 +00:00
|
|
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
2016-08-05 17:46:45 +00:00
|
|
|
# Disable C4503 "decorated name length exceeded" warning,
|
|
|
|
# triggered by some heavily templated types.
|
|
|
|
# We don't care much about that in test code.
|
|
|
|
# Important to do since we have warnings-as-errors.
|
2016-09-07 21:26:18 +00:00
|
|
|
target_compile_options(${target} PRIVATE /wd4503)
|
2017-12-11 17:05:04 +00:00
|
|
|
# Googletest accidentally turns off support for ::testing::Combine
|
|
|
|
# in VS 2017. See https://github.com/google/googletest/issues/1352
|
|
|
|
# Forcibly turn it on again.
|
|
|
|
target_compile_options(${target} PRIVATE /DGTEST_HAS_COMBINE=1)
|
2016-08-05 17:46:45 +00:00
|
|
|
endif()
|
2016-09-07 21:26:18 +00:00
|
|
|
target_include_directories(${target} PRIVATE
|
|
|
|
${SPIRV_HEADER_INCLUDE_DIR}
|
2016-08-05 17:46:45 +00:00
|
|
|
${spirv-tools_SOURCE_DIR}
|
|
|
|
${spirv-tools_SOURCE_DIR}/include
|
2016-09-07 21:26:18 +00:00
|
|
|
${spirv-tools_SOURCE_DIR}/test
|
2017-03-15 21:28:24 +00:00
|
|
|
${spirv-tools_BINARY_DIR}
|
2016-08-05 17:46:45 +00:00
|
|
|
${gtest_SOURCE_DIR}/include
|
|
|
|
${gmock_SOURCE_DIR}/include
|
|
|
|
)
|
2017-11-08 05:23:42 +00:00
|
|
|
if (TARGET effcee)
|
|
|
|
# If using Effcee for testing, then add its include directory.
|
|
|
|
target_include_directories(${target} PRIVATE ${effcee_SOURCE_DIR})
|
|
|
|
endif()
|
2016-09-07 21:26:18 +00:00
|
|
|
target_link_libraries(${target} PRIVATE ${ARG_LIBS})
|
2017-11-08 05:23:42 +00:00
|
|
|
if (TARGET effcee)
|
|
|
|
target_link_libraries(${target} PRIVATE effcee)
|
|
|
|
endif()
|
2016-09-07 21:26:18 +00:00
|
|
|
target_link_libraries(${target} PRIVATE gmock_main)
|
|
|
|
add_test(NAME spirv-tools-${target} COMMAND ${target})
|
2018-02-02 22:37:14 +00:00
|
|
|
if (DEFINED ARG_ENVIRONMENT)
|
|
|
|
set_tests_properties(spirv-tools-${target} PROPERTIES ENVIRONMENT ${ARG_ENVIRONMENT})
|
|
|
|
endif()
|
2017-04-05 21:32:39 +00:00
|
|
|
set_property(TARGET ${target} PROPERTY FOLDER "SPIRV-Tools tests")
|
2016-08-05 17:46:45 +00:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
set(TEST_SOURCES
|
2016-09-22 15:05:30 +00:00
|
|
|
test_fixture.h
|
|
|
|
unit_spirv.h
|
2016-08-05 17:46:45 +00:00
|
|
|
|
2016-09-22 15:05:30 +00:00
|
|
|
assembly_context_test.cpp
|
|
|
|
assembly_format_test.cpp
|
|
|
|
binary_destroy_test.cpp
|
|
|
|
binary_endianness_test.cpp
|
|
|
|
binary_header_get_test.cpp
|
|
|
|
binary_parse_test.cpp
|
2016-12-19 18:26:42 +00:00
|
|
|
binary_strnlen_s_test.cpp
|
2016-09-22 15:05:30 +00:00
|
|
|
binary_to_text_test.cpp
|
|
|
|
binary_to_text.literal_test.cpp
|
|
|
|
comment_test.cpp
|
2017-03-15 21:28:24 +00:00
|
|
|
enum_string_mapping_test.cpp
|
2017-03-09 23:24:35 +00:00
|
|
|
enum_set_test.cpp
|
2017-12-03 17:30:08 +00:00
|
|
|
ext_inst.debuginfo_test.cpp
|
2016-09-22 15:05:30 +00:00
|
|
|
ext_inst.glsl_test.cpp
|
|
|
|
ext_inst.opencl_test.cpp
|
|
|
|
fix_word_test.cpp
|
|
|
|
generator_magic_number_test.cpp
|
|
|
|
hex_float_test.cpp
|
|
|
|
immediate_int_test.cpp
|
|
|
|
libspirv_macros_test.cpp
|
|
|
|
named_id_test.cpp
|
|
|
|
name_mapper_test.cpp
|
|
|
|
opcode_make_test.cpp
|
|
|
|
opcode_require_capabilities_test.cpp
|
|
|
|
opcode_split_test.cpp
|
|
|
|
opcode_table_get_test.cpp
|
|
|
|
operand_capabilities_test.cpp
|
|
|
|
operand_test.cpp
|
|
|
|
operand_pattern_test.cpp
|
|
|
|
software_version_test.cpp
|
|
|
|
target_env_test.cpp
|
|
|
|
text_advance_test.cpp
|
|
|
|
text_destroy_test.cpp
|
|
|
|
text_literal_test.cpp
|
|
|
|
text_start_new_inst_test.cpp
|
|
|
|
text_to_binary.annotation_test.cpp
|
|
|
|
text_to_binary.barrier_test.cpp
|
|
|
|
text_to_binary.constant_test.cpp
|
|
|
|
text_to_binary.control_flow_test.cpp
|
|
|
|
text_to_binary_test.cpp
|
|
|
|
text_to_binary.debug_test.cpp
|
|
|
|
text_to_binary.device_side_enqueue_test.cpp
|
|
|
|
text_to_binary.extension_test.cpp
|
|
|
|
text_to_binary.function_test.cpp
|
|
|
|
text_to_binary.group_test.cpp
|
|
|
|
text_to_binary.image_test.cpp
|
|
|
|
text_to_binary.literal_test.cpp
|
|
|
|
text_to_binary.memory_test.cpp
|
|
|
|
text_to_binary.misc_test.cpp
|
|
|
|
text_to_binary.mode_setting_test.cpp
|
|
|
|
text_to_binary.pipe_storage_test.cpp
|
|
|
|
text_to_binary.type_declaration_test.cpp
|
|
|
|
text_to_binary.subgroup_dispatch_test.cpp
|
2018-03-14 17:06:18 +00:00
|
|
|
text_to_binary.reserved_sampling_test.cpp
|
2016-09-22 15:05:30 +00:00
|
|
|
text_word_get_test.cpp
|
|
|
|
|
|
|
|
unit_spirv.cpp
|
2016-08-05 17:46:45 +00:00
|
|
|
)
|
2016-09-08 21:26:53 +00:00
|
|
|
|
2016-08-05 17:46:45 +00:00
|
|
|
add_spvtools_unittest(
|
2016-09-07 21:26:18 +00:00
|
|
|
TARGET spirv_unit_tests
|
2016-08-05 17:46:45 +00:00
|
|
|
SRCS ${TEST_SOURCES}
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2016-09-08 21:26:53 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET diagnostic
|
2016-09-22 15:05:30 +00:00
|
|
|
SRCS diagnostic_test.cpp
|
2016-09-08 21:26:53 +00:00
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2016-09-02 22:06:18 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET c_interface
|
2016-09-22 15:05:30 +00:00
|
|
|
SRCS c_interface_test.cpp
|
2016-09-02 22:06:18 +00:00
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2018-02-02 22:37:14 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET c_interface_shared
|
|
|
|
SRCS c_interface_test.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS}-shared
|
|
|
|
ENVIRONMENT PATH=$<TARGET_FILE_DIR:${SPIRV_TOOLS}-shared>)
|
|
|
|
|
2016-08-05 17:46:45 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET cpp_interface
|
2016-09-22 15:05:30 +00:00
|
|
|
SRCS cpp_interface_test.cpp
|
|
|
|
LIBS SPIRV-Tools-opt)
|
2016-08-05 17:46:45 +00:00
|
|
|
|
2016-09-01 18:27:04 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET parse_number
|
2016-09-22 15:05:30 +00:00
|
|
|
SRCS parse_number_test.cpp
|
2016-09-01 18:27:04 +00:00
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2017-03-10 20:58:15 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET string_utils
|
|
|
|
SRCS string_utils_test.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2018-03-07 14:25:51 +00:00
|
|
|
if (${SPIRV_TIMER_ENABLED})
|
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET timer
|
|
|
|
SRCS timer_test.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
endif()
|
|
|
|
|
2016-09-08 15:43:48 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET log
|
2016-09-22 15:05:30 +00:00
|
|
|
SRCS log_test.cpp
|
2016-09-08 15:43:48 +00:00
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2017-04-11 23:46:15 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET preserve_numeric_ids
|
|
|
|
SRCS preserve_numeric_ids_test.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2017-04-24 19:17:33 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET bit_stream
|
|
|
|
SRCS bit_stream.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2017-05-25 15:21:12 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET huffman_codec
|
|
|
|
SRCS huffman_codec.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2017-06-12 16:01:39 +00:00
|
|
|
add_spvtools_unittest(
|
|
|
|
TARGET move_to_front
|
|
|
|
SRCS move_to_front_test.cpp
|
|
|
|
LIBS ${SPIRV_TOOLS})
|
|
|
|
|
2017-05-31 17:07:51 +00:00
|
|
|
add_subdirectory(comp)
|
2017-07-13 00:16:51 +00:00
|
|
|
add_subdirectory(link)
|
2016-08-05 17:46:45 +00:00
|
|
|
add_subdirectory(opt)
|
2017-04-06 20:55:26 +00:00
|
|
|
add_subdirectory(stats)
|
2017-10-10 13:47:01 +00:00
|
|
|
add_subdirectory(util)
|
2017-05-31 17:07:51 +00:00
|
|
|
add_subdirectory(val)
|