Unify logger and pipe tests a bit
[platform/core/system/dlog.git] / tests / dlog_test.in
index 9da1a17..7a66586 100644 (file)
@@ -162,11 +162,9 @@ RUNTIME_FILTERS_DIR="/tmp/dlog-filters/"
 mkdir -p "$RUNTIME_FILTERS_DIR"
 
 # Start the daemon
-if [ "$type" = "pipe" ]; then
-       dlog_logger &
-       LOGGER=$!
-       sleep 1
-fi
+dlog_logger -t 0 &
+LOGGER=$!
+sleep 1
 
 if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
        dlogctl -c
@@ -819,20 +817,14 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                LOG_DETAILS="testing if PID limiting works (14/14)"
                [ "$(dlogutil --pid $DLOGSEND_PID -d | grep -c  blocked)" -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.
                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 &
+               dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
 
@@ -844,7 +836,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                if [ "$type" = "logger" ]; then
                        dlogutil -cb main
                fi
-               dlog_logger &
+               dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
 
@@ -856,7 +848,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                if [ "$type" = "logger" ]; then
                        dlogutil -cb main
                fi
-               dlog_logger &
+               dlog_logger -t 0 &
                LOGGER=$!
                sleep 1
 
@@ -872,13 +864,9 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                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
        fi
 fi
 
@@ -930,22 +918,27 @@ LOG_DETAILS="testing if libdlogutil clears the buffer correctly"
 test_libdlogutil clear $LIBDLOGUTIL_CORRECT_PID $type && ok || fail
 
 if [ "$quick" -ne 1 ]; then
-       if [ "$type" = "pipe" ]; then
-               dlogsend -b main -t DLOG_LOGGER_TEST0 -c 100 "hi"
-               sleep 1
-               LOG_DETAILS="testing if logger daemon persistent logging works"
-               [ "$(grep -c DLOG_LOGGER_TEST0 "$TESTDIR"/main)" -eq 100 ] && ok || fail
+       kill $LOGGER > /dev/null
+       sleep 1
+       rm "$TESTDIR"/test*
+       dlog_logger -t 0 &
+       LOGGER=$!
+       sleep 1
 
-               dlogsend -b main -t DLOG_LOGGER_TEST1 -c 500000 "hi"
-               sleep 1
-               RESULT=$(du -c "$TESTDIR"/main* | 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
+       dlogsend -b main -t DLOG_LOGGER_TEST0 -c 100 "hi"
+       sleep 1
+       LOG_DETAILS="testing if logger daemon persistent logging works"
+       [ "$(grep -c DLOG_LOGGER_TEST0 "$TESTDIR"/test)" -eq 100 ] && ok || fail
 
-               dlogutil -cb main
-       fi
+       dlogsend -b main -t DLOG_LOGGER_TEST1 -c 500000 "hi"
+       sleep 1
+       RESULT=$(du -c "$TESTDIR"/test* | 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
 
        LOG_DETAILS="testing if the library works with multithreaded app"
        dlogutil -f $TESTDIR/dlog_mt_test &