[network-manager-openvpn/th/ovpn-import-bgo761285: 2/10] tests: improve FAIL() macro
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/th/ovpn-import-bgo761285: 2/10] tests: improve FAIL() macro
- Date: Fri, 29 Jan 2016 12:22:32 +0000 (UTC)
commit 366cd7f1bb2f6cd06f3e230211349ef8e133a0a3
Author: Thomas Haller <thaller redhat com>
Date: Thu Jan 28 22:34:37 2016 +0100
tests: improve FAIL() macro
exit(1) doesn't even break in debugger...
shared/nm-test-utils.h | 27 +++++++++------------------
1 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/shared/nm-test-utils.h b/shared/nm-test-utils.h
index 840e25f..c91fa96 100644
--- a/shared/nm-test-utils.h
+++ b/shared/nm-test-utils.h
@@ -26,26 +26,17 @@
#include <unistd.h>
#include <stdarg.h>
-static void
-FAIL(const char *test_name, const char *fmt, ...)
-{
- va_list args;
- char buf[500];
-
- snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt);
-
- va_start (args, fmt);
- vfprintf (stderr, buf, args);
- va_end (args);
- _exit (1);
-}
+#define FAIL(test_name, fmt, ...) \
+ G_STMT_START { \
+ g_error ("%s:%d: FAIL[%s]: " fmt, __FILE__, __LINE__, test_name, ## __VA_ARGS__); \
+ } G_STMT_END
#define ASSERT(x, test_name, fmt, ...) \
-{ \
- if (!(x)) { \
- FAIL (test_name, fmt, ## __VA_ARGS__); \
- } \
-}
+ G_STMT_START { \
+ if (!(x)) { \
+ FAIL (test_name, fmt, ## __VA_ARGS__); \
+ } \
+ } G_STMT_END
#endif /* NM_TEST_HELPERS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]