From 23d0f8180e8bfbdd49ff3c7b340c4f33b206f2f7 Mon Sep 17 00:00:00 2001 From: Vivek Kale <11766050+vlkale@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:24:01 -0700 Subject: [PATCH] Update test_parreduce.cpp --- tests/sampler/test_parreduce.cpp | 37 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/tests/sampler/test_parreduce.cpp b/tests/sampler/test_parreduce.cpp index 95eaa35b5..c0497c9e2 100644 --- a/tests/sampler/test_parreduce.cpp +++ b/tests/sampler/test_parreduce.cpp @@ -6,6 +6,8 @@ #include "Kokkos_Core.hpp" +using ::testing::HasSubstr; +using ::testing::Not; struct Tester { template explicit Tester(const execution_space& space) { @@ -17,7 +19,7 @@ struct Tester { long int sum; for (int iter = 0; iter < 150; iter++) { sum = 0; - Kokkos::parallel_reduce("named kernel", + Kokkos::parallel_reduce("named kernel reduce", Kokkos::RangePolicy(space, 0, 1), *this, sum); } @@ -27,20 +29,23 @@ struct Tester { }; static const std::vector matchers{ - "(.*)KokkosP: sample 51 calling child-begin function...(.*)", - "(.*)KokkosP: sample 51 finished with child-begin function.(.*)", - "(.*)KokkosP: sample 51 calling child-end function...(.*)", - "(.*)KokkosP: sample 51 finished with child-end function.(.*)", - "(.*)KokkosP: sample 102 calling child-begin function...(.*)", - "(.*)KokkosP: sample 102 finished with child-begin function.(.*)", - "(.*)KokkosP: sample 102 calling child-end function...(.*)", - "(.*)KokkosP: sample 102 finished with child-end function.(.*)"}; + "KokkosP: sample 51 calling child-begin function...", + "KokkosP: sample 51 finished with child-begin function.", + "KokkosP: sample 51 calling child-end function...", + "KokkosP: sample 51 finished with child-end function.", + "KokkosP: sample 102 calling child-begin function...", + "KokkosP: sample 102 finished with child-begin function.", + "KokkosP: sample 102 calling child-end function...", + "KokkosP: sample 102 finished with child-end function."}; + /** * @test This test checks that the tool effectively samples. * */ + + TEST(SamplerTest, ktoEnvVarDefault) { //! Initialize @c Kokkos. Kokkos::initialize(); @@ -57,12 +62,20 @@ TEST(SamplerTest, ktoEnvVarDefault) { Kokkos::finalize(); //! Restore output buffer. - // std::cout.flush(); + std::cout.flush(); std::cout.rdbuf(coutbuf); std::cout << output.str() << std::endl; //! Analyze test output. for (const auto& matcher : matchers) { - EXPECT_THAT(output.str(), ::testing::ContainsRegex(matcher)); - } // end TEST + EXPECT_THAT(output.str(), HasSubstr(matcher)); + } + + EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: FATAL: No child library of " + "sampler utility library to call"))); + + EXPECT_THAT(output.str(), + Not(HasSubstr("KokkosP: FATAL: Kokkos Tools Programming " + "Interface's tool-invoked Fence is NULL!"))); + }