Put testing programs in a package. 61/129961/9
authorMichal Bloch <m.bloch@samsung.com>
Thu, 11 May 2017 08:57:50 +0000 (10:57 +0200)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 16 Jun 2017 12:50:14 +0000 (12:50 +0000)
 * testing binaries are now compiled
 * test_pipe.sh renamed to dlog_test_pipe
 * testing environment is now isolated

Change-Id: I4e63ffa741feb61882505af5fe87e8f902072c9d
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
Makefile.am
configs/dlog.conf.test [new file with mode: 0644]
configure.ac
packaging/dlog-tests.manifest [new file with mode: 0644]
packaging/dlog.spec
tests/dlog_test_pipe.in [moved from tests/test_pipe.sh with 97% similarity]
tests/performance_test.c
tests/test_libdlog.c

index bacdb8c..c668b10 100644 (file)
@@ -103,6 +103,44 @@ dlogctrl_SOURCES = \
        src/shared/logcommon.c \
        src/logctrl/logctrl.c
 
+usrlibexeclibdlogdir = /usr/libexec/libdlog
+
+usrlibexeclibdlog_PROGRAMS = test_libdlog
+test_libdlog_CFLAGS = \
+       $(AM_CFLAGS) \
+       -fPIE
+
+test_libdlog_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       -pie
+
+test_libdlog_DEPENDENCIES = \
+       libdlog.la
+
+test_libdlog_LDADD = \
+       libdlog.la
+
+test_libdlog_SOURCES = \
+       tests/test_libdlog.c
+
+usrlibexeclibdlog_PROGRAMS += perf_libdlog
+perf_libdlog_CFLAGS = \
+       $(AM_CFLAGS) \
+       -fPIE
+
+perf_libdlog_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       -pie
+
+perf_libdlog_DEPENDENCIES = \
+       libdlog.la
+
+perf_libdlog_LDADD = \
+       libdlog.la
+
+perf_libdlog_SOURCES = \
+       tests/performance_test.c
+
 TESTS = \
        src/tests/test_ptrs_list \
        src/tests/config \
@@ -157,6 +195,10 @@ usrlibtmpfilesd_DATA = configs/dlog-run.conf
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = dlog.pc
 
+data_DATA = configs/dlog.conf.test
+
+bin_SCRIPTS = dlog_test_pipe
+
 dox::
        doxygen
 
diff --git a/configs/dlog.conf.test b/configs/dlog.conf.test
new file mode 100644 (file)
index 0000000..05ace04
--- /dev/null
@@ -0,0 +1,88 @@
+# Lines starting with # are comments and are ignored.
+# Empty lines are also ignored.
+# Every other line is a config value and has to be in key=value format
+
+backend=pipe
+
+##### Settings used by the logging library
+
+# Platform logging. Whether logging happens at all.
+plog=1
+
+# Debugmode - whether write platform debug log or not
+debugmode=1
+
+# Limiter - whether it's enabled and the rules (check the documentation for how to create rules).
+limiter=0
+limiter|*|*=allow
+
+##### Settings used by the logging daemon
+
+# Sockets that all programs connect to to receive a logging pipe.
+main_write_sock=/tmp/dlog_tests/main.wr
+apps_write_sock=/tmp/dlog_tests/apps.wr
+system_write_sock=/tmp/dlog_tests/system.wr
+radio_write_sock=/tmp/dlog_tests/radio.wr
+kmsg_write_sock=/tmp/dlog_tests/kmsg.wr
+syslog_write_sock=/tmp/dlog_tests/syslog.wr
+
+# Sockets that administrative programs connect to to manipulate the daemon.
+main_ctl_sock=/tmp/dlog_tests/main.ctl
+apps_ctl_sock=/tmp/dlog_tests/apps.ctl
+system_ctl_sock=/tmp/dlog_tests/system.ctl
+radio_ctl_sock=/tmp/dlog_tests/radio.ctl
+kmsg_ctl_sock=/tmp/dlog_tests/kmsg.ctl
+syslog_ctl_sock=/tmp/dlog_tests/syslog.ctl
+
+# Permissions for the relevant sockets.
+main_write_sock_rights=0222
+apps_write_sock_rights=0222
+system_write_sock_rights=0222
+radio_write_sock_rights=0222
+kmsg_write_sock_rights=0222
+syslog_write_sock_rights=0222
+
+main_ctl_sock_rights=0222
+apps_ctl_sock_rights=0222
+system_ctl_sock_rights=0222
+radio_ctl_sock_rights=0222
+kmsg_ctl_sock_rights=0222
+syslog_ctl_sock_rights=0222
+
+main_write_sock_owner=log
+apps_write_sock_owner=log
+system_write_sock_owner=log
+radio_write_sock_owner=log
+kmsg_write_sock_owner=log
+syslog_write_sock_owner=log
+
+main_ctl_sock_owner=log
+apps_ctl_sock_owner=log
+system_ctl_sock_owner=log
+radio_ctl_sock_owner=log
+kmsg_ctl_sock_owner=log
+syslog_ctl_sock_owner=log
+
+main_write_sock_group=log
+apps_write_sock_group=log
+system_write_sock_group=log
+radio_write_sock_group=log
+kmsg_write_sock_group=log
+syslog_write_sock_group=log
+
+main_ctl_sock_group=log
+apps_ctl_sock_group=log
+system_ctl_sock_group=log
+radio_ctl_sock_group=log
+kmsg_ctl_sock_group=log
+syslog_ctl_sock_group=log
+
+main_size=1048576
+apps_size=1048576
+system_size=1048576
+radio_size=1048576
+kmsg_size=1048576
+syslog_size=1048576
+
+util_sorting_time_window=5000
+util_sorting_buffer_size=32000
index 8717157..4d8e0c2 100644 (file)
@@ -41,5 +41,8 @@ PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd])
 AC_SUBST(TZ_SYS_ETC)
 
 # output files
