[v4,34/39] dyndbg-test: add test which verifies flags and dst

Message ID 20240210235009.2405808-35-ukaszb@chromium.org
State New
Headers
Series dyndbg: add support for writing debug logs to trace |

Commit Message

Łukasz Bartosik Feb. 10, 2024, 11:50 p.m. UTC
  Add test which verifies different combinations of flags
and trace destination.

Signed-off-by: Łukasz Bartosik <ukaszb@chromium.org>
---
 .../dynamic_debug/dyndbg_selftest.sh          | 98 +++++++++++++++++++
 1 file changed, 98 insertions(+)
  

Patch

diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
index f8b81e8a3bd6..4a0340d2c3e8 100755
--- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
+++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
@@ -246,6 +246,103 @@  function test_percent_splitting {
     ifrmmod test_dynamic_debug
 }
 
+# test verifies different combinations of flags and trace destination
+function test_flags {
+    echo -e "${GREEN}# TEST_FLAGS ${NC}"
+
+    modprobe test_dynamic_debug dyndbg=+Tlm
+    check_match_ct =Tml 5 -v
+
+    ddcmd open selftest
+    check_trace_instance_dir selftest 1
+    is_trace_instance_opened selftest
+
+    # invalid combinations of flags and trace destination
+    ddcmd module test_dynamic_debug =Tm:0 fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =Tm:0. fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =T:m.:0 fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =T:m.:0. fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:0lT fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:0lT. fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:0.lm:0 fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:0.lmT. fail
+    check_err_msg "Invalid argument"
+
+    ddcmd module test_dynamic_debug =Tm:selftest fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =Tm:selftest. fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =T:m.:selftest fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =T:m.:selftest. fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:selftestlT fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:selftestlT. fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:selftest.lm:0 fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =:selftest.lmT fail
+    check_err_msg "Invalid argument"
+
+    ddcmd module test_dynamic_debug =Tl.m fail
+    check_err_msg "Invalid argument"
+    ddcmd module test_dynamic_debug =T.lm fail
+    check_err_msg "Invalid argument"
+
+    # valid combinations of flags and trace destination
+    ddcmd module test_dynamic_debug =p
+    check_match_ct =p 5 -v
+    ddcmd module test_dynamic_debug =T
+    check_match_ct =T:selftest 5 -v
+    ddcmd module test_dynamic_debug =_
+    check_match_ct =:selftest 5 -v
+
+    ddcmd module test_dynamic_debug =T:0
+    check_match_ct =T 5 -v
+    ddcmd module test_dynamic_debug -_
+    check_match_ct =T 5 -v
+    ddcmd module test_dynamic_debug =T:0.mf
+    check_match_ct =Tmf 5 -v
+    ddcmd module test_dynamic_debug =T:selftest
+    check_match_ct =T:selftest 5 -v
+    ddcmd module test_dynamic_debug =T:selftest.mf
+    check_match_ct =T:selftest.mf 5 -v
+    ddcmd module test_dynamic_debug =_:selftest
+    check_match_ct =:selftest 5 -v
+
+    ddcmd module test_dynamic_debug =:0
+    ddcmd module test_dynamic_debug =:selftest
+    check_match_ct =:selftest 5 -v
+    ddcmd module test_dynamic_debug =p:selftest
+    check_match_ct =p:selftest 5 -v
+    ddcmd module test_dynamic_debug +_
+    check_match_ct =p:selftest 5 -v
+
+    ddcmd module test_dynamic_debug =T:selftest.mlf
+    ddcmd module test_dynamic_debug =:0
+    check_match_ct =Tmfl 5 -v
+    ddcmd module test_dynamic_debug =:selftest
+    check_match_ct =T:selftest.mfl 5 -v
+    ddcmd module test_dynamic_debug =:0
+    check_match_ct =Tmfl 5 -v
+    ddcmd module test_dynamic_debug =_:selftest
+    check_match_ct =:selftest 5 -v
+
+    ddcmd module test_dynamic_debug =:0.
+
+    ddcmd close selftest
+    is_trace_instance_closed selftest
+    ifrmmod test_dynamic_debug
+}
+
 function test_actual_trace {
     echo -e "${GREEN}# TEST_ACTUAL_TRACE ${NC}"
     ddcmd =_
@@ -692,6 +789,7 @@  tests_list=(
     basic_tests
     comma_terminator_tests
     test_percent_splitting
+    test_flags
     test_actual_trace
     cycle_tests_normal
     cycle_not_best_practices