mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
libnm-util: flag properties with G_PARAM_CONSTRUCT so default values get set
This caused the 'autoconnect' property of NMSettingConnection to not get updated in some cases (as when a system setting plugin noticed a change to autoconnect=true and emitted the Updated signal, which wouldn't contain the new value). Add a testcase for setting default values too.
This commit is contained in:
parent
8a2393ade2
commit
b61b199776
|
@ -507,6 +507,7 @@ src/dnsmasq-manager/Makefile
|
|||
src/backends/Makefile
|
||||
libnm-util/libnm-util.pc
|
||||
libnm-util/Makefile
|
||||
libnm-util/tests/Makefile
|
||||
libnm-glib/libnm_glib.pc
|
||||
libnm-glib/libnm_glib_vpn.pc
|
||||
libnm-glib/Makefile
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
SUBDIRS=. tests
|
||||
|
||||
INCLUDES = -I${top_srcdir} -I${top_srcdir}/include
|
||||
|
||||
lib_LTLIBRARIES=libnm-util.la
|
||||
|
|
|
@ -1512,7 +1512,7 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
"Use system CA certificates",
|
||||
"Use system CA certificates",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
/* Initialize crypto lbrary. */
|
||||
if (!nm_utils_init (&error)) {
|
||||
|
|
|
@ -439,7 +439,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Autoconnect",
|
||||
"Connection autoconnect",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
/**
|
||||
* NMSettingConnection:timestamp:
|
||||
|
@ -453,7 +453,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Timestamp",
|
||||
"Connection timestamp",
|
||||
0, G_MAXUINT64, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
/**
|
||||
* NMSettingConnection:read-only:
|
||||
|
@ -468,5 +468,5 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
"Read-Only",
|
||||
"Read-Only",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
|
|
@ -455,7 +455,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
|||
NM_GSM_NETWORK_ANY,
|
||||
NM_GSM_NETWORK_PREFER_UMTS_HSPA,
|
||||
NM_GSM_NETWORK_ANY,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BAND,
|
||||
|
@ -463,7 +463,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
|||
"Band",
|
||||
"Band",
|
||||
-1, 5, -1, /* FIXME: Use an enum for it */
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PIN,
|
||||
|
|
|
@ -735,7 +735,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
"Ignore automatic routes",
|
||||
"Ignore automatic routes",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IGNORE_AUTO_DNS,
|
||||
|
@ -743,7 +743,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
"Ignore automatic DNS",
|
||||
"Ignore automatic DNS",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP_CLIENT_ID,
|
||||
|
@ -767,7 +767,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
"Never default",
|
||||
"Never make this connection the default IPv4 connection",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -654,7 +654,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
"Ignore DHCPv6 DNS",
|
||||
"Ignore DHCPv6 DNS",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IGNORE_ROUTER_ADV,
|
||||
|
@ -662,7 +662,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
"Ignore Router Advertisements",
|
||||
"Ignore Router Advertisements",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP_MODE,
|
||||
|
|
|
@ -427,7 +427,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"NoAuth",
|
||||
"NoAuth",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_EAP,
|
||||
|
@ -435,7 +435,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse EAP",
|
||||
"Refuse EAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_PAP,
|
||||
|
@ -443,7 +443,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse PAP",
|
||||
"Refuse PAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_CHAP,
|
||||
|
@ -451,7 +451,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse CHAP",
|
||||
"Refuse CHAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_MSCHAP,
|
||||
|
@ -459,7 +459,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse MSCHAP",
|
||||
"Refuse MSCHAP",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REFUSE_MSCHAPV2,
|
||||
|
@ -467,7 +467,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Refuse MSCHAPv2",
|
||||
"Refuse MSCHAPv2",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NOBSDCOMP,
|
||||
|
@ -475,7 +475,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No BSD compression",
|
||||
"No BSD compression",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NODEFLATE,
|
||||
|
@ -483,7 +483,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No deflate",
|
||||
"No deflate",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_NO_VJ_COMP,
|
||||
|
@ -491,7 +491,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"No VJ compression",
|
||||
"No VJ compression",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REQUIRE_MPPE,
|
||||
|
@ -499,7 +499,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Require MPPE",
|
||||
"Require MPPE",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_REQUIRE_MPPE_128,
|
||||
|
@ -507,7 +507,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Require MPPE 128",
|
||||
"Require MPPE 128",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT| NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MPPE_STATEFUL,
|
||||
|
@ -515,7 +515,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MPPE stateful",
|
||||
"MPPE stateful",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CRTSCTS,
|
||||
|
@ -523,7 +523,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"CRTSCTS",
|
||||
"CRTSCTS",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BAUD,
|
||||
|
@ -531,7 +531,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"Baud",
|
||||
"Baud",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MRU,
|
||||
|
@ -539,7 +539,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MRU",
|
||||
"MRU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MTU,
|
||||
|
@ -547,7 +547,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LCP_ECHO_FAILURE,
|
||||
|
@ -555,7 +555,7 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"LCP echo failure",
|
||||
"LCP echo failure",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LCP_ECHO_INTERVAL,
|
||||
|
@ -563,5 +563,5 @@ nm_setting_ppp_class_init (NMSettingPPPClass *setting_class)
|
|||
"LCP echo interval",
|
||||
"LCP echo interval",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"Speed",
|
||||
"Speed",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DUPLEX,
|
||||
|
@ -308,7 +308,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"AutoNegotiate",
|
||||
"Auto negotiate",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
|
@ -324,6 +324,6 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
}
|
||||
|
||||
|
|
|
@ -916,7 +916,7 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
|
|||
"WEP TX key index",
|
||||
"WEP TX key index",
|
||||
0, 3, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_AUTH_ALG,
|
||||
|
|
|
@ -726,7 +726,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"Channel",
|
||||
"Channel",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BSSID,
|
||||
|
@ -742,7 +742,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"Rate",
|
||||
"Rate",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TX_POWER,
|
||||
|
@ -750,7 +750,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"TX Power",
|
||||
"TX Power",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
|
@ -774,7 +774,7 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
"MTU",
|
||||
"MTU",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SEC,
|
||||
|
|
25
libnm-util/tests/Makefile.am
Normal file
25
libnm-util/tests/Makefile.am
Normal file
|
@ -0,0 +1,25 @@
|
|||
INCLUDES = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/libnm-util
|
||||
|
||||
noinst_PROGRAMS = test-settings-defaults
|
||||
|
||||
test_settings_defaults_SOURCES = \
|
||||
test-settings-defaults.c
|
||||
|
||||
test_settings_defaults_CPPFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(DBUS_CFLAGS)
|
||||
|
||||
test_settings_defaults_LDADD = \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(DBUS_LIBS) \
|
||||
$(top_builddir)/libnm-util/libnm-util.la
|
||||
|
||||
if WITH_TESTS
|
||||
|
||||
check-local: test-settings-defaults
|
||||
$(abs_builddir)/test-settings-defaults
|
||||
|
||||
endif
|
||||
|
135
libnm-util/tests/test-settings-defaults.c
Normal file
135
libnm-util/tests/test-settings-defaults.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2008 Red Hat, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-test-helpers.h"
|
||||
#include <nm-utils.h>
|
||||
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-setting-cdma.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-gsm.h"
|
||||
#include "nm-setting-ip4-config.h"
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "nm-setting-ppp.h"
|
||||
#include "nm-setting-pppoe.h"
|
||||
#include "nm-setting-serial.h"
|
||||
#include "nm-setting-vpn.h"
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
|
||||
|
||||
static void
|
||||
test_defaults (GType type, const char *name)
|
||||
{
|
||||
GParamSpec **property_specs;
|
||||
guint n_property_specs;
|
||||
GObject *setting;
|
||||
int i;
|
||||
|
||||
setting = g_object_new (type, NULL);
|
||||
|
||||
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
|
||||
ASSERT (property_specs != NULL,
|
||||
name, "couldn't find property specs for object of type '%s'",
|
||||
g_type_name (G_OBJECT_TYPE (setting)));
|
||||
|
||||
for (i = 0; i < n_property_specs; i++) {
|
||||
GParamSpec *prop_spec = property_specs[i];
|
||||
GValue value = { 0, };
|
||||
GValue defvalue = { 0, };
|
||||
char *actual, *expected;
|
||||
gboolean ok = FALSE;
|
||||
|
||||
/* Ignore non-fundamental types since they won't really have
|
||||
* defaults.
|
||||
*/
|
||||
if (!G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
|
||||
continue;
|
||||
|
||||
g_value_init (&value, prop_spec->value_type);
|
||||
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
|
||||
|
||||
g_value_init (&defvalue, prop_spec->value_type);
|
||||
g_param_value_set_default (prop_spec, &defvalue);
|
||||
|
||||
actual = g_strdup_value_contents (&value);
|
||||
expected = g_strdup_value_contents (&defvalue);
|
||||
|
||||
if (!strcmp (prop_spec->name, NM_SETTING_NAME)) {
|
||||
/* 'name' is always the setting name, not the default value */
|
||||
ok = !strcmp (nm_setting_get_name (NM_SETTING (setting)), name);
|
||||
g_free (expected);
|
||||
expected = g_strdup (name);
|
||||
} else
|
||||
ok = g_param_value_defaults (prop_spec, &value);
|
||||
|
||||
ASSERT (ok,
|
||||
name, "property '%s' value '%s' not the expected default value '%s'",
|
||||
prop_spec->name, actual, expected);
|
||||
|
||||
g_free (actual);
|
||||
g_free (expected);
|
||||
g_value_unset (&value);
|
||||
g_value_unset (&defvalue);
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
g_object_unref (setting);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
DBusGConnection *bus;
|
||||
char *basename;
|
||||
|
||||
g_type_init ();
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
if (!nm_utils_init (&error))
|
||||
FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message);
|
||||
|
||||
/* The tests */
|
||||
test_defaults (NM_TYPE_SETTING_CONNECTION, NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_802_1X, NM_SETTING_802_1X_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_CDMA, NM_SETTING_CDMA_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_GSM, NM_SETTING_GSM_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_IP4_CONFIG, NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
// test_defaults (NM_TYPE_SETTING_IP6_CONFIG, NM_SETTING_IP6_CONFIG_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_PPP, NM_SETTING_PPP_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_PPPOE, NM_SETTING_PPPOE_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_SERIAL, NM_SETTING_SERIAL_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_VPN, NM_SETTING_VPN_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_WIRED, NM_SETTING_WIRED_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_WIRELESS, NM_SETTING_WIRELESS_SETTING_NAME);
|
||||
test_defaults (NM_TYPE_SETTING_WIRELESS_SECURITY, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
|
||||
|
||||
basename = g_path_get_basename (argv[0]);
|
||||
fprintf (stdout, "%s: SUCCESS\n", basename);
|
||||
g_free (basename);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue