Please sign in to comment.
win32: fix assert-msg-test
On windows, libtool install a wrapper executable in "$(builddir)" which is capable of correctly executing the real (and uninstalled) executable living in "$(builddir)/.libs". We have to ensure $msg_test points to the wrapper executable if it exists. Additionally, g_assert() eventually calls g_assertion_message() which calls abort(). msvcrt's abort() immediately exits the process with this well known message: $ assert-msg-test.exe ** ERROR:c:/dev/gnome.org/gnome-windows/checkout/glib/git/src/tests/assert-msg-test.c:7:main: assertion failed: (42 < 0) This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. and presents the user with a "assert-msg-test.exe has stopped working" dialog box. The message does not belong in the build output as all we care about is "PASS: run-assert-msg-test.sh". The dialog currently prevents the test suite to be run unattended (think build bots). Calling SetErroMode() with the appropriate flags fixes both issues. Additionally, the abort() call exits the application outside the control of MinGW's gdb, so when we want to print the value of (char*) __glib_assert_msg as is done in run-assert-msg-test.sh, the process has already been torn down, the stack is gone and we're basically left with nothing: $ libtool --mode=execute gdb --batch --ex run --ex "set print elements 0" --ex "print (char*) __glib_assert_msg" assert-msg-test.exe 2> /dev/null [New Thread 4384.0x130] [Inferior 1 (process 4384) exited with code 03] $1 = 0x0 However, adding a breakpoint on abort() does allow us to get at the value of (char*) __glib_assert_msg: $ libtool --mode=execute gdb --batch --ex "break abort" --ex run --ex "set print elements 0" --ex "print (char*) __glib_assert_msg" assert-msg-test.exe 2> /dev/null Breakpoint 1 at 0x401b34 [New Thread 8116.0x16b4] Breakpoint 1, 0x68675524 in abort () from c:\dev\gnome.org\gnome-windows\checkout\glib\git\build\glib\.libs\libglib-2.0-0.dll $1 = 0x3a21b0 "ERROR:c:/dev/gnome.org/gnome-windows/checkout/glib/git/src/tests/assert-msg-test.c:7:main: assertion failed: (42 < 0)" Doing so finally makes the test pass on windows.
- Loading branch information...
Showing with 14 additions and 4 deletions.
|@@ -1,8 +1,16 @@|
|int main(int argc, char **argv)|
|- g_assert(42 < 0);|
|- return 0;|
|+ SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);|
|+ g_assert(42 < 0);|
|+ return 0;|