[libcxx-commits] [libcxx] [libc++] Move some standard tests from test/libcxx (PR #152982)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 11 02:29:48 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

<details>
<summary>Changes</summary>

This also removes some tests which were redundant, wrong, or never run. Specifically,

- `libcxx/utilities/meta/stress_tests/*` were never run and are of questionable usefulness
- `libcxx/utilities/template.bitset/includes.pass.cpp` is completely redundant and partially incorrect

Also notably, `libcxx/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp`
has been refactored to only test the standard mandate.




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


14 Files Affected:

- (removed) libcxx/test/libcxx/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp (-39) 
- (removed) libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_is_same.sh.cpp (-55) 
- (removed) libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_metafunctions.sh.cpp (-65) 
- (removed) libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp (-119) 
- (removed) libcxx/test/libcxx/utilities/template.bitset/includes.pass.cpp (-33) 
- (added) libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp (+33) 
- (renamed) libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp () 
- (renamed) libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp () 
- (removed) libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp (-22) 
- (renamed) libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/visibility_inlines_hidden.cpp (-1) 
- (renamed) libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp () 
- (renamed) libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp () 
- (renamed) libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp () 
- (renamed) libcxx/test/std/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp () 


``````````diff
diff --git a/libcxx/test/libcxx/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp b/libcxx/test/libcxx/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp
deleted file mode 100644
index 1b84a9bfe47da..0000000000000
--- a/libcxx/test/libcxx/language.support/support.c.headers/support.c.headers.other/math.lerp.verify.cpp
+++ /dev/null
@@ -1,39 +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
-//
-//===----------------------------------------------------------------------===//
-
-// When built with modules, this test gives diagnostics like
-//  declaration of 'lerp' must be imported from module 'std.compat.cmath'
-//  before it is required
-// therefore disable the test in this configuration.
-// UNSUPPORTED: clang-modules-build
-
-// <math.h>
-
-// [support.c.headers.other]/1
-//   ... except for the functions described in [sf.cmath], the
-//   std::lerp function overloads ([c.math.lerp]) ...
-
-#include <math.h>
-
-void f() {
-  {
-    float f;
-    ::lerp(f, f, f);    // expected-error {{no member named 'lerp' in the global namespace}}
-    std::lerp(f, f, f); // expected-error {{no member named 'lerp' in namespace 'std'}}
-  }
-  {
-    double d;
-    ::lerp(d, d, d);    // expected-error {{no member named 'lerp' in the global namespace}}
-    std::lerp(d, d, d); // expected-error {{no member named 'lerp' in namespace 'std'}}
-  }
-  {
-    long double l;
-    ::lerp(l, l, l);    // expected-error {{no member named 'lerp' in the global namespace}}
-    std::lerp(l, l, l); // expected-error {{no member named 'lerp' in namespace 'std'}}
-  }
-}
diff --git a/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_is_same.sh.cpp b/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_is_same.sh.cpp
deleted file mode 100644
index cfd8adb52d854..0000000000000
--- a/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_is_same.sh.cpp
+++ /dev/null
@@ -1,55 +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 is a dummy feature that prevents this test from running by default.
-// REQUIRES: template-cost-testing
-
-// The table below compares the compile time and object size for each of the
-// variants listed in the RUN script.
-//
-//  Impl          Compile Time    Object Size
-// -------------------------------------------
-// std::_IsSame:    689.634 ms     356 K
-// std::is_same:  8,129.180 ms     560 K
-//
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
-
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "template_cost_testing.h"
-
-template <int N> struct Arg { enum { value = 1 }; };
-
-#ifdef TEST_NEW
-#define IS_SAME  std::_IsSame
-#else
-#define IS_SAME std::is_same
-#endif
-
-#define TEST_CASE_NOP() IS_SAME < Arg< __COUNTER__ >, Arg < __COUNTER__ > >::value,
-#define TEST_CASE_TYPE() IS_SAME < Arg< __COUNTER__ >, Arg < __COUNTER__ > >,
-
-int sink(...);
-
-int x = sink(
-  REPEAT_10000(TEST_CASE_NOP)
-  REPEAT_10000(TEST_CASE_NOP) 42
-);
-
-void Foo( REPEAT_1000(TEST_CASE_TYPE) int) { }
-
-static_assert(__COUNTER__ > 10000, "");
-
-void escape() {
-
-sink(&x);
-sink(&Foo);
-}
diff --git a/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_metafunctions.sh.cpp b/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_metafunctions.sh.cpp
deleted file mode 100644
index 4815ce37b0883..0000000000000
--- a/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_metafunctions.sh.cpp
+++ /dev/null
@@ -1,65 +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 is a dummy feature that prevents this test from running by default.
-// REQUIRES: template-cost-testing
-
-// The table below compares the compile time and object size for each of the
-// variants listed in the RUN script.
-//
-//  Impl          Compile Time    Object Size
-// -------------------------------------------
-// _And:         3,498.639 ms     158 M
-// __lazy_and:  10,138.982 ms     334 M
-// __and_:      14,181.851 ms     648 M
-//
-
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %S/lazy.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace  -std=c++17 -DTEST_LAZY_AND
-// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %S/std.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace   -std=c++17 -DTEST_STD_AND
-
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "template_cost_testing.h"
-using std::true_type;
-using std::false_type;
-
-#define FALSE_T() std::false_type,
-#define TRUE_T() std::true_type,
-
-#ifdef TEST_LAZY_AND
-#define TEST_AND std::__lazy_and
-#define TEST_OR std::__lazy_or
-#elif defined(TEST_STD_AND)
-#define TEST_AND std::__and_
-#define TEST_OR std::__or_
-#else
-#define TEST_AND std::_And
-#define TEST_OR std::_Or
-#endif
-
-void sink(...);
-
-void Foo1(TEST_AND < REPEAT_1000(TRUE_T) true_type > t1) { sink(&t1); }
-void Foo2(TEST_AND < REPEAT_1000(TRUE_T) REPEAT_1000(TRUE_T) true_type > t2) { sink(&t2); }
-void Foo3(TEST_AND < REPEAT_1000(TRUE_T) true_type, false_type > t3) { sink(&t3); }
-void Foo4(TEST_AND < REPEAT_1000(TRUE_T) REPEAT_1000(TRUE_T) true_type, false_type > t4) { sink(&t4); }
-void Foo5(TEST_AND < false_type, REPEAT_1000(TRUE_T) true_type > t5) { sink(&t5); }
-void Foo6(TEST_AND < false_type, REPEAT_1000(TRUE_T) REPEAT_1000(TRUE_T) true_type > t6) { sink(&t6); }
-
-void escape() {
-
-sink(&Foo1);
-sink(&Foo2);
-sink(&Foo3);
-sink(&Foo4);
-sink(&Foo5);
-sink(&Foo6);
-}
diff --git a/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp b/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp
deleted file mode 100644
index b0512325d4c2c..0000000000000
--- a/libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp
+++ /dev/null
@@ -1,119 +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 is a dummy feature that prevents this test from running by default.
-// REQUIRES: template-cost-testing
-
-// Test the cost of the mechanism used to create an overload set used by variant
-// to determine which alternative to construct.
-
-// The table below compares the compile time and object size for each of the
-// variants listed in the RUN script.
-//
-//  Impl           Compile Time  Object Size
-// -----------------------------------------------------
-// flat:              959 ms        792 KiB
-// recursive:      23,444 ms     23,000 KiB
-// -----------------------------------------------------
-// variant_old:    16,894 ms     17,000 KiB
-// variant_new:     1,105 ms        828 KiB
-
-
-// RUN: %{cxx} %{flags} %{compile_flags} -std=c++17 -c %s \
-// RUN:    -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -g \
-// RUN:    -DTEST_NS=flat_impl -o %S/flat.o
-// RUN: %{cxx} %{flags} %{compile_flags} -std=c++17 -c %s \
-// RUN:    -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -g \
-// RUN:    -DTEST_NS=rec_impl -o %S/rec.o
-// RUN: %{cxx} %{flags} %{compile_flags} -std=c++17 -c %s \
-// RUN:    -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -g \
-// RUN:    -DTEST_NS=variant_impl -o %S/variant.o
-
-#include <type_traits>
-#include <tuple>
-#include <cassert>
-#include <variant>
-
-#include "test_macros.h"
-#include "template_cost_testing.h"
-
-template <std::size_t Idx>
-struct TestType {};
-
-template <class T>
-struct ID {
-  using type = T;
-};
-
-namespace flat_impl {
-
-struct OverloadBase { void operator()() const; };
-
-template <class Tp, std::size_t Idx>
-struct Overload {
-  auto operator()(Tp, Tp) const -> ID<Tp>;
-};
-
-template <class ...Bases>
-struct AllOverloads : OverloadBase, Bases... {};
-
-template <class IdxSeq>
-struct MakeOverloads;
-
-template <std::size_t ..._Idx>
-struct MakeOverloads<std::__tuple_indices<_Idx...> > {
-  template <class ...Types>
-  using Apply = AllOverloads<Overload<Types, _Idx>...>;
-};
-
-template <class ...Types>
-using Overloads = typename MakeOverloads<
-    std::__make_indices_imp<sizeof...(Types), 0> >::template Apply<Types...>;
-
-} // namespace flat_impl
-
-
-namespace rec_impl {
-
-template <class... Types> struct Overload;
-
-template <>
-struct Overload<> { void operator()() const; };
-
-template <class Tp, class... Types>
-struct Overload<Tp, Types...> : Overload<Types...> {
-  using Overload<Types...>::operator();
-  auto operator()(Tp, Tp) const -> ID<Tp>;
-};
-
-template <class... Types>
-using Overloads = Overload<Types...>;
-
-} // namespace rec_impl
-
-namespace variant_impl {
-  template <class ...Types>
-  using Overloads = std::__variant_detail::_MakeOverloads<Types...>;
-  } // namespace variant_impl
-
-#ifndef TEST_NS
-#error TEST_NS must be defined
-#endif
-
-#define TEST_TYPE() TestType< __COUNTER__ >,
-using T1 = TEST_NS::Overloads<REPEAT_1000(TEST_TYPE) TestType<1>, TestType<1>, int>;
-static_assert(__COUNTER__ >= 1000, "");
-
-void fn1(T1 x) { DoNotOptimize(&x); }
-void fn2(typename std::invoke_result_t<T1, int, int>::type x) { DoNotOptimize(&x); }
-
-int main(int, char**) {
-  DoNotOptimize(&fn1);
-  DoNotOptimize(&fn2);
-  return 0;
-}
diff --git a/libcxx/test/libcxx/utilities/template.bitset/includes.pass.cpp b/libcxx/test/libcxx/utilities/template.bitset/includes.pass.cpp
deleted file mode 100644
index ae8464ac946a9..0000000000000
--- a/libcxx/test/libcxx/utilities/template.bitset/includes.pass.cpp
+++ /dev/null
@@ -1,33 +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
-//
-//===----------------------------------------------------------------------===//
-
-// test that <bitset> includes <string>, <stdexcept> and <iosfwd>
-
-// XFAIL: FROZEN-CXX03-HEADERS-FIXME
-
-#include <bitset>
-
-#include "test_macros.h"
-
-#ifndef _LIBCPP_STRING
-#error <string> has not been included
-#endif
-
-#ifndef _LIBCPP_STDEXCEPT
-#error <stdexcept> has not been included
-#endif
-
-#ifndef _LIBCPP_IOSFWD
-#error <iosfwd> has not been included
-#endif
-
-int main(int, char**)
-{
-
-  return 0;
-}
diff --git a/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp b/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp
new file mode 100644
index 0000000000000..5267f6f521547
--- /dev/null
+++ b/libcxx/test/std/language.support/support.c.headers/support.c.headers.other/math.lerp.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <math.h>
+
+// [support.c.headers.other]/1
+//   ... except for the functions described in [sf.cmath], the
+//   std::lerp function overloads ([c.math.lerp]) ...
+
+#include <cassert>
+#include <math.h>
+
+template <class = int>
+int lerp(float, float, float) { return 32; }
+
+template <class = int>
+int lerp(double, double, double) { return 32; }
+
+template <class = int>
+int lerp(long double, long double, long double) { return 32; }
+
+int main(int, char**) {
+  assert(lerp(0.f, 0.f, 0.f) == 32);
+  assert(lerp(0., 0., 0.) == 32);
+  assert(lerp(0.l, 0.l, 0.l) == 32);
+
+  return 0;
+}
diff --git a/libcxx/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
rename to libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
diff --git a/libcxx/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
rename to libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for.signals.pass.cpp
diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp
deleted file mode 100644
index 2be9cb4187fa2..0000000000000
--- a/libcxx/test/std/thread/thread.threads/thread.thread.this/sleep_for_tested_elsewhere.pass.cpp
+++ /dev/null
@@ -1,22 +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
-//
-//===----------------------------------------------------------------------===//
-
-// <thread>
-
-// template <class Rep, class Period>
-//   void sleep_for(const chrono::duration<Rep, Period>& rel_time);
-
-// The std::this_thread::sleep_for test requires POSIX specific headers and
-// is therefore non-standard. For this reason the test lives under the 'libcxx'
-// subdirectory.
-
-int main(int, char**)
-{
-
-  return 0;
-}
diff --git a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/visibility_inlines_hidden.cpp
similarity index 97%
rename from libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
rename to libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/visibility_inlines_hidden.cpp
index 3714e4037a2dc..fe5e49f715787 100644
--- a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/visibility_inlines_hidden.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -fvisibility-inlines-hidden
 
 // When there is a weak hidden symbol in user code and a strong definition
diff --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/utilities/function.objects/refwrap/binary.pass.cpp
rename to libcxx/test/std/utilities/function.objects/refwrap/binary.pass.cpp
diff --git a/libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/utilities/function.objects/refwrap/unary.pass.cpp
rename to libcxx/test/std/utilities/function.objects/refwrap/unary.pass.cpp
diff --git a/libcxx/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp
rename to libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/race_condition.pass.cpp
diff --git a/libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp
similarity index 100%
rename from libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp
rename to libcxx/test/std/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp

``````````

</details>


https://github.com/llvm/llvm-project/pull/152982


More information about the libcxx-commits mailing list