From 7a9d5cb6ab4d6baf9e163af60024730a35ca040d Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 30 May 2020 17:07:21 -0700 Subject: [PATCH] WIN32: SetErrorMode(0) --- src/pvxs/unittest.h | 5 +++++ src/unittest.cpp | 14 +++++++++++++- src/utilpvt.h | 1 + test/testbitmask.cpp | 1 + test/testconfig.cpp | 1 + test/testdata.cpp | 1 + test/testev.cpp | 1 + test/testget.cpp | 1 + test/testinfo.cpp | 1 + test/testmon.cpp | 1 + test/testput.cpp | 1 + test/testpvreq.cpp | 1 + test/testrpc.cpp | 1 + test/testshared.cpp | 1 + test/testsock.cpp | 1 + test/testtype.cpp | 1 + test/testudp.cpp | 1 + test/testxcode.cpp | 1 + 18 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/pvxs/unittest.h b/src/pvxs/unittest.h index 8b9c412..265cf01 100644 --- a/src/pvxs/unittest.h +++ b/src/pvxs/unittest.h @@ -22,6 +22,11 @@ namespace pvxs { +/** Prepare for testing. Call after testPlan() + */ +PVXS_API +void testSetup(); + /** Free some internal global allocations to avoid false positives in * valgrind (or similar) tools looking for memory leaks. * diff --git a/src/unittest.cpp b/src/unittest.cpp index 3e21d88..72c6ec7 100644 --- a/src/unittest.cpp +++ b/src/unittest.cpp @@ -1,4 +1,4 @@ -/** +/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. @@ -12,6 +12,18 @@ namespace pvxs { +void testSetup() +{ +#ifdef _WIN32 + // One of the SEM_* options, either SEM_FAILCRITICALERRORS or SEM_NOGPFAULTERRORBOX, + // depending on who you ask, acts to disable Windows Error Reporting entirely. + // This also prevents the AeDebug facility from triggering. + UINT prev = SetErrorMode(0); + if(prev) + testDiag("SetErrorMode() disables 0x%x\n", (unsigned)prev); +#endif +} + void cleanup_for_valgrind() { for(auto& pair : instanceSnapshot()) { diff --git a/src/utilpvt.h b/src/utilpvt.h index 2a0d38e..c868c4e 100644 --- a/src/utilpvt.h +++ b/src/utilpvt.h @@ -12,6 +12,7 @@ # define WIN32_LEAN_AND_MEAN # include # include +# include #else # include #endif diff --git a/test/testbitmask.cpp b/test/testbitmask.cpp index eb8b1a3..75a95fb 100644 --- a/test/testbitmask.cpp +++ b/test/testbitmask.cpp @@ -200,6 +200,7 @@ void testSer() MAIN(testbitmask) { testPlan(76); + testSetup(); testEmpty(); testBasic1(); testBasic2(); diff --git a/test/testconfig.cpp b/test/testconfig.cpp index f0dfc65..d24d711 100644 --- a/test/testconfig.cpp +++ b/test/testconfig.cpp @@ -56,6 +56,7 @@ void testParse() MAIN(testconfig) { testPlan(4); + testSetup(); logger_config_env(); testParse(); cleanup_for_valgrind(); diff --git a/test/testdata.cpp b/test/testdata.cpp index a94cc2e..ee064aa 100644 --- a/test/testdata.cpp +++ b/test/testdata.cpp @@ -262,6 +262,7 @@ void testAssignSimilar() MAIN(testdata) { testPlan(78); + testSetup(); testTraverse(); testAssign(); testName(); diff --git a/test/testev.cpp b/test/testev.cpp index 977bc00..a65393a 100644 --- a/test/testev.cpp +++ b/test/testev.cpp @@ -117,6 +117,7 @@ MAIN(testev) { SockAttach attach; testPlan(15); + testSetup(); test_call(); test_fill_evbuf(); cleanup_for_valgrind(); diff --git a/test/testget.cpp b/test/testget.cpp index 0fff359..1b8771f 100644 --- a/test/testget.cpp +++ b/test/testget.cpp @@ -246,6 +246,7 @@ void testError(bool phase) MAIN(testget) { testPlan(15); + testSetup(); logger_config_env(); Tester().testWaiter(); Tester().loopback(); diff --git a/test/testinfo.cpp b/test/testinfo.cpp index e82791d..ce104eb 100644 --- a/test/testinfo.cpp +++ b/test/testinfo.cpp @@ -207,6 +207,7 @@ void testError() MAIN(testinfo) { testPlan(12); + testSetup(); logger_config_env(); Tester().loopback(); Tester().lazy(); diff --git a/test/testmon.cpp b/test/testmon.cpp index 5fa15ad..07c5cde 100644 --- a/test/testmon.cpp +++ b/test/testmon.cpp @@ -251,6 +251,7 @@ struct TestReconn : public BasicTest MAIN(testmon) { testPlan(22); + testSetup(); logger_config_env(); TestLifeCycle().testBasic(true); TestLifeCycle().testBasic(false); diff --git a/test/testput.cpp b/test/testput.cpp index 2fb7c89..1823fff 100644 --- a/test/testput.cpp +++ b/test/testput.cpp @@ -319,6 +319,7 @@ void testError() MAIN(testput) { testPlan(26); + testSetup(); logger_config_env(); Tester().loopback(false); Tester().loopback(true); diff --git a/test/testpvreq.cpp b/test/testpvreq.cpp index a6fdeab..9d663da 100644 --- a/test/testpvreq.cpp +++ b/test/testpvreq.cpp @@ -265,6 +265,7 @@ void testArgs() MAIN(testpvreq) { testPlan(25); + testSetup(); logger_config_env(); testEmpty(); testAssemble(); diff --git a/test/testrpc.cpp b/test/testrpc.cpp index f7fb83c..8d17796 100644 --- a/test/testrpc.cpp +++ b/test/testrpc.cpp @@ -208,6 +208,7 @@ struct Tester { MAIN(testrpc) { testPlan(16); + testSetup(); Tester().echo(); Tester().lazy(); Tester().null(); diff --git a/test/testshared.cpp b/test/testshared.cpp index a4f3edb..b0e0fd3 100644 --- a/test/testshared.cpp +++ b/test/testshared.cpp @@ -201,6 +201,7 @@ void testFromVector() MAIN(testshared) { testPlan(97); + testSetup(); testEmpty(); testEmpty(); testEmpty(); diff --git a/test/testsock.cpp b/test/testsock.cpp index 0bafff2..8dcbf6c 100644 --- a/test/testsock.cpp +++ b/test/testsock.cpp @@ -208,6 +208,7 @@ MAIN(testsock) { SockAttach attach; testPlan(33); + testSetup(); test_udp(); test_local_mcast(); test_from_wire(); diff --git a/test/testtype.cpp b/test/testtype.cpp index fa46e25..1d61781 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -427,6 +427,7 @@ void testFormat() MAIN(testtype) { testPlan(25); + testSetup(); showSize(); testBasic(); testTypeDef(); diff --git a/test/testudp.cpp b/test/testudp.cpp index fe5550a..ec53f66 100644 --- a/test/testudp.cpp +++ b/test/testudp.cpp @@ -152,6 +152,7 @@ int main(int argc, char *argv[]) { SockAttach attach; testPlan(46); + testSetup(); pvxs::logger_config_env(); testBeacon(true); testBeacon(false); diff --git a/test/testxcode.cpp b/test/testxcode.cpp index c7d3584..c0807ad 100644 --- a/test/testxcode.cpp +++ b/test/testxcode.cpp @@ -953,6 +953,7 @@ void testEmptyRequest() MAIN(testxcode) { testPlan(116); + testSetup(); testSerialize1(); testDeserialize1(); testSimpleDef();