From e9ca6c57f8d1b651c01147238f348bf2d5c36b1a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Nov 2015 18:19:33 +0000 Subject: [PATCH 4/4] Test system bus config files on Unix only Previously, we didn't consistently test parsing of every file in valid-config-files-system/ everywhere that we tested valid-config-files/. We now test it on Unix. The system bus is not supported on Windows, so we do not test valid-config-files-system/ there. valid-config-files/many-rules.conf contains and rules which are not applicable to Windows. Copy the original many-rules.conf to valid-config-files-system/ so that it will be tested on Unix, and remove the non-portable rules from valid-config-files/many-rules.conf. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721 --- bus/config-parser-trivial.c | 11 +++- bus/config-parser.c | 5 ++ cmake/test/CMakeLists.txt | 8 ++- test/Makefile.am | 10 ++-- .../data/valid-config-files-system/many-rules.conf | 60 ++++++++++++++++++++++ test/data/valid-config-files/many-rules.conf | 4 -- 6 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 test/data/valid-config-files-system/many-rules.conf diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c index 64a05c3..03ad838 100644 --- a/bus/config-parser-trivial.c +++ b/bus/config-parser-trivial.c @@ -684,6 +684,13 @@ bus_config_parser_trivial_test (const DBusString *test_data_dir) if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID)) goto finish; +#ifndef DBUS_WIN + /* We already test default_session_servicedirs and default_system_servicedirs + * in bus_config_parser_test() */ + if (!process_test_valid_subdir (test_data_dir, "valid-config-files-system", VALID)) + goto finish; +#endif + /* we don't process all the invalid files, as the trivial parser can't hope * to validate them all for all different syntaxes. We just check one broken * file to see if junk is received */ @@ -693,14 +700,16 @@ bus_config_parser_trivial_test (const DBusString *test_data_dir) goto finish; _dbus_string_free (&full_path); +#ifndef DBUS_WIN /* just test if the check_file_valid works okay and we got sane values */ - if (!make_full_path (test_data_dir, "valid-config-files", "system.conf", &full_path)) + if (!make_full_path (test_data_dir, "valid-config-files-system", "system.conf", &full_path)) goto finish; if (!check_file_valid (&full_path, VALID)) goto finish; /* check to see if we got the correct values from the parser */ if (!check_return_values (&full_path)) goto finish; +#endif /* woot! */ retval = TRUE; diff --git a/bus/config-parser.c b/bus/config-parser.c index 1925d43..d9f6042 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -3680,6 +3680,11 @@ bus_config_parser_test (const DBusString *test_data_dir) if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID)) return FALSE; +#ifndef DBUS_WIN + if (!process_test_valid_subdir (test_data_dir, "valid-config-files-system", VALID)) + return FALSE; +#endif + if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID)) return FALSE; diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 1a12f5a..071589b 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -178,16 +178,20 @@ FOREACH(FILE_TYPE *.conf.in *.service.in) ENDFOREACH(FILE_TYPE) MESSAGE(STATUS "Copying generated bus config files to test directory") -set (OUTDIR ${CMAKE_BINARY_DIR}/test/data/valid-config-files) SET(FILES "${CMAKE_SOURCE_DIR}/../bus/session.conf.in" "${CMAKE_SOURCE_DIR}/../bus/system.conf.in" ) -FILE(MAKE_DIRECTORY ${OUTDIR}) FOREACH(FILE ${FILES}) GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) STRING(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME}) + IF (${FILE} MATCHES "system\\.conf") + SET (OUTDIR ${CMAKE_BINARY_DIR}/test/data/valid-config-files-system) + ELSE() + SET (OUTDIR ${CMAKE_BINARY_DIR}/test/data/valid-config-files) + ENDIF() + FILE(MAKE_DIRECTORY ${OUTDIR}) SET (TARGET ${OUTDIR}/${FILENAME}) configure_file(${FILE} ${TARGET} @ONLY) IF (CONFIG_VERBOSE) diff --git a/test/Makefile.am b/test/Makefile.am index 5812c1a..98998a3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -468,7 +468,7 @@ if DBUS_ENABLE_INSTALLED_TESTS install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \ done ln -nfs $(datadir)/dbus-1/session.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/session.conf - ln -nfs $(datadir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/system.conf + ln -nfs $(datadir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files-system/system.conf else @: endif @@ -486,7 +486,7 @@ clean-local: imported_data = \ data/valid-config-files/session.conf \ - data/valid-config-files/system.conf \ + data/valid-config-files-system/system.conf \ $(NULL) noinst_DATA = $(imported_data) @@ -496,10 +496,14 @@ CLEANFILES += \ installable \ $(NULL) -$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf +data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf $(AM_V_at)$(MKDIR_P) data/valid-config-files $(AM_V_GEN)cp $< $@ +data/valid-config-files-system/system.conf: $(top_builddir)/bus/system.conf + $(AM_V_at)$(MKDIR_P) data/valid-config-files-system + $(AM_V_GEN)cp $< $@ + $(installable_test_meta): %.test: %$(EXEEXT) Makefile $(AM_V_GEN) ( \ echo '[Test]'; \ diff --git a/test/data/valid-config-files-system/many-rules.conf b/test/data/valid-config-files-system/many-rules.conf new file mode 100644 index 0000000..8537fd9 --- /dev/null +++ b/test/data/valid-config-files-system/many-rules.conf @@ -0,0 +1,60 @@ + + + mybususer + unix:path=/foo/bar + tcp:port=1234 + basic.d + + /usr/share/foo + nonexistent.conf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5000 + 5000 + 300 + 5000 + 6000 + 50 + 80 + 64 + 64 + 256 + 512 + diff --git a/test/data/valid-config-files/many-rules.conf b/test/data/valid-config-files/many-rules.conf index 2393162..df9a994 100644 --- a/test/data/valid-config-files/many-rules.conf +++ b/test/data/valid-config-files/many-rules.conf @@ -17,8 +17,6 @@ - - @@ -36,8 +34,6 @@ - - -- 2.6.2