Skip to content

[libc++][hardening] Clean up some legacy debug mode tests: #71016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

var-const
Copy link
Member

  • reenable a few tests that still pass under the new debug mode;
  • delete a placeholder test;
  • delete a test that is no longer relevant.

- reenable a few tests that still pass under the new debug mode;
- delete a placeholder test;
- delete a test that is no longer relevant.
@var-const var-const requested a review from a team as a code owner November 2, 2023 04:23
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 2, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 2, 2023

@llvm/pr-subscribers-libcxx

Author: Konstantin Varlamov (var-const)

Changes
  • reenable a few tests that still pass under the new debug mode;
  • delete a placeholder test;
  • delete a test that is no longer relevant.

Full diff: https://github.com/llvm/llvm-project/pull/71016.diff

6 Files Affected:

  • (modified) libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp (+2-2)
  • (modified) libcxx/test/libcxx/algorithms/debug_less.pass.cpp (+2-2)
  • (modified) libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp (+2-1)
  • (removed) libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp (-60)
  • (removed) libcxx/test/libcxx/debug/extern-templates.sh.cpp (-52)
  • (modified) libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp (+2-2)
diff --git a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
index f58250a2c855fba..701edd1335afa84 100644
--- a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
@@ -12,8 +12,8 @@
 
 // Make sure __debug_less asserts when the comparator is not consistent.
 
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03
+// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
+// UNSUPPORTED: c++03
 
 #include <algorithm>
 #include <iterator>
diff --git a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
index d05cbfac4b8f6a2..4889f94d170a16d 100644
--- a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
@@ -12,8 +12,8 @@
 
 // __debug_less checks that a comparator actually provides a strict-weak ordering.
 
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03
+// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
+// UNSUPPORTED: c++03
 
 #include <algorithm>
 #include <cassert>
diff --git a/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp b/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
index 8a9943693d8a30a..b9bb1c9136f65ce 100644
--- a/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
@@ -12,7 +12,8 @@
 
 // Make sure __debug_three_way_comp asserts when the comparator is not consistent.
 
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03, c++11, c++14, c++17
+// REQUIRES: libcpp-hardening-mode=debug
+// UNSUPPORTED: c++03, c++11, c++14, c++17
 
 #include <algorithm>
 #include <iterator>
diff --git a/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp b/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
deleted file mode 100644
index 449e0244b272495..000000000000000
--- a/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03, c++11, c++14
-
-// test container debugging
-
-#include <map>
-#include <set>
-#include <utility>
-#include <cassert>
-#include "check_assertion.h"
-#include "container_debug_tests.h"
-#include "test_macros.h"
-
-using namespace IteratorDebugChecks;
-
-template <class Container, ContainerType CT>
-struct AssociativeContainerChecks : BasicContainerChecks<Container, CT> {
-  using Base = BasicContainerChecks<Container, CT>;
-  using value_type = typename Container::value_type;
-  using iterator = typename Container::iterator;
-  using const_iterator = typename Container::const_iterator;
-  using traits = std::iterator_traits<iterator>;
-  using category = typename traits::iterator_category;
-
-  using Base::makeContainer;
-public:
-  static void run() {
-    Base::run();
-  }
-
-private:
-  // FIXME Add tests here
-};
-
-int main(int, char**)
-{
-  using SetAlloc = test_allocator<int>;
-  using MapAlloc = test_allocator<std::pair<const int, int>>;
-  // FIXME: Add debug mode to these containers
-  if ((false)) {
-    AssociativeContainerChecks<
-        std::set<int, std::less<int>, SetAlloc>, CT_Set>::run();
-    AssociativeContainerChecks<
-        std::multiset<int, std::less<int>, SetAlloc>, CT_MultiSet>::run();
-    AssociativeContainerChecks<
-        std::map<int, int, std::less<int>, MapAlloc>, CT_Map>::run();
-    AssociativeContainerChecks<
-        std::multimap<int, int, std::less<int>, MapAlloc>, CT_MultiMap>::run();
-  }
-
-  return 0;
-}
diff --git a/libcxx/test/libcxx/debug/extern-templates.sh.cpp b/libcxx/test/libcxx/debug/extern-templates.sh.cpp
deleted file mode 100644
index 88c009337055c22..000000000000000
--- a/libcxx/test/libcxx/debug/extern-templates.sh.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// This test checks that we retain extern template instantiation declarations
-// for members of <locale> even when the debug mode is enabled, which is
-// necessary for correctness. See https://llvm.org/D94718 for details.
-
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode
-// UNSUPPORTED: no-localization
-// UNSUPPORTED: cant-build-shared-library
-
-// This test relies on linking a shared library and then passing that shared
-// library as input when linking an executable; this is generally not supported
-// on Windows (GNU ld supports it, but MS link.exe and LLD don't) - one has to
-// use an import library instead. (Additionally, the test uses the -fPIC
-// option which clang doesn't accept on Windows.)
-// UNSUPPORTED: windows
-
-// RUN: %{cxx} %{flags} %{compile_flags} %s %{link_flags} -fPIC -DTU1 -fvisibility=hidden -shared -o %t.lib
-// RUN: cd %T && %{cxx} %{flags} %{compile_flags} %s ./%basename_t.tmp.lib %{link_flags} -DTU2 -fvisibility=hidden -o %t.exe
-// RUN: %{exec} %t.exe
-
-#include <cassert>
-#include <cstdio>
-#include <sstream>
-#include <string>
-
-std::string __attribute__((visibility("default"))) numToString(int x);
-
-#if defined(TU1)
-
-std::string numToString(int x) {
-  std::stringstream ss;
-  ss << x;
-  return ss.str();
-}
-
-#elif defined(TU2)
-
-int main(int, char**) {
-  std::string s = numToString(42);
-  assert(s == "42");
-
-  return 0;
-}
-
-#endif
diff --git a/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp b/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp
index 6e70d171cb3ef15..305b06295bc44ae 100644
--- a/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp
+++ b/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03, c++11, c++14
-// REQUIRES: has-unix-headers
+// UNSUPPORTED: c++03, c++11, c++14
+// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
 
 // <memory_resource>
 

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a comment! It looks like the CI is passing, the Windows issue is unrelated.

@var-const var-const merged commit 7667723 into llvm:main Nov 2, 2023
@var-const var-const deleted the varconst/reenable-legacy-debug-mode-tests-1 branch November 2, 2023 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants