From 5b3ee279f2af7a9fa2bb16a326602196da35eb47 Mon Sep 17 00:00:00 2001 From: "Alan M. Carroll" Date: Mon, 14 Sep 2020 17:38:10 -0500 Subject: [PATCH 1/2] Create cmake.yml --- .github/workflows/cmake.yml | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..87e214e0 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,46 @@ +name: CMake + +on: [push] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE --target test_libswoc + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: test_libswoc From f1d58d0ea9cec9e8ab44779061d156b56f58e705 Mon Sep 17 00:00:00 2001 From: "Alan M. Carroll" Date: Fri, 25 Sep 2020 16:04:25 -0500 Subject: [PATCH 2/2] Fix testing build errors in Errata. --- code/include/swoc/DiscreteRange.h | 2 +- code/include/swoc/Errata.h | 4 ++++ unit_tests/ex_Lexicon.cc | 1 + unit_tests/test_Errata.cc | 7 +++++-- unit_tests/test_Lexicon.cc | 4 +++- unit_tests/test_ip.cc | 12 ++++++++++++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/code/include/swoc/DiscreteRange.h b/code/include/swoc/DiscreteRange.h index 6e2494d2..28351542 100644 --- a/code/include/swoc/DiscreteRange.h +++ b/code/include/swoc/DiscreteRange.h @@ -1267,7 +1267,7 @@ DiscreteSpace::blend(DiscreteSpace::range_type const& range, U , F&& blender) -> self_type& { // Do a base check for the color to use on unmapped values. If self blending on @a color // is @c false, then do not color currently unmapped values. - PAYLOAD plain_color; // color to paint uncolored metrics. + [[maybe_unused]] PAYLOAD plain_color{}; // color to paint uncolored metrics. bool plain_color_p = blender(plain_color, color); // start with default and blend in @a color. auto node_cleaner = [&](Node *ptr) -> void { _fa.destroy(ptr); }; diff --git a/code/include/swoc/Errata.h b/code/include/swoc/Errata.h index 95fe32ec..334c2546 100644 --- a/code/include/swoc/Errata.h +++ b/code/include/swoc/Errata.h @@ -955,3 +955,7 @@ get(swoc::Rv const& rv) { } }} // namespace swoc + +namespace std { + using swoc::get; // Import specialized overloads to standard namespace. +} diff --git a/unit_tests/ex_Lexicon.cc b/unit_tests/ex_Lexicon.cc index 34281a7e..25c319f2 100644 --- a/unit_tests/ex_Lexicon.cc +++ b/unit_tests/ex_Lexicon.cc @@ -88,6 +88,7 @@ TEST_CASE("Lexicon Example", "[libts][Lexicon]") { // doc.lookup.begin auto && [ range, flags ] = *space.find(addr); // doc.lookup.end + static_cast(range); REQUIRE(flags == bits); } // doc.lookup.end diff --git a/unit_tests/test_Errata.cc b/unit_tests/test_Errata.cc index 088f93aa..28bd22b4 100644 --- a/unit_tests/test_Errata.cc +++ b/unit_tests/test_Errata.cc @@ -102,6 +102,7 @@ TEST_CASE("Rv", "[libswoc][Errata]") REQUIRE(result == 17); // Local copy binding, no update. auto &[r_result, r_erratum] = zret; + REQUIRE(r_erratum.is_ok() == false); REQUIRE(r_result == 38); zret = 56; @@ -109,10 +110,11 @@ TEST_CASE("Rv", "[libswoc][Errata]") auto const &[cr_result, cr_erratum] = zret; REQUIRE(cr_result == 56); + REQUIRE(cr_erratum.is_ok() == false); auto test = [](Rv const &rvc) { - auto const &[cv_result, cv_erratum] = rvc; - REQUIRE(cv_result == 56); + auto n = std::get<0>(rvc); + REQUIRE(n == 56); }; test(zret); // invoke it. @@ -142,4 +144,5 @@ TEST_CASE("Rv", "[libswoc][Errata]") auto &&[tr2, te2]{maker()}; REQUIRE(tr2->s == "made"sv); + REQUIRE(te2.is_ok() == true); }; diff --git a/unit_tests/test_Lexicon.cc b/unit_tests/test_Lexicon.cc index a72bd725..95aaeedd 100644 --- a/unit_tests/test_Lexicon.cc +++ b/unit_tests/test_Lexicon.cc @@ -72,7 +72,9 @@ TEST_CASE("Lexicon", "[libts][Lexicon]") {Radio::DELTA, {"Delta"}}}); // test structured binding for iteration. - for ([[maybe_unused]] auto const &[key, name] : lex) { + for (auto const &[key, name] : lex) { + static_cast(key); + static_cast(name); } }; diff --git a/unit_tests/test_ip.cc b/unit_tests/test_ip.cc index ba81bc68..2195a61f 100644 --- a/unit_tests/test_ip.cc +++ b/unit_tests/test_ip.cc @@ -756,6 +756,7 @@ TEST_CASE("IP Space Int", "[libswoc][ip][ipspace]") { // Verify that earlier ranges are still valid after the double blend. for (auto &&[text, value] : r2) { IPRange range{text}; + static_cast(value); REQUIRE(space.end() != space.find(range.min())); REQUIRE(space.end() != space.find(range.max())); } @@ -765,6 +766,7 @@ TEST_CASE("IP Space Int", "[libswoc][ip][ipspace]") { // Verify all the data is in the ranges. for (auto &&[text, value] : r2) { IPRange range{text}; + static_cast(value); REQUIRE(space.end() != space.find(range.min())); REQUIRE(space.end() != space.find(range.max())); } @@ -777,6 +779,7 @@ TEST_CASE("IP Space Int", "[libswoc][ip][ipspace]") { } { auto && [ r, p ] = *space.find(IPAddr{"2001:4997:58:400::1E"}); + static_cast(p); REQUIRE(true == r.empty()); } } @@ -808,8 +811,10 @@ TEST_CASE("IPSpace bitset", "[libswoc][ipspace][bitset]") { // Check that if an IPv4 lookup misses, it doesn't pass on to the first IPv6 auto && [ r1, p1 ] = *(space.find(IP4Addr{"172.28.56.100"})); + static_cast(p1); REQUIRE(true == r1.empty()); auto && [ r2, p2 ] = *(space.find(IPAddr{"172.28.56.100"})); + static_cast(p2); REQUIRE(true == r2.empty()); } @@ -864,6 +869,7 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") { idx = 0; for (auto const&[range, bits] : space) { + static_cast(range); REQUIRE(idx < results.size()); CHECK(bits == make_bits(results[idx])); ++idx; @@ -872,6 +878,7 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") { idx = results.size(); for (auto spot = space.end(); spot != space.begin();) { auto const&[range, bits]{*--spot}; + static_cast(range); REQUIRE(idx > 0); --idx; CHECK(bits == make_bits(results[idx])); @@ -885,6 +892,7 @@ TEST_CASE("IPSpace docJJ", "[libswoc][ipspace][docJJ]") { for (auto spot = space.begin(); spot != space.end() ; ++spot) { iter = spot; std::tie(range, bits) = *iter; + static_cast(range); REQUIRE(idx < results.size()); CHECK(bits == make_bits(results[idx])); ++idx; @@ -1500,10 +1508,14 @@ TEST_CASE("IPSpace Uthira", "[libswoc][ipspace][uthira]") { auto spot = space.begin(); auto [ r1, p1 ] = *++spot; auto [ r2, p2 ] = *++spot; + static_cast(p1); + static_cast(p2); REQUIRE(r1.max() < r2.min()); // This is supposed to be an invariant! Make sure. auto back = space.end(); auto [ br1, bp1 ] = *--back; auto [ br2, bp2 ] = *--back; + static_cast(bp1); + static_cast(bp2); REQUIRE(br2.max() < br1.min()); // This is supposed to be an invariant! Make sure. } }