2012-02-06 15:11:43 -05:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2014-07-04 13:33:18 -04:00
|
|
|
/*
|
2008-12-31 18:57:36 -05:00
|
|
|
* 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.
|
|
|
|
|
*
|
2014-07-04 13:33:18 -04:00
|
|
|
* Copyright 2008 - 2011 Red Hat, Inc.
|
2008-12-31 18:57:36 -05:00
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NM_GLIB_COMPAT_H__
|
|
|
|
|
#define __NM_GLIB_COMPAT_H__
|
2008-12-31 18:57:36 -05:00
|
|
|
|
2012-02-07 11:20:57 +01:00
|
|
|
|
2008-12-31 18:57:36 -05:00
|
|
|
#include <glib.h>
|
2012-07-02 13:20:21 -05:00
|
|
|
#include <glib-object.h>
|
2008-12-31 18:57:36 -05:00
|
|
|
|
2014-07-26 21:13:52 +02:00
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
|
|
|
|
|
|
#undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
#undef G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
|
|
|
|
|
#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
|
|
|
|
_Pragma("clang diagnostic push") \
|
|
|
|
|
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
|
|
|
|
|
|
|
|
|
|
#define G_GNUC_END_IGNORE_DEPRECATIONS \
|
|
|
|
|
_Pragma("clang diagnostic pop")
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2013-02-24 13:01:08 +01:00
|
|
|
#include "nm-gvaluearray-compat.h"
|
|
|
|
|
|
2014-07-26 21:13:52 +02:00
|
|
|
|
2012-10-22 12:36:09 -05:00
|
|
|
#if !GLIB_CHECK_VERSION(2,34,0)
|
|
|
|
|
static inline void
|
|
|
|
|
g_type_ensure (GType type)
|
|
|
|
|
{
|
|
|
|
|
if (G_UNLIKELY (type == (GType)-1))
|
|
|
|
|
g_error ("can't happen");
|
|
|
|
|
}
|
2013-04-03 12:56:13 -04:00
|
|
|
|
|
|
|
|
#define g_clear_pointer(pp, destroy) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
|
|
|
|
|
/* Only one access, please */ \
|
|
|
|
|
gpointer *_pp = (gpointer *) (pp); \
|
|
|
|
|
gpointer _p; \
|
|
|
|
|
/* This assignment is needed to avoid a gcc warning */ \
|
|
|
|
|
GDestroyNotify _destroy = (GDestroyNotify) (destroy); \
|
|
|
|
|
\
|
|
|
|
|
(void) (0 ? (gpointer) *(pp) : 0); \
|
|
|
|
|
do \
|
|
|
|
|
_p = g_atomic_pointer_get (_pp); \
|
|
|
|
|
while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_pp, _p, NULL)); \
|
|
|
|
|
\
|
|
|
|
|
if (_p) \
|
|
|
|
|
_destroy (_p); \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2014-02-08 14:03:49 +01:00
|
|
|
/* These are used to clean up the output of test programs; we can just let
|
|
|
|
|
* them no-op in older glib.
|
|
|
|
|
*/
|
|
|
|
|
#define g_test_expect_message(log_domain, log_level, pattern)
|
|
|
|
|
#define g_test_assert_expected_messages()
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
/* We build with -DGLIB_MAX_ALLOWED_VERSION set to 2.32 to make sure we don't
|
|
|
|
|
* accidentally use new API that we shouldn't. But we don't want warnings for
|
|
|
|
|
* the APIs that we emulate above.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define g_type_ensure(t) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
|
|
|
|
g_type_ensure (t); \
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
#define g_test_expect_message(domain, level, format...) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
|
|
|
|
g_test_expect_message (domain, level, format); \
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
#define g_test_assert_expected_messages_internal(domain, file, line, func) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
|
|
|
|
|
g_test_assert_expected_messages_internal (domain, file, line, func); \
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
2012-10-22 12:36:09 -05:00
|
|
|
#endif
|
|
|
|
|
|
2014-04-17 10:49:01 +02:00
|
|
|
/* g_test_initialized() is only available since glib 2.36. */
|
|
|
|
|
#if !GLIB_CHECK_VERSION (2, 36, 0)
|
|
|
|
|
#define g_test_initialized() (g_test_config_vars->test_initialized)
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-04-22 17:05:41 +02:00
|
|
|
/* g_test_skip() is only available since glib 2.38. Add a compatibility wrapper. */
|
|
|
|
|
inline static void
|
|
|
|
|
__nmtst_g_test_skip (const gchar *msg)
|
|
|
|
|
{
|
|
|
|
|
#if GLIB_CHECK_VERSION (2, 38, 0)
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
g_test_skip (msg);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
#else
|
|
|
|
|
g_debug ("%s", msg);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#define g_test_skip __nmtst_g_test_skip
|
|
|
|
|
|
2014-08-19 01:24:49 +02:00
|
|
|
|
|
|
|
|
/* g_test_add_data_func_full() is only available since glib 2.34. Add a compatibility wrapper. */
|
|
|
|
|
inline static void
|
|
|
|
|
__g_test_add_data_func_full (const char *testpath,
|
|
|
|
|
gpointer test_data,
|
|
|
|
|
GTestDataFunc test_func,
|
|
|
|
|
GDestroyNotify data_free_func)
|
|
|
|
|
{
|
|
|
|
|
#if GLIB_CHECK_VERSION (2, 34, 0)
|
|
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
|
|
|
g_test_add_data_func_full (testpath, test_data, test_func, data_free_func);
|
|
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
|
|
|
#else
|
|
|
|
|
g_return_if_fail (testpath != NULL);
|
|
|
|
|
g_return_if_fail (testpath[0] == '/');
|
|
|
|
|
g_return_if_fail (test_func != NULL);
|
|
|
|
|
|
|
|
|
|
g_test_add_vtable (testpath, 0, test_data, NULL,
|
|
|
|
|
(GTestFixtureFunc) test_func,
|
|
|
|
|
(GTestFixtureFunc) data_free_func);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#define g_test_add_data_func_full __g_test_add_data_func_full
|
|
|
|
|
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#endif /* __NM_GLIB_COMPAT_H__ */
|