Modify gdb.threads/pthreads.exp to test FLAG qcs arguments for thread apply.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 20 May 2018 18:31:27 +0000 (20:31 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 12 Jul 2018 21:10:29 +0000 (23:10 +0200)
Also, add prefixes to make some non unique tests unique.

gdb/testsuite/ChangeLog
2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.threads/pthreads.exp: Test qcs FLAG arguments.
Add some test prefixes to make tests unique.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/pthreads.exp

index 84bfa77..570ba53 100644 (file)
@@ -1,5 +1,10 @@
 2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
+       * gdb.threads/pthreads.exp: Test qcs FLAG arguments.
+       Add some test prefixes to make tests unique.
+
+2018-07-12  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
        * gdb.base/frameapply.c: New file.
        * gdb.base/frameapply.exp: New file.
 
index 830432b..bbda52e 100644 (file)
@@ -188,8 +188,10 @@ proc check_control_c {} {
     global gdb_prompt
 
     # Verify that all threads are running.
-    if [all_threads_running] then {
-       pass "all threads running after startup"
+    with_test_prefix "after startup" {
+       if [all_threads_running] then {
+           pass "all threads running after startup"
+       }
     }
 
     # Send a continue followed by ^C to the process to stop it.
@@ -216,8 +218,10 @@ proc check_control_c {} {
     gdb_test "bt" ".*"
 
     # Verify that all threads can be run again after a ^C stop.
-    if [all_threads_running] then {
-       pass "all threads running after continuing from ^C stop"
+    with_test_prefix "after continue" {
+       if [all_threads_running] then {
+           pass "all threads running after continuing from ^C stop"
+       }
     }
     return 0
 }
@@ -267,6 +271,76 @@ proc check_backtraces {} {
     }
 }
 
+proc check_qcs {} {
+    set any "\[^\r\n\]*"
+    set ws "\[ \t\]\+"
+    set number "\[0-9]\+"
+
+    # Check -c (continue) and -s (silently continue) flags.
+    gdb_test "thread apply 2-3 p notfound" \
+       [multi_line \
+            "" \
+            "Thread 2 ${any}" \
+            "No symbol \\\"notfound\\\" in current context." \
+           ] \
+       "run a failing command that aborts thread apply"
+
+    gdb_test "thread apply 2-3 -c p notfound" \
+       [multi_line \
+            "" \
+            "Thread 2 ${any}" \
+            "No symbol \\\"notfound\\\" in current context." \
+            "" \
+            "Thread 3 ${any}" \
+            "No symbol \\\"notfound\\\" in current context." \
+           ] \
+       "run a failing command, -c to continue"
+
+    with_test_prefix "silent flag" {
+       foreach_with_prefix cmd_and_args {
+           "thread apply all -s frame apply all -s"
+           "tfaas"
+           "taas faas"} {
+               set cmd "$cmd_and_args p i"
+               gdb_test $cmd \
+                   [multi_line \
+                        "" \
+                        "Thread 3 ${any}" \
+                        "#${number}${ws}${any} in thread2 ${any}" \
+                        "\\\$\[0-9]+ = ${number}${any}" \
+                        "" \
+                        "Thread 2 ${any}" \
+                        "#${number}${ws}${any} in thread1 ${any}" \
+                        "\\\$\[0-9]+ = ${number}${any}" \
+                       ] \
+                   "run a failing command except in one frame of thread 2,3, -s to silently continue"
+           }
+    }
+
+    # Check quietness.
+    gdb_test "thread apply all -s -q frame apply all -s p i" \
+       [multi_line \
+            "#${number}${ws}${any} in thread2 ${any}" \
+            "\\\$\[0-9]+ = ${number}${any}" \
+            "#${number}${ws}${any} in thread1 ${any}" \
+            "\\\$\[0-9]+ = ${number}${any}" \
+           ] \
+       "run a failing command except in one frame of thread 2,3, -s to silently continue.  Do not show thread information"
+
+    gdb_test "thread apply all -s -q frame apply all -s -q p i" \
+       [multi_line \
+            "\\\$\[0-9]+ = ${number}${any}" \
+            "\\\$\[0-9]+ = ${number}${any}" \
+           ] \
+       "run a failing command except in one frame of thread 2,3, -s to silently continue.  Do not show thread and frame info"
+
+    # Check invalid flag combinations.
+    gdb_test "thread apply all -c -s p 1" \
+       "thread apply all: -c and -s are mutually exclusive" \
+       "check -c and -s cannot be used simultaneously"
+
+}
+
 if [runto_main] then {
     if [test_startup] then {
        if [check_control_c] then {
@@ -274,5 +348,6 @@ if [runto_main] then {
            return
        }
        check_backtraces
+       check_qcs
     }
 }