-AC_CONFIG_FILES([Makefile dlog.pc])
+AC_SUBST([datadir])
+AC_SUBST([libexecdir])
+AC_CONFIG_FILES([Makefile dlog.pc]
+                [dlog_test_pipe:tests/dlog_test_pipe.in])
 AC_OUTPUT
diff --git a/packaging/dlog-tests.manifest b/packaging/dlog-tests.manifest
new file mode 100644 (file)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
index dec3973..3222666 100644 (file)
@@ -7,7 +7,8 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source101:  packaging/dlogutil.manifest
 Source102:  packaging/libdlog.manifest
-Source104:     packaging/dlogbackend-logger.manifest
+Source103:  packaging/dlog-tests.manifest
+Source104:  packaging/dlogbackend-logger.manifest
 Source301:  packaging/dlog_logger.service
 Source302:  packaging/dlog_logger.path
 Source501:  packaging/01-dlog.rules
@@ -83,6 +84,12 @@ BuildRequires: doxygen
 %description -n dlog-doc
 Documentation for dlog
 
+%package -n dlog-tests
+Summary: dlog integration tests
+
+%description -n dlog-tests
+Integration tests for dlog.
+
 %prep
 %setup -q
 
@@ -90,7 +97,9 @@ Documentation for dlog
 
 cp %{SOURCE101} .
 cp %{SOURCE102} .
+cp %{SOURCE103} .
 cp %{SOURCE104} .
+
 %autogen --disable-static
 %configure --disable-static \
                        TZ_SYS_ETC=%{TZ_SYS_ETC}
@@ -107,7 +116,6 @@ rm -rf %{buildroot}
 %make_install
 mkdir -p %{buildroot}/usr/bin/
 
-
 mkdir -p %{buildroot}/usr/share/doc/dlog
 cp -r documentation/* %{buildroot}/usr/share/doc/dlog
 
@@ -215,3 +223,10 @@ ln %{upgrade_file_path}/data/dlog.conf.pipe %{upgrade_file_path}/data/dlog.conf
 
 %files -n dlog-doc
 /usr/share/doc/dlog
+
+%files -n dlog-tests
+%manifest dlog-tests.manifest
+%{_bindir}/dlog_test_pipe
+%{_libexecdir}/libdlog/perf_libdlog
+%{_libexecdir}/libdlog/test_libdlog
+%{_datadir}/dlog.conf.test
similarity index 97%
rename from tests/test_pipe.sh
rename to tests/dlog_test_pipe.in
index 25a8a4c..5217a81 100755 (executable)
@@ -17,6 +17,11 @@ ok(){
        echo "#$TOTAL: PASSED"
 }
 
+export DLOG_CONFIG_PATH="@datadir@/dlog.conf.test"
+PATH=$PATH:@libexecdir@/libdlog/
+
+mkdir /tmp/dlog_tests
+
 # dlogctrl (tests 1-10)
 dlogctrl                                             &> /dev/null && ok || fail # no args (display help)
 dlogctrl -g                                          &> /dev/null && fail || ok # no -pk
@@ -71,7 +76,6 @@ if [ $(dlogutil -s -d | wc -l) -eq 0 ]; then ok; else fail; fi
 dlogutil -g &> /dev/null && ok || fail
 
 # 30-37: test -f, -r and -n
-mkdir /tmp/dlog_tests
 dlogutil -f /tmp/dlog_tests/dlog_test_file -d &> /dev/null && ok || fail
 dlogutil -f /tmp/dlog_tests/dlog_rotating_file -r 12 -n 3 & # 3 files at 12 KB each
 UTIL_PID=$!
index bb6ce96..d6c2453 100644 (file)
@@ -6,7 +6,7 @@
 #include <pthread.h>
 #include <time.h>
 
-#include <dlog/dlog.h>
+#include <dlog.h>
 
 #define THREADS 50
 #define LOGS_PER_THREAD 1000
@@ -24,6 +24,8 @@ void *func(void *data)
                RLOGE("test");
                ALOGE("test");
        }
+
+       return NULL;
 }
 
 int main(int argc, char **argv)
index 7cd8ae2..7e25fcc 100644 (file)
@@ -15,6 +15,7 @@ void *func(void *data)
        for (i = 0; i < 10000; ++i)
                LOGE("Multithreading test %d", i);
 
+       return NULL;
 }
 
 int main(int argc, char **argv)