[libc++] Fix some tests that were broken in the single-threaded configuration

We never noticed it because our CI doesn't actually build against a C
library that doesn't have threading functionality, however building
against a truly thread-free platform surfaces these issues.

Differential Revision: https://reviews.llvm.org/D114242

GitOrigin-RevId: e1ce3dabf0c70d30a24f0586ddf2a965d730d30a
diff --git a/test/libcxx/thread/thread.mutex/version.pass.cpp b/test/libcxx/thread/thread.mutex/version.pass.cpp
index 9a18ec7..bf56531 100644
--- a/test/libcxx/thread/thread.mutex/version.pass.cpp
+++ b/test/libcxx/thread/thread.mutex/version.pass.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <mutex>
 
 #include <mutex>
diff --git a/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp b/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp
index 5290e06..59bab22 100644
--- a/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp
+++ b/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable.compile.pass.cpp
@@ -20,13 +20,16 @@
 #include <list>
 #include <map>
 #include <memory>
-#include <mutex>
 #include <optional>
 #include <set>
 #include <unordered_map>
 #include <unordered_set>
 #include <vector>
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#   include <mutex>
+#endif
+
 #include "compare_types.h"
 
 namespace fundamentals {
diff --git a/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp b/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
index a9caf8d..1f82b8a 100644
--- a/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
+++ b/test/std/concepts/concepts.compare/concept.equalitycomparable/equality_comparable_with.compile.pass.cpp
@@ -20,13 +20,16 @@
 #include <list>
 #include <map>
 #include <memory>
-#include <mutex>
 #include <optional>
 #include <set>
 #include <unordered_map>
 #include <unordered_set>
 #include <vector>
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#   include <mutex>
+#endif
+
 #include "compare_types.h"
 
 template <class T, class U>
diff --git a/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp b/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp
index 1278f84..e38e4c6 100644
--- a/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp
+++ b/test/std/concepts/concepts.lang/concept.assignable/assignable_from.compile.pass.cpp
@@ -19,13 +19,16 @@
 #include <list>
 #include <map>
 #include <memory>
-#include <mutex>
 #include <optional>
 #include <string>
 #include <string_view>
 #include <unordered_map>
 #include <vector>
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#   include <mutex>
+#endif
+
 #include "../support/allocators.h"
 
 // Note: is_lvalue_reference is checked in all ModelsAssignableFrom calls.
diff --git a/test/std/concepts/concepts.object/movable.compile.pass.cpp b/test/std/concepts/concepts.object/movable.compile.pass.cpp
index 5459dcd..fff78cf 100644
--- a/test/std/concepts/concepts.object/movable.compile.pass.cpp
+++ b/test/std/concepts/concepts.object/movable.compile.pass.cpp
@@ -18,11 +18,14 @@
 #include <forward_list>
 #include <list>
 #include <map>
-#include <mutex>
 #include <optional>
 #include <unordered_map>
 #include <vector>
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+#   include <mutex>
+#endif
+
 #include "type_classification/moveconstructible.h"
 #include "type_classification/movable.h"
 
diff --git a/test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp b/test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp
index 9e76cfb..dae5a1b 100644
--- a/test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp
+++ b/test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp
@@ -11,6 +11,8 @@
 //
 // clang-format off
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <mutex>
 
 // Test the feature test macros defined by <mutex>
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
index c63cda3..4748c68 100644
--- a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -5,7 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
+
 // UNSUPPORTED: libcpp-has-no-threads
 
 // <mutex>
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
index 54d29ae..0084f0c 100644
--- a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
@@ -5,7 +5,7 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
+
 // UNSUPPORTED: libcpp-has-no-threads
 
 // <mutex>
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.compile.fail.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.compile.fail.cpp
index 40d408d..c5da06c 100644
--- a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.compile.fail.cpp
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/assign.compile.fail.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <mutex>
 
 // struct once_flag;
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.compile.fail.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.compile.fail.cpp
index 9b7c19a..70b145a 100644
--- a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.compile.fail.cpp
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/copy.compile.fail.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <mutex>
 
 // struct once_flag;
diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
index 28d93dc..c6b48f3 100644
--- a/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
+++ b/test/std/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // <mutex>
 
 // struct once_flag;
diff --git a/utils/generate_feature_test_macro_components.py b/utils/generate_feature_test_macro_components.py
index 5ff8330..2e85893 100755
--- a/utils/generate_feature_test_macro_components.py
+++ b/utils/generate_feature_test_macro_components.py
@@ -653,23 +653,26 @@
 # Map from each header to the Lit annotations that should be used for
 # tests that include that header.
 #
-# For example, when threads are not supported, any feature-test-macro test
-# that includes <thread> should be marked as UNSUPPORTED, because including
-# <thread> is a hard error in that case.
+# For example, when threads are not supported, any test that includes
+# <thread> should be marked as UNSUPPORTED, because including <thread>
+# is a hard error in that case.
 lit_markup = {
   "barrier": ["UNSUPPORTED: libcpp-has-no-threads"],
   "filesystem": ["UNSUPPORTED: libcpp-has-no-filesystem-library"],
   "format": ["UNSUPPORTED: libcpp-has-no-incomplete-format"],
   "iomanip": ["UNSUPPORTED: libcpp-has-no-localization"],
+  "ios": ["UNSUPPORTED: libcpp-has-no-localization"],
+  "iostream": ["UNSUPPORTED: libcpp-has-no-localization"],
   "istream": ["UNSUPPORTED: libcpp-has-no-localization"],
   "latch": ["UNSUPPORTED: libcpp-has-no-threads"],
   "locale": ["UNSUPPORTED: libcpp-has-no-localization"],
+  "mutex": ["UNSUPPORTED: libcpp-has-no-threads"],
   "ostream": ["UNSUPPORTED: libcpp-has-no-localization"],
   "ranges": ["UNSUPPORTED: libcpp-has-no-incomplete-ranges"],
   "regex": ["UNSUPPORTED: libcpp-has-no-localization"],
   "semaphore": ["UNSUPPORTED: libcpp-has-no-threads"],
   "shared_mutex": ["UNSUPPORTED: libcpp-has-no-threads"],
-  "thread": ["UNSUPPORTED: libcpp-has-no-threads"],
+  "thread": ["UNSUPPORTED: libcpp-has-no-threads"]
 }
 
 def get_std_dialects():
diff --git a/utils/generate_header_inclusion_tests.py b/utils/generate_header_inclusion_tests.py
index 7d48094..00f6b0a 100755
--- a/utils/generate_header_inclusion_tests.py
+++ b/utils/generate_header_inclusion_tests.py
@@ -86,9 +86,9 @@
 # Map from each header to the Lit annotations that should be used for
 # tests that include that header.
 #
-# For example, when threads are not supported, any test
-# that includes <thread> should be marked as UNSUPPORTED, because including
-# <thread> is a hard error in that case.
+# For example, when threads are not supported, any test that includes
+# <thread> should be marked as UNSUPPORTED, because including <thread>
+# is a hard error in that case.
 lit_markup = {
   "barrier": ["UNSUPPORTED: libcpp-has-no-threads"],
   "filesystem": ["UNSUPPORTED: libcpp-has-no-filesystem-library"],
@@ -99,12 +99,13 @@
   "istream": ["UNSUPPORTED: libcpp-has-no-localization"],
   "latch": ["UNSUPPORTED: libcpp-has-no-threads"],
   "locale": ["UNSUPPORTED: libcpp-has-no-localization"],
+  "mutex": ["UNSUPPORTED: libcpp-has-no-threads"],
   "ostream": ["UNSUPPORTED: libcpp-has-no-localization"],
   "ranges": ["UNSUPPORTED: libcpp-has-no-incomplete-ranges"],
   "regex": ["UNSUPPORTED: libcpp-has-no-localization"],
   "semaphore": ["UNSUPPORTED: libcpp-has-no-threads"],
   "shared_mutex": ["UNSUPPORTED: libcpp-has-no-threads"],
-  "thread": ["UNSUPPORTED: libcpp-has-no-threads"],
+  "thread": ["UNSUPPORTED: libcpp-has-no-threads"]
 }