packaging: Allow disabling dynamic filtering in resulting package 95/197995/5
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 17 Jan 2019 13:03:01 +0000 (14:03 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Tue, 22 Jan 2019 15:59:04 +0000 (16:59 +0100)
Unwanted feature will be disableable via _with_dynamic_filtering
rpm's compile time option.

Change-Id: Icce63a9a62a1aa9f7a1778d5be359b89116371ef

configure.ac
packaging/dlog.spec
tests/dlog_test.in

index 2f763f4..f5c7742 100644 (file)
@@ -59,6 +59,16 @@ if test x$android_monotonic = xtrue; then
        AC_DEFINE_UNQUOTED([USE_ANDROID_MONOTONIC])
 fi
 
+AC_ARG_ENABLE([dynamic-filters],
+        AS_HELP_STRING([--disable-dynamic-filters], [remove dynamic frontend filters feature and dlogctl tool]),
+        [dynamic-filters=false],
+        [dynamic-filters=true])
+if test "${enable_dynamic_filters}" = "yes"; then
+       AC_SUBST(DYNAMIC_FILTERS, "true")
+else
+       AC_SUBST(DYNAMIC_FILTERS, "false")
+fi
+
 # output files
 AC_SUBST([datadir])
 AC_SUBST([libexecdir])
index 5153782..cdb4bbb 100644 (file)
@@ -1,3 +1,6 @@
+%define _with_dlog_dynamic_filters on
+%bcond_with dlog_dynamic_filters
+
 Name:       dlog
 Summary:    Logging service
 Version:    5.5.1
@@ -102,7 +105,13 @@ Integration tests for dlog.
 cp %{SOURCE101} .
 
 %autogen --disable-static
-%configure --disable-static
+%configure --disable-static \
+%if %{without dlog_dynamic_filters}
+--disable-dynamic-filters
+%else
+--enable-dynamic-filters
+%endif
+
 make %{?jobs:-j%jobs} CFLAGS+='-D__DLOG_VERSION=\"%{version}\" -D__DLOG_RELEASE=\"%{release}\"'
 
 # autoconf adds a bunch of flags, including -O2.
@@ -136,6 +145,11 @@ mkdir -p %{buildroot}/var/log/dlog
 mkdir -p %{buildroot}/var/lib/dlog-tests
 mkdir -p %{buildroot}/usr/share/dlog-filters.conf.test
 
+%if %{without dlog_dynamic_filters}
+rm -f %{buildroot}%{_bindir}/dlogctl
+sed -i -e 's,^\(dynamic_config_path=\),#\1,g' -e 's,^\(limiter_apply_to_all_buffers=\),#\1,g' %{buildroot}%{_sysconfdir}/dlog.conf
+%endif
+
 install -D scripts/210.dlog_upgrade_30to40.sh %{buildroot}/%{upgrade_file_path}/scripts/210.dlog_upgrade.sh
 
 %files -n dlogutil
@@ -143,10 +157,14 @@ install -D scripts/210.dlog_upgrade_30to40.sh %{buildroot}/%{upgrade_file_path}/
 %license LICENSE.APACHE2.0 LICENSE.MIT
 %attr(750,log,log) %{_bindir}/dlogutil
 %attr(755,log,log) %{_bindir}/dlogsend
+%if %{with dlog_dynamic_filters}
 %attr(750,log,log) %{_bindir}/dlogctl
+%endif
 
 %post -n dlogutil
+%if %{with dlog_dynamic_filters}
 chsmack %{_bindir}/dlogctl -a "System::Tools"
+%endif
 
 %files -n libdlog
 %manifest dlog.manifest
index 0ee8c7c..9582f1f 100644 (file)
@@ -11,6 +11,7 @@ UTIL_PID=-1
 MT_TEST=-1
 LOGGER=-1
 
+TEST_DYNAMIC_FILTERS="@DYNAMIC_FILTERS@"
 TESTDIR=/var/lib/dlog-tests
 
 extract_timestamp() {
@@ -121,138 +122,139 @@ if [ $type == "pipe" ]; then
        sleep 1
 fi
 
-dlogctl -c
-dlogctl --enable
-dlogutil -c -b radio -b system -b main
-
-LOG_DETAILS="dlogctl --disable (no args)"
-dlogctl --disable
-[ `dlogctl -g | grep ENABLED | wc -l` -eq 0 ] && ok || fail
-LOG_DETAILS="testing if filters were applied"
-dlogsend -b system -t TEST test
-dlogsend -b main -t TEST test
-dlogsend -b radio -t TEST test
-[ `dlogutil -d -b radio -b system -b main | wc -l` -eq 0 ] && ok || fail
-
-LOG_DETAILS="dlogctl --enable (no args)"
-dlogctl --enable
-[ `dlogctl -g | grep DISABLED | wc -l` -eq 0 ] && ok || fail
-LOG_DETAILS="testing if filters were applied"
-dlogutil -c -b radio -b system -b main
-dlogsend -b system -t TEST test
-dlogsend -b main -t TEST test
-dlogsend -b radio -t TEST test
-[ `dlogutil -d -b radio -b system -b main | wc -l` -eq 3 ] && ok || fail
-
-LOG_DETAILS="dlogctl --disable (1 arg)"
-dlogctl --disable -b system
-[ `dlogctl -g | grep DISABLED | grep system | wc -l` -eq 1 ] &&
-[ `dlogctl -g | grep DISABLED               | wc -l` -eq 1 ] && ok || fail
-LOG_DETAILS="testing if filters were applied"
-dlogutil -c -b radio -b system -b main
-dlogsend -b system -t TEST test
-dlogsend -b main -t TEST test
-dlogsend -b radio -t TEST test
-[ `dlogutil -d -b radio -b system -b main | wc -l` -eq 2 ] && ok || fail
-
-LOG_DETAILS="dlogctl --disable (multiple args)"
-dlogctl --disable -b main -b radio
-[ `dlogctl -g | grep DISABLED | grep -v system | wc -l` -eq 2 ] &&
-[ `dlogctl -g | grep DISABLED | grep     radio | wc -l` -eq 1 ] &&
-[ `dlogctl -g | grep DISABLED | grep      main | wc -l` -eq 1 ] && ok || fail
-LOG_DETAILS="testing if filters were applied"
-dlogutil -c -b radio -b system -b main
-dlogsend -b system -t TEST test
-dlogsend -b main -t TEST test
-dlogsend -b radio -t TEST test
-[ `dlogutil -d -b radio -b system -b main | wc -l` -eq 0 ] && ok || fail
-
-LOG_DETAILS="dlogctl --enable (multiple args)"
-dlogctl --enable -b radio -b system
-[ `dlogctl -g | grep DISABLED               | wc -l` -eq 1 ] &&
-[ `dlogctl -g | grep DISABLED | grep   main | wc -l` -eq 1 ] &&
-[ `dlogctl -g | grep  ENABLED | grep system | wc -l` -eq 1 ] &&
-[ `dlogctl -g | grep  ENABLED | grep  radio | wc -l` -eq 1 ] && ok || fail
-LOG_DETAILS="testing if filters were applied"
-dlogutil -c -b radio -b system -b main
-dlogsend -b system -t TEST test
-dlogsend -b main -t TEST test
-dlogsend -b radio -t TEST test
-[ `dlogutil -d -b radio -b system -b main | wc -l` -eq 2 ] && ok || fail
-
-LOG_DETAILS="dlogctl --enable (1 arg)"
-dlogctl --enable -b main
-[ `dlogctl -g | grep DISABLED | wc -l` -eq 0 ] && ok || fail
-LOG_DETAILS="testing if filters were applied"
-dlogutil -c -b radio -b system -b main
-dlogsend -b system -t TEST test
-dlogsend -b main -t TEST test
-dlogsend -b radio -t TEST test
-[ `dlogutil -d -b radio -b system -b main | wc -l` -eq 3 ] && ok || fail
-
-LOG_DETAILS="dlogctl -s allow"
-dlogutil -c -b radio -b system -b main
-dlogctl -c
-dlogctl -s deny
-dlogctl -t TEST_TAG -s allow
-dlogsend -b main -t TEST_TAG test
-dlogsend -b main -t TEST test
-[ `dlogutil -d -b main | wc -l` -eq 1 ] && ok || fail
-
-LOG_DETAILS="dlogctl -s [N]"
-dlogutil -c -b radio -b system -b main
-dlogctl -c
-dlogctl -s deny
-dlogctl -t TEST_TAG -s 3
-dlogsend -b main -c 10 -t TEST_TAG test
-dlogsend -b main -c 10 -t TEST test
-[ `dlogutil -d -b main | wc -l` -eq 4 ] && ok || fail
-
-LOG_DETAILS="testing invalid parameters for dlogctl (1/13)"
-dlogctl -s invalid &> /dev/null && fail || ok
-
-LOG_DETAILS="testing invalid parameters for dlogctl (2/13)"
-dlogctl -p X -g &> /dev/null && fail || ok
-
-LOG_DETAILS="testing invalid parameters for dlogctl (3/13)"
-dlogctl -b invalid --disable &> /dev/null && fail || ok
-
-LOG_DETAILS="testing invalid parameters for dlogctl (4/13)"
-dlogctl -s allow -g -t xyz -p E &> /dev/null && fail || ok
-
-LOG_DETAILS="testing invalid parameters for dlogctl (5/13)"
-dlogctl -s allow -c &> /dev/null && fail || ok
-
-LOG_DETAILS="testing invalid parameters for dlogctl (6/13)"
-dlogctl -c -g -t xyz -p E &> /dev/null && fail || ok
-
-# -s out of range
-LOG_DETAILS="testing invalid parameters for dlogctl (7/13)"
-dlogctl -s -10 &> /dev/null && fail || ok
-
-LOG_DETAILS="testing invalid parameters for dlogctl (8/13)"
-dlogctl -s 999999 &> /dev/null && fail || ok
-
-# -s correctness
-LOG_DETAILS="testing invalid parameters for dlogctl (9/13)"
-dlogctl -s 100 && ok || fail
-
-LOG_DETAILS="testing invalid parameters for dlogctl (10/13)"
-[ `cat $RUNTIME_FILTERS_DIR/FILTERS | grep -E 'limiter\|\*\|\*=100' | wc -l` -eq 1 ] && ok || fail
-
-# -g correctness
-LOG_DETAILS="testing invalid parameters for dlogctl (11/13)"
-[ `dlogctl -g | grep '*:*' | grep 100 | wc -l` -eq 1 ] && ok || fail
-
-# -c correctness
-LOG_DETAILS="testing invalid parameters for dlogctl (12/13)"
-dlogctl -c -t '*' -p '*' && ok || fail
-
-LOG_DETAILS="testing invalid parameters for dlogctl (13/13)"
-[ `cat $RUNTIME_FILTERS_DIR/FILTERS | grep -E 'limiter\|\*\|\*=100' | wc -l` -eq 0 ] && ok || fail
+if [ "$TEST_DYNAMIC_FILTERS" == "true" ]; then
+       dlogctl -c
+       dlogctl --enable
+       dlogutil -c -b radio -b system -b main
+       LOG_DETAILS="dlogctl --disable (no args)"
+       dlogctl --disable
+       [ `dlogctl -g | grep ENABLED | wc -l` -eq 0 ] && ok || fail
+       LOG_DETAILS="testing if filters were applied"
+       dlogsend -b system -t TEST test
+       dlogsend -b main -t TEST test
+       dlogsend -b radio -t TEST test
+       [ `dlogutil -d -b radio -b system -b main | wc -l` -eq 0 ] && ok || fail
+
+       LOG_DETAILS="dlogctl --enable (no args)"
+       dlogctl --enable
+       [ `dlogctl -g | grep DISABLED | wc -l` -eq 0 ] && ok || fail
+       LOG_DETAILS="testing if filters were applied"
+       dlogutil -c -b radio -b system -b main
+       dlogsend -b system -t TEST test
+       dlogsend -b main -t TEST test
+       dlogsend -b radio -t TEST test
+       [ `dlogutil -d -b radio -b system -b main | wc -l` -eq 3 ] && ok || fail
+
+       LOG_DETAILS="dlogctl --disable (1 arg)"
+       dlogctl --disable -b system
+       [ `dlogctl -g | grep DISABLED | grep system | wc -l` -eq 1 ] &&
+       [ `dlogctl -g | grep DISABLED               | wc -l` -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if filters were applied"
+       dlogutil -c -b radio -b system -b main
+       dlogsend -b system -t TEST test
+       dlogsend -b main -t TEST test
+       dlogsend -b radio -t TEST test
+       [ `dlogutil -d -b radio -b system -b main | wc -l` -eq 2 ] && ok || fail
+
+       LOG_DETAILS="dlogctl --disable (multiple args)"
+       dlogctl --disable -b main -b radio
+       [ `dlogctl -g | grep DISABLED | grep -v system | wc -l` -eq 2 ] &&
+       [ `dlogctl -g | grep DISABLED | grep     radio | wc -l` -eq 1 ] &&
+       [ `dlogctl -g | grep DISABLED | grep      main | wc -l` -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if filters were applied"
+       dlogutil -c -b radio -b system -b main
+       dlogsend -b system -t TEST test
+       dlogsend -b main -t TEST test
+       dlogsend -b radio -t TEST test
+       [ `dlogutil -d -b radio -b system -b main | wc -l` -eq 0 ] && ok || fail
+
+       LOG_DETAILS="dlogctl --enable (multiple args)"
+       dlogctl --enable -b radio -b system
+       [ `dlogctl -g | grep DISABLED               | wc -l` -eq 1 ] &&
+       [ `dlogctl -g | grep DISABLED | grep   main | wc -l` -eq 1 ] &&
+       [ `dlogctl -g | grep  ENABLED | grep system | wc -l` -eq 1 ] &&
+       [ `dlogctl -g | grep  ENABLED | grep  radio | wc -l` -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if filters were applied"
+       dlogutil -c -b radio -b system -b main
+       dlogsend -b system -t TEST test
+       dlogsend -b main -t TEST test
+       dlogsend -b radio -t TEST test
+       [ `dlogutil -d -b radio -b system -b main | wc -l` -eq 2 ] && ok || fail
+
+       LOG_DETAILS="dlogctl --enable (1 arg)"
+       dlogctl --enable -b main
+       [ `dlogctl -g | grep DISABLED | wc -l` -eq 0 ] && ok || fail
+       LOG_DETAILS="testing if filters were applied"
+       dlogutil -c -b radio -b system -b main
+       dlogsend -b system -t TEST test
+       dlogsend -b main -t TEST test
+       dlogsend -b radio -t TEST test
+       [ `dlogutil -d -b radio -b system -b main | wc -l` -eq 3 ] && ok || fail
+
+       LOG_DETAILS="dlogctl -s allow"
+       dlogutil -c -b radio -b system -b main
+       dlogctl -c
+       dlogctl -s deny
+       dlogctl -t TEST_TAG -s allow
+       dlogsend -b main -t TEST_TAG test
+       dlogsend -b main -t TEST test
+       [ `dlogutil -d -b main | wc -l` -eq 1 ] && ok || fail
+
+       LOG_DETAILS="dlogctl -s [N]"
+       dlogutil -c -b radio -b system -b main
+       dlogctl -c
+       dlogctl -s deny
+       dlogctl -t TEST_TAG -s 3
+       dlogsend -b main -c 10 -t TEST_TAG test
+       dlogsend -b main -c 10 -t TEST test
+       [ `dlogutil -d -b main | wc -l` -eq 4 ] && ok || fail
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (1/13)"
+       dlogctl -s invalid &> /dev/null && fail || ok
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (2/13)"
+       dlogctl -p X -g &> /dev/null && fail || ok
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (3/13)"
+       dlogctl -b invalid --disable &> /dev/null && fail || ok
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (4/13)"
+       dlogctl -s allow -g -t xyz -p E &> /dev/null && fail || ok
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (5/13)"
+       dlogctl -s allow -c &> /dev/null && fail || ok
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (6/13)"
+       dlogctl -c -g -t xyz -p E &> /dev/null && fail || ok
+
+       # -s out of range
+       LOG_DETAILS="testing invalid parameters for dlogctl (7/13)"
+       dlogctl -s -10 &> /dev/null && fail || ok
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (8/13)"
+       dlogctl -s 999999 &> /dev/null && fail || ok
+
+       # -s correctness
+       LOG_DETAILS="testing invalid parameters for dlogctl (9/13)"
+       dlogctl -s 100 && ok || fail
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (10/13)"
+       [ `cat $RUNTIME_FILTERS_DIR/FILTERS | grep -E 'limiter\|\*\|\*=100' | wc -l` -eq 1 ] && ok || fail
+
+       # -g correctness
+       LOG_DETAILS="testing invalid parameters for dlogctl (11/13)"
+       [ `dlogctl -g | grep '*:*' | grep 100 | wc -l` -eq 1 ] && ok || fail
+
+       # -c correctness
+       LOG_DETAILS="testing invalid parameters for dlogctl (12/13)"
+       dlogctl -c -t '*' -p '*' && ok || fail
+
+       LOG_DETAILS="testing invalid parameters for dlogctl (13/13)"
+       [ `cat $RUNTIME_FILTERS_DIR/FILTERS | grep -E 'limiter\|\*\|\*=100' | wc -l` -eq 0 ] && ok || fail
+       dlogctl -c
+fi
 
 # put 100 log entries in the "main" buffer
-dlogctl -c
 dlogutil -c
 test_libdlog 100
 sleep 1
@@ -415,14 +417,16 @@ sleep 1
 line=`dlogutil -v raw -d --tid $!` #dlogsend is a single threaded app so tid is the same as pid
 [[ "$line" == "tidTEST" ]] && ok || fail
 
-LOG_DETAILS="testing if limiter and runtime filtering works"
-dlogutil -c -b radio
-test_filters
-[ $(dlogutil -d -b radio | wc -l) -eq 12 ] && ok || fail
+if [ "$TEST_DYNAMIC_FILTERS" == "true" ]; then
+       LOG_DETAILS="testing if limiter and runtime filtering works"
+       dlogutil -c -b radio
+       test_filters
+       [ $(dlogutil -d -b radio | wc -l) -eq 12 ] && ok || fail
 
-LOG_DETAILS="testing proper SMACK label for dynamic config file location"
-ORIG_FILTERS_DIR=$(cat $ORIGINAL_CONFIG_PATH | grep dynamic_config_path | awk -F "=" '{print $2}')
-[ $(ls -dZ $ORIG_FILTERS_DIR | awk -F " " '{print $1}') == "System::Shared" ] && ok || fail
+       LOG_DETAILS="testing proper SMACK label for dynamic config file location"
+       ORIG_FILTERS_DIR=$(cat $ORIGINAL_CONFIG_PATH | grep dynamic_config_path | awk -F "=" '{print $2}')
+       [ $(ls -dZ $ORIG_FILTERS_DIR | awk -F " " '{print $1}') == "System::Shared" ] && ok || fail
+fi
 
 LOG_DETAILS="testing if the library works with multithreaded app"
 dlogutil -f $TESTDIR/dlog_mt_test &