How to mock syslog-like function in a useful way?

347 views
Skip to first unread message

MartinS

unread,
Sep 16, 2011, 4:07:21 AM9/16/11
to googl...@googlegroups.com
Hi,

I am mocking/faking a syslog-like function for debug printouts. I only got it to work by faking it and forwarding it to a vsyslog-like mock.
It works nice in principle, but it renders "--gmock_verbose=info" useless, since it fills up the screen with its matching, and that matching doesn't even show anything useful.
Is there a better way?

/Martin

P.S. Example output (imagine this times 20 000, interleaved with 20 _interesting_ messages...):

dcp_module.cpp:39 (do_register) Entry:""

test/suite/suiteNodes.cpp:95: Mock function call matches EXPECT_CALL(*this, nb_vsyslog(_, NotNull(), _))...
    Function call: nb_vsyslog(10, 0x83c1b2a pointing to "%s:%d (%s) %s:\"%s\"", 0xbfa7cfa8 pointing to "")
Stack trace:

dcp_module.cpp:49 (do_register) Exit:""

test/suite/suiteNodes.cpp:95: Mock function call matches EXPECT_CALL(*this, nb_vsyslog(_, NotNull(), _))...
    Function call: nb_vsyslog(10, 0x83c1b2a pointing to "%s:%d (%s) %s:\"%s\"", 0xbfa7cfa8 pointing to "")
Stack trace:

dcp_module.cpp:55 (activate) Entry:""

test/suite/suiteNodes.cpp:95: Mock function call matches EXPECT_CALL(*this, nb_vsyslog(_, NotNull(), _))...
    Function call: nb_vsyslog(10, 0x83c1b2a pointing to "%s:%d (%s) %s:\"%s\"", 0xbfa7cf48 pointing to "")
Stack trace:

Vlad Losev

unread,
Sep 16, 2011, 6:56:07 AM9/16/11
to googl...@googlegroups.com

Martin Svensson

unread,
Sep 16, 2011, 2:19:02 PM9/16/11
to googl...@googlegroups.com
I feel kind of stupid now... Thanks.

/Martin

Martin Svensson

unread,
Oct 3, 2011, 6:34:21 AM10/3/11
to googl...@googlegroups.com

That is a better way, but actually, I still don't know how to get rid of all the (thousands of) "Uninteresting mock function call - taking default action specified at:" messages when using "--gmock_verbose=info".

I seem to need a variant of "--gmock_verbose" that only affects StrictMock.
Sometimes I might possibly need to debug NiceMock calls in that way, but usually I only debug StrictMock calls and then the NiceMock calls are very much in the way.

/Martin

Reply all
Reply to author
Forward
0 new messages