]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/local-enum.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / local-enum.exp
1 # Copyright 2021-2024 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 load_lib "ada.exp"
17
18 require allow_ada_tests
19
20 standard_ada_testfile local
21
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} {
23 return -1
24 }
25
26 clean_restart ${testfile}
27
28 set bp_location [gdb_get_line_number "STOP" ${testdir}/local.adb]
29 if {![runto "local.adb:$bp_location"]} {
30 return
31 }
32
33 # The test has two constants named 'three', with different values.
34 # This prints one of them and checks the value. WHICH_ENUM is the
35 # name of the enum, either "e1" or "e2".
36 proc print_three {which_enum value} {
37 # We don't know which in order gdb will print the constants, so
38 # adapt to either.
39 set menu1 [multi_line \
40 "Multiple matches for three" \
41 "\\\[0\\\] cancel" \
42 "\\\[1\\\] local\\.e2'\\(three\\) \\(enumeral\\)" \
43 "\\\[2\\\] local\\.e1'\\(three\\) \\(enumeral\\)" \
44 "> $"]
45 set menu2 [multi_line \
46 "Multiple matches for three" \
47 "\\\[0\\\] cancel" \
48 "\\\[1\\\] local\\.e1'\\(three\\) \\(enumeral\\)" \
49 "\\\[2\\\] local\\.e2'\\(three\\) \\(enumeral\\)" \
50 "> $"]
51
52 set index -1
53 set test_name "menu for test index $which_enum"
54 gdb_test_multiple "print/d three" $test_name {
55 -re $menu1 {
56 pass $test_name
57 if {$which_enum == "e1"} {
58 set index 2
59 } else {
60 set index 1
61 }
62 }
63 -re $menu2 {
64 pass $test_name
65 if {$which_enum == "e1"} {
66 set index 1
67 } else {
68 set index 2
69 }
70 }
71 default {
72 fail $test_name
73 }
74 }
75
76 if {$index != -1} {
77 gdb_test $index " = $value"
78 }
79 }
80
81 print_three e2 0
82 print_three e1 2
83
84 # These will not result in a menu, as expression resolution should
85 # disambiguate the meaning of 'three'.
86 gdb_test "print v1(three)" " = 2" "print v1 element"
87 gdb_test "print v2(three)" " = 3" "print v2 element"