diff options
| author | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
| commit | 33491bc4279481db8ae47213e34a6d695a0e8830 (patch) | |
| tree | 097d2b0fdff3fae6885381ae5e57a182cd8cbbba /src/settings/plugins/keyfile/tests | |
| parent | 59c3714a494c3b3765657c0551ad82842d98a7d2 (diff) | |
Imported Upstream version 0.9.10.0 upstream/0.9.10.0
Diffstat (limited to 'src/settings/plugins/keyfile/tests')
10 files changed, 775 insertions, 138 deletions
diff --git a/src/settings/plugins/keyfile/tests/Makefile.am b/src/settings/plugins/keyfile/tests/Makefile.am index c2f5fe3d..fae6e4ea 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.am +++ b/src/settings/plugins/keyfile/tests/Makefile.am @@ -2,7 +2,7 @@ if ENABLE_TESTS SUBDIRS=keyfiles -noinst_PROGRAMS = test-keyfile +@GNOME_CODE_COVERAGE_RULES@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ @@ -10,22 +10,36 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/libnm-util \ -I$(top_builddir)/libnm-util \ -I$(top_srcdir)/libnm-glib \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/logging \ + -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ + $(POLKIT_CFLAGS) \ + $(CODE_COVERAGE_CFLAGS) \ + -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ + -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ - -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" + -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ + -DNMCONFDIR=\"nonexistent\" + +noinst_PROGRAMS = test-keyfile test_keyfile_SOURCES = \ - test-keyfile.c + test-keyfile.c \ + ../reader.c \ + ../writer.c \ + ../errors.c \ + ../utils.c test_keyfile_LDADD = \ - $(builddir)/../libkeyfile-io.la \ + $(top_builddir)/src/libNetworkManager.la \ $(top_builddir)/libnm-glib/libnm-glib.la \ $(top_builddir)/libnm-util/libnm-util.la \ - $(DBUS_LIBS) + $(DBUS_LIBS) \ + $(CODE_COVERAGE_LDFLAGS) -check-local: test-keyfile - $(abs_builddir)/test-keyfile +TESTS = test-keyfile endif diff --git a/src/settings/plugins/keyfile/tests/Makefile.in b/src/settings/plugins/keyfile/tests/Makefile.in index 675a9fcf..f7b4b62a 100644 --- a/src/settings/plugins/keyfile/tests/Makefile.in +++ b/src/settings/plugins/keyfile/tests/Makefile.in @@ -79,11 +79,13 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ENABLE_TESTS_TRUE@noinst_PROGRAMS = test-keyfile$(EXEEXT) +@ENABLE_TESTS_TRUE@TESTS = test-keyfile$(EXEEXT) subdir = src/settings/plugins/keyfile/tests DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -102,15 +104,18 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) -am__test_keyfile_SOURCES_DIST = test-keyfile.c -@ENABLE_TESTS_TRUE@am_test_keyfile_OBJECTS = test-keyfile.$(OBJEXT) +am__test_keyfile_SOURCES_DIST = test-keyfile.c ../reader.c ../writer.c \ + ../errors.c ../utils.c +@ENABLE_TESTS_TRUE@am_test_keyfile_OBJECTS = test-keyfile.$(OBJEXT) \ +@ENABLE_TESTS_TRUE@ reader.$(OBJEXT) writer.$(OBJEXT) \ +@ENABLE_TESTS_TRUE@ errors.$(OBJEXT) utils.$(OBJEXT) test_keyfile_OBJECTS = $(am_test_keyfile_OBJECTS) am__DEPENDENCIES_1 = @ENABLE_TESTS_TRUE@test_keyfile_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(builddir)/../libkeyfile-io.la \ +@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-glib/libnm-glib.la \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ -@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) +@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent @@ -191,6 +196,28 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} DIST_SUBDIRS = keyfiles DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ @@ -243,12 +270,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -273,7 +303,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -318,12 +347,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -340,6 +373,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -367,11 +402,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -386,6 +426,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -448,6 +489,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -458,6 +500,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@SUBDIRS = keyfiles @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ @@ -465,20 +508,33 @@ with_resolvconf = @with_resolvconf@ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-util \ @ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-util \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-glib \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/logging \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ @ENABLE_TESTS_TRUE@ $(DBUS_CFLAGS) \ +@ENABLE_TESTS_TRUE@ $(POLKIT_CFLAGS) \ +@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_CFLAGS) \ +@ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-keyfile"\" \ +@ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ -DTEST_KEYFILES_DIR=\"$(abs_srcdir)/keyfiles\" \ -@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" +@ENABLE_TESTS_TRUE@ -DTEST_SCRATCH_DIR=\"$(abs_builddir)/keyfiles\" \ +@ENABLE_TESTS_TRUE@ -DNMCONFDIR=\"nonexistent\" @ENABLE_TESTS_TRUE@test_keyfile_SOURCES = \ -@ENABLE_TESTS_TRUE@ test-keyfile.c +@ENABLE_TESTS_TRUE@ test-keyfile.c \ +@ENABLE_TESTS_TRUE@ ../reader.c \ +@ENABLE_TESTS_TRUE@ ../writer.c \ +@ENABLE_TESTS_TRUE@ ../errors.c \ +@ENABLE_TESTS_TRUE@ ../utils.c @ENABLE_TESTS_TRUE@test_keyfile_LDADD = \ -@ENABLE_TESTS_TRUE@ $(builddir)/../libkeyfile-io.la \ +@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-glib/libnm-glib.la \ @ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) +@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) \ +@ENABLE_TESTS_TRUE@ $(CODE_COVERAGE_LDFLAGS) all: all-recursive @@ -534,7 +590,11 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-keyfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writer.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -557,6 +617,62 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< +reader.o: ../reader.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.o -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.o `test -f '../reader.c' || echo '$(srcdir)/'`../reader.c + +reader.obj: ../reader.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT reader.obj -MD -MP -MF $(DEPDIR)/reader.Tpo -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/reader.Tpo $(DEPDIR)/reader.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../reader.c' object='reader.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reader.obj `if test -f '../reader.c'; then $(CYGPATH_W) '../reader.c'; else $(CYGPATH_W) '$(srcdir)/../reader.c'; fi` + +writer.o: ../writer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.o -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.o `test -f '../writer.c' || echo '$(srcdir)/'`../writer.c + +writer.obj: ../writer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT writer.obj -MD -MP -MF $(DEPDIR)/writer.Tpo -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/writer.Tpo $(DEPDIR)/writer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../writer.c' object='writer.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o writer.obj `if test -f '../writer.c'; then $(CYGPATH_W) '../writer.c'; else $(CYGPATH_W) '$(srcdir)/../writer.c'; fi` + +errors.o: ../errors.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errors.o -MD -MP -MF $(DEPDIR)/errors.Tpo -c -o errors.o `test -f '../errors.c' || echo '$(srcdir)/'`../errors.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/errors.Tpo $(DEPDIR)/errors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../errors.c' object='errors.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errors.o `test -f '../errors.c' || echo '$(srcdir)/'`../errors.c + +errors.obj: ../errors.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT errors.obj -MD -MP -MF $(DEPDIR)/errors.Tpo -c -o errors.obj `if test -f '../errors.c'; then $(CYGPATH_W) '../errors.c'; else $(CYGPATH_W) '$(srcdir)/../errors.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/errors.Tpo $(DEPDIR)/errors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../errors.c' object='errors.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o errors.obj `if test -f '../errors.c'; then $(CYGPATH_W) '../errors.c'; else $(CYGPATH_W) '$(srcdir)/../errors.c'; fi` + +utils.o: ../utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.o -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.o `test -f '../utils.c' || echo '$(srcdir)/'`../utils.c + +utils.obj: ../utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utils.obj -MD -MP -MF $(DEPDIR)/utils.Tpo -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utils.Tpo $(DEPDIR)/utils.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../utils.c' object='utils.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utils.obj `if test -f '../utils.c'; then $(CYGPATH_W) '../utils.c'; else $(CYGPATH_W) '$(srcdir)/../utils.c'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -662,6 +778,99 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -717,9 +926,8 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done -@ENABLE_TESTS_FALSE@check-local: check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-local + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive all-am: Makefile $(PROGRAMS) installdirs: installdirs-recursive @@ -828,7 +1036,7 @@ uninstall-am: .MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am check-local clean clean-generic clean-libtool \ + check-TESTS check-am clean clean-generic clean-libtool \ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ @@ -843,8 +1051,7 @@ uninstall-am: uninstall-am -@ENABLE_TESTS_TRUE@check-local: test-keyfile -@ENABLE_TESTS_TRUE@ $(abs_builddir)/test-keyfile +@ENABLE_TESTS_TRUE@@GNOME_CODE_COVERAGE_RULES@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am index bbad8e30..576164d2 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.am @@ -3,6 +3,8 @@ KEYFILES = \ Test_GSM_Connection \ Test_Wireless_Connection \ Test_Wired_Connection_MAC_Case \ + Test_MAC_Old_Format \ + Test_MAC_IB_Old_Format \ Test_Wired_Connection_IP6 \ ATT_Data_Connect_BT \ ATT_Data_Connect_Plain \ @@ -17,6 +19,8 @@ KEYFILES = \ Test_InfiniBand_Connection \ Test_Bridge_Main \ Test_Bridge_Component \ + Test_New_Wired_Group_Name \ + Test_New_Wireless_Group_Names \ Test_Missing_Vlan_Setting CERTS = \ diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in index 450269b4..05660e3e 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in +++ b/src/settings/plugins/keyfile/tests/keyfiles/Makefile.in @@ -80,7 +80,8 @@ host_triplet = @host@ subdir = src/settings/plugins/keyfile/tests/keyfiles DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -144,12 +145,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -174,7 +178,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -219,12 +222,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -241,6 +248,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -268,11 +277,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -287,6 +301,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -349,6 +364,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -359,11 +375,14 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ KEYFILES = \ Test_Wired_Connection \ Test_GSM_Connection \ Test_Wireless_Connection \ Test_Wired_Connection_MAC_Case \ + Test_MAC_Old_Format \ + Test_MAC_IB_Old_Format \ Test_Wired_Connection_IP6 \ ATT_Data_Connect_BT \ ATT_Data_Connect_Plain \ @@ -378,6 +397,8 @@ KEYFILES = \ Test_InfiniBand_Connection \ Test_Bridge_Main \ Test_Bridge_Component \ + Test_New_Wired_Group_Name \ + Test_New_Wireless_Group_Names \ Test_Missing_Vlan_Setting CERTS = \ diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_MAC_IB_Old_Format b/src/settings/plugins/keyfile/tests/keyfiles/Test_MAC_IB_Old_Format new file mode 100644 index 00000000..b2bf9155 --- /dev/null +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_MAC_IB_Old_Format @@ -0,0 +1,13 @@ +[connection] +id=Test InfiniBand Connection +uuid=5680a56d-c99f-45ad-a6dd-b44d5c398c12 +type=infiniband + +[infiniband] +mac-address=0;17;34;51;68;85;102;119;136;153;1;18;35;52;69;86;103;120;137;144; +transport-mode=datagram +mtu=1400 + +[ipv4] +method=auto + diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_MAC_Old_Format b/src/settings/plugins/keyfile/tests/keyfiles/Test_MAC_Old_Format new file mode 100644 index 00000000..9427b16c --- /dev/null +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_MAC_Old_Format @@ -0,0 +1,10 @@ +[connection] +id=Test MAC Old Format +uuid=8980a26d-c99f-4aad-a6bd-b439bc348ca4 +type=802-3-ethernet + +[802-3-ethernet] +mac-address=00:11:aa:BB:CC:55 +cloned-mac-address=00;22;170;187;204;254; +mtu=1400 + diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_New_Wired_Group_Name b/src/settings/plugins/keyfile/tests/keyfiles/Test_New_Wired_Group_Name new file mode 100644 index 00000000..f27cd4a3 --- /dev/null +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_New_Wired_Group_Name @@ -0,0 +1,13 @@ + +[connection] +id=Test Wired Connection +uuid=4e80a56d-c99f-4aad-a6dd-b449bc398c57 +type=ethernet + +[ethernet] +mac-address=00:11:22:33:44:55 +mtu=1400 + +[ipv4] +method=auto + diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_New_Wireless_Group_Names b/src/settings/plugins/keyfile/tests/keyfiles/Test_New_Wireless_Group_Names new file mode 100644 index 00000000..d9ac5864 --- /dev/null +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_New_Wireless_Group_Names @@ -0,0 +1,16 @@ +[connection] +id=Test New Wireless Group Names +uuid=2f962388-e5f3-45af-a62c-ac220b8f7baa +type=wifi + +[wifi] +ssid=foobar +mode=infrastructure + +[wifi-security] +key-mgmt=wpa-psk +psk=s3cu4e passphrase + +[ipv4] +method=auto + diff --git a/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection b/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection index 203441ef..de8373be 100644 --- a/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection +++ b/src/settings/plugins/keyfile/tests/keyfiles/Test_Wired_Connection @@ -20,8 +20,20 @@ addresses1=192.168.0.5;24;192.168.0.1; addresses2=1.2.3.4;16;1.2.1.1; address=2.3.4.5/24,2.3.4.6 address3=3.4.5.6/16 +address4=4.5.6.7/1.2.3.4 +address5=5.6.7.8 routes1=1.2.3.0/24,2.3.4.8,99 route=5.6.7.8/32 +routes2=1.1.1.2/12, +routes3=1.1.1.3/13,, +routes4=1.1.1.4/14,2.2.2.4 +routes5=1.1.1.5/15,2.2.2.5, +routes6=1.1.1.6/16,2.2.2.6,0 +routes7=1.1.1.7/17,0.0.0.0 +routes8=1.1.1.8/18,0.0.0.0, +routes9=1.1.1.9/19,0.0.0.0,0 +routes10=1.1.1.10/20,,0 +routes11=1.1.1.11/21,,21 ignore-auto-routes=false ignore-auto-dns=false @@ -33,8 +45,18 @@ addresses1=abcd:1234:ffff::cdde/64 addresses2=1:2:3:4:5:6:7:8/96 address=2:3:4:5:6:7:8:9/64,2:3:4:5:1:2:3:4 address3=3:4:5:6:7:8:9:0/128 +address4=3:4:5:6:7:8:9:14 +address5=3:4:5:6:7:8:9:15, +address6=3:4:5:6:7:8:9:16,66 +address7=3:4:5:6:7:8:9:17,67, +address8=3:4:5:6:7:8:9:18,68,:: +address9=3:4:5:6:7:8:9:19,69,1::09 routes1=a:b:c:d::/64;f:e:d:c:1:2:3:4;99; route=d:e:f:0:1:2:3:4/64,f:e:d:c:1:2:3:4 route2=8:7:6:5:4:3:2:1/128 +route3=6:7:8:9:0:1:2:3/126,,1 +route4=7:8:9:0:1:2:3:4/125/::,5 +route5=8:9:0:1:2:3:4:5/124,6 +route6=8:9:0:1:2:3:4:6/123,, ignore-auto-routes=false ignore-auto-dns=false diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 2f89c5f1..cc57c1c3 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -15,7 +15,7 @@ * 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 - 2011 Red Hat, Inc. + * Copyright (C) 2008 - 2014 Red Hat, Inc. */ #include <stdio.h> @@ -40,12 +40,13 @@ #include <nm-setting-gsm.h> #include <nm-setting-8021x.h> #include <nm-setting-infiniband.h> - -#include "nm-test-helpers.h" +#include <nm-logging.h> #include "reader.h" #include "writer.h" +#include "nm-test-utils.h" + #define TEST_WIRED_FILE TEST_KEYFILES_DIR"/Test_Wired_Connection" #define TEST_WIRELESS_FILE TEST_KEYFILES_DIR"/Test_Wireless_Connection" @@ -53,16 +54,15 @@ static void check_ip4_address (NMSettingIP4Config *config, int idx, const char *address_str, int plen, const char *gateway_str) { NMIP4Address *ip4 = nm_setting_ip4_config_get_address (config, idx); - struct in_addr address; - struct in_addr gateway; + guint32 address, gateway; g_assert (inet_pton (AF_INET, address_str, &address) == 1); g_assert (inet_pton (AF_INET, gateway_str, &gateway) == 1); g_assert (ip4); - g_assert (nm_ip4_address_get_address (ip4) == address.s_addr); + g_assert (nm_ip4_address_get_address (ip4) == address); g_assert (nm_ip4_address_get_prefix (ip4) == plen); - g_assert (nm_ip4_address_get_gateway (ip4) == gateway.s_addr); + g_assert (nm_ip4_address_get_gateway (ip4) == gateway); } static void @@ -86,16 +86,15 @@ check_ip4_route (NMSettingIP4Config *config, int idx, const char *destination_st const char *nexthop_str, int metric) { NMIP4Route *route = nm_setting_ip4_config_get_route (config, idx); - struct in_addr destination; - struct in_addr nexthop; + guint32 destination, nexthop; g_assert (inet_pton (AF_INET, destination_str, &destination) == 1); g_assert (inet_pton (AF_INET, nexthop_str, &nexthop) == 1); g_assert (route); - g_assert (nm_ip4_route_get_dest (route) == destination.s_addr); + g_assert (nm_ip4_route_get_dest (route) == destination); g_assert (nm_ip4_route_get_prefix (route) == plen); - g_assert (nm_ip4_route_get_next_hop (route) == nexthop.s_addr); + g_assert (nm_ip4_route_get_next_hop (route) == nexthop); g_assert (nm_ip4_route_get_metric (route) == metric); } @@ -135,7 +134,7 @@ test_read_valid_wired_connection (void) guint64 timestamp; const char *expected_dns1 = "4.2.2.1"; const char *expected_dns2 = "4.2.2.2"; - struct in_addr addr; + guint32 addr; struct in6_addr addr6; const char *expected6_dns1 = "1111:dddd::aaaa"; const char *expected6_dns2 = "1::cafe"; @@ -143,7 +142,36 @@ test_read_valid_wired_connection (void) const char *expected6_dnssearch2 = "redhat.com"; const char *expected6_dnssearch3 = "gnu.org"; + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.addresses1*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.addresses2*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*Missing prefix length*ipv4.address4*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*Missing prefix length*ipv4.address5*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.routes2*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.routes3*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.routes5*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.routes8*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*Missing prefix length*ipv6.address4*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv6.address5*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*Missing prefix length*ipv6.address5*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv6.address7*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv6.routes1*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv6.route6*semicolon at the end*"); connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_FILE, NULL); + g_test_assert_expected_messages (); ASSERT (connection != NULL, "connection-read", "failed to read %s", TEST_WIRED_FILE); @@ -259,7 +287,7 @@ test_read_valid_wired_connection (void) TEST_WIRED_FILE, NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr.s_addr, + ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr, "connection-verify-wired", "failed to verify %s: unexpected %s / %s key value #1", TEST_WIRED_FILE, NM_SETTING_IP4_CONFIG_SETTING_NAME, @@ -270,23 +298,35 @@ test_read_valid_wired_connection (void) TEST_WIRED_FILE, NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr.s_addr, + ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr, "connection-verify-wired", "failed to verify %s: unexpected %s / %s key value #2", TEST_WIRED_FILE, NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS); /* IPv4 addresses */ - g_assert (nm_setting_ip4_config_get_num_addresses (s_ip4) == 4); + g_assert (nm_setting_ip4_config_get_num_addresses (s_ip4) == 6); check_ip4_address (s_ip4, 0, "2.3.4.5", 24, "2.3.4.6"); check_ip4_address (s_ip4, 1, "192.168.0.5", 24, "192.168.0.1"); check_ip4_address (s_ip4, 2, "1.2.3.4", 16, "1.2.1.1"); check_ip4_address (s_ip4, 3, "3.4.5.6", 16, "0.0.0.0"); + check_ip4_address (s_ip4, 4, "4.5.6.7", 24, "1.2.3.4"); + check_ip4_address (s_ip4, 5, "5.6.7.8", 24, "0.0.0.0"); /* IPv4 routes */ - g_assert (nm_setting_ip4_config_get_num_routes (s_ip4) == 2); + g_assert (nm_setting_ip4_config_get_num_routes (s_ip4) == 12); check_ip4_route (s_ip4, 0, "5.6.7.8", 32, "0.0.0.0", 0); check_ip4_route (s_ip4, 1, "1.2.3.0", 24, "2.3.4.8", 99); + check_ip4_route (s_ip4, 2, "1.1.1.2", 12, "0.0.0.0", 0); + check_ip4_route (s_ip4, 3, "1.1.1.3", 13, "0.0.0.0", 0); + check_ip4_route (s_ip4, 4, "1.1.1.4", 14, "2.2.2.4", 0); + check_ip4_route (s_ip4, 5, "1.1.1.5", 15, "2.2.2.5", 0); + check_ip4_route (s_ip4, 6, "1.1.1.6", 16, "2.2.2.6", 0); + check_ip4_route (s_ip4, 7, "1.1.1.7", 17, "0.0.0.0", 0); + check_ip4_route (s_ip4, 8, "1.1.1.8", 18, "0.0.0.0", 0); + check_ip4_route (s_ip4, 9, "1.1.1.9", 19, "0.0.0.0", 0); + check_ip4_route (s_ip4, 10, "1.1.1.10", 20, "0.0.0.0", 0); + check_ip4_route (s_ip4, 11, "1.1.1.11", 21, "0.0.0.0", 21); /* ===== IPv6 SETTING ===== */ @@ -357,17 +397,27 @@ test_read_valid_wired_connection (void) NM_SETTING_IP6_CONFIG_DNS_SEARCH); /* IPv6 addresses */ - g_assert (nm_setting_ip6_config_get_num_addresses (s_ip6) == 4); + g_assert (nm_setting_ip6_config_get_num_addresses (s_ip6) == 10); check_ip6_address (s_ip6, 0, "2:3:4:5:6:7:8:9", 64, "2:3:4:5:1:2:3:4"); check_ip6_address (s_ip6, 1, "abcd:1234:ffff::cdde", 64, "::"); check_ip6_address (s_ip6, 2, "1:2:3:4:5:6:7:8", 96, "::"); check_ip6_address (s_ip6, 3, "3:4:5:6:7:8:9:0", 128, "::"); + check_ip6_address (s_ip6, 4, "3:4:5:6:7:8:9:14", 64, "::"); + check_ip6_address (s_ip6, 5, "3:4:5:6:7:8:9:15", 64, "::"); + check_ip6_address (s_ip6, 6, "3:4:5:6:7:8:9:16", 66, "::"); + check_ip6_address (s_ip6, 7, "3:4:5:6:7:8:9:17", 67, "::"); + check_ip6_address (s_ip6, 8, "3:4:5:6:7:8:9:18", 68, "::"); + check_ip6_address (s_ip6, 9, "3:4:5:6:7:8:9:19", 69, "1::09"); /* Route #1 */ - g_assert (nm_setting_ip6_config_get_num_routes (s_ip6) == 3); + g_assert (nm_setting_ip6_config_get_num_routes (s_ip6) == 7); check_ip6_route (s_ip6, 0, "d:e:f:0:1:2:3:4", 64, "f:e:d:c:1:2:3:4", 0); check_ip6_route (s_ip6, 1, "a:b:c:d::", 64, "f:e:d:c:1:2:3:4", 99); check_ip6_route (s_ip6, 2, "8:7:6:5:4:3:2:1", 128, "::", 0); + check_ip6_route (s_ip6, 3, "6:7:8:9:0:1:2:3", 126, "::", 1); + check_ip6_route (s_ip6, 4, "7:8:9:0:1:2:3:4", 125, "::", 5); + check_ip6_route (s_ip6, 5, "8:9:0:1:2:3:4:5", 124, "::", 6); + check_ip6_route (s_ip6, 6, "8:9:0:1:2:3:4:6", 123, "::", 0); g_object_unref (connection); } @@ -377,17 +427,17 @@ add_one_ip4_address (NMSettingIP4Config *s_ip4, const char *gw, guint32 prefix) { - struct in_addr tmp; + guint32 tmp; NMIP4Address *ip4_addr; ip4_addr = nm_ip4_address_new (); nm_ip4_address_set_prefix (ip4_addr, prefix); inet_pton (AF_INET, addr, &tmp); - nm_ip4_address_set_address (ip4_addr, tmp.s_addr); + nm_ip4_address_set_address (ip4_addr, tmp); inet_pton (AF_INET, gw, &tmp); - nm_ip4_address_set_gateway (ip4_addr, tmp.s_addr); + nm_ip4_address_set_gateway (ip4_addr, tmp); nm_setting_ip4_config_add_address (s_ip4, ip4_addr); nm_ip4_address_unref (ip4_addr); @@ -400,7 +450,7 @@ add_one_ip4_route (NMSettingIP4Config *s_ip4, guint32 prefix, guint32 metric) { - struct in_addr addr; + guint32 addr; NMIP4Route *route; route = nm_ip4_route_new (); @@ -408,10 +458,10 @@ add_one_ip4_route (NMSettingIP4Config *s_ip4, nm_ip4_route_set_metric (route, metric); inet_pton (AF_INET, dest, &addr); - nm_ip4_route_set_dest (route, addr.s_addr); + nm_ip4_route_set_dest (route, addr); inet_pton (AF_INET, nh, &addr); - nm_ip4_route_set_next_hop (route, addr.s_addr); + nm_ip4_route_set_next_hop (route, addr); nm_setting_ip4_config_add_route (s_ip4, route); nm_ip4_route_unref (route); @@ -483,7 +533,7 @@ test_write_wired_connection (void) GError *error = NULL; pid_t owner_grp; uid_t owner_uid; - struct in_addr addr; + guint32 addr; struct in6_addr addr6; const char *dns1 = "4.2.2.1"; const char *dns2 = "4.2.2.2"; @@ -495,6 +545,10 @@ test_write_wired_connection (void) const char *route1_nh = "10.10.10.1"; const char *route2 = "1.1.1.1"; const char *route2_nh = "1.2.1.1"; + const char *route3 = "2.2.2.2"; + const char *route3_nh = "0.0.0.0"; + const char *route4 = "3.3.3.3"; + const char *route4_nh = "0.0.0.0"; const char *dns6_1 = "1::cafe"; const char *dns6_2 = "2::cafe"; const char *address6_1 = "abcd::beef"; @@ -503,18 +557,17 @@ test_write_wired_connection (void) const char *route6_1_nh = "8:7:6:5:4:3:2:1"; const char *route6_2 = "2001::1000"; const char *route6_2_nh = "2001::1111"; + const char *route6_3 = "4:5:6:7:8:9:0:1"; + const char *route6_3_nh = "::"; + const char *route6_4 = "5:6:7:8:9:0:1:2"; + const char *route6_4_nh = "::"; guint64 timestamp = 0x12345678L; connection = nm_connection_new (); - ASSERT (connection != NULL, - "connection-write", "failed to allocate new connection"); /* Connection setting */ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - ASSERT (s_con != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_CONNECTION_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); @@ -530,9 +583,6 @@ test_write_wired_connection (void) /* Wired setting */ s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); - ASSERT (s_wired != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_WIRED_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_wired)); mac = g_byte_array_sized_new (ETH_ALEN); @@ -546,9 +596,6 @@ test_write_wired_connection (void) /* IP4 setting */ s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); - ASSERT (s_ip4 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -562,19 +609,18 @@ test_write_wired_connection (void) /* Routes */ add_one_ip4_route (s_ip4, route1, route1_nh, 24, 3); add_one_ip4_route (s_ip4, route2, route2_nh, 8, 1); + add_one_ip4_route (s_ip4, route3, route3_nh, 7, 0); + add_one_ip4_route (s_ip4, route4, route4_nh, 6, 4); /* DNS servers */ inet_pton (AF_INET, dns1, &addr); - nm_setting_ip4_config_add_dns (s_ip4, addr.s_addr); + nm_setting_ip4_config_add_dns (s_ip4, addr); inet_pton (AF_INET, dns2, &addr); - nm_setting_ip4_config_add_dns (s_ip4, addr.s_addr); + nm_setting_ip4_config_add_dns (s_ip4, addr); /* IP6 setting */ s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ()); - ASSERT (s_ip6 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP6_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -588,6 +634,8 @@ test_write_wired_connection (void) /* Routes */ add_one_ip6_route (s_ip6, route6_1, route6_1_nh, 64, 3); add_one_ip6_route (s_ip6, route6_2, route6_2_nh, 56, 1); + add_one_ip6_route (s_ip6, route6_3, route6_3_nh, 63, 5); + add_one_ip6_route (s_ip6, route6_4, route6_4_nh, 62, 0); /* DNS servers */ inet_pton (AF_INET6, dns6_1, &addr6); @@ -754,15 +802,10 @@ test_write_ip6_wired_connection (void) const char *gw = "dcba::beef"; connection = nm_connection_new (); - ASSERT (connection != NULL, - "connection-write", "failed to allocate new connection"); /* Connection setting */ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - ASSERT (s_con != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_CONNECTION_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); @@ -777,17 +820,11 @@ test_write_ip6_wired_connection (void) /* Wired setting */ s_wired = NM_SETTING_WIRED (nm_setting_wired_new ()); - ASSERT (s_wired != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_WIRED_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_wired)); /* IP4 setting */ s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); - ASSERT (s_ip4 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -797,9 +834,6 @@ test_write_ip6_wired_connection (void) /* IP6 setting */ s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ()); - ASSERT (s_ip6 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP6_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -857,7 +891,14 @@ test_read_wired_mac_case (void) const char *expected_id = "Test Wired Connection MAC Case"; const char *expected_uuid = "4e80a56d-c99f-4aad-a6dd-b449bc398c57"; + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.addresses1*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv4.addresses2*semicolon at the end*"); + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, + "*ipv6.routes1*semicolon at the end*"); connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_MAC_CASE_FILE, NULL); + g_test_assert_expected_messages (); ASSERT (connection != NULL, "connection-read", "failed to read %s", TEST_WIRED_MAC_CASE_FILE); @@ -927,6 +968,79 @@ test_read_wired_mac_case (void) g_object_unref (connection); } +#define TEST_MAC_OLD_FORMAT_FILE TEST_KEYFILES_DIR"/Test_MAC_Old_Format" + +static void +test_read_mac_old_format (void) +{ + NMConnection *connection; + NMSettingWired *s_wired; + GError *error = NULL; + gboolean success; + const GByteArray *array; + char expected_mac[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 }; + char expected_cloned_mac[ETH_ALEN] = { 0x00, 0x16, 0xaa, 0xbb, 0xcc, 0xfe }; + + connection = nm_keyfile_plugin_connection_from_file (TEST_MAC_OLD_FORMAT_FILE, &error); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + + /* MAC address */ + array = nm_setting_wired_get_mac_address (s_wired); + g_assert (array); + g_assert_cmpint (array->len, ==, ETH_ALEN); + g_assert (memcmp (array->data, expected_mac, ETH_ALEN) == 0); + + /* Cloned MAC address */ + array = nm_setting_wired_get_cloned_mac_address (s_wired); + g_assert (array); + g_assert_cmpint (array->len, ==, ETH_ALEN); + g_assert (memcmp (array->data, expected_cloned_mac, ETH_ALEN) == 0); + + g_object_unref (connection); +} + +#define TEST_MAC_IB_OLD_FORMAT_FILE TEST_KEYFILES_DIR"/Test_MAC_IB_Old_Format" + +static void +test_read_mac_ib_old_format (void) +{ + NMConnection *connection; + NMSettingInfiniband *s_ib; + GError *error = NULL; + gboolean success; + const GByteArray *array; + guint8 expected_mac[INFINIBAND_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, + 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, + 0x90 }; + + connection = nm_keyfile_plugin_connection_from_file (TEST_MAC_IB_OLD_FORMAT_FILE, &error); + g_assert_no_error (error); + g_assert (connection); + + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + s_ib = nm_connection_get_setting_infiniband (connection); + g_assert (s_ib); + + /* MAC address */ + array = nm_setting_infiniband_get_mac_address (s_ib); + g_assert (array); + g_assert_cmpint (array->len, ==, INFINIBAND_ALEN); + g_assert_cmpint (memcmp (array->data, expected_mac, sizeof (expected_mac)), ==, 0); + + g_object_unref (connection); +} + static void test_read_valid_wireless_connection (void) { @@ -1066,15 +1180,10 @@ test_write_wireless_connection (void) guint64 timestamp = 0x12344433L; connection = nm_connection_new (); - ASSERT (connection != NULL, - "connection-write", "failed to allocate new connection"); /* Connection setting */ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - ASSERT (s_con != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_CONNECTION_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); @@ -1090,9 +1199,6 @@ test_write_wireless_connection (void) /* Wireless setting */ s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); - ASSERT (s_wireless != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_WIRELESS_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_wireless)); bssid = g_byte_array_sized_new (ETH_ALEN); @@ -1113,9 +1219,6 @@ test_write_wireless_connection (void) /* IP4 setting */ s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); - ASSERT (s_ip4 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -1125,9 +1228,6 @@ test_write_wireless_connection (void) /* IP6 setting */ s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ()); - ASSERT (s_ip6 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP6_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip6)); g_object_set (s_ip6, @@ -1217,15 +1317,10 @@ test_write_string_ssid (void) GKeyFile *keyfile; connection = nm_connection_new (); - ASSERT (connection != NULL, - "connection-write", "failed to allocate new connection"); /* Connection setting */ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - ASSERT (s_con != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_CONNECTION_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); @@ -1239,9 +1334,6 @@ test_write_string_ssid (void) /* Wireless setting */ s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ()); - ASSERT (s_wireless != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_WIRELESS_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_wireless)); ssid = g_byte_array_sized_new (sizeof (tmpssid)); @@ -1252,9 +1344,6 @@ test_write_string_ssid (void) /* IP4 setting */ s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); - ASSERT (s_ip4 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -1276,7 +1365,7 @@ test_write_string_ssid (void) keyfile = g_key_file_new (); ASSERT (g_key_file_load_from_file (keyfile, testfile, 0, NULL) == TRUE, "string-ssid-verify", "failed to load keyfile to verify"); - tmp = g_key_file_get_string (keyfile, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID, NULL); + tmp = g_key_file_get_string (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, NULL); ASSERT (tmp, "string-ssid-verify", "failed to load 'ssid' key from file"); ASSERT (strlen (tmp) == sizeof (tmpssid), "string-ssid-verify", "reread SSID and expected were different sizes"); @@ -1398,7 +1487,7 @@ test_write_intlist_ssid (void) g_assert_no_error (error); g_assert (success); - intlist = g_key_file_get_integer_list (keyfile, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID, &len, &error); + intlist = g_key_file_get_integer_list (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, &len, &error); g_assert_no_error (error); g_assert (intlist); g_assert_cmpint (len, ==, sizeof (tmpssid)); @@ -1554,7 +1643,7 @@ test_write_intlike_ssid (void) g_assert_no_error (error); g_assert (success); - tmp = g_key_file_get_string (keyfile, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID, &error); + tmp = g_key_file_get_string (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, &error); g_assert_no_error (error); g_assert (tmp); g_assert_cmpstr (tmp, ==, "101"); @@ -1642,7 +1731,7 @@ test_write_intlike_ssid_2 (void) g_assert_no_error (error); g_assert (success); - tmp = g_key_file_get_string (keyfile, NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_SSID, &error); + tmp = g_key_file_get_string (keyfile, "wifi", NM_SETTING_WIRELESS_SSID, &error); g_assert_no_error (error); g_assert (tmp); g_assert_cmpstr (tmp, ==, "11\\;12\\;13\\;"); @@ -1843,15 +1932,10 @@ test_write_bt_dun_connection (void) guint64 timestamp = 0x12344433L; connection = nm_connection_new (); - ASSERT (connection != NULL, - "connection-write", "failed to allocate new connection"); /* Connection setting */ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - ASSERT (s_con != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_CONNECTION_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); @@ -1867,9 +1951,6 @@ test_write_bt_dun_connection (void) /* Bluetooth setting */ s_bt = NM_SETTING_BLUETOOTH (nm_setting_bluetooth_new ()); - ASSERT (s_bt != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_BLUETOOTH_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_bt)); bdaddr = g_byte_array_sized_new (ETH_ALEN); @@ -1885,9 +1966,6 @@ test_write_bt_dun_connection (void) /* IP4 setting */ s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); - ASSERT (s_ip4 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -1896,9 +1974,6 @@ test_write_bt_dun_connection (void) /* GSM setting */ s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ()); - ASSERT (s_gsm != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_GSM_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_gsm)); g_object_set (s_gsm, @@ -2103,15 +2178,10 @@ test_write_gsm_connection (void) guint64 timestamp = 0x12344433L; connection = nm_connection_new (); - ASSERT (connection != NULL, - "connection-write", "failed to allocate new connection"); /* Connection setting */ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); - ASSERT (s_con != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_CONNECTION_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_con)); uuid = nm_utils_uuid_generate (); @@ -2127,9 +2197,6 @@ test_write_gsm_connection (void) /* IP4 setting */ s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); - ASSERT (s_ip4 != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_IP4_CONFIG_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_ip4)); g_object_set (s_ip4, @@ -2138,9 +2205,6 @@ test_write_gsm_connection (void) /* GSM setting */ s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ()); - ASSERT (s_gsm != NULL, - "connection-write", "failed to allocate new %s setting", - NM_SETTING_GSM_SETTING_NAME); nm_connection_add_setting (connection, NM_SETTING (s_gsm)); g_object_set (s_gsm, @@ -2228,7 +2292,10 @@ test_read_wired_8021x_tls_blob_connection (void) g_assert_cmpint (nm_setting_802_1x_get_ca_cert_scheme (s_8021x), ==, NM_SETTING_802_1X_CK_SCHEME_BLOB); /* Make sure it's not a path, since it's a blob */ + g_test_expect_message ("libnm-util", G_LOG_LEVEL_CRITICAL, + "*assertion*scheme == NM_SETTING_802_1X_CK_SCHEME_PATH*"); tmp = nm_setting_802_1x_get_ca_cert_path (s_8021x); + g_test_assert_expected_messages (); g_assert (tmp == NULL); /* Validate the path */ @@ -2258,7 +2325,10 @@ test_read_wired_8021x_tls_bad_path_connection (void) char *tmp2; gboolean success; + g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING, + "*does not exist*"); connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_TLS_PATH_MISSING_FILE, &error); + g_test_assert_expected_messages (); if (connection == NULL) { g_assert (error); g_warning ("Failed to read %s: %s", TEST_WIRED_TLS_PATH_MISSING_FILE, error->message); @@ -2894,6 +2964,7 @@ test_write_bridge_main (void) NM_SETTING_CONNECTION_UUID, uuid, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_TYPE, NM_SETTING_BRIDGE_SETTING_NAME, + NM_SETTING_CONNECTION_INTERFACE_NAME, "br0", NULL); g_free (uuid); @@ -3076,6 +3147,247 @@ test_write_bridge_component (void) } static void +test_read_new_wired_group_name (void) +{ + NMConnection *connection; + NMSettingWired *s_wired; + const GByteArray *array; + guint8 expected_mac[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; + GError *error = NULL; + gboolean success; + + connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error); + g_assert_no_error (error); + g_assert (connection); + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Wired setting */ + s_wired = nm_connection_get_setting_wired (connection); + g_assert (s_wired); + g_assert_cmpint (nm_setting_wired_get_mtu (s_wired), ==, 1400); + + array = nm_setting_wired_get_mac_address (s_wired); + g_assert (array); + g_assert_cmpint (array->len, ==, ETH_ALEN); + g_assert_cmpint (memcmp (array->data, expected_mac, sizeof (expected_mac)), ==, 0); + + g_object_unref (connection); +} + +static void +test_write_new_wired_group_name (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWired *s_wired; + char *uuid; + gboolean success; + NMConnection *reread; + char *testfile = NULL; + GError *error = NULL; + pid_t owner_grp; + uid_t owner_uid; + GKeyFile *kf; + char *s; + gint mtu; + + connection = nm_connection_new (); + g_assert (connection); + + /* Connection setting */ + s_con = (NMSettingConnection *) nm_setting_connection_new (); + g_assert (s_con); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write Wired New Group Name", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, + NULL); + g_free (uuid); + + /* Wired setting */ + s_wired = (NMSettingWired *) nm_setting_wired_new (); + g_assert (s_wired); + g_object_set (s_wired, NM_SETTING_WIRED_MTU, 1400, NULL); + nm_connection_add_setting (connection, NM_SETTING (s_wired)); + + /* Write out the connection */ + owner_uid = geteuid (); + owner_grp = getegid (); + success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); + g_assert_no_error (error); + g_assert (success); + g_assert (testfile); + + /* Read the connection back in and compare it to the one we just wrote out */ + reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + g_assert_no_error (error); + g_assert (reread); + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + /* Look at the keyfile itself to ensure we wrote out the new group names and type */ + kf = g_key_file_new (); + success = g_key_file_load_from_file (kf, testfile, G_KEY_FILE_NONE, &error); + g_assert_no_error (error); + g_assert (success); + + s = g_key_file_get_string (kf, NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE, &error); + g_assert_no_error (error); + g_assert_cmpstr (s, ==, "ethernet"); + g_free (s); + + mtu = g_key_file_get_integer (kf, "ethernet", NM_SETTING_WIRED_MTU, &error); + g_assert_no_error (error); + g_assert_cmpint (mtu, ==, 1400); + + unlink (testfile); + g_free (testfile); + + g_object_unref (reread); + g_object_unref (connection); +} + +static void +test_read_new_wireless_group_names (void) +{ + NMConnection *connection; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + const GByteArray *array; + const char *expected_ssid = "foobar"; + GError *error = NULL; + gboolean success; + + connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error); + g_assert_no_error (error); + g_assert (connection); + success = nm_connection_verify (connection, &error); + g_assert_no_error (error); + g_assert (success); + + /* Wifi setting */ + s_wifi = nm_connection_get_setting_wireless (connection); + g_assert (s_wifi); + + array = nm_setting_wireless_get_ssid (s_wifi); + g_assert (array); + g_assert_cmpint (array->len, ==, strlen (expected_ssid)); + g_assert_cmpint (memcmp (array->data, expected_ssid, array->len), ==, 0); + + g_assert_cmpstr (nm_setting_wireless_get_mode (s_wifi), ==, NM_SETTING_WIRELESS_MODE_INFRA); + + /* Wifi security setting */ + s_wsec = nm_connection_get_setting_wireless_security (connection); + g_assert (s_wsec); + g_assert_cmpstr (nm_setting_wireless_security_get_key_mgmt (s_wsec), ==, "wpa-psk"); + g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "s3cu4e passphrase"); + + g_object_unref (connection); +} + +static void +test_write_new_wireless_group_names (void) +{ + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; + NMSettingWirelessSecurity *s_wsec; + char *uuid; + GByteArray *ssid; + unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 }; + const char *expected_psk = "asdfasdfasdfa12315"; + gboolean success; + NMConnection *reread; + char *testfile = NULL; + GError *error = NULL; + pid_t owner_grp; + uid_t owner_uid; + GKeyFile *kf; + char *s; + + connection = nm_connection_new (); + + /* Connection setting */ + + s_con = (NMSettingConnection *) nm_setting_connection_new (); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + uuid = nm_utils_uuid_generate (); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, "Test Write New Wireless Group Names", + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, + NULL); + g_free (uuid); + + /* WiFi setting */ + s_wifi = (NMSettingWireless *) nm_setting_wireless_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wifi)); + + ssid = g_byte_array_sized_new (sizeof (tmpssid)); + g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid)); + g_object_set (s_wifi, + NM_SETTING_WIRELESS_SSID, ssid, + NM_SETTING_WIRELESS_MODE, NM_SETTING_WIRELESS_MODE_INFRA, + NULL); + g_byte_array_free (ssid, TRUE); + + /* WiFi security setting */ + s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new (); + nm_connection_add_setting (connection, NM_SETTING (s_wsec)); + g_object_set (s_wsec, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", + NM_SETTING_WIRELESS_SECURITY_PSK, expected_psk, + NULL); + + /* Write out the connection */ + owner_uid = geteuid (); + owner_grp = getegid (); + success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, &testfile, &error); + g_assert_no_error (error); + g_assert (success); + + g_assert (testfile); + + /* Read the connection back in and compare it to the one we just wrote out */ + reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + g_assert_no_error (error); + g_assert (reread); + g_assert (nm_connection_compare (connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); + + /* Look at the keyfile itself to ensure we wrote out the new group names and type */ + kf = g_key_file_new (); + success = g_key_file_load_from_file (kf, testfile, G_KEY_FILE_NONE, &error); + g_assert_no_error (error); + g_assert (success); + + s = g_key_file_get_string (kf, NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE, &error); + g_assert_no_error (error); + g_assert_cmpstr (s, ==, "wifi"); + g_free (s); + + s = g_key_file_get_string (kf, "wifi", NM_SETTING_WIRELESS_MODE, &error); + g_assert_no_error (error); + g_assert_cmpstr (s, ==, NM_SETTING_WIRELESS_MODE_INFRA); + g_free (s); + + s = g_key_file_get_string (kf, "wifi-security", NM_SETTING_WIRELESS_SECURITY_PSK, &error); + g_assert_no_error (error); + g_assert_cmpstr (s, ==, expected_psk); + g_free (s); + + unlink (testfile); + g_free (testfile); + + g_object_unref (reread); + g_object_unref (connection); +} + +static void test_read_missing_vlan_setting (void) { NMConnection *connection; @@ -3098,15 +3410,13 @@ test_read_missing_vlan_setting (void) g_object_unref (connection); } +NMTST_DEFINE (); + int main (int argc, char **argv) { - GError *error = NULL; char *base; - g_type_init (); - - if (!nm_utils_init (&error)) - FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message); + nmtst_init_assert_logging (&argc, &argv); /* The tests */ test_read_valid_wired_connection (); @@ -3116,6 +3426,8 @@ int main (int argc, char **argv) test_write_ip6_wired_connection (); test_read_wired_mac_case (); + test_read_mac_old_format (); + test_read_mac_ib_old_format (); test_read_valid_wireless_connection (); test_write_wireless_connection (); @@ -3154,6 +3466,11 @@ int main (int argc, char **argv) test_read_bridge_component (); test_write_bridge_component (); + test_read_new_wired_group_name (); + test_write_new_wired_group_name (); + test_read_new_wireless_group_names (); + test_write_new_wireless_group_names (); + test_read_missing_vlan_setting (); base = g_path_get_basename (argv[0]); |