Why does Google Test not print a stack trace or file name?

3,481 views
Skip to first unread message

Scott French

unread,
Jun 14, 2016, 11:07:57 AM6/14/16
to Google C++ Testing Framework
When I use Google Test and Google Mock, with diagnostic level set to "info", I get messages like this:

    Uninteresting mock function call - taking default action specified at:
    src/pkgtest/test_Foo.cpp:216:
        Function call: GetBar()
              Returns: 4-byte object <00-00 00-00>
    Stack trace:
   
    Uninteresting mock function call - taking default action specified at:
    src/pkgtest/test_Foo.cpp:126:
        Function call: GetBaz()
              Returns: {}
    Stack trace:
    unknown file: Failure
    C++ exception with description "Uninteresting mock function call - returning default value.
        Function call: CreateGrille(@0x7fff6a557050 { 16-byte object <80-D8 BB-01 00-00 00-00 70-D8 BB-01 00-00 00-00> })
        The mock function has no default action set, and its return type has no default value set." thrown in the test body.

I cannot find anything on the internet about why Google Test/Mock won't print a stack trace, or claims "unknown file". What do I need to do to teach it how to properly dump a stack trace?

(I'm on Linux using g++ 4.9, if that makes a difference.)

Samuel Benzaquen

unread,
Jun 14, 2016, 11:25:06 AM6/14/16
to Scott French, Google C++ Testing Framework
gTest doesn't include a stack unwinder. You have to provide your own.
You can do this in include/gtest/internal/custom/gtest.h by defining the GTEST_OS_STACK_TRACE_GETTER_ macro to point an implementation of OsStackTraceGetterInterface.
 
(I'm on Linux using g++ 4.9, if that makes a difference.)

I think you can use libunwind here, but I have not done this integration myself.
 

--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott French

unread,
Jun 14, 2016, 11:55:35 AM6/14/16
to Google C++ Testing Framework, scottc...@gmail.com
Thank you, that's very helpful! I'll take a look at that macro.

Scott
Reply all
Reply to author
Forward
0 new messages