Skip to content

Commit

Permalink
add tests cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
paul0403 committed Jan 24, 2025
1 parent 66ff047 commit 294730a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
10 changes: 9 additions & 1 deletion runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif

ifeq ($(ENABLE_OQD), ON)
BUILD_TARGETS += rt_OQD_capi
#TEST_TARGETS += runner_tests_openqasm
TEST_TARGETS += runner_tests_oqd
endif

.PHONY: help
Expand Down Expand Up @@ -76,6 +76,10 @@ ifeq ($(ENABLE_OPENQASM), ON)
# Test the OpenQasm devices C++ tests
$(ASAN_COMMAND) $(RT_BUILD_DIR)/tests/runner_tests_openqasm
endif
ifeq ($(ENABLE_OQD), ON)
# Test the OQD CAPI tests
$(ASAN_COMMAND) $(RT_BUILD_DIR)/tests/runner_tests_oqd
endif

.PHONY: coverage
coverage: RT_BUILD_DIR := $(RT_BUILD_DIR)_cov
Expand All @@ -90,6 +94,9 @@ coverage: test_runner
ifeq ($(ENABLE_OPENQASM), ON)
$(RT_BUILD_DIR)/tests/runner_tests_openqasm
endif
ifeq ($(ENABLE_OQD), ON)
$(RT_BUILD_DIR)/tests/runner_tests_oqd
endif
ifeq ($(PLATFORM),Linux)
lcov --directory $(RT_BUILD_DIR) -b $(MK_DIR)/lib --capture --output-file $(RT_BUILD_DIR)/coverage.info
lcov --remove $(RT_BUILD_DIR)/coverage.info '/usr/*' '*/_deps/*' '*/envs/*' '*/mlir/*' --output-file $(RT_BUILD_DIR)/coverage.info
Expand All @@ -98,6 +105,7 @@ else
xcrun llvm-profdata merge $(RT_BUILD_DIR)/tests/*.profraw -o $(RT_BUILD_DIR)/tests/rt_test_coverage.profdata
xcrun llvm-cov show -instr-profile $(RT_BUILD_DIR)/tests/rt_test_coverage.profdata \
-object $(RT_BUILD_DIR)/tests/runner_tests_openqasm \
$(RT_BUILD_DIR)/tests/runner_tests_oqd \
$(RT_BUILD_DIR)/tests/runner_tests_qir_runtime \
-format=html -output-dir=$(RT_BUILD_DIR)/coverage_html \
$(MK_DIR)/include $(MK_DIR)/lib $(MK_DIR)/tests
Expand Down
23 changes: 22 additions & 1 deletion runtime/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ target_link_libraries(runner_tests_qir_runtime PRIVATE

target_sources(runner_tests_qir_runtime PRIVATE
Test_NullQubit.cpp
Test_OQD_OpenAPLGeneration.cpp
)

catch_discover_tests(runner_tests_qir_runtime)
Expand Down Expand Up @@ -64,3 +63,25 @@ if(ENABLE_OPENQASM)

catch_discover_tests(runner_tests_openqasm)
endif()

if(ENABLE_OQD)
add_executable(runner_tests_oqd runner_main.cpp)
if(NOT APPLE)
set_property(TARGET runner_tests_oqd APPEND PROPERTY BUILD_RPATH $ORIGIN)
set_property(TARGET runner_tests_oqd APPEND PROPERTY BUILD_RPATH $ORIGIN/../lib)
else()
set_property(TARGET runner_tests_oqd APPEND PROPERTY BUILD_RPATH @loader_path)
set_property(TARGET runner_tests_oqd APPEND PROPERTY BUILD_RPATH @loader_path/../lib)
endif()

target_link_libraries(runner_tests_oqd PRIVATE
Catch2::Catch2
catalyst_qir_runtime
)

target_sources(runner_tests_oqd PRIVATE
Test_OQD_OpenAPLGeneration.cpp
)

catch_discover_tests(runner_tests_oqd)
endif()

0 comments on commit 294730a

Please sign in to comment.