/*******************************************************************/
-#define test_assert(condition) \
-do { \
- if (!G_LIKELY (condition)) \
- nm_test_service_cleanup (sinfo); \
- g_assert (condition); \
-} while (0)
-
-#define test_assert_cmpint(a, b, c) \
-do { \
- if (!G_LIKELY (a b c)) \
- nm_test_service_cleanup (sinfo); \
- g_assert_cmpint (a, b, c); \
-} while (0)
-
-#define test_assert_cmpstr(a, b, c) \
-do { \
- if (!G_LIKELY (g_str_hash (a) b g_str_hash (c))) \
- nm_test_service_cleanup (sinfo); \
- g_assert_cmpstr (a, b, c); \
-} while (0)
-
-#define test_assert_no_error(e) \
-do { \
- if (G_UNLIKELY (e)) \
- nm_test_service_cleanup (sinfo); \
- g_assert_no_error (e); \
-} while (0)
-
static NMClient *
test_client_new (void)
{
NM_OBJECT_DBUS_CONNECTION, bus,
NM_OBJECT_DBUS_PATH, NM_DBUS_PATH,
NULL);
- test_assert (client != NULL);
+ g_assert (client != NULL);
dbus_g_connection_unref (bus);
3000,
NULL,
&error);
- test_assert_no_error (error);
- test_assert (ret);
- test_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
if (out_path)
g_variant_get (ret, "(o)", out_path);
g_variant_unref (ret);
NMDevice *device,
DeviceAddedInfo *info)
{
- test_assert (device);
- test_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
+ g_assert (device);
+ g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
info->signaled = TRUE;
device_add_check_quit (info);
}
NMDevice *device;
devices = nm_client_get_devices (c);
- test_assert (devices);
- test_assert_cmpint (devices->len, ==, 1);
+ g_assert (devices);
+ g_assert_cmpint (devices->len, ==, 1);
device = g_ptr_array_index (devices, 0);
- test_assert (device);
- test_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
+ g_assert (device);
+ g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
info->notified = TRUE;
client = test_client_new ();
devices = nm_client_get_devices (client);
- test_assert (devices == NULL);
+ g_assert (devices == NULL);
/* Tell the test service to add a new device */
add_device ("AddWiredDevice", "eth0", NULL);
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.signaled);
- test_assert (info.notified);
+ g_assert (info.signaled);
+ g_assert (info.notified);
g_signal_handlers_disconnect_by_func (client, device_added_cb, &info);
g_signal_handlers_disconnect_by_func (client, devices_notify_cb, &info);
devices = nm_client_get_devices (client);
- test_assert (devices);
- test_assert_cmpint (devices->len, ==, 1);
+ g_assert (devices);
+ g_assert_cmpint (devices->len, ==, 1);
device = g_ptr_array_index (devices, 0);
- test_assert (device);
- test_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
+ g_assert (device);
+ g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
g_object_unref (client);
g_clear_pointer (&sinfo, nm_test_service_cleanup);
NMDevice *device,
WifiApInfo *info)
{
- test_assert_cmpstr (nm_device_get_iface (device), ==, "wlan0");
+ g_assert_cmpstr (nm_device_get_iface (device), ==, "wlan0");
info->found = TRUE;
wifi_check_quit (info);
}
got_ap_path (WifiApInfo *info, const char *path)
{
if (info->ap_path)
- test_assert_cmpstr (info->ap_path, ==, path);
+ g_assert_cmpstr (info->ap_path, ==, path);
else
info->ap_path = g_strdup (path);
}
NMAccessPoint *ap,
WifiApInfo *info)
{
- test_assert (ap);
- test_assert_cmpstr (nm_access_point_get_bssid (ap), ==, expected_bssid);
+ g_assert (ap);
+ g_assert_cmpstr (nm_access_point_get_bssid (ap), ==, expected_bssid);
got_ap_path (info, nm_object_get_path (NM_OBJECT (ap)));
info->signaled = TRUE;
NMAccessPoint *ap;
aps = nm_device_wifi_get_access_points (w);
- test_assert (aps);
- test_assert_cmpint (aps->len, ==, 1);
+ g_assert (aps);
+ g_assert_cmpint (aps->len, ==, 1);
ap = g_ptr_array_index (aps, 0);
- test_assert (ap);
- test_assert_cmpstr (nm_access_point_get_bssid (ap), ==, "66:55:44:33:22:11");
+ g_assert (ap);
+ g_assert_cmpstr (nm_access_point_get_bssid (ap), ==, "66:55:44:33:22:11");
got_ap_path (info, nm_object_get_path (NM_OBJECT (ap)));
info->notified = TRUE;
NMAccessPoint *ap,
WifiApInfo *info)
{
- test_assert (ap);
- test_assert_cmpstr (info->ap_path, ==, nm_object_get_path (NM_OBJECT (ap)));
+ g_assert (ap);
+ g_assert_cmpstr (info->ap_path, ==, nm_object_get_path (NM_OBJECT (ap)));
info->signaled = TRUE;
wifi_check_quit (info);
const GPtrArray *aps;
aps = nm_device_wifi_get_access_points (w);
- test_assert (aps == NULL);
+ g_assert (aps == NULL);
info->notified = TRUE;
wifi_check_quit (info);
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.found);
+ g_assert (info.found);
g_signal_handlers_disconnect_by_func (client, wifi_device_added_cb, &info);
wifi = (NMDeviceWifi *) nm_client_get_device_by_iface (client, "wlan0");
- test_assert (NM_IS_DEVICE_WIFI (wifi));
+ g_assert (NM_IS_DEVICE_WIFI (wifi));
/*************************************/
/* Add the wifi device */
3000,
NULL,
&error);
- test_assert_no_error (error);
- test_assert (ret);
- test_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
g_variant_get (ret, "(o)", &expected_path);
g_variant_unref (ret);
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.signaled);
- test_assert (info.notified);
- test_assert (info.ap_path);
- test_assert_cmpstr (info.ap_path, ==, expected_path);
+ g_assert (info.signaled);
+ g_assert (info.notified);
+ g_assert (info.ap_path);
+ g_assert_cmpstr (info.ap_path, ==, expected_path);
g_signal_handlers_disconnect_by_func (wifi, wifi_ap_added_cb, &info);
g_signal_handlers_disconnect_by_func (wifi, wifi_ap_add_notify_cb, &info);
3000,
NULL,
&error);
- test_assert_no_error (error);
+ g_assert_no_error (error);
g_clear_pointer (&ret, g_variant_unref);
g_signal_connect (wifi,
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.signaled);
- test_assert (info.notified);
+ g_assert (info.signaled);
+ g_assert (info.notified);
g_signal_handlers_disconnect_by_func (wifi, wifi_ap_removed_cb, &info);
g_signal_handlers_disconnect_by_func (wifi, wifi_ap_remove_notify_cb, &info);
NMDevice *device,
WimaxNspInfo *info)
{
- test_assert_cmpstr (nm_device_get_iface (device), ==, "wmx0");
+ g_assert_cmpstr (nm_device_get_iface (device), ==, "wmx0");
info->found = TRUE;
wimax_check_quit (info);
}
got_nsp_path (WimaxNspInfo *info, const char *path)
{
if (info->nsp_path)
- test_assert_cmpstr (info->nsp_path, ==, path);
+ g_assert_cmpstr (info->nsp_path, ==, path);
else
info->nsp_path = g_strdup (path);
}
NMWimaxNsp *nsp,
WimaxNspInfo *info)
{
- test_assert (nsp);
- test_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
+ g_assert (nsp);
+ g_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
got_nsp_path (info, nm_object_get_path (NM_OBJECT (nsp)));
info->signaled = TRUE;
NMWimaxNsp *nsp;
nsps = nm_device_wimax_get_nsps (w);
- test_assert (nsps);
- test_assert_cmpint (nsps->len, ==, 1);
+ g_assert (nsps);
+ g_assert_cmpint (nsps->len, ==, 1);
nsp = g_ptr_array_index (nsps, 0);
- test_assert (nsp);
- test_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
+ g_assert (nsp);
+ g_assert_cmpstr (nm_wimax_nsp_get_name (nsp), ==, expected_nsp_name);
got_nsp_path (info, nm_object_get_path (NM_OBJECT (nsp)));
info->notified = TRUE;
NMWimaxNsp *nsp,
WimaxNspInfo *info)
{
- test_assert (nsp);
- test_assert_cmpstr (info->nsp_path, ==, nm_object_get_path (NM_OBJECT (nsp)));
+ g_assert (nsp);
+ g_assert_cmpstr (info->nsp_path, ==, nm_object_get_path (NM_OBJECT (nsp)));
info->signaled = TRUE;
wimax_check_quit (info);
const GPtrArray *nsps;
nsps = nm_device_wimax_get_nsps (w);
- test_assert (nsps == NULL);
+ g_assert (nsps == NULL);
info->notified = TRUE;
wimax_check_quit (info);
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.found);
+ g_assert (info.found);
g_signal_handlers_disconnect_by_func (client, wimax_device_added_cb, &info);
wimax = (NMDeviceWimax *) nm_client_get_device_by_iface (client, "wmx0");
- test_assert (NM_IS_DEVICE_WIMAX (wimax));
+ g_assert (NM_IS_DEVICE_WIMAX (wimax));
/*************************************/
/* Add the wimax NSP */
3000,
NULL,
&error);
- test_assert_no_error (error);
- test_assert (ret);
- test_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
+ g_assert_no_error (error);
+ g_assert (ret);
+ g_assert_cmpstr (g_variant_get_type_string (ret), ==, "(o)");
g_variant_get (ret, "(o)", &expected_path);
g_variant_unref (ret);
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.signaled);
- test_assert (info.notified);
- test_assert (info.nsp_path);
- test_assert_cmpstr (info.nsp_path, ==, expected_path);
+ g_assert (info.signaled);
+ g_assert (info.notified);
+ g_assert (info.nsp_path);
+ g_assert_cmpstr (info.nsp_path, ==, expected_path);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_added_cb, &info);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_add_notify_cb, &info);
3000,
NULL,
&error);
- test_assert_no_error (error);
+ g_assert_no_error (error);
g_clear_pointer (&ret, g_variant_unref);
g_signal_connect (wimax,
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert (info.signaled);
- test_assert (info.notified);
+ g_assert (info.signaled);
+ g_assert (info.notified);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_removed_cb, &info);
g_signal_handlers_disconnect_by_func (wimax, wimax_nsp_remove_notify_cb, &info);
NMDevice *device,
DaInfo *info)
{
- test_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
+ g_assert_cmpstr (nm_device_get_iface (device), ==, "eth0");
info->signaled = TRUE;
da_check_quit (info);
}
const char *iface;
devices = nm_client_get_devices (c);
- test_assert (devices);
- test_assert_cmpint (devices->len, ==, 2);
+ g_assert (devices);
+ g_assert_cmpint (devices->len, ==, 2);
for (i = 0; i < devices->len; i++) {
device = g_ptr_array_index (devices, i);
iface = nm_device_get_iface (device);
- test_assert (!strcmp (iface, "wlan0") || !strcmp (iface, "eth1"));
+ g_assert (!strcmp (iface, "wlan0") || !strcmp (iface, "eth1"));
}
info->notified = TRUE;
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert_cmpint (info.quit_count, ==, 0);
+ g_assert_cmpint (info.quit_count, ==, 0);
g_signal_handlers_disconnect_by_func (client, da_device_added_cb, &info);
/* Ensure the devices now exist */
devices = nm_client_get_devices (client);
- test_assert (devices);
- test_assert_cmpint (devices->len, ==, 3);
+ g_assert (devices);
+ g_assert_cmpint (devices->len, ==, 3);
device = nm_client_get_device_by_iface (client, "wlan0");
- test_assert (NM_IS_DEVICE_WIFI (device));
+ g_assert (NM_IS_DEVICE_WIFI (device));
device = nm_client_get_device_by_iface (client, "eth0");
- test_assert (NM_IS_DEVICE_ETHERNET (device));
+ g_assert (NM_IS_DEVICE_ETHERNET (device));
device = nm_client_get_device_by_iface (client, "eth1");
- test_assert (NM_IS_DEVICE_ETHERNET (device));
+ g_assert (NM_IS_DEVICE_ETHERNET (device));
/********************************/
/* Now remove the device in the middle */
3000,
NULL,
&error);
- test_assert_no_error (error);
- test_assert (ret);
+ g_assert_no_error (error);
+ g_assert (ret);
g_variant_unref (ret);
g_signal_connect (client,
info.quit_id = g_timeout_add_seconds (5, loop_quit, loop);
g_main_loop_run (loop);
- test_assert_cmpint (info.quit_count, ==, 0);
+ g_assert_cmpint (info.quit_count, ==, 0);
g_signal_handlers_disconnect_by_func (client, da_device_removed_cb, &info);
g_signal_handlers_disconnect_by_func (client, da_devices_notify_cb, &info);
/* Ensure only two are left */
devices = nm_client_get_devices (client);
- test_assert (devices);
- test_assert_cmpint (devices->len, ==, 2);
+ g_assert (devices);
+ g_assert_cmpint (devices->len, ==, 2);
device = nm_client_get_device_by_iface (client, "wlan0");
- test_assert (NM_IS_DEVICE_WIFI (device));
+ g_assert (NM_IS_DEVICE_WIFI (device));
device = nm_client_get_device_by_iface (client, "eth1");
- test_assert (NM_IS_DEVICE_ETHERNET (device));
+ g_assert (NM_IS_DEVICE_ETHERNET (device));
g_free (paths[0]);
g_free (paths[1]);
/*******************************************************************/
-#define test_assert(condition) \
-do { \
- gboolean _condition = !!( condition ); \
- \
- if (G_UNLIKELY (!_condition)) { \
- nm_test_service_cleanup (sinfo); \
- g_assert (!"test_assert() failed for" # condition); \
- } \
-} while (0)
-
-/*******************************************************************/
-
static void
add_cb (NMRemoteSettings *s,
NMRemoteConnection *connection,
connection,
add_cb,
&done);
- test_assert (success == TRUE);
+ g_assert (success == TRUE);
start = time (NULL);
do {
now = time (NULL);
g_main_context_iteration (NULL, FALSE);
} while ((done == FALSE) && (now - start < 5));
- test_assert (done == TRUE);
- test_assert (remote != NULL);
+ g_assert (done == TRUE);
+ g_assert (remote != NULL);
/* Make sure the connection is the same as what we added */
- test_assert (nm_connection_compare (connection,
- NM_CONNECTION (remote),
- NM_SETTING_COMPARE_FLAG_EXACT) == TRUE);
+ g_assert (nm_connection_compare (connection,
+ NM_CONNECTION (remote),
+ NM_SETTING_COMPARE_FLAG_EXACT) == TRUE);
}
/*******************************************************************/
gboolean success;
success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- if (!success)
- g_warning ("Failed to change connection visibility: %s", error->message);
- test_assert (success == TRUE);
- test_assert (error == NULL);
+ g_assert_no_error (error);
+ g_assert (success == TRUE);
}
static void
gboolean done = FALSE, has_settings = FALSE;
char *path;
- test_assert (remote != NULL);
+ g_assert (remote != NULL);
/* Listen for the remove event when the connection becomes invisible */
g_signal_connect (remote, "removed", G_CALLBACK (invis_removed_cb), &done);
NM_DBUS_SERVICE,
path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
- test_assert (proxy != NULL);
+ g_assert (proxy != NULL);
/* Bypass the NMRemoteSettings object so we can test it independently */
dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL,
now = time (NULL);
g_main_context_iteration (NULL, FALSE);
} while ((done == FALSE) && (now - start < 5));
- test_assert (done == TRUE);
+ g_assert (done == TRUE);
g_assert (remote);
g_signal_handlers_disconnect_by_func (remote, G_CALLBACK (invis_removed_cb), &done);
for (iter = list; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = NM_CONNECTION (iter->data);
- test_assert ((gpointer) remote != (gpointer) candidate);
- test_assert (strcmp (path, nm_connection_get_path (candidate)) != 0);
+ g_assert ((gpointer) remote != (gpointer) candidate);
+ g_assert (strcmp (path, nm_connection_get_path (candidate)) != 0);
}
/* And ensure the invisible connection no longer has any settings */
nm_connection_for_each_setting_value (NM_CONNECTION (remote),
invis_has_settings_cb,
&has_settings);
- test_assert (has_settings == FALSE);
+ g_assert (has_settings == FALSE);
g_free (path);
g_object_unref (proxy);
char *path;
NMRemoteConnection *new = NULL;
- test_assert (remote != NULL);
+ g_assert (remote != NULL);
/* Wait for the new-connection signal when the connection is visible again */
g_signal_connect (settings, NM_REMOTE_SETTINGS_NEW_CONNECTION,
NM_DBUS_SERVICE,
path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
- test_assert (proxy != NULL);
+ g_assert (proxy != NULL);
/* Bypass the NMRemoteSettings object so we can test it independently */
dbus_g_proxy_begin_call (proxy, "SetVisible", set_visible_cb, NULL, NULL,
} while ((new == NULL) && (now - start < 5));
/* Ensure the new connection is the same as the one we made visible again */
- test_assert (new);
- test_assert (new == remote);
+ g_assert (new);
+ g_assert (new == remote);
g_signal_handlers_disconnect_by_func (settings, G_CALLBACK (vis_new_connection_cb), &new);
NMConnection *candidate = NM_CONNECTION (iter->data);
if ((gpointer) remote == (gpointer) candidate) {
- test_assert (strcmp (path, nm_connection_get_path (candidate)) == 0);
- test_assert (strcmp (TEST_CON_ID, nm_connection_get_id (candidate)) == 0);
+ g_assert_cmpstr (path, ==, nm_connection_get_path (candidate));
+ g_assert_cmpstr (TEST_CON_ID, ==, nm_connection_get_id (candidate));
found = TRUE;
break;
}
}
- test_assert (found == TRUE);
+ g_assert (found == TRUE);
g_free (path);
g_object_unref (proxy);
gboolean success;
success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- if (!success)
- g_warning ("Failed to delete connection: %s", error->message);
- test_assert (success == TRUE);
- test_assert (error == NULL);
+ g_assert_no_error (error);
+ g_assert (success == TRUE);
}
static void
/* Find a connection to delete */
list = nm_remote_settings_list_connections (settings);
- test_assert (g_slist_length (list) > 0);
+ g_assert_cmpint (g_slist_length (list), >, 0);
connection = NM_REMOTE_CONNECTION (list->data);
g_assert (connection);
NM_DBUS_SERVICE,
path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
- test_assert (proxy != NULL);
+ g_assert (proxy != NULL);
/* Bypass the NMRemoteSettings object so we can test it independently */
dbus_g_proxy_begin_call (proxy, "Delete", deleted_cb, NULL, NULL, G_TYPE_INVALID);
now = time (NULL);
g_main_context_iteration (NULL, FALSE);
} while ((done == FALSE) && (now - start < 5));
- test_assert (done == TRUE);
+ g_assert (done == TRUE);
g_assert (!remote);
for (iter = list; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = NM_CONNECTION (iter->data);
- test_assert ((gpointer) connection != (gpointer) candidate);
- test_assert (strcmp (path, nm_connection_get_path (candidate)) != 0);
+ g_assert ((gpointer) connection != (gpointer) candidate);
+ g_assert_cmpstr (path, ==, nm_connection_get_path (candidate));
}
g_free (path);
g_test_init (&argc, &argv, NULL);
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!bus) {
- g_warning ("Error connecting to D-Bus: %s", error->message);
- g_assert (error == NULL);
- }
+ g_assert_no_error (error);
sinfo = nm_test_service_init ();
settings = nm_remote_settings_new (bus);
- test_assert (settings != NULL);
+ g_assert (settings != NULL);
g_test_add_func ("/remote_settings/add_connection", test_add_connection);
g_test_add_func ("/remote_settings/make_invisible", test_make_invisible);