Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / testsuite / gdb.python / py-completion.exp
1 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 set testfile "py-completion"
17
18 load_lib gdb-python.exp
19
20 gdb_exit
21 gdb_start
22
23 # Skip all tests if Python scripting is not enabled.
24 if { [skip_python_tests] } { continue }
25
26 gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py"
27
28 # Create a temporary directory
29 set testdir "[standard_output_file "py-completion-testdir"]/"
30 set testdir_regex [string_to_regexp $testdir]
31 set testdir_complete [standard_output_file "py-completion-test"]
32 file mkdir $testdir
33
34 # This one should always pass.
35 send_gdb "completefileinit ${testdir_complete}\t"
36 gdb_test_multiple "" "completefileinit completion" {
37     -re "^completefileinit ${testdir_regex}$" {
38         pass "completefileinit completion"
39     }
40 }
41
42 # Just discarding whatever we typed.
43 gdb_test " " ".*" "discard #1"
44
45 # This is the problematic one.
46 send_gdb "completefilemethod ${testdir_complete}\t"
47 gdb_test_multiple "" "completefilemethod completion" {
48     -re "^completefilemethod ${testdir_regex} $" {
49         fail "completefilemethod completion (completed filename as wrong command arg)"
50     }
51     -re "^completefilemethod ${testdir_regex}$" {
52         pass "completefilemethod completion"
53     }
54 }
55
56 # Discarding again
57 gdb_test " " ".*" "discard #2"
58
59 # Another problematic
60 set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
61 send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
62 gdb_test_multiple "" "completefilecommandcond completion" {
63     -re "^completefilecommandcond ${testdir}$" {
64         fail "completefilecommandcond completion (completed filename instead of command)"
65     }
66     -re "^completefilecommandcond ${completion_regex}\007$" {
67         pass "completefilecommandcond completion"
68     }
69 }