libnm/tests: always check expected default value for string properties in test_setting_metadata()

This commit is contained in:
Thomas Haller 2021-10-24 21:30:32 +02:00
parent 572ce7b7a7
commit d805b9ae51
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -4647,19 +4647,19 @@ check_done:;
g_object_get_property(G_OBJECT(setting), sip->name, &val); g_object_get_property(G_OBJECT(setting), sip->name, &val);
if (sip->param_spec->value_type == G_TYPE_STRING) { if (sip->param_spec->value_type == G_TYPE_STRING) {
const char *exp_default_value = NULL;
const char *default_value; const char *default_value;
default_value = ((const GParamSpecString *) sip->param_spec)->default_value; default_value = ((const GParamSpecString *) sip->param_spec)->default_value;
if (default_value) {
/* having a string property with a default != NULL is really ugly. They /* having a string property with a default != NULL is really ugly. They
* should be best avoided... */ * should be best avoided... Only one property is known to have a non-NULL
if (meta_type == NM_META_SETTING_TYPE_DCB * default. Assert that this stays. */
&& nm_streq(sip->name, NM_SETTING_DCB_APP_FCOE_MODE)) { if (meta_type == NM_META_SETTING_TYPE_DCB
/* Whitelist the properties that have a non-NULL default value. */ && nm_streq(sip->name, NM_SETTING_DCB_APP_FCOE_MODE)) {
g_assert_cmpstr(default_value, ==, NM_SETTING_DCB_FCOE_MODE_FABRIC); exp_default_value = NM_SETTING_DCB_FCOE_MODE_FABRIC;
} else
g_assert_not_reached();
} }
g_assert_cmpstr(default_value, ==, exp_default_value);
if (nm_streq(sip->name, NM_SETTING_NAME)) if (nm_streq(sip->name, NM_SETTING_NAME))
g_assert_cmpstr(g_value_get_string(&val), ==, msi->setting_name); g_assert_cmpstr(g_value_get_string(&val), ==, msi->setting_name);