From bb745b71ffee06ce44c8d347da2883308fdf503f Mon Sep 17 00:00:00 2001 From: Maxime Schmitt Date: Sat, 4 Jun 2022 17:26:30 +0200 Subject: [PATCH] Put expensive tests behind an option --- tests/CMakeLists.txt | 8 ++++++++ tests/interfaceTests.cpp | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6078428..5f44ce0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,8 @@ find_package(GTest) if (BUILD_TESTING AND GTest_FOUND) + + option(THOROUGH_TESTING "Enable extensive testing (takes hours, e.g., use once per release)" OFF) + # Create a library for testing add_library(testLib ${PROJECT_SOURCE_DIR}/src/interface_layout_selection.c @@ -18,4 +21,9 @@ if (BUILD_TESTING AND GTest_FOUND) target_link_libraries(interfaceTests PRIVATE testLib GTest::gtest_main) gtest_discover_tests(interfaceTests) + if (THOROUGH_TESTING) + target_compile_definitions(interfaceTests PRIVATE THOROUGH_TESTING) + endif() + + endif() diff --git a/tests/interfaceTests.cpp b/tests/interfaceTests.cpp index 96a6a8d..c409dae 100644 --- a/tests/interfaceTests.cpp +++ b/tests/interfaceTests.cpp @@ -200,11 +200,15 @@ TEST(InterfaceLayout, FixInfiniteLoop) { TEST(InterfaceLayout, LayoutSelection_test_fail_case1) { test_with_terminal_size(32, 3, 55, 16, 1760); } +#ifdef THOROUGH_TESTING + TEST(InterfaceLayout, CheckManyTermSize) { - for (unsigned dev_count = 0; dev_count <= 64; dev_count++) { - for (unsigned screen_rows = 1; screen_rows < 2048; screen_rows++) { - for (unsigned screen_cols = 1; screen_cols < 2048; screen_cols++) { - for (unsigned header_cols = 55; header_cols < 120; header_cols++) { + const std::array dev_count_to_test = {0, 1, 2, 3, 6, 16, 32, 64}; + const std::map extra_increment = {{0, 0}, {1, 0}, {2, 0}, {3, 0}, {6, 4}, {16, 6}, {32, 8}, {64, 17}}; + for (unsigned dev_count : dev_count_to_test) { + for (unsigned screen_rows = 1; screen_rows < 2048; screen_rows += 1 + extra_increment.at(dev_count)) { + for (unsigned screen_cols = 1; screen_cols < 2048; screen_cols += 1 + extra_increment.at(dev_count)) { + for (unsigned header_cols = 55; header_cols < 120; header_cols += 1 + extra_increment.at(dev_count)) { ASSERT_TRUE(test_with_terminal_size(dev_count, 3, header_cols, screen_rows, screen_cols)) << "Problem found with " << dev_count << " devices, (" << 3 << ", header " << header_cols << "), terminal size (" << screen_rows << ", " << screen_cols << ")"; @@ -213,3 +217,5 @@ TEST(InterfaceLayout, CheckManyTermSize) { } } } + +#endif // THOROUGH_TESTING \ No newline at end of file