Skip to content

Commit

Permalink
Use a memcmp for the expected symbol name.
Browse files Browse the repository at this point in the history
I believe that g++ does not guarantee what a particular
symbol name will be.  Thus, in g++ 11.4.0 (what is in
Ubuntu 22.04), the symbol name here ended with "#2", while
in g++ 13.2.0 (what is in Ubuntu 24.04), the symbol name
ends with "#1".  Given that we can't guarantee this, just
search for the first part of the name up to the number,
which should be good enough for this test.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Mar 26, 2024
1 parent 115034b commit 32aff54
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test_tracetools/test/test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ TEST(TestUtils, valid_symbol_lambda_capture) {

auto m = [&](int other_num) {return num + other_num;};
symbol = tracetools::get_symbol(m);
EXPECT_STREQ(
symbol,
"TestUtils_valid_symbol_lambda_capture_Test::TestBody()::{lambda(int)#2}") <<
"invalid symbol";
const std::string expected_symbol_name =
"TestUtils_valid_symbol_lambda_capture_Test::TestBody()::{lambda(int)#";
EXPECT_EQ(memcmp(symbol, expected_symbol_name.c_str(), expected_symbol_name.length()), 0);
std::free(symbol);
}

Expand Down

0 comments on commit 32aff54

Please sign in to comment.