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