开发者

segmentation fault produced by tests running under CppUnit

Today I found that one of my tests is using some code/library that segfaults. I work in Linux environment in C++ and CppUnit.

Is there any feature of function in CppUnit to test against segfault and report it as fa开发者_开发知识库ilure for the specific test case?

In CppUnit I can even test against exceptions, but I think that what I am asking might be too much! The only thing I found is the section How do I print debug info at this page here.

I was thinking to run the CppUnit executable from a script in pyhon or perl and then check if the core is produced. Do you know some better way to achieve what I want?


A seg fault will result in a non-zero exit status from your test (On Solaris I believe it's 139). Are you able to test this from whatever method is being used to call your unit test?


"Is there any feature of function in CppUnit to test against segfault and report it as failure for the specific test case?"

Nope. Segfault is an OS level violation and you're not allowed to catch it. Even if you try (through use of signal() iirc) you can't do anything about being murdered by the OS.

You need to step through your test program with a debugger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