From f936400c388b0664961bb8bba9d02efdce8d7630 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sun, 24 Feb 2013 12:56:53 +0100 Subject: [PATCH] tests: clean up gtester usage Use g_test_add_func() and g_test_add_data_func() to simplify the test cases, getting rid of the GLIB_CHECK_VERSION calls in the process. --- callouts/tests/test-dispatcher-envp.c | 25 +- .../tests/test-remote-settings-client.c | 22 +- src/dhcp-manager/tests/test-dhcp-dhclient.c | 37 +-- .../plugins/ifupdown/tests/test-ifupdown.c | 68 ++-- src/settings/tests/test-wired-defname.c | 23 +- src/tests/test-policy-hosts.c | 23 +- src/tests/test-wifi-ap-utils.c | 303 ++++++++++++------ 7 files changed, 285 insertions(+), 216 deletions(-) diff --git a/callouts/tests/test-dispatcher-envp.c b/callouts/tests/test-dispatcher-envp.c index 677376907b..a93882f470 100644 --- a/callouts/tests/test-dispatcher-envp.c +++ b/callouts/tests/test-dispatcher-envp.c @@ -630,31 +630,20 @@ test_up_empty_vpn_iface (const char *path) /*******************************************/ -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; - g_assert (argc > 1); g_test_init (&argc, &argv, NULL); g_type_init (); - suite = g_test_get_root (); + g_test_add_data_func ("/dispatcher/old_up", argv[1], (GTestDataFunc) test_old_up); + g_test_add_data_func ("/dispatcher/old_down", argv[1], (GTestDataFunc) test_old_down); + g_test_add_data_func ("/dispatcher/old_vpn_up", argv[1], (GTestDataFunc) test_old_vpn_up); + g_test_add_data_func ("/dispatcher/old_vpn_down", argv[1], (GTestDataFunc) test_old_vpn_down); - g_test_suite_add (suite, TESTCASE (test_old_up, argv[1])); - g_test_suite_add (suite, TESTCASE (test_old_down, argv[1])); - g_test_suite_add (suite, TESTCASE (test_old_vpn_up, argv[1])); - g_test_suite_add (suite, TESTCASE (test_old_vpn_down, argv[1])); - - g_test_suite_add (suite, TESTCASE (test_up_empty_vpn_iface, argv[1])); + g_test_add_data_func ("/dispatcher/up_empty_vpn_iface", argv[1], (GTestDataFunc) test_up_empty_vpn_iface); return g_test_run (); } diff --git a/libnm-glib/tests/test-remote-settings-client.c b/libnm-glib/tests/test-remote-settings-client.c index ad62075d41..1299ce8f85 100644 --- a/libnm-glib/tests/test-remote-settings-client.c +++ b/libnm-glib/tests/test-remote-settings-client.c @@ -342,17 +342,9 @@ test_remove_connection (void) /*******************************************************************/ -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; char *service_argv[3] = { NULL, NULL, NULL }; int ret; GError *error = NULL; @@ -390,12 +382,10 @@ int main (int argc, char **argv) settings = nm_remote_settings_new (bus); test_assert (settings != NULL); - suite = g_test_get_root (); - - g_test_suite_add (suite, TESTCASE (test_add_connection, NULL)); - g_test_suite_add (suite, TESTCASE (test_make_invisible, NULL)); - g_test_suite_add (suite, TESTCASE (test_make_visible, NULL)); - g_test_suite_add (suite, TESTCASE (test_remove_connection, NULL)); + g_test_add_func ("/remote_settings/add_connection", test_add_connection); + g_test_add_func ("/remote_settings/make_invisible", test_make_invisible); + g_test_add_func ("/remote_settings/make_visible", test_make_visible); + g_test_add_func ("/remote_settings/remove_connection", test_remove_connection); ret = g_test_run (); diff --git a/src/dhcp-manager/tests/test-dhcp-dhclient.c b/src/dhcp-manager/tests/test-dhcp-dhclient.c index 7eb2d35867..473dc6c988 100644 --- a/src/dhcp-manager/tests/test-dhcp-dhclient.c +++ b/src/dhcp-manager/tests/test-dhcp-dhclient.c @@ -393,37 +393,26 @@ test_write_existing_commented_duid (void) /*******************************************/ -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; - g_test_init (&argc, &argv, NULL); g_type_init (); - suite = g_test_get_root (); + g_test_add_func ("/dhcp/dhclient/orig_missing", test_orig_missing); + g_test_add_func ("/dhcp/dhclient/override_client_id", test_override_client_id); + g_test_add_func ("/dhcp/dhclient/override_hostname", test_override_hostname); + g_test_add_func ("/dhcp/dhclient/existing_alsoreq", test_existing_alsoreq); + g_test_add_func ("/dhcp/dhclient/existing_multiline_alsoreq", test_existing_multiline_alsoreq); + g_test_add_func ("/dhcp/dhclient/duids", test_duids); - g_test_suite_add (suite, TESTCASE (test_orig_missing, NULL)); - g_test_suite_add (suite, TESTCASE (test_override_client_id, NULL)); - g_test_suite_add (suite, TESTCASE (test_override_hostname, NULL)); - g_test_suite_add (suite, TESTCASE (test_existing_alsoreq, NULL)); - g_test_suite_add (suite, TESTCASE (test_existing_multiline_alsoreq, NULL)); - g_test_suite_add (suite, TESTCASE (test_duids, NULL)); + g_test_add_func ("/dhcp/dhclient/read_duid_from_leasefile", test_read_duid_from_leasefile); + g_test_add_func ("/dhcp/dhclient/read_commented_duid_from_leasefile", test_read_commented_duid_from_leasefile); - g_test_suite_add (suite, TESTCASE (test_read_duid_from_leasefile, NULL)); - g_test_suite_add (suite, TESTCASE (test_read_commented_duid_from_leasefile, NULL)); - - g_test_suite_add (suite, TESTCASE (test_write_duid, NULL)); - g_test_suite_add (suite, TESTCASE (test_write_existing_duid, NULL)); - g_test_suite_add (suite, TESTCASE (test_write_existing_commented_duid, NULL)); + g_test_add_func ("/dhcp/dhclient/write_duid", test_write_duid); + g_test_add_func ("/dhcp/dhclient/write_existing_duid", test_write_existing_duid); + g_test_add_func ("/dhcp/dhclient/write_existing_commented_duid", test_write_existing_commented_duid); return g_test_run (); } diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 81a0c64a54..1f29d21d7e 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -904,17 +904,9 @@ test19_read_static_ipv4_plen (const char *path) } -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; GError *error = NULL; g_type_init (); @@ -924,29 +916,45 @@ int main (int argc, char **argv) g_test_init (&argc, &argv, NULL); - suite = g_test_get_root (); - if (0) dump_blocks (); - g_test_suite_add (suite, TESTCASE (test1_ignore_line_before_first_block, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test2_wrapped_line, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test3_wrapped_multiline_multiarg, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test4_allow_auto_is_auto, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test5_allow_auto_multiarg, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test6_mixed_whitespace, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test7_long_line, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test8_long_line_wrapped, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test9_wrapped_lines_in_block, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test11_complex_wrap, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test12_complex_wrap_split_word, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test13_more_mixed_whitespace, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test14_mixed_whitespace_block_start, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test15_trailing_space, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test16_missing_newline, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test17_read_static_ipv4, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test18_read_static_ipv6, TEST_ENI_DIR)); - g_test_suite_add (suite, TESTCASE (test19_read_static_ipv4_plen, TEST_ENI_DIR)); + g_test_add_data_func ("/ifupdate/ignore_line_before_first_block", TEST_ENI_DIR, + (GTestDataFunc) test1_ignore_line_before_first_block); + g_test_add_data_func ("/ifupdate/wrapped_line", TEST_ENI_DIR, + (GTestDataFunc) test2_wrapped_line); + g_test_add_data_func ("/ifupdate/wrapped_multiline_multiarg", TEST_ENI_DIR, + (GTestDataFunc) test3_wrapped_multiline_multiarg); + g_test_add_data_func ("/ifupdate/allow_auto_is_auto", TEST_ENI_DIR, + (GTestDataFunc) test4_allow_auto_is_auto); + g_test_add_data_func ("/ifupdate/allow_auto_multiarg", TEST_ENI_DIR, + (GTestDataFunc) test5_allow_auto_multiarg); + g_test_add_data_func ("/ifupdate/mixed_whitespace", TEST_ENI_DIR, + (GTestDataFunc) test6_mixed_whitespace); + g_test_add_data_func ("/ifupdate/long_line", TEST_ENI_DIR, + (GTestDataFunc) test7_long_line); + g_test_add_data_func ("/ifupdate/long_line_wrapped", TEST_ENI_DIR, + (GTestDataFunc) test8_long_line_wrapped); + g_test_add_data_func ("/ifupdate/wrapped_lines_in_block", TEST_ENI_DIR, + (GTestDataFunc) test9_wrapped_lines_in_block); + g_test_add_data_func ("/ifupdate/complex_wrap", TEST_ENI_DIR, + (GTestDataFunc) test11_complex_wrap); + g_test_add_data_func ("/ifupdate/complex_wrap_split_word", TEST_ENI_DIR, + (GTestDataFunc) test12_complex_wrap_split_word); + g_test_add_data_func ("/ifupdate/more_mixed_whitespace", TEST_ENI_DIR, + (GTestDataFunc) test13_more_mixed_whitespace); + g_test_add_data_func ("/ifupdate/mixed_whitespace_block_start", TEST_ENI_DIR, + (GTestDataFunc) test14_mixed_whitespace_block_start); + g_test_add_data_func ("/ifupdate/trailing_space", TEST_ENI_DIR, + (GTestDataFunc) test15_trailing_space); + g_test_add_data_func ("/ifupdate/missing_newline", TEST_ENI_DIR, + (GTestDataFunc) test16_missing_newline); + g_test_add_data_func ("/ifupdate/read_static_ipv4", TEST_ENI_DIR, + (GTestDataFunc) test17_read_static_ipv4); + g_test_add_data_func ("/ifupdate/read_static_ipv6", TEST_ENI_DIR, + (GTestDataFunc) test18_read_static_ipv6); + g_test_add_data_func ("/ifupdate/read_static_ipv4_plen", TEST_ENI_DIR, + (GTestDataFunc) test19_read_static_ipv4_plen); return g_test_run (); } diff --git a/src/settings/tests/test-wired-defname.c b/src/settings/tests/test-wired-defname.c index f6627fa9c5..97d61a1a68 100644 --- a/src/settings/tests/test-wired-defname.c +++ b/src/settings/tests/test-wired-defname.c @@ -120,27 +120,16 @@ test_defname_multiple_conflicts (void) /*******************************************/ -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; - g_type_init (); g_test_init (&argc, &argv, NULL); - suite = g_test_get_root (); - - g_test_suite_add (suite, TESTCASE (test_defname_no_connections, NULL)); - g_test_suite_add (suite, TESTCASE (test_defname_no_conflict, NULL)); - g_test_suite_add (suite, TESTCASE (test_defname_conflict, NULL)); - g_test_suite_add (suite, TESTCASE (test_defname_multiple_conflicts, NULL)); + g_test_add_func ("/defname/no_connections", test_defname_no_connections); + g_test_add_func ("/defname/no_conflict", test_defname_no_conflict); + g_test_add_func ("/defname/conflict", test_defname_conflict); + g_test_add_func ("/defname/multiple_conflicts", test_defname_multiple_conflicts); return g_test_run (); } diff --git a/src/tests/test-policy-hosts.c b/src/tests/test-policy-hosts.c index 681758900b..5fe8869182 100644 --- a/src/tests/test-policy-hosts.c +++ b/src/tests/test-policy-hosts.c @@ -150,26 +150,15 @@ test_hosts_leftover_double_newline (void) /*******************************************/ -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; - g_test_init (&argc, &argv, NULL); - suite = g_test_get_root (); - - g_test_suite_add (suite, TESTCASE (test_hosts_generic, NULL)); - g_test_suite_add (suite, TESTCASE (test_hosts_generic_no_boilerplate, NULL)); - g_test_suite_add (suite, TESTCASE (test_hosts_leftover, NULL)); - g_test_suite_add (suite, TESTCASE (test_hosts_leftover_double_newline, NULL)); + g_test_add_func ("/hosts/generic", test_hosts_generic); + g_test_add_func ("/hosts/generic_no_boilerplate", test_hosts_generic_no_boilerplate); + g_test_add_func ("/hosts/leftover", test_hosts_leftover); + g_test_add_func ("/hosts/leftover_double_newline", test_hosts_leftover_double_newline); return g_test_run (); } diff --git a/src/tests/test-wifi-ap-utils.c b/src/tests/test-wifi-ap-utils.c index faa023fc73..de4c7e0099 100644 --- a/src/tests/test-wifi-ap-utils.c +++ b/src/tests/test-wifi-ap-utils.c @@ -312,7 +312,7 @@ test_open_ap_empty_connection (void) /*******************************************/ static void -test_open_ap_leap_connection_1 (gboolean add_wifi) +test_open_ap_leap_connection_1 (gconstpointer add_wifi) { NMConnection *src; const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; @@ -374,7 +374,7 @@ test_open_ap_leap_connection_2 (void) /*******************************************/ static void -test_open_ap_wep_connection (gboolean add_wifi) +test_open_ap_wep_connection (gconstpointer add_wifi) { NMConnection *src; const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; @@ -660,8 +660,10 @@ error_code_for_idx (guint32 idx, guint num) } static void -test_ap_wpa_eap_connection_1 (guint32 idx) +test_ap_wpa_eap_connection_1 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); + test_ap_wpa_eap_connection_base (NULL, NULL, flags_for_idx (idx), wpa_flags_for_idx (idx), @@ -672,8 +674,10 @@ test_ap_wpa_eap_connection_1 (guint32 idx) } static void -test_ap_wpa_eap_connection_2 (guint idx) +test_ap_wpa_eap_connection_2 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); + test_ap_wpa_eap_connection_base (NULL, NULL, flags_for_idx (idx), wpa_flags_for_idx (idx), @@ -684,8 +688,10 @@ test_ap_wpa_eap_connection_2 (guint idx) } static void -test_ap_wpa_eap_connection_3 (guint idx) +test_ap_wpa_eap_connection_3 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); + test_ap_wpa_eap_connection_base (NULL, "open", flags_for_idx (idx), wpa_flags_for_idx (idx), @@ -696,8 +702,10 @@ test_ap_wpa_eap_connection_3 (guint idx) } static void -test_ap_wpa_eap_connection_4 (guint idx) +test_ap_wpa_eap_connection_4 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); + test_ap_wpa_eap_connection_base (NULL, "shared", flags_for_idx (idx), wpa_flags_for_idx (idx), @@ -708,8 +716,10 @@ test_ap_wpa_eap_connection_4 (guint idx) } static void -test_ap_wpa_eap_connection_5 (guint idx) +test_ap_wpa_eap_connection_5 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); + test_ap_wpa_eap_connection_base ("wpa-eap", "open", flags_for_idx (idx), wpa_flags_for_idx (idx), @@ -756,7 +766,7 @@ test_priv_ap_empty_connection (void) /*******************************************/ static void -test_priv_ap_leap_connection_1 (gboolean add_wifi) +test_priv_ap_leap_connection_1 (gconstpointer add_wifi) { NMConnection *src, *expected; const char *ssid = "blahblah"; @@ -1050,8 +1060,9 @@ test_priv_ap_wpa_psk_connection_5 (void) /*******************************************/ static void -test_wpa_ap_empty_connection (guint idx) +test_wpa_ap_empty_connection (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *src, *expected; const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; const char *ssid = "blahblah"; @@ -1086,8 +1097,9 @@ test_wpa_ap_empty_connection (guint idx) /*******************************************/ static void -test_wpa_ap_leap_connection_1 (guint idx) +test_wpa_ap_leap_connection_1 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *src; const char *ssid = "blahblah"; const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; @@ -1121,8 +1133,9 @@ test_wpa_ap_leap_connection_1 (guint idx) /*******************************************/ static void -test_wpa_ap_leap_connection_2 (guint idx) +test_wpa_ap_leap_connection_2 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *src; const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; const KeyData src_wsec[] = { @@ -1154,8 +1167,9 @@ test_wpa_ap_leap_connection_2 (guint idx) /*******************************************/ static void -test_wpa_ap_dynamic_wep_connection (guint idx) +test_wpa_ap_dynamic_wep_connection (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *src; const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; const KeyData src_wsec[] = { @@ -1186,8 +1200,9 @@ test_wpa_ap_dynamic_wep_connection (guint idx) /*******************************************/ static void -test_wpa_ap_wpa_psk_connection_1 (guint idx) +test_wpa_ap_wpa_psk_connection_1 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *expected; const KeyData exp_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, @@ -1205,8 +1220,9 @@ test_wpa_ap_wpa_psk_connection_1 (guint idx) } static void -test_wpa_ap_wpa_psk_connection_2 (guint idx) +test_wpa_ap_wpa_psk_connection_2 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *expected; const KeyData exp_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, @@ -1224,8 +1240,9 @@ test_wpa_ap_wpa_psk_connection_2 (guint idx) } static void -test_wpa_ap_wpa_psk_connection_3 (guint idx) +test_wpa_ap_wpa_psk_connection_3 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *expected; const KeyData exp_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, @@ -1243,8 +1260,9 @@ test_wpa_ap_wpa_psk_connection_3 (guint idx) } static void -test_wpa_ap_wpa_psk_connection_4 (guint idx) +test_wpa_ap_wpa_psk_connection_4 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); test_ap_wpa_psk_connection_base (NULL, "shared", NM_802_11_AP_FLAGS_PRIVACY, wpa_flags_for_idx (idx), @@ -1253,8 +1271,9 @@ test_wpa_ap_wpa_psk_connection_4 (guint idx) } static void -test_wpa_ap_wpa_psk_connection_5 (guint idx) +test_wpa_ap_wpa_psk_connection_5 (gconstpointer data) { + guint idx = GPOINTER_TO_UINT (data); NMConnection *expected; const KeyData exp_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 }, @@ -1324,117 +1343,213 @@ test_strength_wext (void) /*******************************************/ -#if GLIB_CHECK_VERSION(2,25,12) -typedef GTestFixtureFunc TCFunc; -#else -typedef void (*TCFunc)(void); -#endif - -#define TESTCASE(t, d) g_test_create_case (#t, 0, (gconstpointer) d, NULL, (TCFunc) t, NULL) - -int main (int argc, char **argv) +int +main (int argc, char **argv) { - GTestSuite *suite; gsize i; g_type_init (); g_test_init (&argc, &argv, NULL); - suite = g_test_get_root (); - - g_test_suite_add (suite, TESTCASE (test_lock_bssid, NULL)); + g_test_add_func ("/wifi/lock_bssid", + test_lock_bssid); /* Open AP tests; make sure that connections to be completed that have * various security-related settings already set cause the completion * to fail. */ - g_test_suite_add (suite, TESTCASE (test_open_ap_empty_connection, NULL)); - g_test_suite_add (suite, TESTCASE (test_open_ap_leap_connection_1, TRUE)); - g_test_suite_add (suite, TESTCASE (test_open_ap_leap_connection_1, FALSE)); - g_test_suite_add (suite, TESTCASE (test_open_ap_leap_connection_2, NULL)); - g_test_suite_add (suite, TESTCASE (test_open_ap_wep_connection, TRUE)); - g_test_suite_add (suite, TESTCASE (test_open_ap_wep_connection, FALSE)); + g_test_add_func ("/wifi/open_ap/empty_connection", + test_open_ap_empty_connection); + g_test_add_data_func ("/wifi/open_ap/leap_connection/1", + (gconstpointer) TRUE, + test_open_ap_leap_connection_1); + g_test_add_data_func ("/wifi/open_ap/leap_connection/1_no_add_wifi", + (gconstpointer) FALSE, + test_open_ap_leap_connection_1); + g_test_add_func ("/wifi/open_ap/leap_connection/2", + test_open_ap_leap_connection_2); + g_test_add_data_func ("/wifi/open_ap/wep_connection", + (gconstpointer) TRUE, + test_open_ap_wep_connection); + g_test_add_data_func ("/wifi/open_ap/wep_connection", + (gconstpointer) FALSE, + test_open_ap_wep_connection); - g_test_suite_add (suite, TESTCASE (test_open_ap_wpa_psk_connection_1, NULL)); - g_test_suite_add (suite, TESTCASE (test_open_ap_wpa_psk_connection_2, NULL)); - g_test_suite_add (suite, TESTCASE (test_open_ap_wpa_psk_connection_3, NULL)); - g_test_suite_add (suite, TESTCASE (test_open_ap_wpa_psk_connection_4, NULL)); - g_test_suite_add (suite, TESTCASE (test_open_ap_wpa_psk_connection_5, NULL)); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/1", + test_open_ap_wpa_psk_connection_1); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/2", + test_open_ap_wpa_psk_connection_2); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/3", + test_open_ap_wpa_psk_connection_3); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/4", + test_open_ap_wpa_psk_connection_4); + g_test_add_func ("/wifi/open_ap/wpa_psk_connection/5", + test_open_ap_wpa_psk_connection_5); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_1, IDX_OPEN)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_2, IDX_OPEN)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_3, IDX_OPEN)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_4, IDX_OPEN)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_5, IDX_OPEN)); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/1", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_1); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/2", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_2); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/3", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_3); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/4", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_4); + g_test_add_data_func ("/wifi/open_ap/wpa_eap_connection/5", + (gconstpointer) IDX_OPEN, + test_ap_wpa_eap_connection_5); /* WEP AP tests */ - g_test_suite_add (suite, TESTCASE (test_priv_ap_empty_connection, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_leap_connection_1, FALSE)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_leap_connection_2, FALSE)); + g_test_add_func ("/wifi/priv_ap/empty_connection", + test_priv_ap_empty_connection); + g_test_add_data_func ("/wifi/priv_ap/leap_connection/1", + (gconstpointer) FALSE, + test_priv_ap_leap_connection_1); + g_test_add_func ("/wifi/priv_ap/leap_connection/2", + test_priv_ap_leap_connection_2); - g_test_suite_add (suite, TESTCASE (test_priv_ap_dynamic_wep_1, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_dynamic_wep_2, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_dynamic_wep_3, NULL)); + g_test_add_func ("/wifi/priv_ap/dynamic_wep/1", + test_priv_ap_dynamic_wep_1); + g_test_add_func ("/wifi/priv_ap/dynamic_wep/2", + test_priv_ap_dynamic_wep_2); + g_test_add_func ("/wifi/priv_ap/dynamic_wep/3", + test_priv_ap_dynamic_wep_3); - g_test_suite_add (suite, TESTCASE (test_priv_ap_wpa_psk_connection_1, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_wpa_psk_connection_2, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_wpa_psk_connection_3, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_wpa_psk_connection_4, NULL)); - g_test_suite_add (suite, TESTCASE (test_priv_ap_wpa_psk_connection_5, NULL)); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/1", + test_priv_ap_wpa_psk_connection_1); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/2", + test_priv_ap_wpa_psk_connection_2); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/3", + test_priv_ap_wpa_psk_connection_3); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/4", + test_priv_ap_wpa_psk_connection_4); + g_test_add_func ("/wifi/priv_ap/wpa_psk_connection/5", + test_priv_ap_wpa_psk_connection_5); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_1, IDX_PRIV)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_2, IDX_PRIV)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_3, IDX_PRIV)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_4, IDX_PRIV)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_5, IDX_PRIV)); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/1", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_1); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/2", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_2); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/3", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_3); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/4", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_4); + g_test_add_data_func ("/wifi/priv_ap/wpa_eap_connection/5", + (gconstpointer) IDX_PRIV, + test_ap_wpa_eap_connection_5); /* WPA-PSK tests */ for (i = IDX_WPA_PSK_PTKIP_GTKIP; i <= IDX_WPA_RSN_PSK_PCCMP_GCCMP; i++) { - g_test_suite_add (suite, TESTCASE (test_wpa_ap_empty_connection, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_leap_connection_1, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_leap_connection_2, i)); + g_test_add_data_func ("/wifi/wpa_psk/empty_connection", + (gconstpointer) i, + test_wpa_ap_empty_connection); + g_test_add_data_func ("/wifi/wpa_psk/leap_connection/1", + (gconstpointer) i, + test_wpa_ap_leap_connection_1); + g_test_add_data_func ("/wifi/wpa_psk/leap_connection/2", + (gconstpointer) i, + test_wpa_ap_leap_connection_2); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_dynamic_wep_connection, i)); + g_test_add_data_func ("/wifi/wpa_psk/dynamic_wep_connection", + (gconstpointer) i, + test_wpa_ap_dynamic_wep_connection); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_1, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_2, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_3, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_4, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_5, i)); + g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/1", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_1); + g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/2", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_2); + g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/3", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_3); + g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/4", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_4); + g_test_add_data_func ("/wifi/wpa_psk/wpa_psk_connection/5", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_5); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_1, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_2, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_3, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_4, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_5, i)); + g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/1", + (gconstpointer) i, + test_ap_wpa_eap_connection_1); + g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/2", + (gconstpointer) i, + test_ap_wpa_eap_connection_2); + g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/3", + (gconstpointer) i, + test_ap_wpa_eap_connection_3); + g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/4", + (gconstpointer) i, + test_ap_wpa_eap_connection_4); + g_test_add_data_func ("/wifi/wpa_psk/wpa_eap_connection/5", + (gconstpointer) i, + test_ap_wpa_eap_connection_5); } /* RSN-PSK tests */ for (i = IDX_WPA_RSN_PSK_PTKIP_PCCMP_GTKIP; i <= IDX_RSN_PSK_PTKIP_PCCMP_GTKIP; i++) { - g_test_suite_add (suite, TESTCASE (test_wpa_ap_empty_connection, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_leap_connection_1, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_leap_connection_2, i)); + g_test_add_data_func ("/wifi/rsn_psk/empty_connection", + (gconstpointer) i, + test_wpa_ap_empty_connection); + g_test_add_data_func ("/wifi/rsn_psk/leap_connection/1", + (gconstpointer) i, + test_wpa_ap_leap_connection_1); + g_test_add_data_func ("/wifi/rsn_psk/leap_connection/2", + (gconstpointer) i, + test_wpa_ap_leap_connection_2); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_dynamic_wep_connection, i)); + g_test_add_data_func ("/wifi/rsn_psk/dynamic_wep_connection", + (gconstpointer) i, + test_wpa_ap_dynamic_wep_connection); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_1, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_2, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_3, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_4, i)); - g_test_suite_add (suite, TESTCASE (test_wpa_ap_wpa_psk_connection_5, i)); + g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/1", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_1); + g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/2", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_2); + g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/3", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_3); + g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/4", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_4); + g_test_add_data_func ("/wifi/rsn_psk/wpa_psk_connection/5", + (gconstpointer) i, + test_wpa_ap_wpa_psk_connection_5); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_1, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_2, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_3, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_4, i)); - g_test_suite_add (suite, TESTCASE (test_ap_wpa_eap_connection_5, i)); + g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/1", + (gconstpointer) i, + test_ap_wpa_eap_connection_1); + g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/2", + (gconstpointer) i, + test_ap_wpa_eap_connection_2); + g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/3", + (gconstpointer) i, + test_ap_wpa_eap_connection_3); + g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/4", + (gconstpointer) i, + test_ap_wpa_eap_connection_4); + g_test_add_data_func ("/wifi/rsn_psk/wpa_eap_connection/5", + (gconstpointer) i, + test_ap_wpa_eap_connection_5); } /* Scanned signal strength conversion tests */ - g_test_suite_add (suite, TESTCASE (test_strength_dbm, NULL)); - g_test_suite_add (suite, TESTCASE (test_strength_percent, NULL)); - g_test_suite_add (suite, TESTCASE (test_strength_wext, NULL)); + g_test_add_func ("/wifi/strength/dbm", + test_strength_dbm); + g_test_add_func ("/wifi/strength/percent", + test_strength_percent); + g_test_add_func ("/wifi/strength/wext", + test_strength_wext); return g_test_run (); } -