tests: extract daemon early quit test to a separate file
[platform/core/system/dlog.git] / tests / dlog_test.in
index ce45dbd..512d30c 100644 (file)
 #!/bin/sh
 
-# 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() {
-       local 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"
-}
+# We use the something && ok || fail pattern quite a lot; it is not correct in general,
+# which makes shellcheck complain about it, but in our case it's ok to use it since
+# the ok function will never fail.
+# shellcheck disable=SC2015
 
-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
-       [ -d $TESTDIR ] && rm -rf $TESTDIR/*
-       [ -d $RUNTIME_FILTERS_DIR ] && rm -rf $RUNTIME_FILTERS_DIR
-}
+source dlog_test_header
 
 trap cleanup 0
 
-check_daemon() {
-       local ret=1
-       if [ $LOGGER -ne -1 ] && [ -z "$(ps -o pid= -p $LOGGER)" ]; then
-               ret=0
-       fi
-       return $ret
-}
-
-fail() {
-       check_daemon
-       [ $? -eq 0 ] && 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
-       [ $? -eq 0 ] && daemon_status="[logger daemon not running]"
+USAGE_MESSAGE="usage: $0 [--verbose] [--quick] pipe|logger|zero-copy"
 
-       OKS=$(($OKS + 1))
-       TOTAL=$(($TOTAL + 1))
-       printf "[%02d] PASSED: %s %s\n" $TOTAL "$LOG_DETAILS" "$daemon_status"
-       LOG_DETAILS=
-}
-
-# supress stderr messages from subcommands
-exec 2> /dev/null
-
-USAGE_MESSAGE="usage: $0 pipe|logger|pipe_quick|logger_quick"
-
-if [ $# -ne 1 ]; then
-       echo $USAGE_MESSAGE
+OPTS=$(getopt --shell sh --options "" --long verbose,quick --quiet -- "$@")
+if [ "$?" -eq 1 ]; then
+       echo "$USAGE_MESSAGE"
        exit 1
 fi
+eval set -- "$OPTS"
 
-if [ "$1" == "pipe" ]; then
+verbose=0
+quick=0
+while true; do
+       case "$1" in
+               --verbose)
+                       verbose=1
+                       ;;
+               --quick)
+                       quick=1
+                       ;;
+               --)
+                       shift
+                       break
+                       ;;
+               *)
+                       echo "This should never happen :)"
+                       exit 1
+                       ;;
+       esac
+       shift
+done
+if [ "$1" = "pipe" ]; then
        type="pipe"
-       quick=0
-elif [ "$1" == "logger" ]; then
+elif [ "$1" = "logger" ]; then
        type="logger"
-       quick=0
-elif [ "$1" == "pipe_quick" ]; then
+elif [ "$1" = "zero-copy" ]; then
+       type="zero-copy"
+# We still accept the legacy {pipe,logger}_quick syntax because there's no reason not to.
+elif [ "$1" = "pipe_quick" ]; then
        type="pipe"
        quick=1
-elif [ "$1" == "logger_quick" ]; then
+elif [ "$1" = "logger_quick" ]; then
        type="logger"
        quick=1
 else
-       echo $USAGE_MESSAGE
+       echo "$USAGE_MESSAGE"
        exit 1
 fi
 
+# supress stderr messages from subcommands
+if [ "$verbose" -eq 0 ]; then
+       exec 2> /dev/null
+fi
+
 NEEDS_TO_QUIT=0
 capsh --print | grep Current | grep cap_syslog > /dev/null || { echo "*** ERROR: cap_syslog missing"; NEEDS_TO_QUIT=1; }
 mount | grep ' / ' | grep rw > /dev/null || { echo "*** ERROR: root not mounted read-write"; NEEDS_TO_QUIT=1; }
-[[ $NEEDS_TO_QUIT -eq 0 ]] || exit 1
+[ "$NEEDS_TO_QUIT" -eq 0 ] || exit 1
+
+if [ "$type" = "pipe" ] || [ -f /lib/modules/"$(uname -r)"/extra/logger.ko ]; then
+       LEGACY_LOGGER=0
+else
+       LEGACY_LOGGER=1
+fi
 
 if [ -z "$DLOG_CONFIG_PATH" ]; then
        ORIGINAL_CONFIG_PATH="/etc/dlog.conf"
@@ -127,167 +82,260 @@ fi
 export DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.test"
 PATH=$PATH:@libexecdir@/libdlog/
 
-#create dir for runtime filters
-RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
-mkdir -p "$RUNTIME_FILTERS_DIR"
+if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
+       #create dir for runtime filters
+       RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
+       mkdir -m 777 -p "$RUNTIME_FILTERS_DIR"
 
-# Start the daemon
-if [ $type == "pipe" ]; then
-       dlog_logger -b 99 -t 0 &
+       if [ "$quick" -ne 1 ]; then
+               dlog_test_daemon_early_quit $type
+       fi
+
+       # Start the daemon
+       dlog_logger -t 0 &
        LOGGER=$!
        sleep 1
-fi
 
-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/05-logctl.conf | 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/05-logctl.conf | grep -E 'limiter\|\*\|\*=100' | wc -l` -eq 0 ] && ok || fail
-       dlogctl -c
-
-       LOG_DETAILS="testing if the whole dynamic config directory is respected"
-       dlogctl -s deny
-       cp $RUNTIME_FILTERS_DIR/{05-logctl.conf,10-other.conf}
-       dlogctl -c
-       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
-       rm $RUNTIME_FILTERS_DIR/10-other.conf
+       if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
+               dlogctl -c
+               dlogctl --enable
+               dlogutil -c -b radio -b system -b main
+               LOG_DETAILS="dlogctl --disable (no args, limiter_apply_to_all_buffers=0)"
+               dlogctl --disable
+
+               # 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
+               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 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
+               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 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
+               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 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
+               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 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
+               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 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
+               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)"
+               [ "$(grep -cE 'limiter\|\*\|\*=100' "$RUNTIME_FILTERS_DIR"/05-logctl.conf)" -eq 1 ] && ok || fail
+
+               # -g correctness
+               LOG_DETAILS="testing invalid parameters for dlogctl (11/13)"
+               [ "$(dlogctl -g | grep -F '*:*' | grep -c 100)" -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)"
+               [ "$(grep -cE 'limiter\|\*\|\*=100' "$RUNTIME_FILTERS_DIR"/05-logctl.conf)" -eq 0 ] && ok || fail
+               dlogctl -c
+
+               LOG_DETAILS="testing if the whole dynamic config directory is respected"
+               dlogctl -s deny
+               cp $RUNTIME_FILTERS_DIR/05-logctl.conf $RUNTIME_FILTERS_DIR/10-other.conf
+               dlogctl -c
+               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
+               rm $RUNTIME_FILTERS_DIR/10-other.conf
+       fi
 fi
 
 SEED=$(head -c 6 /dev/urandom | base64)
-dlogsend -k "$SEED"
-# -k is async, unlike normal mode; therefore we have to wait until the logging process actually finishes
-while ps -o args | grep "dlogsend" | grep -v grep &> /dev/null || ps -o args | grep "dlog-log-critical" | grep -v grep &> /dev/null; do :; done
+dlogsend -b main -k "$SEED"
+# -k is async, unlike normal mode; therefore we have to wait until the logging process actually finishes.
+while pgrep "dlogsend" > /dev/null || pgrep "dlog-log-critical" > /dev/null; do :; done
 CRIT_PATH="@DLOG_CRITICAL_LOGFILE_PATH@"
 LOG_DETAILS="testing if critical logging works"
-cat "$CRIT_PATH".{a,b} | grep -F "$SEED" &> /dev/null && ok || fail
+cat "$CRIT_PATH".a "$CRIT_PATH".b | grep -F "$SEED" > /dev/null && ok || fail
+
+if [ "$type" = "pipe" ] && [ "$quick" -ne 1 ]; then
+       dlogsend -c 2 -d 2 -t DLOGSEND_SIGPIPE_TEST test &
+       DLOGSEND_PID=$!
+       sleep 1
+       kill -s PIPE $DLOGSEND_PID
+       wait $DLOGSEND_PID
+       LOG_DETAILS="testing if dlogsend logs even after SIGPIPE"
+       [ "$(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
@@ -296,71 +344,75 @@ sleep 1
 
 
 LOG_DETAILS="testing if dlogutil -d exits with success after printing logs"
-dlogutil -d &> /dev/null && ok || fail
+dlogutil -d > /dev/null && ok || fail
 
 LOG_DETAILS="testing if -t argument is parsed properly"
-dlogutil -t dummy &> /dev/null && fail || ok
+dlogutil -t dummy > /dev/null && fail || ok
 
 LOG_DETAILS="testing if -u argument is parsed properly"
-dlogutil -du dummy &> /dev/null && fail || ok
+dlogutil -du dummy > /dev/null && fail || ok
 
 LOG_DETAILS="testing if limiting printed log entries to less than exists in the buffer returns proper value"
-[ $(dlogutil -b main -t  20 | wc -l) -eq  20 ] && ok || fail # less logs than currently in buffer
+[ "$(dlogutil -b main -t  20 | wc -l)" -eq  20 ] && ok || fail # less logs than currently in buffer
 
 LOG_DETAILS="testing if limiting printed log entries to more than exists in the buffer returns proper value"
-[ $(dlogutil -b main -t 200 | wc -l) -eq 100 ] && ok || fail # more
+[ "$(dlogutil -b main -t 200 | wc -l)" -eq 100 ] && ok || fail # more
 
 LOG_DETAILS="testing if dlogutil returns exact amount of entries as there is in the buffer"
-[ $(dlogutil -b main -d     | wc -l) -eq 100 ] && ok || fail # exactly
+[ "$(dlogutil -b main -d     | wc -l)" -eq 100 ] && ok || fail # exactly
 
 LOG_DETAILS="testing if reading from  dummy buffer returns an error as expected"
-dlogutil -b nonexistent_buffer &> /dev/null && fail || ok
+dlogutil -b nonexistent_buffer > /dev/null && fail || ok
 
-LOG_DETAILS="testing if reading from \"system\" buffer returns zero entries (logs are in the \"main\" buffer)"
-[ $(dlogutil -d -b system | wc -l) -eq 0 ] && ok || fail
+if [ "$type" != "zero-copy" ]; then # No buffer split in zero-copy
+       LOG_DETAILS="testing if reading from \"system\" buffer returns zero entries (logs are in the \"main\" buffer)"
+       [ "$(dlogutil -d -b system | wc -l)" -eq 0 ] && ok || fail
+fi
 
 LOG_DETAILS="testing if dlogutil -c empties all buffers"
 dlogutil -cb main && ok || fail
 
 LOG_DETAILS="testing if writing entries to empty buffer and reading them returns proper amount of entries"
 test_libdlog 10
-[ $(dlogutil -b main -d | wc -l) -eq 10 ] && ok || fail # should be 10, not 110
+[ "$(dlogutil -b main -d | wc -l)" -eq 10 ] && ok || fail # should be 10, not 110
 
 LOG_DETAILS="testing if filters work (1/3)"
-[ $(dlogutil -b main -d *:E | wc -l) -eq 5 ] && ok || fail # half of current logs (test_libdlog alternates between error and info log levels)
+[ "$(dlogutil -b main -d '*:E' | wc -l)" -eq 5 ] && ok || fail # half of current logs (test_libdlog alternates between error and info log levels)
 
 LOG_DETAILS="testing if filters work (2/3)"
-[ $(dlogutil -b main -d *:W | wc -l) -eq 5 ] && ok || fail
+[ "$(dlogutil -b main -d '*:W' | wc -l)" -eq 5 ] && ok || fail
 
 LOG_DETAILS="testing if filters work (3/3)"
-[ $(dlogutil -b main -d *:I | wc -l) -eq 10 ] && ok || fail
+[ "$(dlogutil -b main -d '*:I' | wc -l)" -eq 10 ] && ok || fail
 
 LOG_DETAILS="testing if exact filters work (1/3)"
-[ $(dlogutil -b main -d *:=E | wc -l) -eq 5 ] && ok || fail
+[ "$(dlogutil -b main -d '*:=E' | wc -l)" -eq 5 ] && ok || fail
 
 LOG_DETAILS="testing if exact filters work (2/3)"
-[ $(dlogutil -b main -d *:=W | wc -l) -eq 0 ] && ok || fail
+[ "$(dlogutil -b main -d '*:=W' | wc -l)" -eq 0 ] && ok || fail
 
 LOG_DETAILS="testing if exact filters work (3/3)"
-[ $(dlogutil -b main -d *:=I | wc -l) -eq 5 ] && ok || fail
+[ "$(dlogutil -b main -d '*:=I' | wc -l)" -eq 5 ] && ok || fail
 
 LOG_DETAILS="testing if adding \"silent\" filter works"
-[ $(dlogutil -b main -s -d | wc -l) -eq 0 ] && ok || fail
+[ "$(dlogutil -b main -s -d | wc -l)" -eq 0 ] && ok || fail
 
-LOG_DETAILS="testing if reading buffer size returns proper exit code"
-dlogutil -gb main &> /dev/null && ok || fail
+if [ "$type" != "zero-copy" ]; then # No buffer size access in zero-copy
+       LOG_DETAILS="testing if reading buffer size returns proper exit code"
+       dlogutil -gb main > /dev/null && ok || fail
+fi
 
 LOG_DETAILS="testing if writing all entries to single file works (-f)"
-dlogutil -f $TESTDIR/dlog_test_file -d &> /dev/null && ok || fail
+dlogutil -f $TESTDIR/dlog_test_file -d > /dev/null && ok || fail
 
-if [ $quick -ne 1 ]; then
+if [ "$quick" -ne 1 ]; then
        LOG_DETAILS="testing if the continuous mode works as expected (1/2)"
        dlogutil -b main -f $TESTDIR/dlog_continuous1_file &
        UTIL_PID=$!
        sleep 1
        kill $UTIL_PID && WAS_ALIVE=1 || WAS_ALIVE=0
        UTIL_PID=-1
-       [[ $WAS_ALIVE -eq 1 && `wc -l < $TESTDIR/dlog_continuous1_file` -eq 10 ]] && ok || fail
+       [ "$WAS_ALIVE" -eq 1 ] && [ "$(wc -l < "$TESTDIR"/dlog_continuous1_file)" -eq 10 ] && ok || fail
 
        LOG_DETAILS="testing if the continuous mode works as expected (2/2)"
        dlogutil -b main -f $TESTDIR/dlog_continuous2_file &
@@ -370,35 +422,37 @@ if [ $quick -ne 1 ]; then
        sleep 1
        kill $UTIL_PID && WAS_ALIVE=1 || WAS_ALIVE=0
        UTIL_PID=-1
-       [[ $WAS_ALIVE -eq 1 && `wc -l < $TESTDIR/dlog_continuous2_file` -eq 11 ]] && ok || fail
+       [ $WAS_ALIVE -eq 1 ] && [ "$(wc -l < "$TESTDIR"/dlog_continuous2_file)" -eq 11 ] && ok || fail
 
        LOG_DETAILS="testing if the monitor mode works as expected (1/2)"
-       dlogutil -mb main -f $TESTDIR/dlog_monitor1_file &
+       dlogutil --monitor -b main -f $TESTDIR/dlog_monitor1_file &
        UTIL_PID=$!
        sleep 1
        kill $UTIL_PID && WAS_ALIVE=1 || WAS_ALIVE=0
        UTIL_PID=-1
-       [[ $WAS_ALIVE -eq 1 && `wc -l < $TESTDIR/dlog_monitor1_file` -eq 0 ]] && ok || fail
+       [ $WAS_ALIVE -eq 1 ] && [ "$(wc -l < "$TESTDIR"/dlog_monitor1_file)" -eq 0 ] && ok || fail
 
        LOG_DETAILS="testing if the monitor mode works as expected (2/2)"
-       dlogutil -mb main -f $TESTDIR/dlog_monitor2_file &
+       dlogutil --monitor -b main -f $TESTDIR/dlog_monitor2_file &
        UTIL_PID=$!
        sleep 1
        dlogsend -b main "Hi!"
        sleep 1
        kill $UTIL_PID && WAS_ALIVE=1 || WAS_ALIVE=0
        UTIL_PID=-1
-       [[ $WAS_ALIVE -eq 1 && `wc -l < $TESTDIR/dlog_monitor2_file` -eq 1 ]] && ok || fail
+       [ $WAS_ALIVE -eq 1 ] && [ "$(wc -l < "$TESTDIR"/dlog_monitor2_file)" -eq 1 ] && ok || fail
 fi
 
-LOG_DETAILS="testing if writing entries to rotating files works (-r/-n)"
-dlogutil -f $TESTDIR/dlog_rotating_file -r 12 -n 3 & # 3 files at 12 KB each
-UTIL_PID=$!
-
+dlogutil -cb main
 test_libdlog 100000 &
 LIBDLOGUTIL_CORRECT_PID=$!
 wait $LIBDLOGUTIL_CORRECT_PID
 
+# NB: rotation only really makes sense in the continuous mode
+# from a user PoV, but the logic doesn't care about dumping
+# so we do it to simplify things
+dlogutil -df $TESTDIR/dlog_rotating_file -r 12 -n 3 # 3 files at 12 KB each
+
 LOG_DETAILS="testing if single file is properly created"
 if [ -e $TESTDIR/dlog_test_file ]; then ok; else fail; fi
 
@@ -415,14 +469,11 @@ LOG_DETAILS="testing if rotating file is properly created (4/4)"
 if [ -e $TESTDIR/dlog_rotating_file.4 ]; then fail; else ok; fi
 
 LOG_DETAILS="testing the size of log files"
-if [ $(du $TESTDIR/dlog_rotating_file.3 | sed "s#$TESTDIR/dlog_rotating_file.3##g") -eq 16 ]; then ok; else fail; fi # the actual size is one sector more (so 12 -> 16) because the limit is checked after reaching it, not before
-
-kill $UTIL_PID
-UTIL_PID=-1
+if [ "$(du "$TESTDIR"/dlog_rotating_file.3 | sed "s#$TESTDIR/dlog_rotating_file.3##g")" -eq 16 ]; then ok; else fail; fi # the actual size is one sector more (so 12 -> 16) because the limit is checked after reaching it, not before
 
 LOG_DETAILS="testing if libdlogutil works correctly in the dump mode"
 test_libdlogutil dump $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
-if [ $quick -ne 1 ]; then
+if [ "$quick" -ne 1 ]; then
        LOG_DETAILS="testing if libdlogutil works correctly if processing the logs takes some time"
        test_libdlogutil timer $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
 fi
@@ -452,18 +503,21 @@ LOG_DETAILS="testing if libdlogutil prefix filter works correctly (1/2)"
 test_libdlogutil prefix_correct $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
 LOG_DETAILS="testing if libdlogutil prefix filter works correctly (2/2)"
 test_libdlogutil prefix_wrong $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
-LOG_DETAILS="testing if libdlogutil returns the correct buffer traits"
-test_libdlogutil traits $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
-LOG_DETAILS="testing if libdlogutil aliasing works"
-if [ $type == "pipe" ]; then
-       test_libdlogutil alias $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
-else
-       DLOG_CONFIG_PATH="@datadir@/dlog-logger.conf.alias" test_libdlogutil alias $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
+if [ "$type" != "zero-copy" ]; then # These rely on things not available in zero-copy
+       LOG_DETAILS="testing if libdlogutil returns the correct buffer traits"
+       test_libdlogutil traits $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
+       LOG_DETAILS="testing if libdlogutil aliasing works"
+       if [ "$type" = "pipe" ]; then
+               test_libdlogutil alias $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
+       else
+               DLOG_CONFIG_PATH="@datadir@/dlog-logger.conf.alias" test_libdlogutil alias $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
+       fi
 fi
 LOG_DETAILS="testing if libdlogutil errors out correctly if used improperly"
 test_libdlogutil negative $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
 
-cmd_prefix="dlogutil -t 1 -u 0 -v"
+cmd_prefix_no_v="dlogutil -t 1 -u 0"
+cmd_prefix="$cmd_prefix_no_v -v"
 
 format="process"
 regex_prio="[VDIWEFS]{1}"
@@ -474,19 +528,19 @@ regex_timezone="[\+-]{1}[0-9]{4}"
 for PARAM in always auto none never; do
        for PRIO in info error; do
                for OUTPUT in pipe tty; do
-                       if [[ "$PARAM" == "always" ]]; then
+                       if [ "$PARAM" = "always" ]; then
                                COLOR_EXPECTED=1
-                       elif [[ "$PARAM" == "never" ]]; then
+                       elif [ "$PARAM" = "never" ]; then
                                COLOR_EXPECTED=0
-                       elif [[ "$OUTPUT" == "tty" ]]; then
+                       elif [ "$OUTPUT" = "tty" ]; then
                                COLOR_EXPECTED=1
                        else
                                COLOR_EXPECTED=0
                        fi
 
-                       if [[ "$PRIO" == "info" ]]; then
+                       if [ "$PRIO" = "info" ]; then
                                REGEX="s/^I\([0-9[:space:]]{5,}\)[[:print:]]*\([[:print:]]*\)@$/1/g"
-                       elif [[ "$COLOR_EXPECTED" -eq 0 ]]; then
+                       elif [ "$COLOR_EXPECTED" -eq 0 ]; then
                                REGEX="s/^E\([0-9[:space:]]{5,}\)[[:print:]]*\([[:print:]]*\)@$/1/g"
                        else
                                REGEX="s/^~\[31;1mE\([0-9[:space:]]{5,}\) ~\[0m[[:print:]]*~\[31;1m  \([[:print:]]*\)@~\[0m$/1/g"
@@ -495,27 +549,27 @@ for PARAM in always auto none never; do
                        # -t 1 instead of | head -n 1 because the `script` command can't cope with SIGPIPE.
                        COMMAND="$cmd_prefix $format"
 
-                       if [[ "$PARAM" == "none" ]]; then
+                       if [ "$PARAM" = "none" ]; then
                                LOG_DETAILS="testing if color output is correct (implicit --color=auto/$PRIO priority/$OUTPUT output)"
                        else
                                COMMAND="$COMMAND --color=$PARAM"
                                LOG_DETAILS="testing if color output is correct (--color=$PARAM/$PRIO priority/$OUTPUT output)"
                        fi
 
-                       if [[ "$PRIO" == "info" ]]; then
+                       if [ "$PRIO" = "info" ]; then
                                COMMAND="$COMMAND '*:=I'"
                        else
                                COMMAND="$COMMAND '*:=E'"
                        fi
 
-                       if [[ "$OUTPUT" == "tty" ]]; then
+                       if [ "$OUTPUT" = "tty" ]; then
                                # This emulates a TTY. The sed call is because `script` likes to mess up the output for some reason.
                                COMMAND="script -qc\"$COMMAND\" /dev/null | sed 's/\r$//'"
                        fi
 
-                       # `eval` is needed since `$COMMAND` may contain `"`
-                       line=`eval $COMMAND | tr '\033\n' '~@'`
-                       [[ `echo "$line" | sed -re "$REGEX"` == "1" ]] && ok || fail
+                       # $(eval) is needed since `$COMMAND` may contain `"`
+                       line="$(eval "$COMMAND" | tr '\033\n' '~@')"
+                       [ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
                done
        done
 done
@@ -524,81 +578,101 @@ done
 
 REGEX="s/^$regex_prio\([0-9[:space:]]{5,}\)[[:print:]]*\([[:print:]]*\)$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="tag"
 REGEX="s/^$regex_prio\/[[:print:]]{9,}:\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="thread"
 REGEX="s/^$regex_prio\($regex_pidtid\)\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="time"
 REGEX="s/^$regex_time.[0-9]{3}$regex_timezone\s{1}$regex_prio\/[[:print:]]{8,}\([0-9[:space:]]{5,}\):\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="threadtime"
 REGEX="s/^$regex_time.[0-9]{3}$regex_timezone\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="kerneltime"
 REGEX="s/^[0-9[:space:]]{1,}.[0-9]{3,}\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="recv_realtime"
 REGEX="s/^$regex_time.[0-9]{3}\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="rwtime"
 REGEX="s/^$regex_time\s{1}\[[0-9[:space:]]{3,}.[0-9[:space:]]{3,}\]\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="long"
 REGEX="s/^\[\s{1}$regex_time.[0-9]{3,}\s{1}$regex_prio\/[[:print:]]{8,}\s{1}$regex_pidtid\]@[[:print:]]+@$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | tr '\n' '@' | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | tr '\n' '@' | sed -re "$REGEX")" = "1" ] && ok || fail
 
 format="brief"
 REGEX="s/^$regex_prio\/[[:print:]]{8,}\([0-9[:space:]]{5,}\):\s{1}[[:print:]]*$/1/g"
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
 
 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"
-else
-       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"
+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_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\",\"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
 LOG_DETAILS="testing if \"$format\" print format works"
-line=`$cmd_prefix $format`
-[[ `echo "$line" | sed -re $REGEX` == "1" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
+
+SOURCE="$DLOG_CONFIG_PATH"
+DLOG_CONFIG_PATH="$TESTDIR/defaultprintformat.conf"
+cp "$SOURCE" "$DLOG_CONFIG_PATH"
+
+# TODO: It would be good to also test the daemon side of things.
+LOG_DETAILS="testing default log format selection (none -> brief)"
+REGEX="s/^$regex_prio\/[[:print:]]{8,}\([0-9[:space:]]{5,}\):\s{1}[[:print:]]*$/1/g"
+line=$($cmd_prefix_no_v)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
+
+echo "util_default_format=rwtime" >> $DLOG_CONFIG_PATH
+LOG_DETAILS="testing default log format selection (rwtime)"
+REGEX="s/^$regex_time\s{1}\[[0-9[:space:]]{3,}.[0-9[:space:]]{3,}\]\s{1}$regex_prio\/[[:print:]]{8,}\($regex_pidtid\):\s{1}[[:print:]]*$/1/g"
+line=$($cmd_prefix_no_v)
+[ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
+
+DLOG_CONFIG_PATH="$SOURCE"
 
 format="raw"
 LOG_DETAILS="testing if \"$format\" print format works"
 dlogutil -c
 dlogsend -b main -t DLOG_TESTSUITE rawformatTEST
-line=`$cmd_prefix $format`
-[[ "$line" == "rawformatTEST" ]] && ok || fail
+line=$($cmd_prefix $format)
+[ "$line" = "rawformatTEST" ] && ok || fail
 
-if [ $quick -ne 1 ]; then
+if [ "$quick" -ne 1 ]; then
        LOG_DETAILS="testing if dlogsend -d works"
        dlogutil -c
        dlogsend -b main -c 9999 -d 4 -f 7 -t DLOG_TESTSUITE "hi" &
@@ -606,17 +680,17 @@ if [ $quick -ne 1 ]; then
        sleep 10
        kill $DLOGSEND_PID
        # In 10 seconds, 3 cycles 7 logs each should have happened.
-       [[ "$(dlogutil -d DLOG_TESTSUITE | wc -l)" -eq 21 ]] && ok || fail
+       [ "$(dlogutil -d DLOG_TESTSUITE | wc -l)" -eq 21 ] && ok || fail
 fi
 
-if [ $type == "pipe" ]; then
+if [ "$type" = "pipe" ]; then
        for format in raw brief long; do
-               for i in {1..8} 10 15 20 25 {513..520}; do
+               for i in 1 2 3 4 5 6 7 8 10 15 20 25 513 514 515 516 517 518 519 520; do
                        LOG_DETAILS="testing if padding works correctly (format $format/count $i)"
                        log=$(printf '%0.s&' $(seq 1 $i)) # Print the '&' character $i times
 
                        dlogutil -c
-                       dlogsend -b main $log
+                       dlogsend -b main "$log"
                        line=$($cmd_prefix $format | tr '\n' '@')
 
                        case $format in
@@ -631,33 +705,37 @@ if [ $type == "pipe" ]; then
                                        ;;
                        esac
 
-                       [[ $(echo "$line" | sed -re $REGEX) == "1" ]] && ok || fail
+                       [ "$(echo "$line" | sed -re "$REGEX")" = "1" ] && ok || fail
                done
        done
 fi
 
-LOG_DETAILS="testing if KMSG works in the default format"
-# We check if the command returns at least 100 logs. This seems to be a safe value.
-# Feel free to change it to a reasonable yet lower value if the test happens to fail otherwise.
-[[ "$(dlogutil -db kmsg | wc -l)" -gt 100 ]] && ok || fail
+if [ "$type" != "zero-copy" ]; then # No KMSG in zero-copy
+       LOG_DETAILS="testing if KMSG works in the default format"
+       # We check if the command returns at least 100 logs. This seems to be a safe value.
+       # Feel free to change it to a reasonable yet lower value if the test happens to fail otherwise.
+       [ "$(dlogutil -db kmsg | wc -l)" -gt 100 ] && ok || fail
+fi
 
-if [ $quick -ne 1 ]; then
-       LOG_DETAILS="testing if KMSG works in the raw format"
-       last_dmesg=`dmesg | tail -n1 | sed -re "s/^\[[ 0-9]{5,}\.[0-9]{6}\] (.*)$/\1/g"`
-       sleep 1 # To make sure dlog has already parsed the log
-       dlogutil -db kmsg -v raw | grep -Fm1 "$last_dmesg" >/dev/null && ok || fail
+if [ "$quick" -ne 1 ]; then
+       if [ "$type" != "zero-copy" ]; then # No KMSG in zero-copy
+               LOG_DETAILS="testing if KMSG works in the raw format"
+               last_dmesg=$(dmesg | tail -n1 | sed -re "s/^\[[ 0-9]{5,}\.[0-9]{6}\] (.*)$/\1/g")
+               sleep 1 # To make sure dlog has already parsed the log
+               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
+       line=$(dlogutil -v raw -d --pid $!)
+       [ "$line" = "pidTEST" ] && ok || fail
 
        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
+       line=$(dlogutil -v raw -d --tid $!) #dlogsend is a single threaded app so tid is the same as pid
+       [ "$line" = "tidTEST" ] && ok || fail
 
        mv $DLOG_CONFIG_PATH $DLOG_CONFIG_PATH.1
        LOG_DETAILS="testing if secure logging works (1/2)"
@@ -668,8 +746,8 @@ if [ $quick -ne 1 ]; then
        sleep 1
        dlogsend -b main -t DLOG_TESTSUITE insecure &
        sleep 1
-       line=`dlogutil -v raw -d | head -n1`
-       [[ "$line" == "secure" ]] && ok || fail
+       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
@@ -678,8 +756,8 @@ if [ $quick -ne 1 ]; then
        sleep 1
        dlogsend -b main -t DLOG_TESTSUITE insecure &
        sleep 1
-       line=`dlogutil -v raw -d | head -n1`
-       [[ "$line" == "insecure" ]] && ok || fail
+       line=$(dlogutil -v raw -d | head -n1)
+       [ "$line" = "insecure" ] && ok || fail
        mv $DLOG_CONFIG_PATH.1 $DLOG_CONFIG_PATH
 fi
 
@@ -688,84 +766,89 @@ dlogsend -b main -t DLOG_TESTSUITE_TAG1 -pI tagTEST1
 dlogsend -b main -t DLOG_TESTSUITE_TAG2 -pF tagTEST2
 
 LOG_DETAILS="testing if tag filtering works (1/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_TAG0' | wc -l` -eq 1 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_TAG0' | wc -l)" -eq 1 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (2/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_TAG1' | wc -l` -eq 1 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_TAG1' | wc -l)" -eq 1 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (3/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_TAG' | wc -l` -eq 0 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_TAG' | wc -l)" -eq 0 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (4/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_TAG*' | wc -l` -eq 3 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_TAG*' | wc -l)" -eq 3 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (5/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_TAG*:I' | wc -l` -eq 3 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_TAG*:I' | wc -l)" -eq 3 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (6/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_TAG*:W' | wc -l` -eq 1 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_TAG*:W' | wc -l)" -eq 1 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (7/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_SAMSUNG' | wc -l` -eq 0 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_SAMSUNG' | wc -l)" -eq 0 ] && ok || fail
 LOG_DETAILS="testing if tag filtering works (8/8)"
-[[ `dlogutil -dv raw 'DLOG_TESTSUITE_SAMSUNG*' | wc -l` -eq 0 ]] && ok || fail
+[ "$(dlogutil -dv raw 'DLOG_TESTSUITE_SAMSUNG*' | wc -l)" -eq 0 ] && ok || fail
 
-if [ "$TEST_DYNAMIC_FILTERS" == "true" ]; then
+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
-       [ $(dlogutil -d -b radio | wc -l) -eq 12 ] && ok || fail
+       [ "$(dlogutil -d -b radio | wc -l)" -eq 12 ] && ok || fail
+       dlogutil -c -b radio
 
        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
-
-       if [ $quick -ne 1 ]; then
+       ORIG_FILTERS_DIR=$(grep dynamic_config_path "$ORIGINAL_CONFIG_PATH" | awk -F "=" '{print $2}')
+       # Running ls on an arbitrary directory and trying to make sense of results is problematic.
+       # However, this is not a problem in our usecase, as we only care about the first field, the security context.
+       # We don't even care about the filename, which isn't arbitrary anyway (-d on fixed path).
+       # shellcheck disable=SC2012
+       [ "$(ls -dZ "$ORIG_FILTERS_DIR" | awk -F ' ' '{print $1}')" = "System::Shared" ] && ok || fail
+
+       if [ "$quick" -ne 1 ]; then
                # This creates a process which will wait for SIGCONT and then spam logs. We know its PID, so we can add
                # PID-based limits and see what happens.
                sh -c 'kill -s STOP $$; exec dlogsend -b main -c 100 "Pid test"' &
                DLOGSEND_PID=$!
-               while [[ $(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat) != "T" ]]; do :; done
+               while [ "$(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat)" != "T" ]; do :; done
                dlogctl --pid $DLOGSEND_PID -s deny
                kill -s CONT $DLOGSEND_PID
                wait $DLOGSEND_PID
                LOG_DETAILS="testing if PID limiting works (1/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep -v blocked | wc -l) -eq 0 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -cv blocked)" -eq 0 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (2/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep blocked | wc -l) -eq 1 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -c  blocked)" -eq 1 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (3/14)"
-               [[ $(dlogctl --pid $DLOGSEND_PID -g) == "Denied" ]] && ok || fail
+               [ "$(dlogctl --pid $DLOGSEND_PID -g)" = "Denied" ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (4/14)"
                dlogctl -g | grep -q "Denied for $DLOGSEND_PID" && ok || fail
 
                sh -c 'kill -s STOP $$; exec dlogsend -b main -c 100 "Pid test"' &
                DLOGSEND_PID=$!
-               while [[ $(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat) != "T" ]]; do :; done
+               while [ "$(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat)" != "T" ]; do :; done
                dlogctl --pid $DLOGSEND_PID -s 25
                kill -s CONT $DLOGSEND_PID
                wait $DLOGSEND_PID
                LOG_DETAILS="testing if PID limiting works (5/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep -v blocked | wc -l) -eq 25 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -cv blocked)" -eq 25 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (6/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep blocked | wc -l) -eq 1 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -c  blocked)" -eq 1 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (7/14)"
-               [[ $(dlogctl --pid $DLOGSEND_PID -g) == '25 logs/min' ]] && ok || fail
+               [ "$(dlogctl --pid $DLOGSEND_PID -g)" = '25 logs/min' ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (8/14)"
                dlogctl -g | grep -q "25 logs/min for $DLOGSEND_PID" && ok || fail
 
                sh -c 'kill -s STOP $$; exec dlogsend -b main -c 100 "Pid test"' &
                DLOGSEND_PID=$!
-               while [[ $(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat) != "T" ]]; do :; done
+               while [ "$(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat)" != "T" ]; do :; done
                dlogctl --pid $DLOGSEND_PID -s allow
                kill -s CONT $DLOGSEND_PID
                wait $DLOGSEND_PID
                LOG_DETAILS="testing if PID limiting works (9/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep -v blocked | wc -l) -eq 100 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -cv blocked)" -eq 100 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (10/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep blocked | wc -l) -eq 0 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -c  blocked)" -eq 0 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (11/14)"
-               [[ $(dlogctl --pid $DLOGSEND_PID -g) == 'Unlimited' ]] && ok || fail
+               [ "$(dlogctl --pid $DLOGSEND_PID -g)" = 'Unlimited' ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (12/14)"
                dlogctl -g | grep -q "Unlimited for $DLOGSEND_PID" && ok || fail
 
                echo "qos_refresh_rate_s=5" > "$RUNTIME_FILTERS_DIR/69-refresh-rate.conf"
                sh -c 'kill -s STOP $$; exec dlogsend -b main -c 15 -d 1 "Pid test"' &
                DLOGSEND_PID=$!
-               while [[ $(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat) != "T" ]]; do :; done
+               while [ "$(cut -d ' ' -f 3 < /proc/$DLOGSEND_PID/stat)" != "T" ]; do :; done
                dlogctl --pid $DLOGSEND_PID -s 2
                kill -s CONT $DLOGSEND_PID
                wait $DLOGSEND_PID
@@ -773,48 +856,42 @@ if [ "$TEST_DYNAMIC_FILTERS" == "true" ]; then
                LOG_DETAILS="testing if PID limiting works (13/14)"
                # In each 5 second period, 5 logs are sent, so there are 3 periods.
                # 2 logs from each period are allowed.
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep -v blocked | wc -l) -eq 6 ]] && ok || fail
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -cv blocked)" -eq 6 ] && ok || fail
                LOG_DETAILS="testing if PID limiting works (14/14)"
-               [[ $(dlogutil --pid $DLOGSEND_PID -d | grep blocked | wc -l) -eq 3 ]] && ok || fail
-
-               # TODO: HACK ALERT!
-               # The following QoS tests make perfect sense for the pipe backend, since we kill the already
-               # existing dlog_logger and then start the new one, configured with QoS. However, on the logger
-               # backend this is impossible, as dlog_test uses the global service started by systemd then.
-               # This means that we have to just launch the second instance and hope nothing breaks.
-               # This can be improved by not using the global service in the logger backend, and by having it
-               # completely disabled in the config file -- this way, the tests would be completely uniform.
+               [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -c  blocked)" -eq 3 ] && ok || fail
+
                PREQOS_CONFIG_PATH=$DLOG_CONFIG_PATH
                DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.qos"
-               if [ $type == "pipe" ]; then
-                       kill $LOGGER > /dev/null
-                       sleep 1
+               kill $LOGGER > /dev/null
+               sleep 1
+               if [ "$type" = "logger" ]; then
+                       dlogutil -cb main
                fi
-               dlog_logger -b 99 -t 0 &
+               dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
 
                dlogsend -b main -t DLOG_QOS_TEST0 -c 30 -d 1 -f 2 "A normal app that just wants to log"
                LOG_DETAILS="testing if QoS works (1/4)"
-               [[ $(dlogutil -d DLOG_QOS_TEST0 | grep -v blocked | wc -l) -eq 30 ]] && ok || fail
+               [ "$(dlogutil -d DLOG_QOS_TEST0 | grep -cv blocked)" -eq 30 ] && ok || fail
                kill $LOGGER > /dev/null
                sleep 1
-               if [ $type == "logger" ]; then
+               if [ "$type" = "logger" ]; then
                        dlogutil -cb main
                fi
-               dlog_logger -b 99 -t 0 &
+               dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
 
                dlogsend -b main -t DLOG_QOS_TEST1 -c 300 -d 1 -f 20 "Some log spam"
                LOG_DETAILS="testing if QoS works (2/4)"
-               [[ $(dlogutil -d DLOG_QOS_TEST1 | grep -v blocked | wc -l) -le 180 ]] && ok || fail
+               [ "$(dlogutil -d DLOG_QOS_TEST1 | grep -cv blocked)" -le 210 ] && ok || fail
                kill $LOGGER > /dev/null
                sleep 1
-               if [ $type == "logger" ]; then
+               if [ "$type" = "logger" ]; then
                        dlogutil -cb main
                fi
-               dlog_logger -b 99 -t 0 &
+               dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
 
@@ -823,27 +900,343 @@ if [ "$TEST_DYNAMIC_FILTERS" == "true" ]; then
                dlogsend -b main -t DLOG_QOS_TEST3 -c 270 -d 1 -f 18 "Some log spam"
                wait $DLOGSEND_PID
                LOG_DETAILS="testing if QoS works (3/4)"
-               [[ $(dlogutil -d DLOG_QOS_TEST2 DLOG_QOS_TEST3 | grep -v blocked | wc -l) -le 180 ]] && ok || fail
+               [ "$(dlogutil -d DLOG_QOS_TEST2 DLOG_QOS_TEST3 | grep -cv blocked)" -le 210 ] && ok || fail
                LOG_DETAILS="testing if QoS works (4/4)"
-               [[ $(dlogutil -d DLOG_QOS_TEST2 | grep -v blocked | wc -l) -gt 24 ]] && ok || fail
+               [ "$(dlogutil -d DLOG_QOS_TEST2 | grep -cv blocked)" -gt 24 ] && ok || fail
 
                DLOG_CONFIG_PATH=$PREQOS_CONFIG_PATH
                kill $LOGGER > /dev/null
                sleep 1
-               if [ $type == "pipe" ]; then
-                       dlog_logger -b 99 -t 0 &
-                       LOGGER=$!
-                       sleep 1
-               else
-                       LOGGER=-1
-               fi
+               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
 
+if [ "$LEGACY_LOGGER" -ne 1 ] && [ "$quick" -ne 1 ]; then
+       dlogutil -cb main
+
+       LOG_DETAILS="testing if basic stdout redirection works correctly (1/2)"
+       [ "$(dlog_redirect_stdout --outtag FOO -- /usr/bin/echo Hi)" = "" ] && ok || fail
+       sleep 1
+       LOG_DETAILS="testing if basic stdout redirection works correctly (2/2)"
+       [ "$(dlogutil -db main -v tag)" = "I/FOO     : Hi" ] && ok || fail
+       dlogutil -cb main
+
+       # No need to check output in this case, as nothing is written to stdout anyway
+       dlog_redirect_stdout --errtag BAR -- /usr/bin/sh -c "echo Hi >&2"
+       sleep 1
+       LOG_DETAILS="testing if basic stderr redirection works correctly"
+       [ "$(dlogutil -db main -v tag)" = "E/BAR     : Hi" ] && ok || fail
+       dlogutil -cb main
+
+       LOG_DETAILS="testing if redirector doesn't redirect anything by default (1/2)"
+       [ "$(dlog_redirect_stdout -- /usr/bin/echo Hi)" = "Hi" ] && ok || fail
+       sleep 1
+       LOG_DETAILS="testing if redirector doesn't redirect anything by default (2/2)"
+       [ "$(dlogutil -db main -v tag)" = "" ] && ok || fail
+       dlogutil -cb main
+
+       if [ "$type" != "zero-copy" ]; then # No buffers in zero-copy
+               dlog_redirect_stdout --outbuffer radio --outtag AN_INTERESTING_TAG --outprio W -- /usr/bin/echo Hi
+               sleep 1
+               LOG_DETAILS="testing if redirector settings work correctly on stdout (1/2)"
+               [ "$(dlogutil -db main -v tag)" = "" ] && ok || fail
+               LOG_DETAILS="testing if redirector settings work correctly on stdout (2/2)"
+               [ "$(dlogutil -db radio -v tag)" = "W/AN_INTERESTING_TAG: Hi" ] && ok || fail
+               dlogutil -cb radio
+
+               dlog_redirect_stdout --errbuffer radio --errtag ANOTHER_INTERESTING_TAG --errprio I -- /usr/bin/sh -c "echo Hi >&2"
+               sleep 1
+               LOG_DETAILS="testing if redirector settings work correctly on stderr (1/2)"
+               [ "$(dlogutil -db main -v tag)" = "" ] && ok || fail
+               LOG_DETAILS="testing if redirector settings work correctly on stderr (2/2)"
+               [ "$(dlogutil -db radio -v tag)" = "I/ANOTHER_INTERESTING_TAG: Hi" ] && ok || fail
+               dlogutil -cb radio
+       fi
+
+       echo "Testing" | dlog_redirect_stdout --outtag BAZ -- /usr/bin/cat
+       sleep 1
+       LOG_DETAILS="testing if redirector passes stdin correctly"
+       [ "$(dlogutil -db main -v tag)" = "I/BAZ     : Testing" ] && ok || fail
+       dlogutil -cb main
+
+       dlog_redirect_stdout --outtag QUUX -- /usr/bin/cat << EOF
+line 1
+line 2
+line 3
+line 4
+line 5
+EOF
+       sleep 1
+       LOG_DETAILS="testing if multiline logs are handled correctly"
+       [ "$(dlogutil -db main | wc -l)" -eq 5 ] && ok || fail
+       dlogutil -cb main
+
+       dlog_redirect_stdout --outtag QUUX -- /usr/bin/sh -c "printf \"line 1\0line 2\0line 3\0line 4\0line 5\""
+       sleep 1
+       LOG_DETAILS="testing if logs with the '\\0' character are handled correctly"
+       [ "$(dlogutil -db main | wc -l)" -eq 5 ] && ok || fail
+       dlogutil -cb main
+
+       dlog_redirect_stdout --outtag QUUX -- /usr/bin/sh -c "printf \"line 1\0line 2\nline 3\0line 4\nline 5\""
+       sleep 1
+       LOG_DETAILS="testing if logs with mixed delimiters are handled correctly"
+       [ "$(dlogutil -db main | wc -l)" -eq 5 ] && ok || fail
+       dlogutil -cb main
+
+       rm -f "$TESTDIR"/input
+       rm -f "$TESTDIR"/output
+       base64 -w 0 < /dev/urandom 2> /dev/null | head -c 250000 > "$TESTDIR"/input
+       dlog_redirect_stdout --outtag XYZZY -- /usr/bin/cat "$TESTDIR"/input
+       sleep 1
+       dlogutil -db main -v raw | tr -d '\n' > "$TESTDIR"/output
+       LOG_DETAILS="testing if long lines are handled correctly"
+       # Usually we would just diff or cmp the files. Unfortunately, as of writing, Tizen doesn't have such luxuries.
+       [ "$(sha256sum < "$TESTDIR"/input)" = "$(sha256sum < "$TESTDIR"/output)" ] && ok || fail
+       dlogutil -cb main
+
+       if [ "$type" = "pipe" ]; then
+               # TODO: Actually implement and enable this in the logger backend
+               dlogctl -b main --disable-stdout
+               LOG_DETAILS="testing if redirection can be disabled (1/3)"
+               [ "$(dlog_redirect_stdout --outtag THETAG -- /usr/bin/echo test)" = "" ] && ok || fail
+               sleep 1
+               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 (regular)')" = "* main (regular): ENABLED" ] && ok || fail
+
+               dlogctl -b main --enable-stdout
+               LOG_DETAILS="testing if redirection can be reenabled (1/3)"
+               [ "$(dlog_redirect_stdout --outtag THETAG -- /usr/bin/echo test)" = "" ] && ok || fail
+               sleep 1
+               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 (regular)')" = "* main (regular): ENABLED" ] && ok || fail
+               dlogutil -cb main
+       fi
+
+       if [ "$type" != "zero-copy" ]; then # No buffers in zero-copy
+               dlogctl -b radio --disable-stdout
+               dlog_redirect_stdout --outtag THETAG -- /usr/bin/echo test
+               sleep 1
+               LOG_DETAILS="testing if dlogctl --disable-stdout respects buffer choice"
+               [ "$(dlogutil -db main -v raw)" = "test" ] && ok || fail
+               dlogutil -cb main
+       fi
+
+       LOG_DETAILS="testing if redirection check works (1/5)"
+       test_libredirect 0 0 && ok || fail
+       LOG_DETAILS="testing if redirection check works (2/5)"
+       dlog_redirect_stdout -- /usr/libexec/libdlog/test_libredirect 0 0 && ok || fail
+       LOG_DETAILS="testing if redirection check works (3/5)"
+       dlog_redirect_stdout --outtag X -- /usr/libexec/libdlog/test_libredirect 1 0 && ok || fail
+       LOG_DETAILS="testing if redirection check works (4/5)"
+       dlog_redirect_stdout --errtag X -- /usr/libexec/libdlog/test_libredirect 0 1 && ok || fail
+       LOG_DETAILS="testing if redirection check works (5/5)"
+       dlog_redirect_stdout --outtag X --errtag Y -- /usr/libexec/libdlog/test_libredirect 1 1 && ok || fail
+
+       if [ "$type" != "zero-copy" ]; then # No buffers in zero-copy
+               LOG_DETAILS="testing if multiple redirections work (1/4)"
+               test_libredirect_multi && ok || fail
+               LOG_DETAILS="testing if multiple redirections work (2/4)"
+               [ "$(dlogutil -db main -v tag | grep "Message 1")" = "W/TAG1    : Message 1" ] && ok || fail
+               LOG_DETAILS="testing if multiple redirections work (3/4)"
+               [ "$(dlogutil -db main -v tag | grep "Message 2")" = "E/TAG2    : Message 2" ] && ok || fail
+               LOG_DETAILS="testing if multiple redirections work (4/4)"
+               [ "$(dlogutil -db system -v tag)" = "I/TAG3    : Message 3" ] && ok || fail
+               dlogutil -cb main -b system
+       fi
+fi
+
+if [ "$type" != "zero-copy" ]; then # No dynamic filters in zero-copy
+       dlogutil -c
+       echo "deduplicate_method=only_identical_neighbours" > "$RUNTIME_FILTERS_DIR/30-deduplicate.conf"
+       echo "deduplicate_interval_ms=10" >> "$RUNTIME_FILTERS_DIR/30-deduplicate.conf"
+
+       dlogsend -p Info -b main -c 9 -t DLOG_DEDUP_TEST "Basic deduplication, default warn_quantity"
+       LOG_DETAILS="testing if deduplication with warnings works properly (1/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication, default warn_quantity')" -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (2/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication, default warn_quantity LOG DUPLICATED')" -eq 0 ] && ok || fail
+
+       dlogsend -p Info -b main -c 12 -t DLOG_DEDUP_TEST "Basic deduplication, default warn_quantity"
+       LOG_DETAILS="testing if deduplication with warnings works properly (3/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication, default warn_quantity')" -eq 3 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (4/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication, default warn_quantity LOG DUPLICATED')" -eq 1 ] && ok || fail
+
+       echo "deduplicate_warn_quantity=8" >> "$RUNTIME_FILTERS_DIR/30-deduplicate.conf"
+
+       dlogsend -p Info -b main -c 24 -t DLOG_DEDUP_TEST Message
+       LOG_DETAILS="testing if deduplication with warnings works properly (5/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c Message)" -eq 4 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (6/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Message LOG DUPLICATED')" -eq 3 ] && ok || fail
+
+       dlogsend -p Info -b main -c 8 -t DLOG_DEDUP_TEST longerMessage
+       LOG_DETAILS="testing if deduplication with warnings works properly (7/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c longerMessage)" -eq 2 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (8/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c Message)" -eq 6 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (9/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'longerMessage LOG DUPLICATED')" -eq 1 ] && ok || fail
+
+       echo "deduplicate_warn_quantity=-1" >> "$RUNTIME_FILTERS_DIR/30-deduplicate.conf"
+
+       dlogsend -p Info -b main -c 12 -t DLOG_DEDUP_TEST "Basic deduplication, no warning"
+       LOG_DETAILS="testing if deduplication with warnings works properly (10/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication, no warning')" -eq 1 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (11/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication')" -eq 4 ] && ok || fail
+       LOG_DETAILS="testing if deduplication with warnings works properly (12/12)"
+       [ "$(dlogutil -d DLOG_DEDUP_TEST | grep -c 'Basic deduplication, no warning LOG DUPLICATED')" -eq 0 ] && ok || fail
+
+       rm "$RUNTIME_FILTERS_DIR/30-deduplicate.conf"
+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 [ $quick -ne 1 ]; then
+if [ "$(date +%Y)" -le 2000 ]; then
+       # This implies that the date isn't set. Let's set it to some date to better test timestamps.
+       date -s "@2121212121" > /dev/null
+fi
+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
+
+DLOG_PREV_PATH=$DLOG_CONFIG_PATH
+
+LOG_DETAILS="testing if config has control over redirecting to stdout (1/3)"
+DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.stdout_enable.1"
+
+test_config_redirect 1 1 1 1 && ok || fail
+
+LOG_DETAILS="testing if config has control over redirecting to stdout (2/3)"
+DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.stdout_enable.2"
+test_config_redirect 0 0 1 1 && ok || fail
+
+LOG_DETAILS="testing if config has control over redirecting to stdout (3/3)"
+DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.stdout_enable.3"
+test_config_redirect 1 1 0 0 && ok || fail
+
+DLOG_CONFIG_PATH=$DLOG_PREV_PATH
+
+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
+
+               kill $LOGGER > /dev/null
+               sleep 1
+               rm "$TESTDIR"/test*
+               dlog_logger -t 0 &
+               LOGGER=$!
+               sleep 1
+
+               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
+
+               dlogutil -cb main
+               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
+
+               sleep 1
+               kill $LOGGER > /dev/null
+               LOGGER=-1
+               sleep 1
+               LOG_DETAILS="testing if logger daemon buffering works (4/5)"
+               [ "$(grep -c DLOG_LOGGER_TEST3 "$TESTDIR"/test0)" -eq 100 ] && ok || fail
+
+               dlogutil -cb main
+
+               dlog_logger -t 10000 -b 100 &
+               LOGGER=$!
+               sleep 1
+
+               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
+       fi
+
        LOG_DETAILS="testing if the library works with multithreaded app"
        dlogutil -f $TESTDIR/dlog_mt_test &
        MT_TEST=$!
@@ -863,9 +1256,9 @@ if [ $quick -ne 1 ]; then
        # a single message. This gets us 5 groups of logs separated by a second; there are about 200 logs in each
        # group, sent about at the same time.
        (
-               for i in `seq 1 $SPAWN_CNT`; do
-                       delay=$(( (RANDOM) % 5 ))
-                       ( sleep $delay && dlogsend -b main -t DLOG_TESTSUITE $delay ) &
+               for i in $(seq 1 $SPAWN_CNT); do
+                       delay=$(shuf -i 1-5 -n 1)
+                       ( sleep "$delay" && dlogsend -b main -t DLOG_TESTSUITE "$delay" ) &
                done
                wait
        )
@@ -874,75 +1267,87 @@ if [ $quick -ne 1 ]; then
 
        test_libdlogutil sorting $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
 
+       if [ "$type" = "pipe" ]; then
+               for P in recv sent; do
+                       for Q in mono real; do
+                               LOG_DETAILS="testing if dlogutil --sort-by works correctly (${P}_${Q})"
+                               [ "$(dlogutil -db main --sort-by "${P}_${Q}" | wc -l)" -eq "$SPAWN_CNT" ] && ok || fail
+                       done
+               done
+               for P in recv sent; do
+                       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\":\"([^\"]*)\",\"${P}_real_ns\":([^,}]*).*\$/\\1 \2/" | sort -c -k1,1 -k2,2g && ok || fail
+               done
+       fi
+
        sort_formats="kerneltime time recv_realtime rwtime threadtime long"
 
        for format in $sort_formats; do
                LOG_DETAILS="testing if sorting by timestamp from random sources on heavy load works ($format format)"
-               prev_ts=0
-               unsorted=""
-               prev_line=""
 
                # collect data and analyze timestamps
-               lines=`dlogutil -b main -d -v $format`
-               while read line; do
-                       # filter out empty lines in "long" format
-                       [ -z "$line" ] && continue
-                       # filter out non-timestamp lines in "long" format
-                       if [ $format == "long" ] && [ "`echo "$line" | sed -re 's/^\[[[:print:]]*\]$/line_ok/g'`" != "line_ok" ]; then
-                               continue
-                       fi
-
-                       [ "$line" -eq "$line" ] 2>/dev/null && continue
+               dlogutil -b main -d -v "$format" | (
+                       prev_ts=0
+                       prev_line=""
+
+                       while read -r line; do
+                               # filter out empty lines in "long" format
+                               [ -z "$line" ] && continue
+                               # filter out non-timestamp lines in "long" format
+                               if [ "$format" = "long" ] && [ "$(echo "$line" | sed -re 's/^\[[:print:]*\]$/line_ok/g')" != "line_ok" ]; then
+                                       continue
+                               fi
+
+                               ts=$(extract_timestamp "$format" "$line")
+
+                               if [ "$ts" -ge "$prev_ts" ]; then
+                                       prev_ts=$ts
+                               else
+                                       printf "%s\n%s\n\n" "$prev_line" "$line" || break
+                               fi
+                               prev_line=$line
+                       done
+               ) | grep -q ^ && fail || ok
 
-                       ts=$(extract_timestamp "$format" "$line")
+       done
+fi
 
-                       if [ "$ts" -ge "$prev_ts" ]; then
-                               prev_ts=$ts
-                       else
-                               printf -v unsorted '%s\n\n%s\n%s' "$unsorted" "$prev_line" "$line"
-                               break
-                       fi
-                       prev_line=$line
-               done <<< "$lines"
+if [ "$type" = "pipe" ]; then
+       kill $LOGGER > /dev/null
+       sleep 1
 
-               [ -z "$unsorted" ] && ok || fail
-       done
+       PRERESIZE_CONFIG_PATH="$DLOG_CONFIG_PATH"
+       DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.compress"
 
-       sleep 3
+       RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
+       mkdir -m 777 -p "$RUNTIME_FILTERS_DIR"
 
-       if [ $type == "pipe" ]; then
+       dlog_logger -t 0 &
+       LOGGER=$!
+       sleep 1
 
-               # spawn a new daemon with limited FDs for the FD checks
-               kill $LOGGER > /dev/null
-               sleep 1
-               ULIMIT_CURRENT=`ulimit -n`
-               ulimit -n 30
-               dlog_logger -b 99 -t 600 &> /dev/null &
-               LOGGER=$!
-               ulimit -n $ULIMIT_CURRENT
+       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
 
-               LOG_DETAILS="checking if the daemon closes util connections without logs stored"
-               run_utils
-               sleep 3
-               [ `ls -la /proc/$LOGGER/fd | grep fifo | wc -l` -eq 0 -a `ls -la /proc/$LOGGER/fd | grep pipe | wc -l` -eq 0 ] && 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
 
-               LOG_DETAILS="checking if the daemon closes libdlog connections"
-               for i in {1..30}; do
-                       dlogsend -c $i -b main -p e -t FOO BAR BAZ &
-               done
-               dlogsend -c 99999 -b main -p e -t FOO BAR BAZ &
-               sleep 0.5
-               kill $!
-               sleep 1.5
-               [ `ls -la /proc/$LOGGER/fd | grep fifo | wc -l` -eq 0 -a `ls -la /proc/$LOGGER/fd | grep pipe | 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
 
-               LOG_DETAILS="checking if the daemon closes util connections with logs stored"
-               run_utils
-               sleep 0.5
-               killall dlogutil &> /dev/null
-               sleep 1.5
-               [ `ls -la /proc/$LOGGER/fd | grep fifo | wc -l` -eq 0 -a `ls -la /proc/$LOGGER/fd | grep pipe | wc -l` -eq 0 ] && ok || fail
-       fi
+       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
@@ -950,13 +1355,17 @@ fi
 echo "$OKS / $TOTAL tests passed"
 echo "$FAILS / $TOTAL tests failed"
 
-if [ $quick -eq 1 ]; then
+if [ "$quick" -eq 1 ]; then
        echo "WARNING: quick mode!"
        echo "About 20% slowest running tests are disabled. Some functionality might be untested."
-       echo "Rerun with '$type' instead of '${type}_quick' to run all tests."
+       echo "Rerun without '--quick' to run all tests."
+elif [ "$LEGACY_LOGGER" -eq 1 ]; then
+       echo "WARNING: legacy logger module!"
+       echo "Some functionality is untested."
+       echo "Rerun on a device with the out-of-tree logger module to run all tests."
 fi
 
-[[ "$FAILS" -eq 0 ]]
+[ "$FAILS" -eq 0 ]
 # THE LINE ABOVE MUST STAY THE LAST COMMAND IN THE FILE!
 # This is because it is used to pass the exit code. If another command
 # is executed after it, its exit code will be propagated instead.