tests: zlogger nominally runs the daemon
[platform/core/system/dlog.git] / tests / dlog_test.in
index 10e4f00..bb4b3f0 100644 (file)
@@ -5,94 +5,11 @@
 # the ok function will never fail.
 # shellcheck disable=SC2015
 
-# stuff for tracking test case counts
-FAILS=0
-OKS=0
-TOTAL=0
-LOG_DETAILS=
-
-#relevant pids default vals
-UTIL_PID=-1
-DLOGSEND_PID=-1
-MT_TEST=-1
-LOGGER=-1
-
-TEST_DYNAMIC_FILTERS="@DYNAMIC_FILTERS@"
-TESTDIR=/var/lib/dlog-tests
-
-extract_timestamp() {
-       ts=0
-       case "$1" in
-               "threadtime")
-                       time=$(echo "$2" | awk -F '[ +]' '{print $2}')
-                       ts=$(date +%s%N -d "$time")
-               ;;
-               "long")
-                       time=$(echo "$2" | awk -F '[ +.]' '{print $3}')
-                       ms=$(echo "$2" | awk -F '[ +.]' '{print $4}')
-                       sec=$(date +%s%N -d "$time")
-                       ns=$((10#$ms * 1000000))
-                       ts=$((sec + ns))
-               ;;
-               "rwtime")
-                       time=$(echo "$2" | awk -F '[ +.]' '{print $2}')
-                       ts=$(date +%s%N -d "$time")
-               ;;
-               "recv_realtime")
-                       time=$(echo "$2" | awk -F '[ +.]' '{print $2}')
-                       ts=$(date +%s%N -d "$time")
-               ;;
-               "time")
-                       time=$(echo "$2" | awk -F '[ +.]' '{print $2}')
-                       ts=$(date +%s%N -d "$time")
-               ;;
-               "kerneltime")
-                       ts=$(echo "$2" | awk -F '[ +]' '{print $1}' | sed -e 's/\.//g')
-               ;;
-       esac
-       echo "$ts"
-}
-
-cleanup() {
-       [ "$UTIL_PID" -ne -1 ] && kill "$UTIL_PID" > /dev/null 2>&1
-       [ "$MT_TEST"  -ne -1 ] && kill "$MT_TEST"  > /dev/null 2>&1
-       [ "$LOGGER"   -ne -1 ] && kill "$LOGGER"   > /dev/null 2>&1
-       # Shellcheck doesn't like this because the rm call is bad if $TESTDIR is empty.
-       # However, such cases would be caught by the conditional.
-       # shellcheck disable=SC2115
-       [ -d "$TESTDIR" ] && rm -rf "$TESTDIR"/*
-       [ -d "$RUNTIME_FILTERS_DIR" ] && rm -rf "$RUNTIME_FILTERS_DIR"
-}
+source dlog_test_header
 
 trap cleanup 0
 
-check_daemon() {
-       ret=1
-       if [ "$LOGGER" -ne -1 ] && [ -z "$(ps -o pid= -p "$LOGGER")" ]; then
-               ret=0
-       fi
-       return "$ret"
-}
-
-fail() {
-       check_daemon && daemon_status="[logger daemon not running]"
-
-       FAILS=$((FAILS + 1))
-       TOTAL=$((TOTAL + 1))
-       printf "[%02d] FAILED: %s %s\n" "$TOTAL" "$LOG_DETAILS" "$daemon_status"
-       LOG_DETAILS=
-}
-
-ok() {
-       check_daemon && daemon_status="[logger daemon not running]"
-
-       OKS=$((OKS + 1))
-       TOTAL=$((TOTAL + 1))
-       printf "[%02d] PASSED: %s %s\n" "$TOTAL" "$LOG_DETAILS" "$daemon_status"
-       LOG_DETAILS=
-}
-
-USAGE_MESSAGE="usage: $0 [--verbose] [--quick] pipe|logger"
+USAGE_MESSAGE="usage: $0 [--verbose] [--quick] pipe|logger|zero-copy"
 
 OPTS=$(getopt --shell sh --options "" --long verbose,quick --quiet -- "$@")
 if [ "$?" -eq 1 ]; then
@@ -170,50 +87,9 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
        RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
        mkdir -m 777 -p "$RUNTIME_FILTERS_DIR"
 
-       PREEARLYQUIT_CONFIG_PATH="$DLOG_CONFIG_PATH"
-       DLOG_CONFIG_PATH="$TESTDIR/earlyquit.conf"
        if [ "$quick" -ne 1 ]; then
-               for PERSISTENT in 1 0; do
-               for KMSG in 1 0; do
-               for SYSLOG in 1 0; do
-               for QOS in 1 0; do
-                       # TODO: Does syslog even work? Disabling for now.
-                       [ "$SYSLOG" -eq 1 ] && continue
-
-                       if [ "$QOS" -eq 1 ]; then
-                               SOURCE="@datadir@/dlog-$type.conf.qos"
-                       else
-                               SOURCE="@datadir@/dlog-$type.conf.test"
-                       fi
-
-                       if [ "$PERSISTENT" -eq 1 ]; then
-                               cp "$SOURCE" "$DLOG_CONFIG_PATH"
-                       else
-                               sed 's/^dlog_logger_conf.*$/#\0/' <"$SOURCE" >"$DLOG_CONFIG_PATH"
-                       fi
-
-                       echo "handle_kmsg=$KMSG" >> "$DLOG_CONFIG_PATH"
-                       echo "syslog_force=$SYSLOG" >> "$DLOG_CONFIG_PATH"
-
-                       dlog_logger -t 0 &
-                       LOGGER=$!
-                       sleep 1
-
-                       kill $LOGGER > /dev/null
-                       STOPPED=$?
-                       LOGGER=-1
-
-                       if [ "$PERSISTENT" -eq 0 ] && [ "$KMSG" -eq 0 ] && [ "$SYSLOG" -eq 0 ] && [ "$QOS" -eq 0 ] && [ "$type" = "logger" ]; then
-                               EXPECTED=1
-                       else
-                               EXPECTED=0
-                       fi
-
-                       LOG_DETAILS="testing if daemon stops when not needed (persistent=$PERSISTENT, kmsg=$KMSG, syslog=$SYSLOG, qos=$QOS)"
-                       [ "$STOPPED" -eq "$EXPECTED" ] && ok || fail
-               done; done; done; done
+               dlog_test_daemon_early_quit $type
        fi
-       DLOG_CONFIG_PATH="$PREEARLYQUIT_CONFIG_PATH"
 
        # Start the daemon
        dlog_logger -t 0 &
@@ -224,9 +100,21 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
                dlogctl -c
                dlogctl --enable
                dlogutil -c -b radio -b system -b main
-               LOG_DETAILS="dlogctl --disable (no args)"
+               LOG_DETAILS="dlogctl --disable (no args, limiter_apply_to_all_buffers=0)"
                dlogctl --disable
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: ENABLED')" -eq 0 ] && ok || fail
+
+               # without 'limiter_apply_to_all_buffers=1' this
+               # only applies to the three platform buffers:
+               # main, radio, and system
+               PREPLOG_CONFIG_PATH="$DLOG_CONFIG_PATH"
+               DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.plog"
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED)" -eq 3 ] && ok || fail
+               DLOG_CONFIG_PATH="$PREPLOG_CONFIG_PATH"
+
+               LOG_DETAILS="dlogctl --disable (no args, limiter_apply_to_all_buffers=1)"
+               dlogctl --disable
+               [ "$(dlogctl -g | grep regular | grep -c ENABLED)" -eq 0 ] && ok || fail
+
                LOG_DETAILS="testing if filters were applied"
                dlogsend -b system -t TEST test
                dlogsend -b main -t TEST test
@@ -235,7 +123,7 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --enable (no args)"
                dlogctl --enable
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED')" -eq 0 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED)" -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
@@ -245,8 +133,8 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --disable (1 arg)"
                dlogctl --disable -b system
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: DISABLED' | grep -c system)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED'                 )" -eq 1 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep    DISABLED | grep -c system)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED                 )" -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
@@ -256,9 +144,9 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --disable (multiple args)"
                dlogctl --disable -b main -b radio
-               [ "$(dlogctl -g | grep '^\* [a-z]*: DISABLED' | grep -cv system)" -eq 2 ] &&
-               [ "$(dlogctl -g | grep '^\* [a-z]*: DISABLED' | grep -c   radio)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep '^\* [a-z]*: DISABLED' | grep -c    main)" -eq 1 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep DISABLED | grep -cv system)" -eq 2 ] &&
+               [ "$(dlogctl -g | grep regular | grep DISABLED | grep -c   radio)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep DISABLED | grep -c    main)" -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
@@ -268,10 +156,10 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --enable (multiple args)"
                dlogctl --enable -b radio -b system
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED'                 )" -eq 1 ] &&
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: DISABLED' | grep -c   main)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: ENABLED'  | grep -c system)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: ENABLED'  | grep -c  radio)" -eq 1 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED                 )" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep    DISABLED | grep -c   main)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep     ENABLED | grep -c system)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep     ENABLED | grep -c  radio)" -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
@@ -281,7 +169,7 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --enable (1 arg)"
                dlogctl --enable -b main
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED')" -eq 0 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED)" -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
@@ -382,6 +270,73 @@ if [ "$type" = "pipe" ] && [ "$quick" -ne 1 ]; then
        [ "$(dlogutil -d DLOGSEND_SIGPIPE_TEST | wc -l)" -eq 2 ] && ok || fail
 fi
 
+dlogutil -c
+
+LOG_DETAILS="testing if dlogutil rejects dotnet"
+dlogutil -db dotnet_api && fail || ok
+
+LOG_DETAILS="testing if dlogutil rejects native"
+dlogutil -db native_api && fail || ok
+
+LOG_DETAILS="testing if dotnet redirects to regular apps (1/2)"
+dlogsend -b dotnet_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 1 ] && ok || fail
+
+LOG_DETAILS="testing if dotnet redirects to regular apps (2/2)"
+dlogsend -c 6 -b dotnet_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 7 ] && ok || fail
+
+LOG_DETAILS="testing if native redirects to regular apps (1/2)"
+dlogsend -b native_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 8 ] && ok || fail
+
+LOG_DETAILS="testing if native redirects to regular apps (2/2)"
+dlogsend -c 6 -b native_api "TEST"
+sleep 0.25
+[ "$(dlogutil -d -b apps | wc -l)" -eq 14 ] && ok || fail
+
+if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
+       dlogutil -c
+       LOG_DETAILS="testing if blocking dotnet and regular apps is separate (1/4)"
+       dlogctl -b apps --enable
+       dlogctl -b dotnet_api --disable
+       dlogsend -b dotnet_api "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 0 ] && ok || fail
+       LOG_DETAILS="testing if blocking dotnet and regular apps is separate (2/4)"
+       dlogsend -b apps "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if blocking dotnet and regular apps is separate (3/4)"
+       dlogctl -b apps --disable
+       dlogctl -b dotnet_api --enable
+       dlogsend -b dotnet_api "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+       LOG_DETAILS="testing if blocking dotnet and regular apps is separate (4/4)"
+       dlogsend -b apps "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+
+
+       dlogutil -c
+       LOG_DETAILS="testing if blocking native and regular apps is separate (1/4)"
+       dlogctl -b apps --enable
+       dlogctl -b native_api --disable
+       dlogsend -b native_api "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 0 ] && ok || fail
+       LOG_DETAILS="testing if blocking native and regular apps is separate (2/4)"
+       dlogsend -b apps "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if blocking native and regular apps is separate (3/4)"
+       dlogctl -b apps --disable
+       dlogctl -b native_api --enable
+       dlogsend -b native_api "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+       LOG_DETAILS="testing if blocking native and regular apps is separate (4/4)"
+       dlogsend -b apps "TEST"
+       [ "$(dlogutil -d -b apps | wc -l)" -eq 2 ] && ok || fail
+fi
+
 # put 100 log entries in the "main" buffer
 dlogutil -c
 test_libdlog 100
@@ -682,9 +637,9 @@ line=$($cmd_prefix $format)
 
 format="json"
 if [ "$type" = "pipe" ]; then
-       REGEX="s/^\{\"priority\":\"(verbose|debug|info|warning|error|fatal|silent)\",\"pid\":[1-9][0-9]*,\"tid\":[1-9][0-9]*,\"recv_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"recv_mono\":[1-9][0-9]+\.[0-9]{9},\"sent_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"sent_mono\":[1-9][0-9]+\.[0-9]{9},\"tag\":\"[[:print:]]*\",\"msg\":\"[[:print:]]*\"\}$/1/g"
+       REGEX="s/^\{\"priority\":\"(verbose|debug|info|warning|error|fatal|silent)\",\"pid\":[1-9][0-9]*,\"tid\":[1-9][0-9]*,\"recv_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"recv_real_ns\":[1-9][0-9]*,\"recv_mono\":[1-9][0-9]+\.[0-9]{9},\"sent_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"sent_real_ns\":[1-9][0-9]*,\"sent_mono\":[1-9][0-9]+\.[0-9]{9},\"tag\":\"[[:print:]]*\",\"msg\":\"[[:print:]]*\"\}$/1/g"
 elif [ "$type" = "logger" ]; then
-       REGEX="s/^\{\"priority\":\"(verbose|debug|info|warning|error|fatal|silent)\",\"pid\":[1-9][0-9]*,\"tid\":[1-9][0-9]*,\"sent_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"tag\":\"[[:print:]]*\",\"msg\":\"[[:print:]]*\"\}$/1/g"
+       REGEX="s/^\{\"priority\":\"(verbose|debug|info|warning|error|fatal|silent)\",\"pid\":[1-9][0-9]*,\"tid\":[1-9][0-9]*,\"sent_real\":\"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$regex_timezone\",\"sent_real_ns\":[1-9][0-9]*,\"tag\":\"[[:print:]]*\",\"msg\":\"[[:print:]]*\"\}$/1/g"
 else # zero-copy
        REGEX="s/^\{\"priority\":\"(verbose|debug|info|warning|error|fatal|silent)\",\"pid\":[1-9][0-9]*,\"tid\":[1-9][0-9]*,\"sent_mono\":[1-9][0-9]+\.[0-9]{9},\"tag\":\"[[:print:]]*\",\"msg\":\"[[:print:]]*\"\}$/1/g"
 fi
@@ -770,41 +725,14 @@ if [ "$quick" -ne 1 ]; then
                dlogutil -db kmsg -v raw | grep -Fm1 "$last_dmesg" >/dev/null && ok || fail
        fi
 
-       LOG_DETAILS="testing if pid filtering works"
-       dlogsend -b main -t DLOG_TESTSUITE pidTEST &
-       sleep 1
-       line=$(dlogutil -v raw -d --pid $!)
-       [ "$line" = "pidTEST" ] && ok || fail
+       dlog_test_tid_filtering_secure_logging $type
+fi
 
-       LOG_DETAILS="testing if tid filtering works"
-       dlogsend -b main -t DLOG_TESTSUITE tidTEST &
-       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
+DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.test"
 
-       mv $DLOG_CONFIG_PATH $DLOG_CONFIG_PATH.1
-       LOG_DETAILS="testing if secure logging works (1/2)"
-       grep -v enable_secure_logs $DLOG_CONFIG_PATH.1 > $DLOG_CONFIG_PATH
-       echo "enable_secure_logs=1" >> $DLOG_CONFIG_PATH
-       dlogutil -c
-       dlogsend -zb main -t DLOG_TESTSUITE secure &
-       sleep 1
-       dlogsend -b main -t DLOG_TESTSUITE insecure &
-       sleep 1
-       line=$(dlogutil -v raw -d | head -n1)
-       [ "$line" = "secure" ] && ok || fail
-       LOG_DETAILS="testing if secure logging works (2/2)"
-       grep -v enable_secure_logs $DLOG_CONFIG_PATH.1 > $DLOG_CONFIG_PATH
-       echo "enable_secure_logs=0" >> $DLOG_CONFIG_PATH
-       dlogutil -c
-       dlogsend -zb main -t DLOG_TESTSUITE secure &
-       sleep 1
-       dlogsend -b main -t DLOG_TESTSUITE insecure &
-       sleep 1
-       line=$(dlogutil -v raw -d | head -n1)
-       [ "$line" = "insecure" ] && ok || fail
-       mv $DLOG_CONFIG_PATH.1 $DLOG_CONFIG_PATH
-fi
+dlog_logger -t 0 &
+LOGGER=$!
+sleep 1
 
 dlogsend -b main -t DLOG_TESTSUITE_TAG0 -pI tagTEST0
 dlogsend -b main -t DLOG_TESTSUITE_TAG1 -pI tagTEST1
@@ -827,7 +755,7 @@ LOG_DETAILS="testing if tag filtering works (7/8)"
 LOG_DETAILS="testing if tag filtering works (8/8)"
 [ "$(dlogutil -dv raw 'DLOG_TESTSUITE_SAMSUNG*' | wc -l)" -eq 0 ] && ok || fail
 
-if [ "$TEST_DYNAMIC_FILTERS" = "true" ] && [ "$type" != "zero-copy" ]; then # No dynamic things in zero-copy
+if [ "$type" != "zero-copy" ]; then # No dynamic filters in zero-copy
        LOG_DETAILS="testing if limiter and runtime filtering works"
        dlogutil -c -b radio
        test_filters
@@ -955,6 +883,24 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ] && [ "$type" != "zero-copy" ]; then # No
                dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
+
+               # limiter test (the feature allows to enable/disable particular log type)
+               dlogsend -c 11 -d 1 -t QWE blabla &
+
+               sleep 0.5
+               dlogctl -t QWE -s deny
+               LOG_DETAILS="testing if log limiter works (deny) (1/3)"
+               [ "$(dlogutil -d QWE | wc -l)" -eq 1 ] && ok || fail
+               sleep 6
+               LOG_DETAILS="testing if log limiter works (deny) (2/3)"
+               [ "$(dlogutil -d QWE | wc -l)" -eq 1 ] && ok || fail
+
+               dlogctl -t QWE -s allow
+               sleep 4
+               LOG_DETAILS="testing if log limiter works (allow) (3/3)"
+               [ "$(dlogutil -d QWE | wc -l)" -eq 5 ] && ok || fail
+
+               dlogutil -c
        fi
 fi
 
@@ -1050,7 +996,7 @@ EOF
                LOG_DETAILS="testing if redirection can be disabled (2/3)"
                [ "$(dlogutil -db main -v raw)" = "" ] && ok || fail
                LOG_DETAILS="testing if redirection can be disabled (3/3)"
-               [ "$(dlogctl --get | grep main)" = "* main: ENABLED (stdout: DISABLED)" ] && ok || fail
+               [ "$(dlogctl --get | grep 'main (regular)')" = "* main (regular): ENABLED" ] && ok || fail
 
                dlogctl -b main --enable-stdout
                LOG_DETAILS="testing if redirection can be reenabled (1/3)"
@@ -1059,7 +1005,7 @@ EOF
                LOG_DETAILS="testing if redirection can be reenabled (2/3)"
                [ "$(dlogutil -db main -v raw)" = "test" ] && ok || fail
                LOG_DETAILS="testing if redirection can be reenabled (3/3)"
-               [ "$(dlogctl --get | grep main)" = "* main: ENABLED (stdout: ENABLED)" ] && ok || fail
+               [ "$(dlogctl --get | grep 'main (regular)')" = "* main (regular): ENABLED" ] && ok || fail
                dlogutil -cb main
        fi
 
@@ -1143,6 +1089,7 @@ if [ "$type" != "zero-copy" ]; then # No dynamic filters in zero-copy
 fi
 
 LOG_DETAILS="testing if libdlogutil clears the buffer correctly"
+sleep 1 # make sure the earlier logs are handled so that they don't end up handled after the clear
 test_libdlogutil clear $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
 
 if [ "$(date +%Y)" -le 2000 ]; then
@@ -1153,95 +1100,25 @@ dlogsend -b main -t DLOG_TS_TEST "The future is now, old man"
 LOG_DETAILS="testing if the timestamps are correct"
 test_verifytime && ok || fail
 
-if [ "$quick" -ne 1 ]; then
-       if [ "$type" != "zero-copy" ]; then # Backend autodection and logger daemon stuff don't really work on zero-copy
-               PREAUTODETECT_CONFIG_PATH=$DLOG_CONFIG_PATH
-               DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.autodetect"
-               kill $LOGGER > /dev/null
-               sleep 1
-               if [ "$type" = "logger" ]; then
-                       dlogutil -cb main
-               fi
-               dlog_logger -t 0 &
-               LOGGER=$!
-               sleep 1
-
-               LOG_DETAILS="testing if backend autodetection works properly (1/2)"
-               dlogsend -b main -t DLOG_AUTODETECT "xd" && ok || fail
-               sleep 1
-
-               DLOG_CONFIG_PATH=$PREAUTODETECT_CONFIG_PATH
-               LOG_DETAILS="testing if backend autodetection works properly (2/2)"
-               [ "$(dlogutil -db main -v raw)" = "xd" ] && ok || fail
+DLOG_PREV_PATH=$DLOG_CONFIG_PATH
 
-               kill $LOGGER > /dev/null
-               sleep 1
-               rm "$TESTDIR"/test*
-               dlog_logger -t 0 &
-               LOGGER=$!
-               sleep 1
+dlog_test_stdout_redirect $type
 
-               dlogsend -b main -t DLOG_LOGGER_TEST0 -c 100 "hi"
-               sleep 1
-               LOG_DETAILS="testing if logger daemon persistent logging works (1/3)"
-               [ "$(grep -c DLOG_LOGGER_TEST0 "$TESTDIR"/test0)" -eq 100 ] && ok || fail
-               LOG_DETAILS="testing if logger daemon persistent logging works (2/3)"
-               [ "$(grep -c DLOG_LOGGER_TEST0 "$TESTDIR"/test1)" -eq 100 ] && ok || fail
-               LOG_DETAILS="testing if logger daemon persistent logging works (3/3)"
-               [ "$(grep -c DLOG_LOGGER_TEST0 "$TESTDIR"/test2)" -eq 0 ] && ok || fail
-
-               dlogsend -b main -t DLOG_LOGGER_TEST1 -c 500000 "hi"
-               sleep 1
-               RESULT=$(du -c "$TESTDIR"/test0* | tail -n 1 | cut -f 1)
-               LOG_DETAILS="testing if logger daemon log rotating works (1/2)"
-               [ "$RESULT" -gt 4096 ] && ok || fail # Min 4 MB
-               LOG_DETAILS="testing if logger daemon log rotating works (2/2)"
-               [ "$RESULT" -lt 6144 ] && ok || fail # Max 6 MB
+DLOG_CONFIG_PATH=$DLOG_PREV_PATH
 
-               dlogutil -cb main
+if [ "$quick" -ne 1 ]; then
+       if [ "$type" != "zero-copy" ]; then # Backend autodection and logger daemon stuff don't really work on zero-copy
                kill $LOGGER > /dev/null
                sleep 1
-               rm "$TESTDIR"/test0*
-               dlog_logger -t 5 -b 100000 &
-               LOGGER=$!
-               sleep 1
-
-               dlogsend -b main -t DLOG_LOGGER_TEST2 -c 100 "hi"
-               sleep 1
-               LOG_DETAILS="testing if logger daemon buffering works (1/5)"
-               [ "$(grep -c DLOG_LOGGER_TEST2 "$TESTDIR"/test0)" -eq 0 ] && ok || fail
-
-               sleep 6
-               LOG_DETAILS="testing if logger daemon buffering works (2/5)"
-               [ "$(grep -c DLOG_LOGGER_TEST2 "$TESTDIR"/test0)" -eq 100 ] && ok || fail
 
-               dlogsend -b main -t DLOG_LOGGER_TEST3 -c 100 "hi"
-               sleep 1
-               LOG_DETAILS="testing if logger daemon buffering works (3/5)"
-               [ "$(grep -c DLOG_LOGGER_TEST3 "$TESTDIR"/test0)" -eq 0 ] && ok || fail
-
-               dlogutil -cb main
-               kill $LOGGER > /dev/null
-               sleep 1
-               dlog_logger -t 10000 -b 100 &
-               LOGGER=$!
-               sleep 1
-               LOG_DETAILS="testing if logger daemon buffering works (4/5)"
-               [ "$(grep -c DLOG_LOGGER_TEST3 "$TESTDIR"/test0)" -eq 100 ] && ok || fail
-
-               dlogsend -b main -t DLOG_LOGGER_TEST4 -c 100 "hi"
-               sleep 1
-               LOG_DETAILS="testing if logger daemon buffering works (5/5)"
-               [ "$(grep -c DLOG_LOGGER_TEST4 "$TESTDIR"/test0)" -gt 90 ] && ok || fail
-
-               dlogutil -cb main
-               kill $LOGGER > /dev/null
-               sleep 1
-               dlog_logger -t 0 &
-               LOGGER=$!
-               sleep 1
+               dlog_test_backend_autodetection $type
+               dlog_test_logger_buffering_logging $type
        fi
 
+       dlog_logger -t 0 &
+       LOGGER=$!
+       sleep 1
+
        LOG_DETAILS="testing if the library works with multithreaded app"
        dlogutil -f $TESTDIR/dlog_mt_test &
        MT_TEST=$!
@@ -1283,7 +1160,7 @@ if [ "$quick" -ne 1 ]; then
                        LOG_DETAILS="testing if dlogutil --sort-by sorts correctly (${P}_mono)"
                        dlogutil -db main --sort-by "${P}_mono" -v json | sed -Ee "s/^.*\"${P}_mono\":([^,}]*).*\$/\\1/" | sort -c && ok || fail
                        LOG_DETAILS="testing if dlogutil --sort-by sorts correctly (${P}_real)"
-                       dlogutil -db main --sort-by "${P}_real" -v json | sed -Ee "s/^.*\"${P}_real\":\"([^\"]*)\".*\$/\\1/" | sort -c && ok || fail
+                       dlogutil -db main --sort-by "${P}_real" -v json | sed -Ee "s/^.*\"${P}_real\":\"([^\"]*)\",\"${P}_real_ns\":([^,}]*).*\$/\\1 \2/" | sort -c -k1,1 -k2,2g && ok || fail
                done
        fi
 
@@ -1319,6 +1196,42 @@ if [ "$quick" -ne 1 ]; then
        done
 fi
 
+if [ "$type" = "pipe" ]; then
+       kill $LOGGER > /dev/null
+       sleep 1
+
+       PRERESIZE_CONFIG_PATH="$DLOG_CONFIG_PATH"
+       DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.compress"
+
+       RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
+       mkdir -m 777 -p "$RUNTIME_FILTERS_DIR"
+
+       dlog_logger -t 0 &
+       LOGGER=$!
+       sleep 1
+
+       dlogsend -b main -c 9999 resizetestblalbl &
+       sleep 4
+       LOG_DETAILS="testing if compression-resize works (1/3)"
+       [ "$(dlogutil -d -m xyz123 | wc -l)" -ge 1 ] && ok || fail
+
+       dlogctl --compression-name xyz123 --compression-resize 1
+       sleep 5
+       LOG_DETAILS="testing if compression-resize works (2/3)"
+       [ "$(dlogutil -d -m xyz123 | wc -l)" -eq 0 ] && ok || fail
+
+       dlogctl --compression-name xyz123 --compression-resize 200000
+       dlogsend -b main -c 9999 resizetestblalbl &
+       sleep 4
+       LOG_DETAILS="testing if compression-resize works (3/3)"
+       [ "$(dlogutil -d -m xyz123 | wc -l)" -ge 1 ] && ok || fail
+
+       dlogutil -c
+       kill $LOGGER > /dev/null
+       DLOG_CONFIG_PATH=$PRERESIZE_CONFIG_PATH
+       rm -rf $RUNTIME_FILTERS_DIR
+fi
+
 # show results, clean up and return an exit code
 
 echo "$OKS / $TOTAL tests passed"