|
From: Branden A. <b.m...@gm...> - 2016-06-14 17:33:27
|
Are you attempting to detect the segfault and allow the test to pass or fail? If you expect the test to pass if and only if it ends in a segfault, you will need to use the tcase_add_test_raise_signal() <https://libcheck.github.io/check/doc/doxygen/html/check_8h.html#a5bee959c746a315a6ac360d6516c2119> call to add the test case. For example <https://github.com/libcheck/check/blob/master/tests/check_check_sub.c>: START_TEST(test_segv_pass) { raise (SIGSEGV); } END_TEST ... TCase *tc_signal; tc_signal = tcase_create("Signal Tests"); tcase_add_test_raise_signal (tc_signal, test_segv_pass, 11); /* pass */ If you expect the test case to fail if a segfault is encountered, nothing special needs to be done; the test will fail if a signal is not caught. In both cases, make sure that you are configuring the suite runner to use fork. This should be the case by default, but it can be explicitly set using srunner_set_fork_status() <https://libcheck.github.io/check/doc/doxygen/html/check_8h.html#a0085fc05eba2e9048822aa93aeebc2d2> . - Branden On Tue, Jun 14, 2016 at 11:37 AM, JIN, ZHEMING <ji...@em...> wrote: > Hi > > > > How can I catch the segfault error when malloc(0) happens in C check ? > > On the CentOS, malloc(0) doesn’t return NULL. > > > > Thanks > > > ------------------------------------------------------------------------------ > What NetFlow Analyzer can do for you? Monitors network bandwidth and > traffic > patterns at an interface-level. Reveals which users, apps, and protocols > are > consuming the most bandwidth. Provides multi-vendor support for NetFlow, > J-Flow, sFlow and other flows. Make informed decisions using capacity > planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e > _______________________________________________ > Check-devel mailing list > Che...@li... > https://lists.sourceforge.net/lists/listinfo/check-devel > > |