diff options
Diffstat (limited to 'src/core/tests')
| -rw-r--r-- | src/core/tests/config/nm-test-device.c | 2 | ||||
| -rw-r--r-- | src/core/tests/config/test-config.c | 192 | ||||
| -rw-r--r-- | src/core/tests/meson.build | 2 | ||||
| -rw-r--r-- | src/core/tests/test-core-with-expect.c | 12 | ||||
| -rw-r--r-- | src/core/tests/test-core.c | 142 | ||||
| -rw-r--r-- | src/core/tests/test-dcb.c | 20 | ||||
| -rw-r--r-- | src/core/tests/test-ip4-config.c | 380 | ||||
| -rw-r--r-- | src/core/tests/test-ip6-config.c | 538 | ||||
| -rw-r--r-- | src/core/tests/test-l3cfg.c | 87 | ||||
| -rw-r--r-- | src/core/tests/test-systemd.c | 14 | ||||
| -rw-r--r-- | src/core/tests/test-utils.c | 12 | ||||
| -rw-r--r-- | src/core/tests/test-wired-defname.c | 8 |
12 files changed, 245 insertions, 1164 deletions
diff --git a/src/core/tests/config/nm-test-device.c b/src/core/tests/config/nm-test-device.c index f724b03a..21f9bec4 100644 --- a/src/core/tests/config/nm-test-device.c +++ b/src/core/tests/config/nm-test-device.c @@ -69,7 +69,7 @@ nm_test_device_new(const char *hwaddr) static void nm_test_device_class_init(NMTestDeviceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructed = constructed; diff --git a/src/core/tests/config/test-config.c b/src/core/tests/config/test-config.c index 6794fbf6..fa7fae07 100644 --- a/src/core/tests/config/test-config.c +++ b/src/core/tests/config/test-config.c @@ -23,10 +23,10 @@ static void _assert_config_value(const NMConfigData *config_data, - const char * group, - const char * key, - const char * expected_value, - const char * file, + const char *group, + const char *key, + const char *expected_value, + const char *file, int line) { gs_free char *value = NULL; @@ -59,22 +59,22 @@ _assert_config_value(const NMConfigData *config_data, /*****************************************************************************/ static NMConfig * -setup_config(GError ** error, - const char * config_file, - const char * intern_config, +setup_config(GError **error, + const char *config_file, + const char *intern_config, const char *const *atomic_section_prefixes, - const char * config_dir, - const char * system_config_dir, + const char *config_dir, + const char *system_config_dir, ...) { va_list ap; - GPtrArray * args; - char ** argv, *arg; + GPtrArray *args; + char **argv, *arg; int argc; - GOptionContext * context; + GOptionContext *context; gboolean success; - NMConfig * config; - GError * local_error = NULL; + NMConfig *config; + GError *local_error = NULL; NMConfigCmdLineOptions *cli; g_assert(!error || !*error); @@ -149,9 +149,9 @@ static void test_config_simple(void) { gs_unref_object NMConfig *config = NULL; - gs_strfreev char ** plugins = NULL; - char * value; - const char * cvalue; + gs_strfreev char **plugins = NULL; + char *value; + const char *cvalue; gs_unref_object NMDevice *dev50 = nm_test_device_new("00:00:00:00:00:50"); gs_unref_object NMDevice *dev51 = nm_test_device_new("00:00:00:00:00:51"); gs_unref_object NMDevice *dev52 = nm_test_device_new("00:00:00:00:00:52"); @@ -277,7 +277,7 @@ static void test_config_override(void) { gs_unref_object NMConfig *config = NULL; - gs_strfreev char ** plugins = NULL; + gs_strfreev char **plugins = NULL; config = setup_config(NULL, TEST_DIR "/NetworkManager.conf", @@ -311,10 +311,10 @@ test_config_override(void) static void test_config_global_dns(void) { - NMConfig * config; + NMConfig *config; const NMGlobalDnsConfig *dns; - NMGlobalDnsDomain * domain; - const char *const * strv; + NMGlobalDnsDomain *domain; + const char *const *strv; config = setup_config(NULL, TEST_DIR "/NetworkManager.conf", "", NULL, "/no/such/dir", "", NULL); @@ -382,8 +382,8 @@ static void test_config_connectivity_check(void) { #if WITH_CONCHECK - const char * CONFIG_INTERN = BUILD_DIR "/test-connectivity-check-intern.conf"; - NMConfig * config; + const char *CONFIG_INTERN = BUILD_DIR "/test-connectivity-check-intern.conf"; + NMConfig *config; NMConnectivity *connectivity; g_assert(g_file_set_contents(CONFIG_INTERN, "", 0, NULL)); @@ -425,9 +425,9 @@ static void test_config_no_auto_default(void) { NMConfig *config; - GError * error = NULL; + GError *error = NULL; int fd, nwrote; - char * state_file; + char *state_file; NMDevice *dev1, *dev2, *dev3, *dev4; fd = g_file_open_tmp(NULL, &state_file, &error); @@ -497,9 +497,9 @@ static void test_config_confdir(void) { gs_unref_object NMConfig *config = NULL; - gs_strfreev char ** plugins = NULL; - char * value; - GSList * specs; + gs_strfreev char **plugins = NULL; + char *value; + GSList *specs; config = setup_config(NULL, TEST_DIR "/NetworkManager.conf", "", NULL, TEST_DIR "/conf.d", "", NULL); @@ -680,7 +680,7 @@ static void test_config_warnings(void) { gs_unref_object NMConfig *config = NULL; - const char *const * warnings; + const char *const *warnings; config = setup_config(NULL, TEST_DIR "/NetworkManager-warn.conf", @@ -716,15 +716,15 @@ test_config_warnings(void) /*****************************************************************************/ -typedef void (*TestSetValuesUserSetFcn)(NMConfig * config, +typedef void (*TestSetValuesUserSetFcn)(NMConfig *config, gboolean is_user, - GKeyFile * keyfile_user, + GKeyFile *keyfile_user, NMConfigChangeFlags *out_expected_changes); -typedef void (*TestSetValuesCheckStateFcn)(NMConfig * config, - NMConfigData * config_data, +typedef void (*TestSetValuesCheckStateFcn)(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data); + NMConfigData *old_data); typedef struct { NMConfigChangeFlags changes; @@ -732,10 +732,10 @@ typedef struct { } TestSetValuesConfigChangedData; static void -_set_values_config_changed_cb(NMConfig * config, - NMConfigData * config_data, +_set_values_config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, + NMConfigData *old_data, TestSetValuesConfigChangedData *config_changed_data) { g_assert(changes != NM_CONFIG_CHANGE_NONE); @@ -753,19 +753,19 @@ _set_values_config_changed_cb(NMConfig * config, } static void -_set_values_user(NMConfig * config, - const char * CONFIG_USER, +_set_values_user(NMConfig *config, + const char *CONFIG_USER, TestSetValuesUserSetFcn set_fcn, TestSetValuesCheckStateFcn check_state_fcn) { - GKeyFile * keyfile_user; - gboolean success; - gs_free_error GError * error = NULL; + GKeyFile *keyfile_user; + gboolean success; + gs_free_error GError *error = NULL; TestSetValuesConfigChangedData config_changed_data = { .changes = NM_CONFIG_CHANGE_NONE, .check_state_fcn = check_state_fcn, }; - NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; + NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; gs_unref_object NMConfigData *config_data_before = NULL; keyfile_user = nm_config_create_keyfile(); @@ -812,16 +812,16 @@ _set_values_user(NMConfig * config, } static void -_set_values_intern(NMConfig * config, +_set_values_intern(NMConfig *config, TestSetValuesUserSetFcn set_fcn, TestSetValuesCheckStateFcn check_state_fcn) { - GKeyFile * keyfile_intern; + GKeyFile *keyfile_intern; TestSetValuesConfigChangedData config_changed_data = { .changes = NM_CONFIG_CHANGE_NONE, .check_state_fcn = check_state_fcn, }; - NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; + NMConfigChangeFlags expected_changes = NM_CONFIG_CHANGE_NONE; gs_unref_object NMConfigData *config_data_before = NULL; config_data_before = g_object_ref(nm_config_get_data(config)); @@ -860,9 +860,9 @@ _set_values_intern(NMConfig * config, } static void -_set_values_user_intern_section_set(NMConfig * config, +_set_values_user_intern_section_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, @@ -872,11 +872,11 @@ _set_values_user_intern_section_set(NMConfig * config, } static void -_set_values_user_intern_section_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_intern_section_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { g_assert(changes == NM_CONFIG_CHANGE_NONE); g_assert( @@ -884,9 +884,9 @@ _set_values_user_intern_section_check(NMConfig * config, } static void -_set_values_user_initial_values_set(NMConfig * config, +_set_values_user_initial_values_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_remove_group(keyfile, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN "section1", NULL); @@ -895,11 +895,11 @@ _set_values_user_initial_values_set(NMConfig * config, } static void -_set_values_user_initial_values_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_initial_values_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes == (NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER)); @@ -907,9 +907,9 @@ _set_values_user_initial_values_check(NMConfig * config, } static void -_set_values_intern_internal_set(NMConfig * config, +_set_values_intern_internal_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, @@ -921,11 +921,11 @@ _set_values_intern_internal_set(NMConfig * config, } static void -_set_values_intern_internal_check(NMConfig * config, - NMConfigData * config_data, +_set_values_intern_internal_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -938,9 +938,9 @@ _set_values_intern_internal_check(NMConfig * config, } static void -_set_values_user_atomic_section_1_set(NMConfig * config, +_set_values_user_atomic_section_1_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, "atomic-prefix-1.section-a", "key1", "user-value1"); @@ -952,11 +952,11 @@ _set_values_user_atomic_section_1_set(NMConfig * config, } static void -_set_values_user_atomic_section_1_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_atomic_section_1_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes == (NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_USER)); @@ -968,9 +968,9 @@ _set_values_user_atomic_section_1_check(NMConfig * config, } static void -_set_values_intern_atomic_section_1_set(NMConfig * config, +_set_values_intern_atomic_section_1_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, "atomic-prefix-1.section-a", "key1", "intern-value1"); @@ -982,11 +982,11 @@ _set_values_intern_atomic_section_1_set(NMConfig * config, } static void -_set_values_intern_atomic_section_1_check(NMConfig * config, - NMConfigData * config_data, +_set_values_intern_atomic_section_1_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -1005,9 +1005,9 @@ _set_values_intern_atomic_section_1_check(NMConfig * config, } static void -_set_values_user_atomic_section_2_set(NMConfig * config, +_set_values_user_atomic_section_2_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { g_key_file_set_string(keyfile, "atomic-prefix-1.section-a", "key1", "user-value1-x"); @@ -1019,11 +1019,11 @@ _set_values_user_atomic_section_2_set(NMConfig * config, } static void -_set_values_user_atomic_section_2_check(NMConfig * config, - NMConfigData * config_data, +_set_values_user_atomic_section_2_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -1040,9 +1040,9 @@ _set_values_user_atomic_section_2_check(NMConfig * config, } static void -_set_values_intern_atomic_section_2_set(NMConfig * config, +_set_values_intern_atomic_section_2_set(NMConfig *config, gboolean set_user, - GKeyFile * keyfile, + GKeyFile *keyfile, NMConfigChangeFlags *out_expected_changes) { /* let's hide an atomic section and one key. */ @@ -1068,11 +1068,11 @@ _set_values_intern_atomic_section_2_set(NMConfig * config, } static void -_set_values_intern_atomic_section_2_check(NMConfig * config, - NMConfigData * config_data, +_set_values_intern_atomic_section_2_check(NMConfig *config, + NMConfigData *config_data, gboolean is_change_event, NMConfigChangeFlags changes, - NMConfigData * old_data) + NMConfigData *old_data) { if (is_change_event) g_assert(changes @@ -1100,9 +1100,9 @@ static void test_config_set_values(void) { gs_unref_object NMConfig *config = NULL; - const char * CONFIG_USER = BUILD_DIR "/test-set-values-user.conf"; - const char * CONFIG_INTERN = BUILD_DIR "/test-set-values-intern.conf"; - const char * atomic_section_prefixes[] = { + const char *CONFIG_USER = BUILD_DIR "/test-set-values-user.conf"; + const char *CONFIG_INTERN = BUILD_DIR "/test-set-values-intern.conf"; + const char *atomic_section_prefixes[] = { "atomic-prefix-1.", "atomic-prefix-2.", NULL, @@ -1150,10 +1150,10 @@ test_config_set_values(void) /*****************************************************************************/ static void -_test_signal_config_changed_cb(NMConfig * config, - NMConfigData * config_data, +_test_signal_config_changed_cb(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, + NMConfigData *old_data, gpointer user_data) { const NMConfigChangeFlags *expected = user_data; @@ -1168,10 +1168,10 @@ _test_signal_config_changed_cb(NMConfig * config, } static void -_test_signal_config_changed_cb2(NMConfig * config, - NMConfigData * config_data, +_test_signal_config_changed_cb2(NMConfig *config, + NMConfigData *config_data, NMConfigChangeFlags changes, - NMConfigData * old_data, + NMConfigData *old_data, gpointer user_data) { const NMConfigChangeFlags *expected = user_data; @@ -1183,8 +1183,8 @@ _test_signal_config_changed_cb2(NMConfig * config, static void test_config_signal(void) { - gs_unref_object NMConfig *config = NULL; - NMConfigChangeFlags expected; + gs_unref_object NMConfig *config = NULL; + NMConfigChangeFlags expected; gs_unref_object NMConfigData *config_data_orig = NULL; config = @@ -1234,7 +1234,7 @@ test_config_enable(void) { gs_unref_object NMConfig *config = NULL; guint match_nm_version = _nm_config_match_nm_version; - char * match_env = g_strdup(_nm_config_match_env); + char *match_env = g_strdup(_nm_config_match_env); nm_clear_g_free(&_nm_config_match_env); _nm_config_match_env = g_strdup("something-else"); @@ -1278,11 +1278,11 @@ test_config_enable(void) static void test_config_state_file(void) { - NMConfig * config; - const NMConfigState *state; + NMConfig *config; + const NMConfigState *state; gs_free_error GError *error = NULL; gboolean ret; - gs_free char * file_data = NULL; + gs_free char *file_data = NULL; gsize file_size; const char *const TMP_FILE = BUILD_DIR "/tmp.state"; diff --git a/src/core/tests/meson.build b/src/core/tests/meson.build index 99fa0ae9..78c689f7 100644 --- a/src/core/tests/meson.build +++ b/src/core/tests/meson.build @@ -6,8 +6,6 @@ test_units = [ 'test-core', 'test-core-with-expect', 'test-dcb', - 'test-ip4-config', - 'test-ip6-config', 'test-l3cfg', 'test-utils', 'test-wired-defname', diff --git a/src/core/tests/test-core-with-expect.c b/src/core/tests/test-core-with-expect.c index 01784863..eca098c4 100644 --- a/src/core/tests/test-core-with-expect.c +++ b/src/core/tests/test-core-with-expect.c @@ -98,7 +98,7 @@ test_nm_utils_kill_child_async_do(const char *name, int sig, guint32 wait_before_kill_msec, gboolean expected_success, - const int * expected_child_status) + const int *expected_child_status) { gboolean success; struct test_nm_utils_kill_child_async_data data = {}; @@ -135,7 +135,7 @@ test_nm_utils_kill_child_sync_do(const char *name, int sig, guint32 wait_before_kill_msec, gboolean expected_success, - const int * expected_child_status) + const int *expected_child_status) { gboolean success; int child_status = -1; @@ -226,11 +226,11 @@ static void do_test_nm_utils_kill_child(void) { GLogLevelFlags fatal_mask; - char * argv_watchdog[] = { + char *argv_watchdog[] = { "bash", "-c", "sleep 4; " - "kill -KILL 0; #watchdog for #" TEST_TOKEN, + "kill -KILL 0; #watchdog for #" TEST_TOKEN, NULL, }; char *argv1[] = { @@ -464,7 +464,7 @@ test_nm_utils_kill_child(void) static void _remove_at_indexes_init_random_idx(GArray *idx, guint array_len, guint idx_len) { - GRand * rand = nmtst_get_rand(); + GRand *rand = nmtst_get_rand(); gs_free char *mask = NULL; guint i, max_test_idx; @@ -515,7 +515,7 @@ _remove_at_indexes_init_random_idx(GArray *idx, guint array_len, guint idx_len) static void test_nm_utils_array_remove_at_indexes(void) { - gs_unref_array GArray *idx = NULL, *array = NULL; + gs_unref_array GArray *idx = NULL, *array = NULL; gs_unref_hashtable GHashTable *unique = NULL; guint i_len, i_idx_len, i_rnd, i; diff --git a/src/core/tests/test-core.c b/src/core/tests/test-core.c index 3524cb17..f61d66d9 100644 --- a/src/core/tests/test-core.c +++ b/src/core/tests/test-core.c @@ -389,11 +389,11 @@ test_nm_utils_sysctl_ip_conf_path(void) static NMConnection * _match_connection_new(void) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4, *s_ip6; - char * uuid; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4, *s_ip6; + char *uuid; connection = nm_simple_connection_new(); @@ -433,7 +433,7 @@ _match_connection_new(void) } static NMConnection * -_match_connection(GSList * connections, +_match_connection(GSList *connections, NMConnection *original, gboolean device_has_carrier, gint64 default_v4_metric, @@ -466,8 +466,8 @@ _match_connection(GSList * connections, static void test_connection_match_basic(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -495,8 +495,8 @@ test_connection_match_basic(void) static void test_connection_match_ip6_method(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -534,8 +534,8 @@ test_connection_match_ip6_method(void) static void test_connection_match_ip6_method_ignore(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -570,8 +570,8 @@ test_connection_match_ip6_method_ignore(void) static void test_connection_match_ip6_method_ignore_auto(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -606,8 +606,8 @@ test_connection_match_ip6_method_ignore_auto(void) static void test_connection_match_ip4_method(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -649,8 +649,8 @@ test_connection_match_ip4_method(void) static void test_connection_match_interface_name(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingConnection *s_con; orig = _match_connection_new(); @@ -679,11 +679,11 @@ test_connection_match_interface_name(void) static void test_connection_match_wired(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingWired *s_wired; - char * subchan_arr[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL}; - const char * mac = "52:54:00:ab:db:23"; + char *subchan_arr[] = {"0.0.8000", "0.0.8001", "0.0.8002", NULL}; + const char *mac = "52:54:00:ab:db:23"; orig = _match_connection_new(); copy = nm_simple_connection_new_clone(orig); @@ -722,10 +722,10 @@ test_connection_match_wired(void) static void test_connection_match_wired2(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingWired *s_wired; - const char * mac = "52:54:00:ab:db:23"; + const char *mac = "52:54:00:ab:db:23"; orig = _match_connection_new(); s_wired = nm_connection_get_setting_wired(orig); @@ -756,8 +756,8 @@ test_connection_match_wired2(void) static void test_connection_match_cloned_mac(void) { - NMConnection * orig, *exact, *fuzzy, *matched; - GSList * connections = NULL; + NMConnection *orig, *exact, *fuzzy, *matched; + GSList *connections = NULL; NMSettingWired *s_wired; orig = _match_connection_new(); @@ -794,11 +794,11 @@ test_connection_match_cloned_mac(void) static void test_connection_no_match_ip4_addr(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingIPConfig *s_ip4, *s_ip6; - NMIPAddress * nm_addr; - GError * error = NULL; + NMIPAddress *nm_addr; + GError *error = NULL; orig = _match_connection_new(); copy = nm_simple_connection_new_clone(orig); @@ -858,11 +858,11 @@ test_connection_no_match_ip4_addr(void) static void test_connection_no_match_vlan(void) { - NMConnection * orig, *copy, *matched; - GSList * connections = NULL; + NMConnection *orig, *copy, *matched; + GSList *connections = NULL; NMSettingConnection *s_con; - NMSettingVlan * s_vlan_orig, *s_vlan_copy; - char * uuid; + NMSettingVlan *s_vlan_orig, *s_vlan_copy; + char *uuid; orig = nm_simple_connection_new(); s_con = (NMSettingConnection *) nm_setting_connection_new(); @@ -915,9 +915,9 @@ static void test_connection_match_ip4_routes1(void) { gs_unref_object NMConnection *orig = NULL, *copy = NULL; - NMConnection * matched; - nm_auto_free_slist GSList *connections = NULL; - NMSettingIPConfig * s_ip4; + NMConnection *matched; + nm_auto_free_slist GSList *connections = NULL; + NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -952,9 +952,9 @@ static void test_connection_match_ip4_routes2(void) { gs_unref_object NMConnection *orig = NULL, *copy = NULL; - NMConnection * matched; - nm_auto_free_slist GSList *connections = NULL; - NMSettingIPConfig * s_ip4; + NMConnection *matched; + nm_auto_free_slist GSList *connections = NULL; + NMSettingIPConfig *s_ip4; orig = _match_connection_new(); @@ -992,9 +992,9 @@ static void test_connection_match_ip6_routes(void) { gs_unref_object NMConnection *orig = NULL, *copy = NULL; - NMConnection * matched; - nm_auto_free_slist GSList *connections = NULL; - NMSettingIPConfig * s_ip6; + NMConnection *matched; + nm_auto_free_slist GSList *connections = NULL; + NMSettingIPConfig *s_ip6; orig = _match_connection_new(); @@ -1122,7 +1122,7 @@ test_wildcard_match(void) static NMConnection * _create_connection_autoconnect(const char *id, gboolean autoconnect, int autoconnect_priority) { - NMConnection * c; + NMConnection *c; NMSettingConnection *s_con; c = nmtst_create_minimal_connection(id, NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con); @@ -1146,8 +1146,8 @@ _cmp_autoconnect_priority_p_with_data(gconstpointer pa, gconstpointer pb, gpoint static void _test_connection_sort_autoconnect_priority_one(NMConnection **list, gboolean shuffle) { - int i, j; - int count = 0; + int i, j; + int count = 0; gs_unref_ptrarray GPtrArray *connections = g_ptr_array_new(); while (list[count]) @@ -1253,7 +1253,7 @@ _test_match_spec_device(const GSList *specs, const char *match_str) NULL); if (match_str && g_str_has_prefix(match_str, MATCH_DRIVER)) { gs_free char *s = g_strdup(&match_str[NM_STRLEN(MATCH_DRIVER)]); - char * t; + char *t; t = strchr(s, '|'); if (t) { @@ -1266,15 +1266,15 @@ _test_match_spec_device(const GSList *specs, const char *match_str) } static void -_do_test_match_spec_device(const char * spec_str, +_do_test_match_spec_device(const char *spec_str, const char *const *matches, const char *const *no_matches, const char *const *neg_matches) { - GSList * specs, *specs_randperm = NULL, *specs_resplit, *specs_i, *specs_j; + GSList *specs, *specs_randperm = NULL, *specs_resplit, *specs_i, *specs_j; guint i; - gs_free char * specs_joined = NULL; - const char * s; + gs_free char *specs_joined = NULL; + const char *s; static const char *no_matches_default[] = {"e", "em", "em*", @@ -1463,16 +1463,16 @@ test_match_spec_device(void) /*****************************************************************************/ static void -_do_test_match_spec_config(const char * file, +_do_test_match_spec_config(const char *file, int line, - const char * spec_str, + const char *spec_str, guint version, guint v_maj, guint v_min, guint v_mic, NMMatchSpecMatchType expected) { - GSList * specs; + GSList *specs; NMMatchSpecMatchType match_result; guint c_maj, c_min, c_mic; @@ -1500,8 +1500,8 @@ _do_test_match_spec_config(const char * file, if (g_slist_length(specs) == 1 && !g_str_has_prefix(specs->data, "except:")) { /* there is only one spec in the list... test that we match except: */ - char * sss = g_strdup_printf("except:%s", (char *) specs->data); - GSList * specs2 = g_slist_append(NULL, sss); + char *sss = g_strdup_printf("except:%s", (char *) specs->data); + GSList *specs2 = g_slist_append(NULL, sss); NMMatchSpecMatchType match_result2; match_result2 = nm_match_spec_config(specs2, version, NULL); @@ -1731,9 +1731,9 @@ test_nm_utils_strbuf_append(void) #define _strbuf_append(buf, len, format, ...) \ G_STMT_START \ { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ - const char * _str_iter; \ + char **_buf = (buf); \ + gsize *_len = (len); \ + const char *_str_iter; \ gs_free char *_str = NULL; \ \ switch (nmtst_get_rand_uint32() % 4) { \ @@ -1762,8 +1762,8 @@ test_nm_utils_strbuf_append(void) #define _strbuf_append_str(buf, len, str) \ G_STMT_START \ { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ + char **_buf = (buf); \ + gsize *_len = (len); \ const char *_str = (str); \ \ switch (nmtst_get_rand_uint32() % 4) { \ @@ -1813,7 +1813,7 @@ test_nm_utils_strbuf_append(void) for (buf_len = 0; buf_len < 10; buf_len++) { for (rep = 0; rep < 50; rep++) { const int s_len = nmtst_get_rand_uint32() % (sizeof(str) - 5); - char * t_buf; + char *t_buf; gsize t_len; int test_mode; @@ -2044,7 +2044,7 @@ static void test_reverse_dns_ip6(void) { struct in6_addr addr; - GPtrArray * domains = g_ptr_array_new_full(8, g_free); + GPtrArray *domains = g_ptr_array_new_full(8, g_free); inet_pton(AF_INET6, "1234::56", &addr); nm_utils_get_reverse_dns_domains_ip_6(&addr, 16, domains); @@ -2097,11 +2097,11 @@ test_reverse_dns_ip6(void) /*****************************************************************************/ static void -do_test_stable_id_parse(const char * stable_id, +do_test_stable_id_parse(const char *stable_id, NMUtilsStableType expected_stable_type, - const char * expected_generated) + const char *expected_generated) { - gs_free char * generated = NULL; + gs_free char *generated = NULL; NMUtilsStableType stable_type; if (expected_stable_type == NM_UTILS_STABLE_TYPE_GENERATED) @@ -2263,7 +2263,7 @@ test_utils_file_is_in_path(void) const char *const *const _searches = (searches); \ const char *const *const _nameservers = (nameservers); \ const char *const *const _options = (options); \ - gs_free char * _content = NULL; \ + gs_free char *_content = NULL; \ \ _content = nmtst_dns_create_resolv_conf(_searches, _nameservers, _options); \ g_assert_cmpstr(_content, ==, expected); \ @@ -2443,9 +2443,9 @@ test_nm_utils_dhcp_client_id_systemd_node_specific(gconstpointer test_data) g_assert_cmpint(u64, ==, d->duid_id); for (i = 0; i < 2; i++) { - const gboolean legacy_unstable_byteorder = (i != 0); - gs_unref_bytes GBytes *client_id = NULL; - const guint8 * cid; + const gboolean legacy_unstable_byteorder = (i != 0); + gs_unref_bytes GBytes *client_id = NULL; + const guint8 *cid; guint32 iaid = d->iaid_ifname; guint32 tmp; @@ -2489,7 +2489,7 @@ _kernel_cmdline_match(gboolean expected_match, const char *const *patterns) { gs_free_error GError *error = NULL; - GError ** p_error = nmtst_get_rand_bool() ? &error : NULL; + GError **p_error = nmtst_get_rand_bool() ? &error : NULL; gboolean match; nm_assert(proc_cmdline); diff --git a/src/core/tests/test-dcb.c b/src/core/tests/test-dcb.c index fc591fcb..f85e90f9 100644 --- a/src/core/tests/test-dcb.c +++ b/src/core/tests/test-dcb.c @@ -18,7 +18,7 @@ static gboolean test_dcb_func(char **argv, guint which, gpointer user_data, GError **error) { DcbExpected *e = user_data; - char * f; + char *f; g_assert(argv[0] == NULL); argv[0] = (which == DCBTOOL) ? "dcbtool" : "fcoeadm"; @@ -49,7 +49,7 @@ test_dcb_fcoe(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -82,7 +82,7 @@ test_dcb_iscsi(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -115,7 +115,7 @@ test_dcb_fip(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -147,7 +147,7 @@ test_dcb_fip_default_prio(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -180,7 +180,7 @@ test_dcb_pfc(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -221,7 +221,7 @@ test_dcb_priority_groups(void) NULL}, }; NMSettingDcb *s_dcb; - GError * error = NULL; + GError *error = NULL; gboolean success; guint i; @@ -267,7 +267,7 @@ test_dcb_cleanup(void) "dcbtool sc eth0 dcb off", NULL}, }; - GError * error = NULL; + GError *error = NULL; gboolean success; success = _fcoe_cleanup("eth0", test_dcb_func, &expected, &error); @@ -292,7 +292,7 @@ test_fcoe_create(void) 0, {"fcoeadm -m vn2vn -c eth0", NULL}, }; - GError * error = NULL; + GError *error = NULL; gboolean success; NMSettingDcb *s_dcb; @@ -323,7 +323,7 @@ test_fcoe_cleanup(void) 0, {"fcoeadm -d eth0", NULL}, }; - GError * error = NULL; + GError *error = NULL; gboolean success; success = _fcoe_cleanup("eth0", test_dcb_func, &expected, &error); diff --git a/src/core/tests/test-ip4-config.c b/src/core/tests/test-ip4-config.c deleted file mode 100644 index 3a095d4a..00000000 --- a/src/core/tests/test-ip4-config.c +++ /dev/null @@ -1,380 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2013 - 2014 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include <arpa/inet.h> - -#include "nm-ip4-config.h" -#include "libnm-platform/nm-platform.h" - -#include "nm-test-utils-core.h" - -static NMIP4Config * -build_test_config(void) -{ - NMIP4Config * config; - NMPlatformIP4Address addr; - NMPlatformIP4Route route; - - /* Build up the config to subtract */ - config = nmtst_ip4_config_new(1); - - nm_assert(NM_IP_CONFIG_CAST(config)); - - addr = *nmtst_platform_ip4_address("192.168.1.10", "1.2.3.4", 24); - nm_ip4_config_add_address(config, &addr); - - route = *nmtst_platform_ip4_route("10.0.0.0", 8, "192.168.1.1"); - nm_ip4_config_add_route(config, &route, NULL); - - route = *nmtst_platform_ip4_route("172.16.0.0", 16, "192.168.1.1"); - nm_ip4_config_add_route(config, &route, NULL); - - { - const NMPlatformIP4Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_DHCP, - .gateway = nmtst_inet4_from_string("192.168.1.1"), - .table_coerced = 0, - .metric = 100, - }; - - nm_ip4_config_add_route(config, &r, NULL); - } - - nm_ip4_config_add_nameserver(config, nmtst_inet4_from_string("4.2.2.1")); - nm_ip4_config_add_nameserver(config, nmtst_inet4_from_string("4.2.2.2")); - nm_ip4_config_add_domain(config, "foobar.com"); - nm_ip4_config_add_domain(config, "baz.com"); - nm_ip4_config_add_search(config, "blahblah.com"); - nm_ip4_config_add_search(config, "beatbox.com"); - - nm_ip4_config_add_nis_server(config, nmtst_inet4_from_string("1.2.3.9")); - nm_ip4_config_add_nis_server(config, nmtst_inet4_from_string("1.2.3.10")); - - nm_ip4_config_add_wins(config, nmtst_inet4_from_string("4.2.3.9")); - nm_ip4_config_add_wins(config, nmtst_inet4_from_string("4.2.3.10")); - - return config; -} - -static void -test_replace(void) -{ - gs_unref_object NMIP4Config *config1 = NULL; - gs_unref_object NMIP4Config *config2 = NULL; - NMPlatformIP4Address addr; - gboolean relevant_changes; - - config1 = nmtst_ip4_config_new(1); - - addr = *nmtst_platform_ip4_address("172.16.0.1", NULL, 24); - addr.timestamp = 10; - addr.preferred = 3600; - addr.lifetime = 7200; - nm_ip4_config_add_address(config1, &addr); - - addr = *nmtst_platform_ip4_address("172.16.0.2", NULL, 24); - addr.timestamp = 10; - addr.preferred = 3600; - addr.lifetime = 7200; - nm_ip4_config_add_address(config1, &addr); - - config2 = nmtst_ip4_config_new(1); - - addr = *nmtst_platform_ip4_address("192.168.1.1", NULL, 24); - addr.timestamp = 40; - addr.preferred = 60; - addr.lifetime = 120; - nm_ip4_config_add_address(config2, &addr); - - addr = *nmtst_platform_ip4_address("172.16.0.2", NULL, 24); - addr.timestamp = 40; - addr.preferred = 60; - addr.lifetime = 120; - nm_ip4_config_add_address(config2, &addr); - - g_assert(nm_ip4_config_replace(config2, config1, &relevant_changes)); - g_assert(relevant_changes); - g_assert(nm_ip4_config_equal(config1, config2)); -} - -static void -test_subtract(void) -{ - NMIP4Config * src, *dst; - NMPlatformIP4Address addr; - NMPlatformIP4Route route; - const NMPlatformIP4Address *test_addr; - const NMPlatformIP4Route * test_route; - const char * expected_addr = "192.168.1.12"; - guint32 expected_addr_plen = 24; - const char * expected_route_dest = "8.0.0.0"; - guint32 expected_route_plen = 8; - const char * expected_route_next_hop = "192.168.1.1"; - guint32 expected_ns1 = nmtst_inet4_from_string("8.8.8.8"); - guint32 expected_ns2 = nmtst_inet4_from_string("8.8.8.9"); - const char * expected_domain = "wonderfalls.com"; - const char * expected_search = "somewhere.com"; - guint32 expected_nis = nmtst_inet4_from_string("1.2.3.13"); - guint32 expected_wins = nmtst_inet4_from_string("2.3.4.5"); - guint32 expected_mtu = 1492; - - src = build_test_config(); - - /* add a couple more things to the test config */ - dst = build_test_config(); - addr = *nmtst_platform_ip4_address(expected_addr, NULL, expected_addr_plen); - nm_ip4_config_add_address(dst, &addr); - - route = *nmtst_platform_ip4_route(expected_route_dest, - expected_route_plen, - expected_route_next_hop); - nm_ip4_config_add_route(dst, &route, NULL); - - nm_ip4_config_add_nameserver(dst, expected_ns1); - nm_ip4_config_add_nameserver(dst, expected_ns2); - nm_ip4_config_add_domain(dst, expected_domain); - nm_ip4_config_add_search(dst, expected_search); - - nm_ip4_config_add_nis_server(dst, expected_nis); - nm_ip4_config_add_wins(dst, expected_wins); - - nm_ip4_config_set_mtu(dst, expected_mtu, NM_IP_CONFIG_SOURCE_UNKNOWN); - - nm_ip4_config_subtract(dst, src, 0); - - /* ensure what's left is what we expect */ - g_assert_cmpuint(nm_ip4_config_get_num_addresses(dst), ==, 1); - test_addr = _nmtst_ip4_config_get_address(dst, 0); - g_assert(test_addr != NULL); - g_assert_cmpuint(test_addr->address, ==, nmtst_inet4_from_string(expected_addr)); - g_assert_cmpuint(test_addr->peer_address, ==, test_addr->address); - g_assert_cmpuint(test_addr->plen, ==, expected_addr_plen); - - g_assert(!nm_ip4_config_best_default_route_get(dst)); - g_assert_cmpuint(nmtst_ip4_config_get_gateway(dst), ==, 0); - - g_assert_cmpuint(nm_ip4_config_get_num_routes(dst), ==, 1); - test_route = _nmtst_ip4_config_get_route(dst, 0); - g_assert(test_route != NULL); - g_assert_cmpuint(test_route->network, ==, nmtst_inet4_from_string(expected_route_dest)); - g_assert_cmpuint(test_route->plen, ==, expected_route_plen); - g_assert_cmpuint(test_route->gateway, ==, nmtst_inet4_from_string(expected_route_next_hop)); - - g_assert_cmpuint(nm_ip4_config_get_num_nameservers(dst), ==, 2); - g_assert_cmpuint(nm_ip4_config_get_nameserver(dst, 0), ==, expected_ns1); - g_assert_cmpuint(nm_ip4_config_get_nameserver(dst, 1), ==, expected_ns2); - - g_assert_cmpuint(nm_ip4_config_get_num_domains(dst), ==, 1); - g_assert_cmpstr(nm_ip4_config_get_domain(dst, 0), ==, expected_domain); - g_assert_cmpuint(nm_ip4_config_get_num_searches(dst), ==, 1); - g_assert_cmpstr(nm_ip4_config_get_search(dst, 0), ==, expected_search); - - g_assert_cmpuint(nm_ip4_config_get_num_nis_servers(dst), ==, 1); - g_assert_cmpuint(nm_ip4_config_get_nis_server(dst, 0), ==, expected_nis); - - g_assert_cmpuint(nm_ip4_config_get_num_wins(dst), ==, 1); - g_assert_cmpuint(nm_ip4_config_get_wins(dst, 0), ==, expected_wins); - - g_assert_cmpuint(nm_ip4_config_get_mtu(dst), ==, expected_mtu); - - g_object_unref(src); - g_object_unref(dst); -} - -static void -test_compare_with_source(void) -{ - NMIP4Config * a, *b; - NMPlatformIP4Address addr; - NMPlatformIP4Route route; - - a = nmtst_ip4_config_new(1); - b = nmtst_ip4_config_new(2); - - /* Address */ - addr = *nmtst_platform_ip4_address("1.2.3.4", NULL, 24); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_address(a, &addr); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_address(b, &addr); - - /* Route */ - route = *nmtst_platform_ip4_route("10.0.0.0", 8, "192.168.1.1"); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_route(a, &route, NULL); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_route(b, &route, NULL); - - /* Assert that the configs are basically the same, eg that the source is ignored */ - g_assert(nm_ip4_config_equal(a, b)); - - g_object_unref(a); - g_object_unref(b); -} - -static void -test_add_address_with_source(void) -{ - NMIP4Config * a; - NMPlatformIP4Address addr; - const NMPlatformIP4Address *test_addr; - - a = nmtst_ip4_config_new(1); - - /* Test that a higher priority source is not overwritten */ - addr = *nmtst_platform_ip4_address("1.2.3.4", NULL, 24); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - /* Test that a lower priority address source is overwritten */ - _nmtst_ip4_config_del_address(a, 0); - addr.addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_address(a, &addr); - - test_addr = _nmtst_ip4_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - g_object_unref(a); -} - -static void -test_add_route_with_source(void) -{ - gs_unref_object NMIP4Config *a = NULL; - NMPlatformIP4Route route; - const NMPlatformIP4Route * test_route; - - a = nmtst_ip4_config_new(1); - - /* Test that a higher priority source is not overwritten */ - route = *nmtst_platform_ip4_route("1.2.3.0", 24, "1.2.3.1"); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - _nmtst_ip4_config_del_route(a, 0); - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 0); - - /* Test that a lower priority address source is overwritten */ - route.rt_source = NM_IP_CONFIG_SOURCE_RTPROT_KERNEL; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_RTPROT_KERNEL); - - route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip4_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip4_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip4_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); -} - -static void -test_merge_subtract_mtu(void) -{ - NMIP4Config *cfg1, *cfg2, *cfg3; - guint32 expected_mtu2 = 1492; - guint32 expected_mtu3 = 666; - - cfg1 = build_test_config(); - cfg2 = build_test_config(); - cfg3 = build_test_config(); - - /* add MSS, MTU to configs to test them */ - nm_ip4_config_set_mtu(cfg2, expected_mtu2, NM_IP_CONFIG_SOURCE_UNKNOWN); - nm_ip4_config_set_mtu(cfg3, expected_mtu3, NM_IP_CONFIG_SOURCE_UNKNOWN); - - nm_ip4_config_merge(cfg1, cfg2, NM_IP_CONFIG_MERGE_DEFAULT, 0); - /* ensure MSS and MTU are in cfg1 */ - g_assert_cmpuint(nm_ip4_config_get_mtu(cfg1), ==, expected_mtu2); - - nm_ip4_config_merge(cfg1, cfg3, NM_IP_CONFIG_MERGE_DEFAULT, 0); - /* ensure again the MSS and MTU in cfg1 got overridden */ - g_assert_cmpuint(nm_ip4_config_get_mtu(cfg1), ==, expected_mtu3); - - nm_ip4_config_subtract(cfg1, cfg3, 0); - /* ensure MSS and MTU are zero in cfg1 */ - g_assert_cmpuint(nm_ip4_config_get_mtu(cfg1), ==, 0); - - g_object_unref(cfg1); - g_object_unref(cfg2); - g_object_unref(cfg3); -} - -static void -test_strip_search_trailing_dot(void) -{ - NMIP4Config *config; - - config = nmtst_ip4_config_new(1); - - nm_ip4_config_add_search(config, "."); - nm_ip4_config_add_search(config, "foo"); - nm_ip4_config_add_search(config, "bar."); - nm_ip4_config_add_search(config, "baz.com"); - nm_ip4_config_add_search(config, "baz.com."); - nm_ip4_config_add_search(config, "foobar.."); - nm_ip4_config_add_search(config, ".foobar"); - nm_ip4_config_add_search(config, "~."); - - g_assert_cmpuint(nm_ip4_config_get_num_searches(config), ==, 4); - g_assert_cmpstr(nm_ip4_config_get_search(config, 0), ==, "foo"); - g_assert_cmpstr(nm_ip4_config_get_search(config, 1), ==, "bar"); - g_assert_cmpstr(nm_ip4_config_get_search(config, 2), ==, "baz.com"); - g_assert_cmpstr(nm_ip4_config_get_search(config, 3), ==, "~"); - - g_object_unref(config); -} - -/*****************************************************************************/ - -NMTST_DEFINE(); - -int -main(int argc, char **argv) -{ - nmtst_init_with_logging(&argc, &argv, NULL, "DEFAULT"); - - g_test_add_func("/ip4-config/replace", test_replace); - g_test_add_func("/ip4-config/subtract", test_subtract); - g_test_add_func("/ip4-config/compare-with-source", test_compare_with_source); - g_test_add_func("/ip4-config/add-address-with-source", test_add_address_with_source); - g_test_add_func("/ip4-config/add-route-with-source", test_add_route_with_source); - g_test_add_func("/ip4-config/merge-subtract-mtu", test_merge_subtract_mtu); - g_test_add_func("/ip4-config/strip-search-trailing-dot", test_strip_search_trailing_dot); - - return g_test_run(); -} diff --git a/src/core/tests/test-ip6-config.c b/src/core/tests/test-ip6-config.c deleted file mode 100644 index 2e6d8aaa..00000000 --- a/src/core/tests/test-ip6-config.c +++ /dev/null @@ -1,538 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2013 Red Hat, Inc. - */ - -#include "src/core/nm-default-daemon.h" - -#include <arpa/inet.h> -#include <linux/if_addr.h> - -#include "nm-ip6-config.h" - -#include "libnm-platform/nm-platform.h" -#include "nm-test-utils-core.h" - -static NMIP6Config * -build_test_config(void) -{ - NMIP6Config *config; - - /* Build up the config to subtract */ - config = nmtst_ip6_config_new(1); - - nm_ip6_config_add_address(config, - nmtst_platform_ip6_address("abcd:1234:4321::cdde", "1:2:3:4::5", 64)); - nm_ip6_config_add_route( - config, - nmtst_platform_ip6_route("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL), - NULL); - nm_ip6_config_add_route(config, - nmtst_platform_ip6_route("2001::", 16, "2001:abba::2234", NULL), - NULL); - - nm_ip6_config_add_route(config, - nmtst_platform_ip6_route("::", 0, "3001:abba::3234", NULL), - NULL); - - nm_ip6_config_add_nameserver(config, nmtst_inet6_from_string("1:2:3:4::1")); - nm_ip6_config_add_nameserver(config, nmtst_inet6_from_string("1:2:3:4::2")); - nm_ip6_config_add_domain(config, "foobar.com"); - nm_ip6_config_add_domain(config, "baz.com"); - nm_ip6_config_add_search(config, "blahblah.com"); - nm_ip6_config_add_search(config, "beatbox.com"); - - return config; -} - -static void -test_subtract(void) -{ - NMIP6Config * src, *dst; - const NMPlatformIP6Address *test_addr; - const NMPlatformIP6Route * test_route; - const char * expected_addr = "1122:3344:5566::7788"; - guint32 expected_addr_plen = 96; - const char * expected_route_dest = "9991:8800::"; - guint32 expected_route_plen = 24; - const char * expected_route_next_hop = "1119:2228:3337:4446::5555"; - struct in6_addr expected_ns1; - struct in6_addr expected_ns2; - const char * expected_domain = "wonderfalls.com"; - const char * expected_search = "somewhere.com"; - struct in6_addr tmp; - - src = build_test_config(); - - /* add a couple more things to the test config */ - dst = build_test_config(); - nm_ip6_config_add_address(dst, - nmtst_platform_ip6_address(expected_addr, NULL, expected_addr_plen)); - nm_ip6_config_add_route(dst, - nmtst_platform_ip6_route(expected_route_dest, - expected_route_plen, - expected_route_next_hop, - NULL), - NULL); - - expected_ns1 = *nmtst_inet6_from_string("2222:3333:4444::5555"); - nm_ip6_config_add_nameserver(dst, &expected_ns1); - expected_ns2 = *nmtst_inet6_from_string("2222:3333:4444::5556"); - nm_ip6_config_add_nameserver(dst, &expected_ns2); - - nm_ip6_config_add_domain(dst, expected_domain); - nm_ip6_config_add_search(dst, expected_search); - - nm_ip6_config_subtract(dst, src, 0); - - /* ensure what's left is what we expect */ - g_assert_cmpuint(nm_ip6_config_get_num_addresses(dst), ==, 1); - test_addr = _nmtst_ip6_config_get_address(dst, 0); - g_assert(test_addr != NULL); - tmp = *nmtst_inet6_from_string(expected_addr); - g_assert(memcmp(&test_addr->address, &tmp, sizeof(tmp)) == 0); - g_assert(memcmp(&test_addr->peer_address, &in6addr_any, sizeof(tmp)) == 0); - g_assert_cmpuint(test_addr->plen, ==, expected_addr_plen); - - g_assert(nm_ip6_config_best_default_route_get(dst) == NULL); - - g_assert_cmpuint(nm_ip6_config_get_num_routes(dst), ==, 1); - test_route = _nmtst_ip6_config_get_route(dst, 0); - g_assert(test_route != NULL); - - tmp = *nmtst_inet6_from_string(expected_route_dest); - g_assert(memcmp(&test_route->network, &tmp, sizeof(tmp)) == 0); - g_assert_cmpuint(test_route->plen, ==, expected_route_plen); - tmp = *nmtst_inet6_from_string(expected_route_next_hop); - g_assert(memcmp(&test_route->gateway, &tmp, sizeof(tmp)) == 0); - - g_assert_cmpuint(nm_ip6_config_get_num_nameservers(dst), ==, 2); - g_assert(memcmp(nm_ip6_config_get_nameserver(dst, 0), &expected_ns1, sizeof(expected_ns1)) - == 0); - g_assert(memcmp(nm_ip6_config_get_nameserver(dst, 1), &expected_ns2, sizeof(expected_ns2)) - == 0); - - g_assert_cmpuint(nm_ip6_config_get_num_domains(dst), ==, 1); - g_assert_cmpstr(nm_ip6_config_get_domain(dst, 0), ==, expected_domain); - g_assert_cmpuint(nm_ip6_config_get_num_searches(dst), ==, 1); - g_assert_cmpstr(nm_ip6_config_get_search(dst, 0), ==, expected_search); - - g_object_unref(src); - g_object_unref(dst); -} - -static void -test_compare_with_source(void) -{ - NMIP6Config * a, *b; - NMPlatformIP6Address addr; - NMPlatformIP6Route route; - - a = nmtst_ip6_config_new(1); - b = nmtst_ip6_config_new(2); - - /* Address */ - addr = *nmtst_platform_ip6_address("1122:3344:5566::7788", NULL, 64); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_address(a, &addr); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_address(b, &addr); - - /* Route */ - route = *nmtst_platform_ip6_route("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_route(a, &route, NULL); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_route(b, &route, NULL); - - /* Assert that the configs are basically the same, eg that the source is ignored */ - g_assert(nm_ip6_config_equal(a, b)); - - g_object_unref(a); - g_object_unref(b); -} - -static void -test_add_address_with_source(void) -{ - NMIP6Config * a; - NMPlatformIP6Address addr; - const NMPlatformIP6Address *test_addr; - - a = nmtst_ip6_config_new(1); - - /* Test that a higher priority source is not overwritten */ - addr = *nmtst_platform_ip6_address("1122:3344:5566::7788", NULL, 64); - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - addr.addr_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - /* Test that a lower priority address source is overwritten */ - _nmtst_ip6_config_del_address(a, 0); - addr.addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - - addr.addr_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_address(a, &addr); - - test_addr = _nmtst_ip6_config_get_address(a, 0); - g_assert_cmpint(test_addr->addr_source, ==, NM_IP_CONFIG_SOURCE_USER); - - g_object_unref(a); -} - -static void -test_add_route_with_source(void) -{ - gs_unref_object NMIP6Config *a = NULL; - NMPlatformIP6Route route; - const NMPlatformIP6Route * test_route; - - a = nmtst_ip6_config_new(1); - - /* Test that a higher priority source is not overwritten */ - route = *nmtst_platform_ip6_route("abcd:1200::", 24, "abcd:1234:4321:cdde::2", NULL); - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - route.rt_source = NM_IP_CONFIG_SOURCE_VPN; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); - - _nmtst_ip6_config_del_route(a, 0); - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 0); - - /* Test that a lower priority address source is overwritten */ - route.rt_source = NM_IP_CONFIG_SOURCE_KERNEL; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_KERNEL); - - route.rt_source = NM_IP_CONFIG_SOURCE_USER; - nm_ip6_config_add_route(a, &route, NULL); - - g_assert_cmpint(nm_ip6_config_get_num_routes(a), ==, 1); - test_route = _nmtst_ip6_config_get_route(a, 0); - g_assert_cmpint(test_route->rt_source, ==, NM_IP_CONFIG_SOURCE_USER); -} - -static void -test_nm_ip6_config_addresses_sort_check(NMIP6Config * config, - NMSettingIP6ConfigPrivacy use_tempaddr, - int repeat) -{ - int addr_count = nm_ip6_config_get_num_addresses(config); - int i, irepeat; - NMIP6Config *copy, *copy2; - int * idx = g_new(int, addr_count); - - nm_ip6_config_set_privacy(config, use_tempaddr); - copy = nm_ip6_config_clone(config); - g_assert(copy); - copy2 = nm_ip6_config_clone(config); - g_assert(copy2); - - /* initialize the array of indices, and keep shuffling them for every @repeat iteration. */ - for (i = 0; i < addr_count; i++) - idx[i] = i; - - for (irepeat = 0; irepeat < repeat; irepeat++) { - /* randomly shuffle the addresses. */ - nm_ip6_config_reset_addresses(copy); - for (i = 0; i < addr_count; i++) { - int j = g_rand_int_range(nmtst_get_rand(), i, addr_count); - - NM_SWAP(&idx[i], &idx[j]); - nm_ip6_config_add_address(copy, _nmtst_ip6_config_get_address(config, idx[i])); - } - - /* reorder them again */ - _nmtst_ip6_config_addresses_sort(copy); - - /* check equality using nm_ip6_config_equal() */ - if (!nm_ip6_config_equal(copy, config)) { - g_message("%s", "SORTING yields unexpected output:"); - for (i = 0; i < addr_count; i++) { - g_message( - " >> [%d] = %s", - i, - nm_platform_ip6_address_to_string(_nmtst_ip6_config_get_address(config, i), - NULL, - 0)); - g_message(" << [%d] = %s", - i, - nm_platform_ip6_address_to_string(_nmtst_ip6_config_get_address(copy, i), - NULL, - 0)); - } - g_assert_not_reached(); - } - - /* also check equality using nm_ip6_config_replace() */ - g_assert(nm_ip6_config_replace(copy2, copy, NULL) == FALSE); - } - - g_free(idx); - g_object_unref(copy); - g_object_unref(copy2); -} - -static void -test_nm_ip6_config_addresses_sort(void) -{ - NMIP6Config *config = build_test_config(); - -#define ADDR_ADD(...) \ - nm_ip6_config_add_address(config, nmtst_platform_ip6_address_full(__VA_ARGS__)) - - nm_ip6_config_reset_addresses(config); - ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::6", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_NDISC, - 0, - 0, - 0, - IFA_F_MANAGETEMPADDR); - ADDR_ADD("2607:f0d0:1002:51::3", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::8", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::0", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_KERNEL, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::2", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_TENTATIVE); - test_nm_ip6_config_addresses_sort_check(config, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, 8); - test_nm_ip6_config_addresses_sort_check(config, NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED, 8); - test_nm_ip6_config_addresses_sort_check(config, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR, - 8); - - nm_ip6_config_reset_addresses(config); - ADDR_ADD("2607:f0d0:1002:51::3", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::8", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::0", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_KERNEL, - 0, - 0, - 0, - IFA_F_SECONDARY); - ADDR_ADD("2607:f0d0:1002:51::6", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_NDISC, - 0, - 0, - 0, - IFA_F_MANAGETEMPADDR); - ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); - ADDR_ADD("::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); - ADDR_ADD("2607:f0d0:1002:51::2", - NULL, - 64, - 0, - NM_IP_CONFIG_SOURCE_USER, - 0, - 0, - 0, - IFA_F_TENTATIVE); - test_nm_ip6_config_addresses_sort_check(config, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - 8); - -#undef ADDR_ADD - g_object_unref(config); -} - -static void -test_strip_search_trailing_dot(void) -{ - NMIP6Config *config; - - config = nmtst_ip6_config_new(1); - - nm_ip6_config_add_search(config, "."); - nm_ip6_config_add_search(config, "foo"); - nm_ip6_config_add_search(config, "bar."); - nm_ip6_config_add_search(config, "baz.com"); - nm_ip6_config_add_search(config, "baz.com."); - nm_ip6_config_add_search(config, "foobar.."); - nm_ip6_config_add_search(config, ".foobar"); - nm_ip6_config_add_search(config, "~."); - - g_assert_cmpuint(nm_ip6_config_get_num_searches(config), ==, 4); - g_assert_cmpstr(nm_ip6_config_get_search(config, 0), ==, "foo"); - g_assert_cmpstr(nm_ip6_config_get_search(config, 1), ==, "bar"); - g_assert_cmpstr(nm_ip6_config_get_search(config, 2), ==, "baz.com"); - g_assert_cmpstr(nm_ip6_config_get_search(config, 3), ==, "~"); - - g_object_unref(config); -} - -/*****************************************************************************/ - -static void -test_replace(gconstpointer user_data) -{ - nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = nm_dedup_multi_index_new(); - const int TEST_IDX = GPOINTER_TO_INT(user_data); - const int IFINDEX = 1; - gs_unref_object NMIP6Config *src_conf = NULL; - gs_unref_object NMIP6Config *dst_conf = NULL; - NMPlatformIP6Address * addr; - NMPlatformIP6Address addrs[5] = {}; - guint addrs_n = 0; - guint i; - - dst_conf = nm_ip6_config_new(multi_idx, IFINDEX); - src_conf = nm_ip6_config_new(multi_idx, IFINDEX); - - switch (TEST_IDX) { - case 1: - addr = &addrs[addrs_n++]; - addr->ifindex = IFINDEX; - addr->address = *nmtst_inet6_from_string("fe80::78ec:7a6d:602d:20f2"); - addr->plen = 64; - addr->n_ifa_flags = IFA_F_PERMANENT; - addr->addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - break; - case 2: - addr = &addrs[addrs_n++]; - addr->ifindex = IFINDEX; - addr->address = *nmtst_inet6_from_string("fe80::78ec:7a6d:602d:20f2"); - addr->plen = 64; - addr->n_ifa_flags = IFA_F_PERMANENT; - addr->addr_source = NM_IP_CONFIG_SOURCE_KERNEL; - - addr = &addrs[addrs_n++]; - addr->ifindex = IFINDEX; - addr->address = *nmtst_inet6_from_string("1::1"); - addr->plen = 64; - addr->addr_source = NM_IP_CONFIG_SOURCE_USER; - - nm_ip6_config_add_address(dst_conf, addr); - break; - default: - g_assert_not_reached(); - } - - g_assert(addrs_n < G_N_ELEMENTS(addrs)); - - for (i = 0; i < addrs_n; i++) - nm_ip6_config_add_address(src_conf, &addrs[i]); - - nm_ip6_config_replace(dst_conf, src_conf, NULL); - - for (i = 0; i < addrs_n; i++) { - const NMPlatformIP6Address *a = _nmtst_ip6_config_get_address(dst_conf, i); - const NMPlatformIP6Address *b = _nmtst_ip6_config_get_address(src_conf, i); - - g_assert(nm_platform_ip6_address_cmp(&addrs[i], a) == 0); - g_assert(nm_platform_ip6_address_cmp(&addrs[i], b) == 0); - } - g_assert(addrs_n == nm_ip6_config_get_num_addresses(dst_conf)); - g_assert(addrs_n == nm_ip6_config_get_num_addresses(src_conf)); -} - -/*****************************************************************************/ - -NMTST_DEFINE(); - -int -main(int argc, char **argv) -{ - nmtst_init_with_logging(&argc, &argv, NULL, "ALL"); - - g_test_add_func("/ip6-config/subtract", test_subtract); - g_test_add_func("/ip6-config/compare-with-source", test_compare_with_source); - g_test_add_func("/ip6-config/add-address-with-source", test_add_address_with_source); - g_test_add_func("/ip6-config/add-route-with-source", test_add_route_with_source); - g_test_add_func("/ip6-config/test_nm_ip6_config_addresses_sort", - test_nm_ip6_config_addresses_sort); - g_test_add_func("/ip6-config/strip-search-trailing-dot", test_strip_search_trailing_dot); - g_test_add_data_func("/ip6-config/replace/1", GINT_TO_POINTER(1), test_replace); - g_test_add_data_func("/ip6-config/replace/2", GINT_TO_POINTER(2), test_replace); - - return g_test_run(); -} diff --git a/src/core/tests/test-l3cfg.c b/src/core/tests/test-l3cfg.c index 100c2496..5501079e 100644 --- a/src/core/tests/test-l3cfg.c +++ b/src/core/tests/test-l3cfg.c @@ -22,9 +22,9 @@ _netns_access_l3cfg(NMNetns *netns, int ifindex) g_assert(NM_IS_NETNS(netns)); g_assert(ifindex > 0); - g_assert(!nm_netns_get_l3cfg(netns, ifindex)); + g_assert(!nm_netns_l3cfg_get(netns, ifindex)); - l3cfg = nm_netns_access_l3cfg(netns, ifindex); + l3cfg = nm_netns_l3cfg_acquire(netns, ifindex); g_assert(NM_IS_L3CFG(l3cfg)); return l3cfg; } @@ -33,11 +33,11 @@ _netns_access_l3cfg(NMNetns *netns, int ifindex) typedef struct { int test_idx; - NMPlatform * platform; - NMNetns * netns; + NMPlatform *platform; + NMNetns *netns; NMDedupMultiIndex *multiidx; - const char * ifname0; - const char * ifname1; + const char *ifname0; + const char *ifname1; NMPLinkAddress hwaddr0; NMPLinkAddress hwaddr1; int ifindex0; @@ -163,9 +163,9 @@ _test_l3cfg_data_set_notify_type(TestL3cfgData *tdata, TestL3cfgNotifyType notif } static void -_test_l3cfg_signal_notify(NML3Cfg * l3cfg, +_test_l3cfg_signal_notify(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, - TestL3cfgData * tdata) + TestL3cfgData *tdata) { guint i; @@ -327,13 +327,13 @@ test_l3cfg(gconstpointer test_data) const int TEST_IDX = GPOINTER_TO_INT(test_data); const guint32 ACD_TIMEOUT_BASE_MSEC = 1000; nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; - const TestFixture1 * f; - NML3CfgCommitTypeHandle * commit_type_1; - NML3CfgCommitTypeHandle * commit_type_2; - gs_unref_object NML3Cfg *l3cfg0 = NULL; - nm_auto_unref_l3cd const NML3ConfigData *l3cd_a = NULL; - TestL3cfgData tdata_stack = { - .f = NULL, + const TestFixture1 *f; + NML3CfgCommitTypeHandle *commit_type_1; + NML3CfgCommitTypeHandle *commit_type_2; + gs_unref_object NML3Cfg *l3cfg0 = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_a = NULL; + TestL3cfgData tdata_stack = { + .f = NULL, }; TestL3cfgData *const tdata = &tdata_stack; @@ -519,10 +519,10 @@ test_l3cfg(gconstpointer test_data) #define L3IPV4LL_ACD_TIMEOUT_MSEC 1500u typedef struct { - const TestFixture1 * f; + const TestFixture1 *f; NML3CfgCommitTypeHandle *l3cfg_commit_type_1; guint acd_timeout_msec; - NML3IPv4LL * l3ipv4ll; + NML3IPv4LL *l3ipv4ll; bool has_addr4_101; gint8 ready_seen; gint8 addr_commit; @@ -541,8 +541,8 @@ static void _test_l3_ipv4ll_maybe_add_addr_4(const TestL3IPv4LLData *tdata, int ifindex, guint one_case_in_num, - bool * has_addr, - const char * addr) + bool *has_addr, + const char *addr) { if (has_addr) { if (*has_addr || !nmtst_get_rand_one_case_in(one_case_in_num)) @@ -570,9 +570,9 @@ _test_l3_ipv4ll_maybe_add_addr_4(const TestL3IPv4LLData *tdata, } static void -_test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg, +_test_l3_ipv4ll_signal_notify(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, - TestL3IPv4LLData * tdata) + TestL3IPv4LLData *tdata) { char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -653,17 +653,17 @@ test_l3_ipv4ll(gconstpointer test_data) { const int TEST_IDX = GPOINTER_TO_INT(test_data); nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; - const TestFixture1 * f; - gs_unref_object NML3Cfg *l3cfg0 = NULL; - TestL3IPv4LLData tdata_stack = { - .f = NULL, + const TestFixture1 *f; + gs_unref_object NML3Cfg *l3cfg0 = NULL; + TestL3IPv4LLData tdata_stack = { + .f = NULL, }; - TestL3IPv4LLData *const tdata = &tdata_stack; - NMTstpAcdDefender * acd_defender_1 = NULL; - NMTstpAcdDefender * acd_defender_2 = NULL; - nm_auto_unref_l3ipv4ll NML3IPv4LL * l3ipv4ll = NULL; - gint64 start_time_msec; - gint64 total_poll_time_msec; + TestL3IPv4LLData *const tdata = &tdata_stack; + NMTstpAcdDefender *acd_defender_1 = NULL; + NMTstpAcdDefender *acd_defender_2 = NULL; + nm_auto_unref_l3ipv4ll NML3IPv4LL *l3ipv4ll = NULL; + gint64 start_time_msec; + gint64 total_poll_time_msec; nm_auto_remove_l3ipv4ll_registration NML3IPv4LLRegistration *l3ipv4ll_reg = NULL; char sbuf_addr[NM_UTILS_INET_ADDRSTRLEN]; @@ -805,12 +805,12 @@ test_l3_ipv4ll(gconstpointer test_data) typedef struct { const TestFixture1 *f; - NML3Cfg * l3cfg0; - NML3IPv6LL * l3ipv6ll; + NML3Cfg *l3cfg0; + NML3IPv6LL *l3ipv6ll; int step; int ipv6ll_callback_step; bool steps_done : 1; - const NMPObject * lladdr0; + const NMPObject *lladdr0; } TestL3IPv6LLData; static const NMPlatformIP6Address * @@ -818,7 +818,7 @@ _test_l3_ipv6ll_find_lladdr(TestL3IPv6LLData *tdata, int ifindex) { const NMPlatformIP6Address *found = NULL; NMDedupMultiIter iter; - const NMPObject * obj; + const NMPObject *obj; NMPLookup lookup; g_assert(tdata); @@ -880,21 +880,21 @@ _test_l3_ipv6ll_find_inet6(TestL3IPv6LLData *tdata, const struct in6_addr *addr) } static void -_test_l3_ipv6ll_signal_notify(NML3Cfg * l3cfg, +_test_l3_ipv6ll_signal_notify(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, - TestL3IPv6LLData * tdata) + TestL3IPv6LLData *tdata) { g_assert_cmpint(tdata->step, >=, 1); g_assert_cmpint(tdata->step, <=, 2); } static void -_test_l3_ipv6ll_callback_changed(NML3IPv6LL * ipv6ll, +_test_l3_ipv6ll_callback_changed(NML3IPv6LL *ipv6ll, NML3IPv6LLState state, const struct in6_addr *lladdr, gpointer user_data) { - TestL3IPv6LLData * tdata = user_data; + TestL3IPv6LLData *tdata = user_data; int step = tdata->ipv6ll_callback_step++; const NMPlatformIP6Address *a1; @@ -950,10 +950,10 @@ test_l3_ipv6ll(gconstpointer test_data) NMTST_UTILS_HOST_ID_CONTEXT("l3-ipv6ll"); const int TEST_IDX = GPOINTER_TO_INT(test_data); nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; - gs_unref_object NML3Cfg *l3cfg0 = NULL; - TestL3IPv6LLData tdata_stack = { - .step = 0, - .steps_done = FALSE, + gs_unref_object NML3Cfg *l3cfg0 = NULL; + TestL3IPv6LLData tdata_stack = { + .step = 0, + .steps_done = FALSE, }; TestL3IPv6LLData *const tdata = &tdata_stack; char sbuf1[sizeof(_nm_utils_to_string_buffer)]; @@ -1025,6 +1025,7 @@ test_l3_ipv6ll(gconstpointer test_data) NM_UTILS_STABLE_TYPE_UUID, tdata->f->ifname0, "b6a5b934-c649-43dc-a524-3dfdb74f9419", + 0, _test_l3_ipv6ll_callback_changed, tdata); diff --git a/src/core/tests/test-systemd.c b/src/core/tests/test-systemd.c index be070248..71a6a60d 100644 --- a/src/core/tests/test-systemd.c +++ b/src/core/tests/test-systemd.c @@ -49,7 +49,7 @@ test_lldp_create(void) /*****************************************************************************/ typedef struct { - GMainLoop * mainloop; + GMainLoop *mainloop; sd_event_source *event_source; } TestSdEventData; @@ -76,7 +76,7 @@ test_sd_event(void) guint sd_id = 0; int r; int i, n; - sd_event * other_events[3] = {NULL}, *event = NULL; + sd_event *other_events[3] = {NULL}, *event = NULL; TestSdEventData user_data = {0}; g_assert_cmpint(sd_event_default(NULL), ==, 0); @@ -125,10 +125,10 @@ test_path_equal(void) #define _path_equal_check(path, expected) \ G_STMT_START \ { \ - const char * _path0 = (path); \ - const char * _expected = (expected); \ + const char *_path0 = (path); \ + const char *_expected = (expected); \ gs_free char *_path = g_strdup(_path0); \ - const char * _path_result; \ + const char *_path_result; \ \ _path_result = nm_sd_utils_path_simplify(_path); \ g_assert(_path_result == _path); \ @@ -177,8 +177,8 @@ _test_unbase64char(char ch, gboolean maybe_invalid) static void _test_unbase64mem_mem(const char *base64, const guint8 *expected_arr, gsize expected_len) { - gs_free char *expected_base64 = NULL; - int r; + gs_free char *expected_base64 = NULL; + int r; nm_auto_free guint8 *exp2_arr = NULL; nm_auto_free guint8 *exp3_arr = NULL; gsize exp2_len; diff --git a/src/core/tests/test-utils.c b/src/core/tests/test-utils.c index 59d5fd53..2d2b7340 100644 --- a/src/core/tests/test-utils.c +++ b/src/core/tests/test-utils.c @@ -72,15 +72,15 @@ test_stable_privacy(void) static void _do_test_hw_addr(NMUtilsStableType stable_type, - const char * stable_id, - const guint8 * secret_key, + const char *stable_id, + const guint8 *secret_key, gsize key_len, - const char * ifname, - const char * current_mac_address, - const char * generate_mac_address_mask, + const char *ifname, + const char *current_mac_address, + const char *generate_mac_address_mask, const char *const *expected) { - gs_free char * generated = NULL; + gs_free char *generated = NULL; const char *const *e; gboolean found = FALSE; diff --git a/src/core/tests/test-wired-defname.c b/src/core/tests/test-wired-defname.c index f810c56f..9f7aae16 100644 --- a/src/core/tests/test-wired-defname.c +++ b/src/core/tests/test-wired-defname.c @@ -15,7 +15,7 @@ static NMConnection * _new_connection(const char *id) { NMConnection *a; - NMSetting * setting; + NMSetting *setting; a = nm_simple_connection_new(); setting = nm_setting_connection_new(); @@ -55,7 +55,7 @@ test_defname_no_connections(void) static void test_defname_no_conflict(void) { - GSList * list = NULL; + GSList *list = NULL; gs_free char *name = NULL; list = g_slist_append(list, _new_connection("asdfasdfasdfadf")); @@ -73,7 +73,7 @@ test_defname_no_conflict(void) static void test_defname_conflict(void) { - GSList * list = NULL; + GSList *list = NULL; gs_free char *name = NULL; list = g_slist_append(list, _new_connection("asdfasdfasdfadf")); @@ -91,7 +91,7 @@ test_defname_conflict(void) static void test_defname_multiple_conflicts(void) { - GSList * list = NULL; + GSList *list = NULL; gs_free char *name = NULL; list = g_slist_append(list, _new_connection("random gsm connection")); |