Skip tests on completion and readline when readline lib isn't used
authorYao Qi <yao@codesourcery.com>
Wed, 19 Mar 2014 02:16:35 +0000 (10:16 +0800)
committerYao Qi <yao@codesourcery.com>
Wed, 26 Mar 2014 13:11:08 +0000 (21:11 +0800)
The completion feature and other features on readline depend on the
readline library.  However, readline library is not always used, for
example, running testsuite like

  make check RUNTESTFLAGS="--host_board=local-remote-host"

the input stream is not a tty, and GDB doesn't use readline library
as a result.

This patch is to skip tests on completion and readline if
'show editing' is off, which means readline isn't used.  Note that
some tests in gdb.base/completion.exp test command complete, which
isn't related to readline, so these tests aren't affected by readline
library.  This patch also moves these tests up, run them
unconditionally, and run the rest if readline library is used.

gdb/testsuite:

2014-03-26  Yao Qi  <yao@codesourcery.com>

* lib/gdb.exp (readline_is_used): New proc.
* gdb.base/completion.exp: Move tests on command complete up.
Skip the rest of tests if readline is not used.
* gdb.ada/complete.exp: Skp the test if readline is not
used.
* gdb.base/filesym.exp: Likewise.
* gdb.base/macscp.exp: Likewise.
* gdb.base/readline-ask.exp: Likewise.
* gdb.base/readline.exp: Likewise.
* gdb.python/py-cmd.exp: Likewise.
* gdb.trace/tfile.exp: Likewise.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/complete.exp
gdb/testsuite/gdb.base/completion.exp
gdb/testsuite/gdb.base/filesym.exp
gdb/testsuite/gdb.base/macscp.exp
gdb/testsuite/gdb.base/readline-ask.exp
gdb/testsuite/gdb.base/readline.exp
gdb/testsuite/gdb.python/py-cmd.exp
gdb/testsuite/gdb.trace/tfile.exp
gdb/testsuite/lib/gdb.exp

index 694efd67c9af9b2f86b7fe53d950fffb9097dd96..45355f3ac6c87fa86bbf0d1e0ce76ab0845fb7d3 100644 (file)
@@ -1,3 +1,17 @@
+2014-03-26  Yao Qi  <yao@codesourcery.com>
+
+       * lib/gdb.exp (readline_is_used): New proc.
+       * gdb.base/completion.exp: Move tests on command complete up.
+       Skip the rest of tests if readline is not used.
+       * gdb.ada/complete.exp: Skp the test if readline is not
+       used.
+       * gdb.base/filesym.exp: Likewise.
+       * gdb.base/macscp.exp: Likewise.
+       * gdb.base/readline-ask.exp: Likewise.
+       * gdb.base/readline.exp: Likewise.
+       * gdb.python/py-cmd.exp: Likewise.
+       * gdb.trace/tfile.exp: Likewise.
+
 2014-03-26  Yao Qi  <yao@codesourcery.com>
 
        * gdb.base/macscp.exp: Fix code format issues.
index 5b52f73aa045b3c332282f9da27e8d9d8b7ff1d5..1e1ebaaf67f5bf6af51a20719fbdcab6bfa0f5f1 100644 (file)
@@ -176,15 +176,18 @@ test_gdb_complete "<pck__my" \
 # The verification we are trying to make involves the event loop,
 # and using the "complete" command is not sufficient to reproduce
 # the original problem.
