11#include < iostream>
2- #include < regex>
32#include < sstream>
43
5- #include " Kokkos_Core.hpp"
4+ #include " gmock/gmock.h"
5+ #include " gtest/gtest.h"
66
7- #include " utils/demangle .hpp"
7+ #include " Kokkos_Core .hpp"
88
99struct Tester {
1010 struct TagNamed {};
@@ -49,9 +49,18 @@ static const std::vector<std::string> matchers{
4949 " [0-9.e]+ sec [0-9.]+% 100.0% 0.0% ------ 1 Tester/Tester::TagUnnamed "
5050 " \\ [for\\ ]" };
5151
52- int main (int argc, char * argv[]) {
52+ /* *
53+ * @test This test checks that the tool effectively uses
54+ * the demangling helpers.
55+ */
56+ TEST (SpaceTimeStackTest, demangling) {
57+ // ! Fake arguments a user would give via CLI.
58+ std::string arg {" --kokkos-tools-libs=" LIBKP_SPACE_TIME_STACK};
59+ int argc = 1 ;
60+ std::vector<char *> argv {arg.data (), nullptr };
61+
5362 // ! Initialize @c Kokkos.
54- Kokkos::initialize (argc, argv);
63+ Kokkos::initialize (argc, argv. data () );
5564
5665 // ! Redirect output for later analysis.
5766 std::cout.flush ();
@@ -71,10 +80,6 @@ int main(int argc, char* argv[]) {
7180
7281 // ! Analyze test output.
7382 for (const auto & matcher : matchers) {
74- if (!std::regex_search (output.str (), std::regex (matcher)))
75- throw std::runtime_error (" Couln't find " + matcher + " in output\n " +
76- output.str ());
83+ EXPECT_THAT (output.str (), ::testing::ContainsRegex (matcher));
7784 }
78-
79- return EXIT_SUCCESS;
8085}
0 commit comments