diff options
author | Hyotaek Shim <hyotaek.shim@samsung.com> | 2017-02-28 21:44:33 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.vlan103.tizen.org> | 2017-02-28 21:44:34 -0800 |
commit | 128b0ba7bb678173d251514a975b3aa275dfe77f (patch) | |
tree | e0448725a98cca126f8f32cc3ec3e56193d8b61b | |
parent | 7153a31c2fffef7fa451f43084a7f7b93a628d12 (diff) | |
parent | 321a18e45eaf5a04597749c541f35deaa723ee1d (diff) | |
download | dbus-128b0ba7bb678173d251514a975b3aa275dfe77f.tar.gz dbus-128b0ba7bb678173d251514a975b3aa275dfe77f.tar.bz2 dbus-128b0ba7bb678173d251514a975b3aa275dfe77f.zip |
Merge changes Icf330ba3,I7354c21e into tizen
* changes:
tests: general fix for tests setup
tests: generating coverage version of the library
-rw-r--r-- | packaging/coverage.txt | 14 | ||||
-rw-r--r-- | packaging/dbus.spec | 101 | ||||
-rw-r--r-- | test-runner.c | 29 |
3 files changed, 114 insertions, 30 deletions
diff --git a/packaging/coverage.txt b/packaging/coverage.txt new file mode 100644 index 00000000..b3674cb2 --- /dev/null +++ b/packaging/coverage.txt @@ -0,0 +1,14 @@ +How to analyze coverage: +1. read HACKING file. +2. gbs build adding --define '_with_coverage 1' +3. take *.o and *.gcno files from compilation (<gbs-build-root>/home/abuild/rpmbuild/BUILD/dbus-1.10.6/dbus/.libs) into a /safe/place + you may also use generated rpm package dbus-coverage-objects. +4. install coverage package (dbus-coverage) on the target +5. run test programs adding LD_LIBRARY_PATH=/usr/lib/dbus-tests/coverage-libs + Data gathering is cumulative, so you can run multiple programs one after another. + Use GCOV_PREFIX and GCOV_PREFIX_STRIP environment variables to set output directory. + If not set, data files (*.gcda) will be generated in /home/abuild/rpmbuild/BUILD/dbus-1.10.6 +6. download generated gcda files from the target to /safe/place +7. put source code *.c files together with object files into a /safe/place +8. run gcov /safe/place/*.o + or gcov -r /safe/place/*.o for only local source code output diff --git a/packaging/dbus.spec b/packaging/dbus.spec index 431fa56d..88500864 100644 --- a/packaging/dbus.spec +++ b/packaging/dbus.spec @@ -2,6 +2,7 @@ %bcond_with kdbus %bcond_with dbuspolicy +%bcond_with coverage Name: dbus Url: http://dbus.freedesktop.org/ @@ -82,6 +83,24 @@ Summary: Package with binaries and data for dbus tests %description tests This package contains installable tests. Tests are compatible with 'dbus-integration-tests' framework. +%if %{with coverage} +%package coverage +Summary: Special version of dbus library for getting coverage analysis + +%description coverage +Special version of dbus library for getting coverage analysis. *.gcda coverage files +are generated on each use of library in directory set by GCOV_PREFIX and GCOV_PREFIX_STRIP. +Use the library by modifying LD_LIBRARY_PATH. +This package is intended for debug/test use only. + +%package coverage-objects +Summary: Generated object files and gcov notes for coverage analysis + +%description coverage-objects +We need to keep objects and gcno files to analyze coverage. +This package is intended for debug/test use only. +%endif + %prep # COMMON2-BEGIN %setup -n dbus-%{version} -q @@ -96,6 +115,47 @@ export CXXFLAGS="${RPM_OPT_FLAGS} -fno-strict-aliasing" export CFLAGS="$CFLAGS -fstack-protector" export CXXFLAGS="$CXXFLAGS -fstack-protector" export V=1 + +# Support for generating separate packages with libraries generating coverage files +# WARNING: if coverage build is enabled, incremental builds will not work correctly. +# Use the option only to generate dbus-coverage packages. +%if %{with coverage} +%reconfigure \ + --disable-static \ + --with-pic \ + --with-dbus-user=dbus \ + --libexecdir=%{_libdir}/%{name} \ + --libdir=%{_libdir} \ + --with-init-scripts=suse \ + --enable-inotify \ + --disable-doxygen-docs \ + --disable-xml-docs \ +%if %{with_systemd} + --enable-systemd \ +%endif +%if %{with kdbus} + --enable-kdbus-transport \ +%if %{with dbuspolicy} + --enable-libdbuspolicy \ +%endif +%endif + --with-system-pid-file=/tmp/dbus_launch \ + --with-console-auth-dir=/var/run/dbus/at_console/ \ + --with-systemdsystemunitdir=%{_unitdir} \ + --enable-smack \ + --enable-cynara \ + --enable-modular-tests \ + --enable-installed-tests \ + --enable-compiler-coverage +make %{?_smp_mflags} +mkdir coverage +cp dbus/.libs/libdbus-1.so.3 coverage +mkdir coverage-objects +find dbus -name '*.o' -exec cp '{}' coverage-objects ';' +find dbus -name '*.gcno' -exec cp '{}' coverage-objects ';' + +%endif + %reconfigure \ --disable-static \ --with-pic \ @@ -163,12 +223,31 @@ install -m 0644 %{SOURCE7} %{buildroot}%{_sysconfdir}/profile.d/dbus.sh rm -rf %{buildroot}%{_datadir}/doc # build test binaries and copy test data -mkdir -p %{buildroot}/usr/lib/dbus-tests/test-suites/dbus-tests/ -mkdir -p %{buildroot}/usr/lib/dbus-tests/runner/ -%__cc %{_builddir}/%{name}-%{version}/test-runner.c -o %{buildroot}/usr/lib/dbus-tests/runner/dbus-tests -cp -fr %{buildroot}%{_libdir}/dbus/installed-tests/dbus/* %{buildroot}/usr/lib/dbus-tests/test-suites/dbus-tests/ -rm -fr %{buildroot}%{_libdir}/dbus/installed-tests/dbus +%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 -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 +%define cov_lib_dir %{buildroot}%{relative_cov_lib_dir} +mkdir -p %{cov_lib_dir} +mkdir -p %{cov_lib_dir}/objects +install -m 0755 coverage/* %{cov_lib_dir} +install -m 0644 coverage-objects/* %{cov_lib_dir}/objects +%endif %pre # Add the "dbus" user and group @@ -248,7 +327,15 @@ rm -fr %{buildroot}/usr/share/installed-tests/dbus %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 +%{relative_cov_lib_dir}/* +%files coverage-objects +%{relative_cov_lib_dir}/objects/* +%endif %changelog diff --git a/test-runner.c b/test-runner.c index 66400c00..a248c641 100644 --- a/test-runner.c +++ b/test-runner.c @@ -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, @@ -87,9 +89,6 @@ char** prepare_args_for_binary(const struct binary* b, const char* test_name); char** prepare_args_for_dir_iter(const struct binary* b, const char* test_name); int init_environment_vars(); -static struct test_case desc_1[] = { - {"", "Simple sanity-check for authentication and authorization."}, {NULL, NULL} -}; static struct test_case desc_2[] = { {"", "Testing DBus ability to iterate over directory contents."}, {NULL, NULL} }; @@ -145,8 +144,6 @@ static struct test_case desc_18[] = { /* This table is used to start binaries */ struct binary tests[] = { /*path, name, TC_table, timeout in us, prepare_args_handler, parse_function_handler, init_handler, clean_handler*/ - {"/usr/lib/dbus-tests/test-suites/dbus-tests/manual-authz", - "manual-authz", desc_1, 1000*1000, prepare_args_for_binary, parse_binary_outputs, init_environment_vars, NULL}, {"/usr/lib/dbus-tests/test-suites/dbus-tests/manual-dir-iter", "manual-dir-iter", desc_2, 1000*1000, prepare_args_for_dir_iter, parse_binary_outputs, init_environment_vars, NULL}, {"/usr/lib/dbus-tests/test-suites/dbus-tests/manual-tcp", @@ -260,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) @@ -317,8 +314,6 @@ static int stdin_pipe[2]; static int stdout_pipe[2]; static int stderr_pipe[2]; static int gravedigger_pipe[2]; -static struct test_result test_results[MAX_TC_NUM]; -static int test_results_i; static char buffer[MAX_BUFFER]; static const char* requested_tc[MAX_TC_NUM]; @@ -616,19 +611,8 @@ static int parse_option(int argc, char* argv[]) void add_test_result(const char* test_id, const char* result, const char* comment, int res) { - test_results[test_results_i].is_positive = res; - strcpy(test_results[test_results_i].result, result); - strcpy(test_results[test_results_i].comment, comment); - strcpy(test_results[test_results_i++].name, test_id); -} - -static void print_results() -{ - int i = 0; - for (i = 0; i < test_results_i; i++) - { - printf("%s;%s;%s\n", test_results[i].name, test_results[i].result, test_results[i].comment); - } + printf("%s;%s;%s\n", test_id, result, comment); + fflush(stdout); } int main(int argc, char* argv[]) @@ -649,6 +633,5 @@ int main(int argc, char* argv[]) } } - print_results(); return 0; } |