Skip to content

Commit

Permalink
Support capture replay tests under CMake.
Browse files Browse the repository at this point in the history
Add support for building tests through CMakelist #386
  • Loading branch information
bbernhar committed Jun 11, 2022
1 parent 55b4b84 commit dfae875
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/win_msvc_dbg_x64_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ jobs:
run: |
cd test
Debug\gpgmm_unittests.exe
- name: Run gpgmm_capture_replay_tests (with patch)
shell: cmd
run: |
cd test
Debug\gpgmm_capture_replay_tests.exe --log-level=DEBUG 2>&1
50 changes: 50 additions & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,53 @@ target_link_libraries(gpgmm_end2end_tests PRIVATE
gpgmm
gtest
)

###############################################################################
# Capture replay tests
###############################################################################

add_executable(gpgmm_capture_replay_tests)

set(TRACE_INDEX_FILE_NAME "traces.json")
set(TRACE_INPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/capture_replay_tests/traces")
set(TRACE_INDEX_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${TRACE_INDEX_FILE_NAME}")

add_custom_command(
TARGET gpgmm_capture_replay_tests PRE_BUILD
COMMAND python3 ${GPGMM_ROOT_DIR}/scripts/generate_capture_replay_trace_index.py --traces_dir "${TRACE_INPUT_DIR}" --trace_index "${TRACE_INDEX_OUTPUT_PATH}"
COMMENT "Generating capture replay trace index"
VERBATIM
)

target_compile_definitions(gpgmm_capture_replay_tests PRIVATE -DGPGMM_CAPTURE_REPLAY_TESTS_TRACE_INDEX="${TRACE_INDEX_OUTPUT_PATH}")

target_sources(gpgmm_capture_replay_tests PRIVATE
"GPGMMTest.cpp"
"GPGMMTest.h"
"capture_replay_tests/GPGMMCaptureReplayTests.cpp"
"capture_replay_tests/GPGMMCaptureReplayTests.h"
"CaptureReplayTestsMain.cpp"
)

target_link_libraries(gpgmm_capture_replay_tests
PRIVATE gpgmm_common_config
)

if (GPGMM_ENABLE_D3D12)
target_sources(gpgmm_capture_replay_tests PRIVATE
"D3D12Test.cpp"
"D3D12Test.h"
"capture_replay_tests/D3D12EventTraceReplay.cpp"
)

target_link_libraries(gpgmm_capture_replay_tests PRIVATE
d3d12.lib
dxgi.lib
)
endif()

target_link_libraries(gpgmm_capture_replay_tests PRIVATE
gpgmm
gtest
jsoncpp_static
)
2 changes: 1 addition & 1 deletion src/tests/CaptureReplayTestsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "src/tests/capture_replay_tests/GPGMMCaptureReplayTests.h"
#include "tests/capture_replay_tests/GPGMMCaptureReplayTests.h"

int main(int argc, char** argv) {
InitGPGMMCaptureReplayTestEnvironment(argc, argv);
Expand Down
3 changes: 3 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ if (GPGMM_ENABLE_TESTS)
# Prevent overriding the GPGMM's compiler/linker settings (or "mismatch detected" LNK2005 errors result)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(googletest)

# JsonCpp is only used for capture_replay_tests.
add_subdirectory(jsoncpp/source)
endif()

if (GPGMM_ENABLE_VK_LOADER)
Expand Down

0 comments on commit dfae875

Please sign in to comment.