You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
When testing a function, say "foo", that uses "printf", if I a
mock "printf" using mock() and check_expected() and write a test
for "foo", when executing the test, cmockery crashes (segfault). Here is a
small snippet of code illustrating what I mean:
// foo.c
int foo() {
return printf("toto");
}
// foo_test.c
int printf(const char *format, ...) {
check_expected(format);
return (int)mock();
}
void my_test(void **state) {
expect_string(printf, format, "toto");
will_return(printf, 30);
assert_int_equal(foo(), 30);
}
When executing the test, the program segfaults. Here is the gdb backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x0804928b in list_find ()
(gdb) bt
#0 0x0804928b in list_find ()
#1 0x080495fb in get_symbol_value ()
#2 0x0804a6ff in _check_expected ()
#3 0x08048ce3 in printf ()
#4 0x0804aff0 in vprint_message ()
#5 0x0804b057 in print_message ()
#6 0x0804b106 in _run_test ()
#7 0x0804b3d1 in _run_tests ()
#8 0x08048db3 in main ()
What is the expected output? What do you see instead?
the test should pass (?)
What version of the product are you using? On what operating system?
cmockery 0.1.2 on linux (debian 4.1.1-21) with gcc 4.1.2
I attached the code provoking the buf...
Otherwise cmockery rules! ;-)
Thanks for looking into this!
Original issue reported on code.google.com by Cedric.M...@gmail.com on 15 Oct 2009 at 9:22
Original issue reported on code.google.com by
Cedric.M...@gmail.com
on 15 Oct 2009 at 9:22Attachments:
The text was updated successfully, but these errors were encountered: