Remove unnecessary wc -l 68/242968/1
authorMateusz Majewski <m.majewski2@samsung.com>
Wed, 2 Sep 2020 06:33:52 +0000 (08:33 +0200)
committerMateusz Majewski <m.majewski2@samsung.com>
Wed, 2 Sep 2020 06:33:52 +0000 (08:33 +0200)
Change-Id: I29d8541202e5a98b26b2f09c0f14bdf9b6f97f92

tests/dlog_test.in

index 7159983..b1c185f 100644 (file)
@@ -142,7 +142,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
        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
+       [ "$(dlogctl -g | 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
@@ -151,7 +151,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
        LOG_DETAILS="dlogctl --enable (no args)"
        dlogctl --enable
-       [ "$(dlogctl -g | grep DISABLED | wc -l)" -eq 0 ] && ok || fail
+       [ "$(dlogctl -g | 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
@@ -161,8 +161,8 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
        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
+       [ "$(dlogctl -g | grep    DISABLED | grep -c system)" -eq 1 ] &&
+       [ "$(dlogctl -g | 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
@@ -172,9 +172,9 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
        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
+       [ "$(dlogctl -g | grep DISABLED | grep -cv system)" -eq 2 ] &&
+       [ "$(dlogctl -g | grep DISABLED | grep -c   radio)" -eq 1 ] &&
+       [ "$(dlogctl -g | 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
@@ -184,10 +184,10 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
        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
+       [ "$(dlogctl -g | grep -c DISABLED                 )" -eq 1 ] &&
+       [ "$(dlogctl -g | grep    DISABLED | grep -c   main)" -eq 1 ] &&
+       [ "$(dlogctl -g | grep    ENABLED  | grep -c system)" -eq 1 ] &&
+       [ "$(dlogctl -g | 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
@@ -197,7 +197,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
        LOG_DETAILS="dlogctl --enable (1 arg)"
        dlogctl --enable -b main
-       [ "$(dlogctl -g | grep DISABLED | wc -l)" -eq 0 ] && ok || fail
+       [ "$(dlogctl -g | 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
@@ -253,18 +253,18 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
        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
+       [ $(cat "$RUNTIME_FILTERS_DIR/05-logctl.conf" | grep -cE 'limiter\|\*\|\*=100') -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
+       [ "$(dlogctl -g | grep '*:*' | 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)"
-       [ $(cat "$RUNTIME_FILTERS_DIR/05-logctl.conf" | grep -E 'limiter\|\*\|\*=100' | wc -l) -eq 0 ] && ok || fail
+       [ $(cat "$RUNTIME_FILTERS_DIR/05-logctl.conf" | grep -cE 'limiter\|\*\|\*=100') -eq 0 ] && ok || fail
        dlogctl -c
 
        LOG_DETAILS="testing if the whole dynamic config directory is respected"
@@ -722,9 +722,9 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                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
                LOG_DETAILS="testing if PID limiting works (4/14)"
@@ -737,9 +737,9 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                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
                LOG_DETAILS="testing if PID limiting works (8/14)"
@@ -752,9 +752,9 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
                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
                LOG_DETAILS="testing if PID limiting works (12/14)"
@@ -771,9 +771,9 @@ 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
+               [ "$(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
@@ -794,7 +794,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
                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
@@ -806,7 +806,7 @@ if [ "$TEST_DYNAMIC_FILTERS" = "true" ]; then
 
                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 180 ] && ok || fail
                kill $LOGGER > /dev/null
                sleep 1
                if [ "$type" = "logger" ]; then
@@ -821,9 +821,9 @@ 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 180 ] && 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