Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.fortran / size.exp
CommitLineData
88b9d363 1# Copyright 2021-2022 Free Software Foundation, Inc.
7ba155b3
AB
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# Testing GDB's implementation of SIZE keyword.
17
18if {[skip_fortran_tests]} { return -1 }
19
20standard_testfile ".f90"
21load_lib fortran.exp
22
23if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
24 {debug f90}]} {
25 return -1
26}
27
28if ![fortran_runto_main] {
29 untested "could not run to main"
30 return -1
31}
32
33gdb_breakpoint [gdb_get_line_number "Test Breakpoint"]
34gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
35
36# We place a limit on the number of tests that can be run, just in
37# case something goes wrong, and GDB gets stuck in an loop here.
38set found_final_breakpoint false
39set test_count 0
40while { $test_count < 500 } {
41 with_test_prefix "test $test_count" {
42 incr test_count
43
44 gdb_test_multiple "continue" "continue" {
45 -re -wrap "! Test Breakpoint" {
46 # We can run a test from here.
47 }
48 -re -wrap "! Final Breakpoint" {
49 # We're done with the tests.
50 set found_final_breakpoint true
51 }
52 }
53
54 if ($found_final_breakpoint) {
55 break
56 }
57
58 # First grab the expected answer.
59 set answer [get_valueof "" "answer" "**unknown**"]
60
61 # Now move up a frame and figure out a command for us to run
62 # as a test.
63 set command ""
64 gdb_test_multiple "up" "up" {
65 -re -wrap "\r\n\[0-9\]+\[ \t\]+call test_size \\((\[^\r\n\]+)\\)" {
66 set command $expect_out(1,string)
67 }
68 }
69
70 gdb_assert { ![string equal $command ""] } "found a command to run"
71
72 gdb_test "p $command" " = $answer"
73 }
74}
75
76# Ensure we reached the final breakpoint. If more tests have been added
77# to the test script, and this starts failing, then the safety 'while'
78# loop above might need to be increased.
79gdb_assert {$found_final_breakpoint} "ran all compiled in tests"
80
81foreach var {array_1d_p array_2d_p allocatable_array_1d \
82 allocatable_array_2d} {
83 gdb_test "p size ($var)" \
84 "SIZE can only be used on allocated/associated arrays"
85}
86
87foreach var {an_integer a_real} {
88 gdb_test "p size ($var)" "SIZE can only be applied to arrays"
89}
This page took 0.070867 seconds and 4 git commands to generate.