I'm finally getting back to this.
This patch adds test suite support for the libstdc++ pretty-printers.
These tests require a new gdb, so following Mike Stump's advice and the
consensus of the libstdc++ list, we now check for an appropriate gdb
feature before deciding whether to run the tests.
I tested this against gdb 7.2 (= unsupported) and 7.3 (= all tests
pass).
Let me know what you think.
Tom
2011-08-03 Tom Tromey tro...@redhat.com
* testsuite/libstdc++-prettyprinters/simple.cc: New file.
* testsuite/lib/gdb-test.exp: New file.
* testsuite/libstdc++-prettyprinters/prettyprinters.exp: New
file.
Index: testsuite/libstdc++-prettyprinters/prettyprinters.exp
===
--- testsuite/libstdc++-prettyprinters/prettyprinters.exp (revision 0)
+++ testsuite/libstdc++-prettyprinters/prettyprinters.exp (revision 0)
@@ -0,0 +1,51 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# http://www.gnu.org/licenses/.
+
+load_lib gdb-test.exp
+
+dg-init
+v3-build_support
+
+global GDB
+if ![info exists ::env(GUALITY_GDB_NAME)] {
+if [info exists GDB] {
+ set guality_gdb_name $GDB
+} else {
+ set guality_gdb_name [transform gdb]
+}
+setenv GUALITY_GDB_NAME $guality_gdb_name
+}
+
+if {! [gdb_version_check]} {
+unsupported prettyprinters.exp
+return
+}
+
+# This can be used to keep the .exe around. dg-test has an option for
+# this but there is no way to pass it through dg-runtest.
+global dg-interpreter-batch-mode
+set dg-interpreter-batch-mode 1
+
+global DEFAULT_CXXFLAGS
+global PCH_CXXFLAGS
+dg-runtest [lsort [glob $srcdir/$subdir/*.cc]] \
+ $DEFAULT_CXXFLAGS $PCH_CXXFLAGS
+
+if [info exists guality_gdb_name] {
+unsetenv GUALITY_GDB_NAME
+}
+
+dg-finish
Index: testsuite/libstdc++-prettyprinters/simple.cc
===
--- testsuite/libstdc++-prettyprinters/simple.cc(revision 0)
+++ testsuite/libstdc++-prettyprinters/simple.cc(revision 0)
@@ -0,0 +1,87 @@
+// { dg-do run }
+// { dg-options -g }
+
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// http://www.gnu.org/licenses/.
+
+#include string
+#include deque
+#include bitset
+#include iostream
+#include list
+#include map
+
+templateclass T
+void
+placeholder(const T s)
+{
+ std::cout s;
+}
+
+templateclass T, class S
+void
+placeholder(const std::pairT,S s)
+{
+ std::cout s.first;
+}
+
+templateclass T
+void
+use(const T container)
+{
+ for (typename T::const_iterator i = container.begin();
+ i != container.end();
+ ++i)
+placeholder(*i);
+}
+
+int
+main()
+{
+ std::string str = zardoz;
+// { dg-final { note-test str \zardoz\ } }
+
+ std::bitset10 bs;
+ bs[0] = 1;
+ bs[5] = 1;
+ bs[7] = 1;
+// { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
+
+ std::dequestd::string deq;
+ deq.push_back(one);
+ deq.push_back(two);
+// { dg-final { note-test deq {std::deque with 2 elements = {one, two}} } }
+
+ std::liststd::string lst;
+ lst.push_back(one);
+ lst.push_back(two);
+// { dg-final { note-test lst {std::list = {[0] = one, [1] = two}} } }
+
+ std::mapstd::string, int mp;
+ mp[zardoz] = 23;
+// { dg-final { note-test mp {std::map with 1 elements = {[zardoz] = 23}} } }
+
+ placeholder(str); // Mark SPOT
+ std::cout bs;
+ use(deq);
+ use(lst);
+ use(mp);
+
+ return 0;
+}
+
+// { dg-final { gdb-test SPOT } }
Index: testsuite/lib/gdb-test.exp
===
--- testsuite/lib/gdb-test.exp (revision 0)
+++