dlogctl: adjust the buffer enable/disable display 75/286775/3
authorMichal Bloch <m.bloch@samsung.com>
Thu, 22 Dec 2022 13:32:00 +0000 (14:32 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 1 Feb 2023 16:37:15 +0000 (17:37 +0100)
Put each ENABLE/DISABLE in its own line for easy parsing.

Fix tests to use only the lines they were meant to use.
When stdout status was added to the same line, parsing
in tests became able to use either of the two statuses.

Change-Id: I4d05b9dbb9ac3899976f13ff7e3fc1ed756359ee
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/logctl/logctl.c
tests/dlog_test.in

index 581c057..5b49499 100644 (file)
@@ -754,10 +754,14 @@ int handle_dump(const struct parsed_params *params, const char *config_path, str
 
                bool stdout_enabled;
                ret = (is_pipe ? get_stdout_one_pipe : get_stdout_one_nonpipe)(i, conf, &stdout_enabled);
-               printf("* %s: %s (stdout: %s)\n",
-                               log_name_by_id((log_id_t)i),
-                               log_config_get_boolean(conf, key, i == LOG_ID_APPS ? plog_default : true) ? "ENABLED" : "DISABLED",
-                               ret != 0 ? "UNKNOWN" : stdout_enabled ? "ENABLED" : "DISABLED");
+               printf("* %s (regular): %s\n"
+                       , log_name_by_id((log_id_t)i)
+                       , log_config_get_boolean(conf, key, i == LOG_ID_APPS ? plog_default : true) ? "ENABLED" : "DISABLED"
+               );
+               printf("* %s (stdout): %s\n"
+                       , log_name_by_id((log_id_t)i)
+                       , ret != 0 ? "UNKNOWN" : stdout_enabled ? "ENABLED" : "DISABLED"
+               );
        }
 
        __log_limiter_destroy(limiter_data);
index a1540bc..b281da8 100644 (file)
@@ -161,7 +161,7 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
                dlogutil -c -b radio -b system -b main
                LOG_DETAILS="dlogctl --disable (no args)"
                dlogctl --disable
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: ENABLED')" -eq 0 ] && ok || fail
+               [ "$(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
@@ -170,7 +170,7 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --enable (no args)"
                dlogctl --enable
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED')" -eq 0 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED)" -eq 0 ] && ok || fail
                LOG_DETAILS="testing if filters were applied"
                dlogutil -c -b radio -b system -b main
                dlogsend -b system -t TEST test
@@ -180,8 +180,8 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --disable (1 arg)"
                dlogctl --disable -b system
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: DISABLED' | grep -c system)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED'                 )" -eq 1 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep    DISABLED | grep -c system)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED                 )" -eq 1 ] && ok || fail
                LOG_DETAILS="testing if filters were applied"
                dlogutil -c -b radio -b system -b main
                dlogsend -b system -t TEST test
@@ -191,9 +191,9 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --disable (multiple args)"
                dlogctl --disable -b main -b radio
-               [ "$(dlogctl -g | grep '^\* [a-z]*: DISABLED' | grep -cv system)" -eq 2 ] &&
-               [ "$(dlogctl -g | grep '^\* [a-z]*: DISABLED' | grep -c   radio)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep '^\* [a-z]*: DISABLED' | grep -c    main)" -eq 1 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep DISABLED | grep -cv system)" -eq 2 ] &&
+               [ "$(dlogctl -g | grep regular | grep DISABLED | grep -c   radio)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep DISABLED | grep -c    main)" -eq 1 ] && ok || fail
                LOG_DETAILS="testing if filters were applied"
                dlogutil -c -b radio -b system -b main
                dlogsend -b system -t TEST test
@@ -203,10 +203,10 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --enable (multiple args)"
                dlogctl --enable -b radio -b system
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED'                 )" -eq 1 ] &&
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: DISABLED' | grep -c   main)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: ENABLED'  | grep -c system)" -eq 1 ] &&
-               [ "$(dlogctl -g | grep    '^\* [a-z]*: ENABLED'  | grep -c  radio)" -eq 1 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED                 )" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep    DISABLED | grep -c   main)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep     ENABLED | grep -c system)" -eq 1 ] &&
+               [ "$(dlogctl -g | grep regular | grep     ENABLED | grep -c  radio)" -eq 1 ] && ok || fail
                LOG_DETAILS="testing if filters were applied"
                dlogutil -c -b radio -b system -b main
                dlogsend -b system -t TEST test
@@ -216,7 +216,7 @@ if [ "$type" != "zero-copy" ]; then # These tests are inherently dynamic.
 
                LOG_DETAILS="dlogctl --enable (1 arg)"
                dlogctl --enable -b main
-               [ "$(dlogctl -g | grep -c '^\* [a-z]*: DISABLED')" -eq 0 ] && ok || fail
+               [ "$(dlogctl -g | grep regular | grep -c DISABLED)" -eq 0 ] && ok || fail
                LOG_DETAILS="testing if filters were applied"
                dlogutil -c -b radio -b system -b main
                dlogsend -b system -t TEST test
@@ -1003,7 +1003,7 @@ EOF
                LOG_DETAILS="testing if redirection can be disabled (2/3)"
                [ "$(dlogutil -db main -v raw)" = "" ] && ok || fail
                LOG_DETAILS="testing if redirection can be disabled (3/3)"
-               [ "$(dlogctl --get | grep main)" = "* main: ENABLED (stdout: DISABLED)" ] && ok || fail
+               [ "$(dlogctl --get | grep 'main (regular)')" = "* main (regular): ENABLED" ] && ok || fail
 
                dlogctl -b main --enable-stdout
                LOG_DETAILS="testing if redirection can be reenabled (1/3)"
@@ -1012,7 +1012,7 @@ EOF
                LOG_DETAILS="testing if redirection can be reenabled (2/3)"
                [ "$(dlogutil -db main -v raw)" = "test" ] && ok || fail
                LOG_DETAILS="testing if redirection can be reenabled (3/3)"
-               [ "$(dlogctl --get | grep main)" = "* main: ENABLED (stdout: ENABLED)" ] && ok || fail
+               [ "$(dlogctl --get | grep 'main (regular)')" = "* main (regular): ENABLED" ] && ok || fail
                dlogutil -cb main
        fi