tests: general fix for tests setup 52/115152/1
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 16 Feb 2017 11:47:41 +0000 (12:47 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Thu, 16 Feb 2017 11:57:59 +0000 (12:57 +0100)
Before this patch tests were installed into custom directory
  /usr/lib/dbus-tests/test-suites/dbus-tests
Originally, dbus wants its installed tests in
  /usr/lib/dbus/installed-tests/dbus
This path seems to be partially hardcoded in the configuration
files - it relies on defined datadir. As datadir is used
also for something else than tests, we don't want to change it.

This commit switches installation directory to the original,
and adds symbolic links in our custom directory.

Change-Id: Icf330ba3b5be59ee941d51b15a8f78a082297846

packaging/dbus.spec
test-runner.c

index afaad50..50d1da3 100644 (file)
@@ -220,15 +220,22 @@ install -m 0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/profile.d/dbus.sh
 rm -rf %{buildroot}%{_datadir}/doc
 
 # build test binaries and copy test data
-%define relative_dbus_tests_base_dir %{_prefix}/lib/dbus-tests
+%define relative_dbus_tests_base_dir %{_libdir}/dbus-tests
 %define dbus_tests_base_dir %{buildroot}%{relative_dbus_tests_base_dir}
+%define dbus_installed_tests_dir %{_libdir}/dbus/installed-tests/dbus
 mkdir -p %{dbus_tests_base_dir}/test-suites/dbus-tests/
 
 mkdir -p %{dbus_tests_base_dir}/runner/
-%__cc %{_builddir}/%{name}-%{version}/test-runner.c -o %{dbus_tests_base_dir}/runner/dbus-tests
-cp -fr %{buildroot}%{_libdir}/dbus/installed-tests/dbus/* %{dbus_tests_base_dir}/test-suites/dbus-tests/
-rm -fr %{buildroot}%{_libdir}/dbus/installed-tests/dbus
+%__cc %{_builddir}/%{name}-%{version}/test-runner.c -g -o %{dbus_tests_base_dir}/runner/dbus-tests
 rm -fr %{buildroot}/usr/share/installed-tests/dbus
+# The tests are installed in standard directory for dbus tests.
+# However, we need to have the tests also available for dbus-integration-tests package.
+# Thus, we link selected tests to our dbus-integration-tests directory
+for f in manual-dir-iter manual-tcp test-corrupt test-dbus-daemon \
+                test-dbus-daemon-eavesdrop test-fdpass test-loopback test-marshal \
+                test-monitor test-printf test-refs test-relay test-sd-activation \
+                test-shell test-syntax test-syslog test-uid-permissions
+do ln -s %{dbus_installed_tests_dir}/$f %{dbus_tests_base_dir}/test-suites/dbus-tests/$f; done
 
 %if %{with coverage}
 %define relative_cov_lib_dir %{relative_dbus_tests_base_dir}/coverage-libs
@@ -315,8 +322,9 @@ install -m 0644 coverage-objects/* %{cov_lib_dir}/objects
 %files tests
 %manifest %{name}.manifest
 %defattr(-,root,root)
-%{_prefix}/lib/dbus-tests/test-suites/dbus-tests
-%{_prefix}/lib/dbus-tests/runner/dbus-tests
+%{_libdir}/dbus-tests/test-suites/dbus-tests
+%{_libdir}/dbus-tests/runner/dbus-tests
+%{_libdir}/dbus/installed-tests
 
 %if %{with coverage}
 %files coverage
index c750e32..a248c64 100644 (file)
@@ -41,6 +41,8 @@
 #define MAX_BUFFER (64*1024)
 #define MAX_COMMENT 1024
 
+#define INSTALLED_TESTS_DIR "/usr/lib/dbus/installed-tests/dbus/data"
+
 enum {
        INIT_TEST,
        NEW_STDOUT,
@@ -255,13 +257,13 @@ char** prepare_args_for_dir_iter(const struct binary* b, const char* test_name)
 {
        static char* args_dir[2];
        args_dir[0] = (char*)b->name;
-       args_dir[1] = "/usr/lib/dbus-tests/test-suites/dbus-tests/data";
+       args_dir[1] = INSTALLED_TESTS_DIR;
        return args_dir;
 }
 
 int init_environment_vars()
 {
-       return !(putenv("DBUS_TEST_DATA=/usr/lib/dbus-tests/test-suites/dbus-tests/data"));
+       return !(putenv("DBUS_TEST_DATA="INSTALLED_TESTS_DIR));
 }
 
 void parse_binary_outputs(const struct binary* b, const char* test_name, char* buffer, int state_change, int state_option)