How to run unit tests in gdb debugger

19,440 views
Skip to first unread message

Chris

unread,
Jan 3, 2011, 12:33:32 AM1/3/11
to Google C++ Testing Framework
This may sound like a stupid question (at least it does to me), but
how do you run unit tests in the gdb debugger on the command line?
I've built some unit tests and they ran and passed. I then made a
change to the code under test and now the tests failed. I know I can
revert the change or fix the production code to make it pass, but I
would really like to know how to step through the production code
while it is under test. I couldn't find anything in the FAQ or other
documentation that explained how to do this. Any help is greatly
appreciated. I'm running on Kubuntu (Ubuntu with KDE) 10.10
Maverick. Thanks!

-Chris

Mike

unread,
Jan 3, 2011, 6:21:18 AM1/3/11
to Google C++ Testing Framework
This is pretty easy, just invoke gdb <test_executable> from the
directory containing the executable.

Here is a quick intro to gdb if you are unfamiliar:
http://www.cs.cmu.edu/~gilpin/tutorial/

Regards,
Mike

Qingpeng Niu

unread,
Mar 24, 2015, 5:31:04 PM3/24/15
to googletes...@googlegroups.com
This did not answer the question at all. Your answer is about how to use GDB. 
The question is how to debug google unit test with GDB. 

Keith Ray

unread,
Mar 24, 2015, 5:37:20 PM3/24/15
to Qingpeng Niu, googletes...@googlegroups.com
You debug unit tests just like you debug application code. Set a breakpoint.
--

---
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.

Qingpeng Niu

unread,
Mar 24, 2015, 5:51:56 PM3/24/15
to Keith Ray, googletes...@googlegroups.com
Suppose in YourLiteralTest you have two unit tests
TestStringConstructor
TestBlobConstructor

When your run the binary, it will show:
[==========] Running 2 tests from 1 test cases.
[----------] Global test environment set-up.
[----------] 2 tests from YourLiteralTest
[ RUN      ] YourLiteralTest.TestStringConstructor
[       OK ] YourLiteralTest.TestStringConstructor (0 ms)
[ RUN      ] YourLiteralTest.TestBlobConstructor
[       OK ] YourLiteralTest.TestBlobConstructor (0 ms)

The original question is how to setup break point or what is the function name for break point setup? Not how to use GDB. There are a bunch of tutorials about GDB. If they ask how to use gdb, he will not ask here. 

The answer should be 

"gdb ./helloword.x
break YourLiteralTest_TestStringConstructor_Test::TestBody

Not how to use GDB.  

--
Qingpeng Niu
Department of Computer Science and Engineering at OSU

Vineet Ghatge H

unread,
Aug 14, 2015, 10:36:14 AM8/14/15
to Google C++ Testing Framework, keit...@gmail.com
What is Testbody?
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages