tst_qsharedpointer: Fix auto test fail under Windows 7
authorDebao Zhang <dbzhang800@gmail.com>
Tue, 13 Mar 2012 17:46:39 +0000 (10:46 -0700)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Mar 2012 10:40:50 +0000 (11:40 +0100)
The tst_QSharedPointer generate another Process to test some invalid
codes, and it expect that the prcoess will crash and return a non-zero
value.

The process which is a console application was linked to windows
subsystem, and QProcess seems can not get its return value. This
cause the unit test fail.

In addition, when the process crash under debug mode, a debug error
report-dialog will appear, which is very annoying, so I suppress it too.

Task-number: QTBUG-24160
Change-Id: Ia1c872d4515c83b0aa516bcfe3783f59797d2d49
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
tests/auto/corelib/tools/qsharedpointer/externaltests.cpp
tests/auto/corelib/tools/qsharedpointer/qsharedpointer.pro

index fb946d9..0e7e2fa 100644 (file)
@@ -353,15 +353,25 @@ namespace QTest {
             "\n"
             "#ifdef Q_OS_WIN\n"
             "#include <windows.h>\n"
+            "#if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)\n"
+            "#include <crtdbg.h>\n"
+            "#endif\n"
             "static void q_test_setup()\n"
             "{\n"
             "    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);\n"
             "}\n"
+            "static int __cdecl CrtDbgHook(int /*reportType*/, char * /*message*/, int * /*returnValue*/)\n"
+            "{\n"
+            "    return TRUE;\n"
+            "}\n"
             "#else\n"
             "static void q_test_setup() { }\n"
             "#endif\n"
             "int main(int argc, char **argv)\n"
-            "{\n";
+            "{\n"
+            "#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) && !defined(Q_OS_WINCE)\n"
+            "    _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, CrtDbgHook);\n"
+            "#endif\n";
 
         switch (appType) {
         applicationless:
@@ -456,6 +466,7 @@ namespace QTest {
             "TARGET   = externaltest\n"
             "CONFIG   -= app_bundle\n"        // for the Mac
             "CONFIG   -= debug_and_release\n"
+            "CONFIG   += console\n"
             "DESTDIR  = .\n"
             "OBJECTS_DIR = .\n"
             "UI_DIR   = .\n"
index 1b22710..b1cd309 100644 (file)
@@ -13,5 +13,3 @@ HEADERS = forwarddeclared.h \
 TESTDATA += forwarddeclared.cpp forwarddeclared.h
 
 include(externaltests.pri)
-
-win32:CONFIG += insignificant_test # QTBUG-24160