diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-09-14 16:10:41 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-09-14 16:31:06 +0300 |
commit | 965d285ed2dd71331107e82b1b919ce292cb841a (patch) | |
tree | f64a23501e907a80f1b36265c9083fd03c14732e /test | |
parent | disable incremental linking for the tests (diff) | |
download | winapi-debug-965d285ed2dd71331107e82b1b919ce292cb841a.tar.gz winapi-debug-965d285ed2dd71331107e82b1b919ce292cb841a.zip |
unit_tests: fix the tests
Sometimes, 0x0 would creep into a call stack for some reason.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit_tests/call_stack.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/test/unit_tests/call_stack.cpp b/test/unit_tests/call_stack.cpp index 481ab6e..cc5b74e 100644 --- a/test/unit_tests/call_stack.cpp +++ b/test/unit_tests/call_stack.cpp @@ -3,6 +3,7 @@ #include <pdb/all.hpp> #include <test_lib.hpp> +#include <boost/optional.hpp> #include <boost/test/unit_test.hpp> #include <algorithm> @@ -30,15 +31,21 @@ BOOST_AUTO_TEST_CASE(call_stack) { } // Second, resolve the symbols: - std::vector<pdb::SymbolInfo> symbols; + std::vector<boost::optional<pdb::SymbolInfo>> symbols; symbols.reserve(call_stack.length); BOOST_TEST_MESSAGE("Resolved symbols:"); for (const auto& addr : call_stack) { - symbols.emplace_back(dbghelp.resolve_symbol(addr)); - const auto& symbol = symbols.back(); - BOOST_TEST_MESSAGE('\t' << pdb::format_address(symbol.get_offline_address()) << ' ' - << symbol.get_name()); + try { + auto symbol = dbghelp.resolve_symbol(addr); + BOOST_TEST_MESSAGE('\t' << pdb::format_address(symbol.get_offline_address()) << ' ' + << symbol.get_name()); + symbols.emplace_back(std::move(symbol)); + } catch (const std::system_error& e) { + symbols.emplace_back(boost::none); + BOOST_TEST_MESSAGE('\t' << pdb::format_address(addr) + << " Couldn't resolve symbol: " << e.what()); + } } { @@ -47,7 +54,7 @@ BOOST_AUTO_TEST_CASE(call_stack) { const auto check = [&](pdb::Address addr) { for (const auto& symbol : symbols) - if (symbol.get_offline_address() == addr) + if (symbol && symbol->get_offline_address() == addr) return true; return false; }; |