diff --git a/include/Makefile.am b/include/Makefile.am index 9dc989ec1c..087afe48f6 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -4,7 +4,6 @@ EXTRA_DIST = \ nm-dbus-glib-types.h \ nm-glib-compat.h \ nm-gvaluearray-compat.h \ - nm-test-helpers.h \ nm-test-utils.h \ nm-version.h.in \ nm-settings-flags.h diff --git a/include/nm-test-helpers.h b/include/nm-test-helpers.h deleted file mode 100644 index cae099a848..0000000000 --- a/include/nm-test-helpers.h +++ /dev/null @@ -1,49 +0,0 @@ -/* NetworkManager -- Network link manager - * - * Dan Williams - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * (C) Copyright 2008 Red Hat, Inc. - */ - -#ifndef NM_TEST_HELPERS_H -#define NM_TEST_HELPERS_H - -#include -#include -#include - -static void -FAIL(const char *test_name, const char *fmt, ...) -{ - va_list args; - char buf[500]; - - g_snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt); - - va_start (args, fmt); - vfprintf (stderr, buf, args); - va_end (args); - _exit (1); -} - -#define ASSERT(x, test_name, fmt, ...) \ - if (!(x)) { \ - FAIL (test_name, fmt, ## __VA_ARGS__); \ - } - -#endif /* NM_TEST_HELPERS_H */ - diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index f42c70d183..3d807153a0 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -24,6 +24,8 @@ #include +#include +#include #include #include #include @@ -302,6 +304,27 @@ nmtst_inet6_from_string (const char *str) return &addr; } +inline static void +FAIL(const char *test_name, const char *fmt, ...) +{ + va_list args; + char buf[500]; + + g_snprintf (buf, 500, "FAIL: (%s) %s\n", test_name, fmt); + + va_start (args, fmt); + vfprintf (stderr, buf, args); + va_end (args); + _exit (1); +} + +#define ASSERT(x, test_name, fmt, ...) \ + if (!(x)) { \ + FAIL (test_name, fmt, ## __VA_ARGS__); \ + } + +/*******************************************************************************/ + #ifdef NM_PLATFORM_H inline static NMPlatformIP6Address * diff --git a/libnm-util/tests/test-crypto.c b/libnm-util/tests/test-crypto.c index 223f407d94..c11b6392f0 100644 --- a/libnm-util/tests/test-crypto.c +++ b/libnm-util/tests/test-crypto.c @@ -28,10 +28,11 @@ #include #include -#include "nm-test-helpers.h" #include "crypto.h" #include "nm-utils.h" +#include "nm-test-utils.h" + #if 0 static const char *pem_rsa_key_begin = "-----BEGIN RSA PRIVATE KEY-----"; static const char *pem_rsa_key_end = "-----END RSA PRIVATE KEY-----"; diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c index c65bd6cad1..5922f1fb87 100644 --- a/libnm-util/tests/test-general.c +++ b/libnm-util/tests/test-general.c @@ -25,7 +25,6 @@ #include #include -#include "nm-test-helpers.h" #include #include "nm-setting-private.h" @@ -46,6 +45,8 @@ #include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" +#include "nm-test-utils.h" + static void vpn_check_func (const char *key, const char *value, gpointer user_data) { diff --git a/libnm-util/tests/test-secrets.c b/libnm-util/tests/test-secrets.c index 19c41943dc..73fc9224b0 100644 --- a/libnm-util/tests/test-secrets.c +++ b/libnm-util/tests/test-secrets.c @@ -22,7 +22,6 @@ #include #include -#include "nm-test-helpers.h" #include #include "nm-setting-connection.h" @@ -37,6 +36,7 @@ #include "nm-setting-pppoe.h" #include "nm-setting-vpn.h" +#include "nm-test-utils.h" #define TEST_NEED_SECRETS_EAP_TLS_CA_CERT TEST_CERT_DIR "/test_ca_cert.pem" #define TEST_NEED_SECRETS_EAP_TLS_CLIENT_CERT TEST_CERT_DIR "/test_key_and_cert.pem" diff --git a/libnm-util/tests/test-setting-8021x.c b/libnm-util/tests/test-setting-8021x.c index a536a2069b..62889c61fc 100644 --- a/libnm-util/tests/test-setting-8021x.c +++ b/libnm-util/tests/test-setting-8021x.c @@ -22,12 +22,13 @@ #include #include -#include "nm-test-helpers.h" #include #include "nm-setting-connection.h" #include "nm-setting-8021x.h" +#include "nm-test-utils.h" + static void compare_blob_data (const char *test, const char *key_path, diff --git a/libnm-util/tests/test-settings-defaults.c b/libnm-util/tests/test-settings-defaults.c index 93468bcce3..15412fed55 100644 --- a/libnm-util/tests/test-settings-defaults.c +++ b/libnm-util/tests/test-settings-defaults.c @@ -22,7 +22,6 @@ #include #include -#include "nm-test-helpers.h" #include #include "nm-setting-8021x.h" @@ -39,6 +38,7 @@ #include "nm-setting-wireless.h" #include "nm-setting-wireless-security.h" +#include "nm-test-utils.h" static void test_defaults (GType type, const char *name) diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c index e32ad78901..cdb1f1f274 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils.c @@ -23,11 +23,10 @@ #include #include -#include "nm-test-helpers.h" - #include "common.h" #include "utils.h" +#include "nm-test-utils.h" static void test_get_ifcfg_name (const char *desc, diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index cb57e04227..98706725e5 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -48,7 +48,6 @@ #include #include -#include "nm-test-helpers.h" #include "NetworkManagerUtils.h" #include "nm-glib-compat.h" @@ -57,6 +56,8 @@ #include "writer.h" #include "utils.h" +#include "nm-test-utils.h" + #if 0 static void connection_diff (NMConnection *a, NMConnection *b) diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c index e2b1576ad9..dc93dcccd6 100644 --- a/src/settings/plugins/ifnet/tests/test_all.c +++ b/src/settings/plugins/ifnet/tests/test_all.c @@ -28,7 +28,6 @@ #include #include -#include "nm-test-helpers.h" #include "nm-linux-platform.h" #include "nm-logging.h" @@ -38,6 +37,8 @@ #include "connection_parser.h" #include "nm-config.h" +#include "nm-test-utils.h" + /* Fake NMConfig handling; the values it returns don't matter, so this * is easier than forcing it to read our own config file, etc. */ diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 652e4af219..8386428703 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -23,12 +23,12 @@ #include -#include "nm-test-helpers.h" #include "nm-logging.h" - #include "interface_parser.h" #include "parser.h" +#include "nm-test-utils.h" + typedef struct { char *key; char *data; diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index a300163b71..5084a45bda 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -41,12 +41,13 @@ #include #include -#include "nm-test-helpers.h" #include "nm-glib-compat.h" #include "reader.h" #include "writer.h" +#include "nm-test-utils.h" + #define TEST_WIRED_FILE TEST_KEYFILES_DIR"/Test_Wired_Connection" #define TEST_WIRELESS_FILE TEST_KEYFILES_DIR"/Test_Wireless_Connection" diff --git a/src/supplicant-manager/tests/test-supplicant-config.c b/src/supplicant-manager/tests/test-supplicant-config.c index d1d0562f2c..9b1038b618 100644 --- a/src/supplicant-manager/tests/test-supplicant-config.c +++ b/src/supplicant-manager/tests/test-supplicant-config.c @@ -39,12 +39,13 @@ #include #include -#include "nm-test-helpers.h" #include "nm-glib-compat.h" #include "nm-supplicant-config.h" #include "nm-supplicant-settings-verify.h" +#include "nm-test-utils.h" + static gboolean validate_opt (const char *detail, GHashTable *hash, diff --git a/src/tests/test-dhcp-options.c b/src/tests/test-dhcp-options.c index c9748cf775..96e9b5c822 100644 --- a/src/tests/test-dhcp-options.c +++ b/src/tests/test-dhcp-options.c @@ -25,12 +25,13 @@ #include #include -#include "nm-test-helpers.h" #include #include "nm-dhcp-manager.h" #include "nm-logging.h" +#include "nm-test-utils.h" + typedef struct { const char *name; const char *value;