gdb: Merge similar tests into a single test script
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / vla-optimized-out.exp
1 # Copyright 2018 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 # Check whether we can determine the size of an optimized-out vla.
17
18 standard_testfile
19
20 # The EXE_SUFFIX is a string appended to the name of the test binary
21 # to make it unique per variation.
22 # The OPTIONS is a two item list, the first item is a list of compiler
23 # flags used for building the test binary, and the second item is a
24 # pattern which matches some expected output within this proc.
25 proc vla_optimized_out {exe_suffix options} {
26 global testfile srcfile
27
28 lassign $options compile_flags sizeof_result
29
30 if { [prepare_for_testing "failed to prepare" "$testfile-$exe_suffix" $srcfile \
31 $compile_flags] } {
32 return -1
33 }
34
35 if ![runto f1] {
36 fail "can't run to f1"
37 return
38 }
39
40 gdb_test "p a" \
41 " = <optimized out>" \
42 "printed optimized out vla"
43
44 gdb_test "p sizeof (a)" \
45 " = $sizeof_result" \
46 "printed size of optimized out vla"
47 }
48
49 foreach {test_prefix options} \
50 { "o1" {{debug optimize=-O1 additional_flags=-DNOCLONE} "6"} \
51 "o3" {{debug optimize=-O3} "<optimized out>"} \
52 "o3_strict" {{debug optimize=-O3 \
53 additional_flags=-gstrict-dwarf} \
54 "<optimized out>"}} {
55 with_test_prefix $test_prefix {
56 vla_optimized_out $test_prefix $options
57 }
58 }
59
This page took 0.030635 seconds and 4 git commands to generate.