[03/15] gdb/testsuite: update gdb.tui/tui-nl-filtered-output.exp

Message ID b07bc1689329c6a5e28dab7b8c28c13f5f64f6e7.1673000632.git.aburgess@redhat.com
State New
Headers
Series Mixed bag of TUI tests and fixes |

Commit Message

Andrew Burgess Jan. 6, 2023, 10:25 a.m. UTC
  Following on from the previous commit, in this commit I am updating
the test script gdb.tui/tui-nl-filtered-output.exp to take account of
the changes in commit:

  commit 9162a27c5f5828240b53379d735679e2a69a9f41
  Date:   Tue Nov 13 11:59:03 2018 -0700

      Change gdb test suite's TERM setting

In the above commit the TERM environment variable was changed to be
'dumb' by default, which means that tests, that previously activated
tui mode, no longer do unless TERM is set to 'ansi'.

As the gdb.tui/tui-nl-filtered-output.exp script didn't do this, the
test stopped working.  As the expect patterns in this script were
pretty generic no tests actually started failing, and we never
noticed.

In this commit I update the test script to correctly activate our
terminal emulator, the test continues to pass after this update, but
now we are testing in tui mode.
---
 .../gdb.tui/tui-nl-filtered-output.exp        | 41 ++++++++-----------
 1 file changed, 16 insertions(+), 25 deletions(-)
  

Comments

Andrew Burgess Jan. 25, 2023, 11:30 a.m. UTC | #1
Andrew Burgess <aburgess@redhat.com> writes:

> Following on from the previous commit, in this commit I am updating
> the test script gdb.tui/tui-nl-filtered-output.exp to take account of
> the changes in commit:
>
>   commit 9162a27c5f5828240b53379d735679e2a69a9f41
>   Date:   Tue Nov 13 11:59:03 2018 -0700
>
>       Change gdb test suite's TERM setting
>
> In the above commit the TERM environment variable was changed to be
> 'dumb' by default, which means that tests, that previously activated
> tui mode, no longer do unless TERM is set to 'ansi'.
>
> As the gdb.tui/tui-nl-filtered-output.exp script didn't do this, the
> test stopped working.  As the expect patterns in this script were
> pretty generic no tests actually started failing, and we never
> noticed.
>
> In this commit I update the test script to correctly activate our
> terminal emulator, the test continues to pass after this update, but
> now we are testing in tui mode.

I've gone ahead and pushed this patch.  The final version that I pushed
is included below.

Thanks,
Andrew

---

commit 3602634035f6a346ac043a7f01442a7290b9f588
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Thu Dec 22 10:24:22 2022 +0000

    gdb/testsuite: update gdb.tui/tui-nl-filtered-output.exp
    
    Following on from the previous commit, in this commit I am updating
    the test script gdb.tui/tui-nl-filtered-output.exp to take account of
    the changes in commit:
    
      commit 9162a27c5f5828240b53379d735679e2a69a9f41
      Date:   Tue Nov 13 11:59:03 2018 -0700
    
          Change gdb test suite's TERM setting
    
    In the above commit the TERM environment variable was changed to be
    'dumb' by default, which means that tests, that previously activated
    tui mode, no longer do unless TERM is set to 'ansi'.
    
    As the gdb.tui/tui-nl-filtered-output.exp script didn't do this, the
    test stopped working.  As the expect patterns in this script were
    pretty generic no tests actually started failing, and we never
    noticed.
    
    In this commit I update the test script to correctly activate our
    terminal emulator, the test continues to pass after this update, but
    now we are testing in tui mode.

diff --git a/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp b/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp
index b7ea67cf723..5b1d6b7d9ba 100644
--- a/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp
+++ b/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp
@@ -32,24 +32,19 @@
 
 require allow_tui_tests
 
-gdb_exit
-gdb_start
-
-# Enable the TUI.
-
-set test "tui enable"
-gdb_test_multiple "tui enable" $test {
-    -re "$gdb_prompt $" {
-	pass $test
-    }
-}
-
-# Make sure filtering/pagination is enabled, but make the window high
-# enough that we don't paginate in practice.
-gdb_test_no_output "set pagination on"
-gdb_test_no_output "set height 2000"
-
-gdb_test \
-    {printf "hello\nworld\n"} \
-    "hello\r\nworld" \
-    "correct line breaks"
+tuiterm_env
+
+# Setup and enter TUI mode.
+Term::clean_restart 24 80
+Term::enter_tui
+
+# Send the command, and check the output is correctly split over
+# multiple lines.
+Term::command \
+    {printf "hello\nworld\n"}
+Term::check_region_contents "check printf output" \
+    0 16 80 4 [multi_line \
+		   "$gdb_prompt printf \"hello\\\\nworld\\\\n\"\\s+" \
+		   "hello\\s+" \
+		   "world\\s+" \
+		   "$gdb_prompt\\s+"]
  

Patch

diff --git a/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp b/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp
index 5a2a4205bb5..b3d80a36a6f 100644
--- a/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp
+++ b/gdb/testsuite/gdb.tui/tui-nl-filtered-output.exp
@@ -30,28 +30,19 @@ 
 #
 #  (gdb)
 
-gdb_exit
-gdb_start
-
-if {[skip_tui_tests]} {
-    return
-}
-
-# Enable the TUI.
-
-set test "tui enable"
-gdb_test_multiple "tui enable" $test {
-    -re "$gdb_prompt $" {
-	pass $test
-    }
-}
-
-# Make sure filtering/pagination is enabled, but make the window high
-# enough that we don't paginate in practice.
-gdb_test_no_output "set pagination on"
-gdb_test_no_output "set height 2000"
-
-gdb_test \
-    {printf "hello\nworld\n"} \
-    "hello\r\nworld" \
-    "correct line breaks"
+tuiterm_env
+
+# Setup and enter TUI mode.
+Term::clean_restart 24 80
+Term::enter_tui
+
+# Send the command, and check the output is correctly split over
+# multiple lines.
+Term::command \
+    {printf "hello\nworld\n"}
+Term::check_region_contents "check printf output" \
+    0 16 80 4 [multi_line \
+		   "$gdb_prompt printf \"hello\\\\nworld\\\\n\"\\s+" \
+		   "hello\\s+" \
+		   "world\\s+" \
+		   "$gdb_prompt\\s+"]