From 6871e2180fcaf0b0478b932306992a7b37999f2f Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 28 Aug 2023 13:46:36 +0200 Subject: [PATCH] [gdb/testsuite] Refactor gdb.cp/subtypes.exp Make test-case gdb.cp/subtypes.exp less repetitive by using foreach. Tested on x86_64-linux. --- gdb/testsuite/gdb.cp/subtypes.exp | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.cp/subtypes.exp b/gdb/testsuite/gdb.cp/subtypes.exp index afad478cba3..48c9784dd68 100644 --- a/gdb/testsuite/gdb.cp/subtypes.exp +++ b/gdb/testsuite/gdb.cp/subtypes.exp @@ -33,23 +33,27 @@ if {[prepare_for_testing "failed to prepare" $testfile \ gdb_test "ptype Outer::Inner::InnerInner" \ "type = struct Outer::Inner::InnerInner.*" gdb_test "ptype Outer::Inner" "type = struct Outer::Inner.*" -gdb_test "ptype main::Foo" "type = struct Foo.*" -gdb_test "ptype main::Bar" "type = struct Bar.*" -gdb_test "ptype main::Baz" "type = struct Baz.*" + +foreach s { Foo Bar Baz } { + gdb_test "ptype main::$s" "type = struct $s.*" +} + gdb_test "ptype Outer::Oenum" "type = enum class Outer::Oenum.*" -gdb_test "ptype foobar::Foo" "type = struct Foo.*" -gdb_test "ptype foobar::Bar" "type = struct Bar.*" -gdb_test "ptype foobar::Baz" "type = struct Baz.*" -gdb_test "ptype foobar::Foo" "type = struct Foo.*" -gdb_test "ptype foobar::Bar" "type = struct Bar.*" -gdb_test "ptype foobar::Baz" "type = struct Baz.*" + +foreach t { int char } { + foreach s { Foo Bar Baz } { + gdb_test "ptype foobar<$t>::$s" "type = struct $s.*" + } +} + gdb_breakpoint "Outer::Inner::doit" message -gdb_breakpoint "main::Foo::doit" message -gdb_breakpoint "main::Bar::doit" message -gdb_breakpoint "main::Baz::doit" message -gdb_breakpoint "foobar(int)::Foo::doit" message -gdb_breakpoint "foobar(int)::Bar::doit" message -gdb_breakpoint "foobar(int)::Baz::doit" message -gdb_breakpoint "foobar(int)::Foo::doit" message -gdb_breakpoint "foobar(int)::Bar::doit" message -gdb_breakpoint "foobar(int)::Baz::doit" message + +foreach s { Foo Bar Baz } { + gdb_breakpoint "main::${s}::doit" message +} + +foreach t { int char } { + foreach s { Foo Bar Baz } { + gdb_breakpoint "foobar<$t>(int)::${s}::doit" message + } +} -- 2.30.2