Unattended regression tests are blocked by Windows Dialog
Hi all, I have searched through some of the previous postings on this list, but have not been able to find the solution - so I'll try here. I have a test case that (due to an error of course) tries to run code like this: class MyObject { public: virtual void f() {}; }; void MyFailingTestCase() { MyObject * a = NULL; a->f(); } When running these tests in release mode - the whole process is stopped by a windows dialog letting be know that there was a system error (Access Violation) and asks the user to click OK/Debug. I have also tried to pass the --catch_system_errors=yes, but that did not help I am running 1_33_1 version of the library. (libboost_unit_test_framework-vc80-mt-1_33_1.lib) Does anybody know a way around this problem? Olav
________________________________ Date: Wed, 13 Aug 2008 14:45:41 +0200 From: ok@epsis.no To: boost-users@lists.boost.org Subject: [Boost-users] Unattended regression tests are blocked by Windows Dialog Have you tried to catch (...)? I know in the past with boost and a compiler problem, I could not catch (...) and since you are testing the build, I'm not sure this is a complete solution to your problem in any case. I think in the past I have run into this and back on vc6 I think there was some MS specific error handling ( IIRC, I'd have to load the code from CD to check ) or sytem calls you could make but, yes, it can be hard to eliminate all blocks in a system predicated on user interaction. _________________________________________________________________ Your PC, mobile phone, and online services work together like never before. http://clk.atdmt.com/MRT/go/108587394/direct/01/
Olav Kindt wrote:
Hi all,
I have searched through some of the previous postings on this list, but have not been able to find the solution – so I’ll try here.
I have a test case that (due to an error of course) tries to run code like this:
class MyObject
{
public:
virtual void f() {};
};
void MyFailingTestCase()
{
MyObject * a = NULL;
a->f();
}
When running these tests in release mode – the whole process is stopped by a windows dialog letting be know that there was a system error (Access Violation) and asks the user to click OK/Debug.
I have also tried to pass the –-catch_system_errors=yes, but that did not help
I am running 1_33_1 version of the library. (libboost_unit_test_framework-vc80-mt-1_33_1.lib)
Does anybody know a way around this problem?
The only reasonable solution is to fix the test. According to standard C++ the expression "a->f()" using an a with a null pointer value causes undefined behaviour. Why don't you use a valid argument? Possible examples are: void MyFailingTestCase() { MyObject mo; MyObject* a = &mo; a->f(); } or void MyFailingTestCase() { MyObject a; a.f(); } or void MyFailingTestCase() { std::auto_ptr<MyObject> a(new MyObject()); a->f(); } Greetings from Bremen, Daniel Krügler
Daniel Krügler wrote:
Olav Kindt wrote:
Hi all,
I have searched through some of the previous postings on this list, but have not been able to find the solution – so I’ll try here.
I have a test case that (due to an error of course) tries to run code like this:
[snip]
void MyFailingTestCase() { MyObject * a = NULL;
a->f(); }
When running these tests in release mode – the whole process is stopped by a windows dialog letting be know that there was a system error (Access Violation) and asks the user to click OK/Debug.
I have also tried to pass the –-catch_system_errors=yes, but that did not help
I am running 1_33_1 version of the library. (libboost_unit_test_framework-vc80-mt-1_33_1.lib)
Does anybody know a way around this problem?
The only reasonable solution is to fix the test. According to standard C++ the expression "a->f()" using an a with a null pointer value causes undefined behaviour. Why don't you use a valid argument? Possible examples are:
I believe the above is just an example. Under Windows, the dereferencing of the null pointer leads to an access violation which can be handled via SEH (Structured Exception Handling). MSVC provides a way to translate strutured exceptions to C++ exceptions, which Boost.Test is supposed to use. Regards, Johan
Johan Nilsson wrote:
Daniel Krügler wrote: [..]
The only reasonable solution is to fix the test. According to standard C++ the expression "a->f()" using an a with a null pointer value causes undefined behaviour. Why don't you use a valid argument? Possible examples are:
I believe the above is just an example. Under Windows, the dereferencing of the null pointer leads to an access violation which can be handled via SEH (Structured Exception Handling). MSVC provides a way to translate strutured exceptions to C++ exceptions, which Boost.Test is supposed to use.
Thanks for clarification. I was aware of the compiler-specific (and OS-supported) behavior, but not of the extended support of Boost.Test. - Daniel
Olav Kindt
I have also tried to pass the –-catch_system_errors=yes, but that did not help
I am running 1_33_1 version of the library. (libboost_unit_test_framework-vc80-mt-1_33_1.lib)
Does anybody know a way around this problem?
How did you build the library? With VC 8.0 you need to make sure that async exceptions are explicitly enabled. I believe 1.33 version of build tools did not do this. Gennadiy
participants (5)
-
Daniel Krügler
-
Gennadiy Rozental
-
Johan Nilsson
-
Mike Marchywka
-
Olav Kindt