/** @file $Id$ $Date$ $Author$ @copy © Marc Wäckerlin @license LGPL, see file COPYING 1 2 3 4 5 6 7 8 5678901234567890123456789012345678901234567890123456789012345678901234567890 */ #include #include #include #include #include #include #include namespace mrw { class StackTraceTest: public CppUnit::TestFixture { public: /// test if symbols are correctely evaluated void StackTrace() { bool init(mrw::StackTrace::createSymtable()); CPPUNIT_ASSERT_MESSAGE("createSymtable() failed! ERROR=" +mrw::StackTrace::error(), init || mrw::StackTrace::error().find("/valgrind/") !=std::string::npos); mrw::StackTrace s; int l(__LINE__); std::string f(__FILE__); std::stringstream ss; ss<first+"\"\n"; msg += "----------------------------------------\n"; std::string::size_type pos(st.find("mrw::StackTraceTest::StackTrace()")); CPPUNIT_ASSERT_MESSAGE("\"mrw::StackTraceTest::StackTrace()\"" " not found!\n"+msg, pos!=std::string::npos); CPPUNIT_ASSERT_MESSAGE('"'+ss.str()+"\" not found!\n"+msg, st.find(ss.str(), pos) < st.size()); CPPUNIT_ASSERT_MESSAGE("\"CppUnit::TestCaller" "::runTest()\" not found!\n"+msg, st.find("CppUnit::TestCaller" "::runTest()") nm /usr/lib/libcppunit-1.10.so.2.0.0 // nm: /usr/lib/libcppunit-1.10.so.2.0.0: no symbols // > file /usr/lib/libcppunit-1.10.so.2.0.0 // /usr/lib/libcppunit-1.10.so.2.0.0: // ELF 32-bit LSB shared object, Intel 80386, // version 1 (SYSV), stripped //CPPUNIT_ASSERT_MESSAGE("\"CppUnit::TestCase::run\" not found!\n"+msg, // st.find("CppUnit::TestCase::run")=st.size()); } CPPUNIT_TEST_SUITE(StackTraceTest); CPPUNIT_TEST(StackTrace); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_REGISTRATION(StackTraceTest); } int main(int argc, char** argv) try { std::ofstream ofs((*argv+std::string(".xml")).c_str()); CppUnit::TextUi::TestRunner runner; runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), ofs)); runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); return runner.run() ? 0 : 1; } catch (std::exception& e) { std::cerr<<"***Exception: "<