-set test "interactive complete 'print some'"
-send_gdb "print some\t"
-gdb_test_multiple "" "$test" {
-    -re "^print some_local_variable $" {
-        send_gdb "\n"
-        gdb_test_multiple "" "$test" {
-            -re " = 1$eol$gdb_prompt $" {
-                pass "$test"
-            }
-        }
+
+if { [readline_is_used] } {
+    set test "interactive complete 'print some'"
+    send_gdb "print some\t"
+    gdb_test_multiple "" "$test" {
+       -re "^print some_local_variable $" {
+           send_gdb "\n"
+           gdb_test_multiple "" "$test" {
+               -re " = 1$eol$gdb_prompt $" {
+                   pass "$test"
+               }
+           }
+       }
     }
 }
index d51a8476345d28bd96acedf5cd12c7a3ef54ad32..8d9eea5c093c414422801d8708ca62d079cb24c4 100644 (file)
@@ -69,6 +69,70 @@ if ![runto_main] then {
 set oldtimeout1 $timeout
 set timeout 30
 
+gdb_test_no_output "complete print values\[0\].x." \
+    "field completion with invalid field"
+
+# If there is a non-deprecated completion, it should be returned.
+gdb_test "complete sav" "save" "test non-deprecated completion"
+# If there is only a deprecated completion, then it should be returned.
+gdb_test "complete save-t" "save-tracepoints" "test deprecated completion"
+
+
+#
+# Tag name completion.
+#
+
+gdb_test "complete ptype struct some_" "ptype struct some_struct"
+gdb_test "complete ptype enum some_" "ptype enum some_enum"
+gdb_test "complete ptype union some_" "ptype union some_union"
+
+
+gdb_test "complete set gnutarget aut" "set gnutarget auto"
+
+
+gdb_test "complete set cp-abi aut" "set cp-abi auto"
+
+# Test that completion of commands 'target FOO' works well.
+set targets [list "core" "tfile" "exec"]
+
+# Test that completion of command 'target ctf' if GDB supports ctf
+# target.
+gdb_test_multiple "target ctf" "" {
+    -re "Undefined target command: \"ctf\"\.  Try \"help target\"\.\r\n$gdb_prompt $" {
+    }
+    -re "No CTF directory specified.*\r\n$gdb_prompt $" {
+       lappend targets "ctf"
+    }
+}
+
+foreach target_name ${targets} {
+    gdb_test "complete target ${target_name} ./gdb.base/completion" \
+       "target ${target_name} \\./gdb.base/completion.*\\./gdb.base/completion0\\.o.*\\./gdb.base/completion1\\.o.*"
+}
+
+#
+# "set foo unlimited" completion.
+#
+
+# A var_uinteger command.
+gdb_test "complete set height " "set height unlimited"
+gdb_test "complete set height u" "set height unlimited"
+
+# A var_integer command.
+gdb_test "complete set listsize " "set listsize unlimited"
+gdb_test "complete set listsize unl" "set listsize unlimited"
+
+# A var_zuinteger_unlimited command.
+gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited"
+gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited"
+
+# Tests below are about tab-completion, which doesn't work if readline
+# library isn't used.  Check it first.
+
+if { ![readline_is_used] } {
+    return -1
+}
+
 set test "complete 'hfgfh'"
 send_gdb "hfgfh\t"
 gdb_test_multiple "" "$test" {
@@ -672,63 +736,6 @@ gdb_test_multiple "" "$test" {
     }
 }
 
-gdb_test_no_output "complete print values\[0\].x." \
-    "field completion with invalid field"
-
-# If there is a non-deprecated completion, it should be returned.
-gdb_test "complete sav" "save" "test non-deprecated completion"
-# If there is only a deprecated completion, then it should be returned.
-gdb_test "complete save-t" "save-tracepoints" "test deprecated completion"
-
-
-#
-# Tag name completion.
-#
-
-gdb_test "complete ptype struct some_" "ptype struct some_struct"
-gdb_test "complete ptype enum some_" "ptype enum some_enum"
-gdb_test "complete ptype union some_" "ptype union some_union"
-
-
-gdb_test "complete set gnutarget aut" "set gnutarget auto"
-
-
-gdb_test "complete set cp-abi aut" "set cp-abi auto"
-
-# Test that completion of commands 'target FOO' works well.
-set targets [list "core" "tfile" "exec"]
-
-# Test that completion of command 'target ctf' if GDB supports ctf
-# target.
-gdb_test_multiple "target ctf" "" {
-    -re "Undefined target command: \"ctf\"\.  Try \"help target\"\.\r\n$gdb_prompt $" {
-    }
-    -re "No CTF directory specified.*\r\n$gdb_prompt $" {
-       lappend targets "ctf"
-    }
-}
-
-foreach target_name ${targets} {
-    gdb_test "complete target ${target_name} ./gdb.base/completion" \
-       "target ${target_name} ./gdb.base/completion\\.exp.*"
-}
-
-#
-# "set foo unlimited" completion.
-#
-
-# A var_uinteger command.
-gdb_test "complete set height " "set height unlimited"
-gdb_test "complete set height u" "set height unlimited"
-
-# A var_integer command.
-gdb_test "complete set listsize " "set listsize unlimited"
-gdb_test "complete set listsize unl" "set listsize unlimited"
-
-# A var_zuinteger_unlimited command.
-gdb_test "complete set trace-buffer-size " "set trace-buffer-size unlimited"
-gdb_test "complete set trace-buffer-size unl" "set trace-buffer-size unlimited"
-
 # Restore globals modified in this test...
 set timeout $oldtimeout1
 
index 5f4311624d5fc8dd249a78b96013e2a9f90ab87a..77e643b645d92a4df1218f22d5c2aa30baef7085 100644 (file)
@@ -22,6 +22,12 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
     return -1
 }
 
+if { ![readline_is_used] } {
+    unsupported "completion doesn't work when readline isn't used."
+    return -1
+}
+
+
 # Test completion list for "filesy".  We expect the immediate result to
 # complete to "filesym"; completing again, we expect the symbol name and the
 # filename (in that order).
index e953c0dab547c4d87e46e839adb5b229de2e6f35..9503e758ddd0244e11bc5d85a840e0d75efa999c 100644 (file)
@@ -517,77 +517,80 @@ gdb_test "macro undef" \
     "usage: macro undef.*" \
     "macro undef with no arguments"
 
-# Completion tests.
-
-# The macro FIFTY_SEVEN is in scope at this point.
-send_gdb "p FIFTY_\t"
-gdb_expect  {
-    -re "^p FIFTY_SEVEN $" {
-       send_gdb "\n"
-       gdb_expect {
-           -re "^.* = 57.*$gdb_prompt $" {
-               pass "complete 'p FIFTY_SEVEN'"
-           }
-           -re ".*$gdb_prompt $" { fail "complete 'p FIFTY_SEVEN'" }
-           timeout { fail "(timeout) complete 'p FIFTY_SEVEN'" }
+# Do completion tests if readline is used.
+
+if { [readline_is_used] } {
+
+    # The macro FIFTY_SEVEN is in scope at this point.
+    send_gdb "p FIFTY_\t"
+    gdb_expect  {
+       -re "^p FIFTY_SEVEN $" {
+           send_gdb "\n"
+           gdb_expect {
+               -re "^.* = 57.*$gdb_prompt $" {
+                   pass "complete 'p FIFTY_SEVEN'"
+               }
+               -re ".*$gdb_prompt $" { fail "complete 'p FIFTY_SEVEN'" }
+               timeout { fail "(timeout) complete 'p FIFTY_SEVEN'" }
            }
        }
-    -re ".*$gdb_prompt $" { fail "complete 'p FIFTY_SEVEN'" }
-    timeout { fail "(timeout) complete 'p FIFTY_SEVEN' 2" }
-}
+       -re ".*$gdb_prompt $" { fail "complete 'p FIFTY_SEVEN'" }
+       timeout { fail "(timeout) complete 'p FIFTY_SEVEN' 2" }
+    }
 
-# The macro TWENTY_THREE is not in scope.
-send_gdb "p TWENTY_\t"
-gdb_expect  {
-    -re "^p TWENTY_\\\x07$" {
-       send_gdb "\n"
-       gdb_expect {
-           -re "No symbol \"TWENTY_\" in current context\\..*$gdb_prompt $" {
-               pass "complete 'p TWENTY_'"
+    # The macro TWENTY_THREE is not in scope.
+    send_gdb "p TWENTY_\t"
+    gdb_expect  {
+       -re "^p TWENTY_\\\x07$" {
+           send_gdb "\n"
+           gdb_expect {
+               -re "No symbol \"TWENTY_\" in current context\\..*$gdb_prompt $" {
+                   pass "complete 'p TWENTY_'"
+               }
+               -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_'" }
+               timeout { fail "(timeout) complete 'p TWENTY_'"}
            }
-           -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_'" }
-           timeout { fail "(timeout) complete 'p TWENTY_'"}
        }
+       -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_'" }
+       timeout { fail "(timeout) complete 'p TWENTY_' 2" }
     }
-    -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_'" }
-    timeout { fail "(timeout) complete 'p TWENTY_' 2" }
-}
 
-# The macro FORTY_EIGHT was undefined and thus is not in scope.
-send_gdb "p FORTY_\t"
-gdb_expect  {
-    -re "^p FORTY_\\\x07$" {
-       send_gdb "\n"
-       gdb_expect {
-           -re "No symbol \"FORTY_\" in current context\\..*$gdb_prompt $" {
-               pass "complete 'p FORTY_'"
-           }
-           -re ".*$gdb_prompt $" { fail "complete 'p FORTY_'" }
-           timeout {fail "(timeout) complete 'p FORTY_'"}
+    # The macro FORTY_EIGHT was undefined and thus is not in scope.
+    send_gdb "p FORTY_\t"
+    gdb_expect  {
+       -re "^p FORTY_\\\x07$" {
+           send_gdb "\n"
+           gdb_expect {
+               -re "No symbol \"FORTY_\" in current context\\..*$gdb_prompt $" {
+                   pass "complete 'p FORTY_'"
+               }
+               -re ".*$gdb_prompt $" { fail "complete 'p FORTY_'" }
+               timeout {fail "(timeout) complete 'p FORTY_'"}
            }
        }
-    -re ".*$gdb_prompt $" { fail "complete 'p FORTY_'" }
-    timeout { fail "(timeout) complete 'p FORTY_' 2" }
-}
+       -re ".*$gdb_prompt $" { fail "complete 'p FORTY_'" }
+       timeout { fail "(timeout) complete 'p FORTY_' 2" }
+    }
 
-gdb_test_no_output "macro define TWENTY_THREE 25" \
-  "defining TWENTY_THREE"
-
-# User-defined macros are always in scope.
-send_gdb "p TWENTY_\t"
-gdb_expect  {
-    -re "^p TWENTY_THREE $" {
-       send_gdb "\n"
-       gdb_expect {
-           -re "^.* = 25.*$gdb_prompt $" {
-               pass "complete 'p TWENTY_THREE'"
+    gdb_test_no_output "macro define TWENTY_THREE 25" \
+       "defining TWENTY_THREE"
+
+    # User-defined macros are always in scope.
+    send_gdb "p TWENTY_\t"
+    gdb_expect  {
+       -re "^p TWENTY_THREE $" {
+           send_gdb "\n"
+           gdb_expect {
+               -re "^.* = 25.*$gdb_prompt $" {
+                   pass "complete 'p TWENTY_THREE'"
+               }
+               -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_THREE'"}
+               timeout { fail "(timeout) complete 'p TWENTY_THREE'" }
            }
-           -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_THREE'"}
-           timeout { fail "(timeout) complete 'p TWENTY_THREE'" }
        }
+       -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_THREE'" }
+       timeout { fail "(timeout) complete 'p TWENTY_THREE' 2" }
     }
-    -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_THREE'" }
-    timeout { fail "(timeout) complete 'p TWENTY_THREE' 2" }
 }
 
 # Splicing tests.
index e15dcca42b10ccc1f424dc5a809d4e35c8932906..d0a349d9df35128e9c314edfaedecacea50b5df3 100644 (file)
@@ -25,6 +25,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}]
 setenv INPUTRC $inputrc
 clean_restart ${binfile}
 
+if { ![readline_is_used] } {
+    unsupported "completion doesn't work when readline isn't used."
+    return -1
+}
+
 gdb_test_no_output "set width 50"
 gdb_test_no_output "set height 3"
 
index 3c7d4c1cb08bf2640d4508f9eef2a5a9cbc3aebb..ef7fa130c80688c71f406fc82f663eab9cbdc442 100644 (file)
@@ -145,6 +145,11 @@ proc operate_and_get_next {name args} {
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
+if { ![readline_is_used] } {
+    unsupported "readline isn't used."
+    return -1
+}
+
 set oldtimeout1 $timeout
 set timeout 30
 
index c48c8bf37ffc32251f0f1f8da9bc02dd9009bcf5..a87aecba7a22d67fcf8bedebe1631c90c6a83c23 100644 (file)
@@ -177,14 +177,16 @@ gdb_test "complete expr_test bar\." \
     "expr_test bar\.bc.*expr_test bar\.ij.*" \
     "Test completion through complete command"
 
-set test "complete 'expr_test bar.i'"
-send_gdb "expr_test bar\.i\t\t"
-gdb_test_multiple "" "$test" {
-    -re "expr_test bar\.ij \\\x07$" {
-       send_gdb "\n"
-       gdb_test_multiple "" $test {
-           -re "invoked on = bar.ij.*$gdb_prompt $" {
-               pass "$test"
+if { [readline_is_used] } {
+    set test "complete 'expr_test bar.i'"
+    send_gdb "expr_test bar\.i\t\t"
+    gdb_test_multiple "" "$test" {
+       -re "expr_test bar\.ij \\\x07$" {
+           send_gdb "\n"
+           gdb_test_multiple "" $test {
+               -re "invoked on = bar.ij.*$gdb_prompt $" {
+                   pass "$test"
+               }
            }
        }
     }
index 634c2fc41930dd25482edda961ee101e2787af69..c98e64cc7bf451862532d8fecc3e98fea7e31f27 100644 (file)
@@ -148,6 +148,8 @@ gdb_test "interpreter-exec mi \"-trace-status\"" \
 
 # Test completion works well.
 
-gdb_test "target tfile [file rootname $tfile_basic]\t" \
-    "Assuming tracepoint.*" \
-    "complete-command 'target tfile'"
+if { [readline_is_used] } {
+    gdb_test "target tfile [file rootname $tfile_basic]\t" \
+       "Assuming tracepoint.*" \
+       "complete-command 'target tfile'"
+}
index 4a6f930a58fce0642dea80307a9d7b0cccd88b91..608fae0b5bb859a238e5c071b068a1dff8c550e9 100644 (file)
@@ -1831,6 +1831,21 @@ proc supports_reverse {} {
     return 0
 }
 
+# Return 1 if readline library is used.
+
+proc readline_is_used { } {
+    global gdb_prompt
+
+    gdb_test_multiple "show editing" "" {
+       -re ".*Editing of command lines as they are typed is on\..*$gdb_prompt $" {
+           return 1
+       }
+       -re ".*$gdb_prompt $" {
+           return 0
+       }
+    }
+}
+
 # Return 1 if target is ELF.
 gdb_caching_proc is_elf_target {
     set me "is_elf_target"
This page took 0.046306 seconds and 4 git commands to generate.