aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-07-25 00:48:45 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-07-24 22:04:18 +0000
commitdd42994f423a1ea71bd3ec1b686b58c51cfadd64 (patch)
tree621ef8ddc919865fceb4e87460322e29d88f81f4
parentc2b3208e288b8194ba385dee2c84942ab61b552f (diff)
downloadmeson-dd42994f423a1ea71bd3ec1b686b58c51cfadd64.zip
meson-dd42994f423a1ea71bd3ec1b686b58c51cfadd64.tar.gz
meson-dd42994f423a1ea71bd3ec1b686b58c51cfadd64.tar.bz2
tests/122 shared module: More verbose logging
So we know why the syscalls failed.
-rw-r--r--test cases/common/122 shared module/module.c16
-rw-r--r--test cases/common/122 shared module/prog.c2
2 files changed, 16 insertions, 2 deletions
diff --git a/test cases/common/122 shared module/module.c b/test cases/common/122 shared module/module.c
index 181b760..9c8774d 100644
--- a/test cases/common/122 shared module/module.c
+++ b/test cases/common/122 shared module/module.c
@@ -27,6 +27,19 @@ fptr find_any_f (const char *name) {
#include <windows.h>
#include <tlhelp32.h>
+static wchar_t*
+win32_get_last_error (void)
+{
+ wchar_t *msg = NULL;
+
+ FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
+ | FORMAT_MESSAGE_IGNORE_INSERTS
+ | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, GetLastError (), 0,
+ (LPWSTR) &msg, 0, NULL);
+ return msg;
+}
+
/* Unlike Linux and OS X, when a library is loaded, all the symbols aren't
* loaded into a single namespace. You must fetch the symbol by iterating over
* all loaded modules. Code for finding the function from any of the loaded
@@ -38,7 +51,8 @@ fptr find_any_f (const char *name) {
snapshot = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE, 0);
if (snapshot == (HANDLE) -1) {
- printf("Could not get snapshot\n");
+ wchar_t *msg = win32_get_last_error ();
+ printf("Could not get snapshot: %S\n", msg);
return 0;
}
diff --git a/test cases/common/122 shared module/prog.c b/test cases/common/122 shared module/prog.c
index 2b63840..8b56d93 100644
--- a/test cases/common/122 shared module/prog.c
+++ b/test cases/common/122 shared module/prog.c
@@ -8,7 +8,7 @@ typedef int (*fptr) (void);
#include <windows.h>
-wchar_t*
+static wchar_t*
win32_get_last_error (void)
{
wchar_t *msg = NULL;