diff options
Diffstat (limited to 'libcxx/test')
22 files changed, 101 insertions, 40 deletions
diff --git a/libcxx/test/benchmarks/spec.gen.py b/libcxx/test/benchmarks/spec.gen.py index c36dd0a..f355b2c 100644 --- a/libcxx/test/benchmarks/spec.gen.py +++ b/libcxx/test/benchmarks/spec.gen.py @@ -8,13 +8,13 @@ # REQUIRES: enable-spec-benchmarks -# RUN: mkdir -p %T -# RUN: echo "%{cxx}" > %T/cxx.subs -# RUN: echo "%{compile_flags}" > %T/compile_flags.subs -# RUN: echo "%{flags}" > %T/flags.subs -# RUN: echo "%{link_flags}" > %T/link_flags.subs -# RUN: echo "%{spec_dir}" > %T/spec_dir.subs -# RUN: %{python} %s %T +# RUN: mkdir -p %{temp} +# RUN: echo "%{cxx}" > %{temp}/cxx.subs +# RUN: echo "%{compile_flags}" > %{temp}/compile_flags.subs +# RUN: echo "%{flags}" > %{temp}/flags.subs +# RUN: echo "%{link_flags}" > %{temp}/link_flags.subs +# RUN: echo "%{spec_dir}" > %{temp}/spec_dir.subs +# RUN: %{python} %s %{temp} # END. import json @@ -66,18 +66,18 @@ spec_benchmarks &= no_fortran for benchmark in spec_benchmarks: print(f'#--- {benchmark}.sh.test') - print(f'RUN: rm -rf %T') # clean up any previous (potentially incomplete) run - print(f'RUN: mkdir %T') - print(f'RUN: cp {spec_config} %T/spec-config.cfg') - print(f'RUN: %{{spec_dir}}/bin/runcpu --config %T/spec-config.cfg --size train --output-root %T --rebuild {benchmark}') - print(f'RUN: rm -rf %T/benchspec') # remove the temporary directory, which can become quite large + print(f'RUN: rm -rf %{{temp}}') # clean up any previous (potentially incomplete) run + print(f'RUN: mkdir %{{temp}}') + print(f'RUN: cp {spec_config} %{{temp}}/spec-config.cfg') + print(f'RUN: %{{spec_dir}}/bin/runcpu --config %{{temp}}/spec-config.cfg --size train --output-root %{{temp}} --rebuild {benchmark}') + print(f'RUN: rm -rf %{{temp}}/benchspec') # remove the temporary directory, which can become quite large # The `runcpu` command above doesn't fail even if the benchmark fails to run. To determine failure, parse the CSV # results and ensure there are no compilation errors or runtime errors in the status row. Also print the logs and # fail if there are no CSV files at all, which implies a SPEC error. - print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results --extract "Base Status" --keep-failed %T/result/*.train.csv > %T/status || ! cat %T/result/*.log') - print(f'RUN: ! grep -E "CE|RE" %T/status || ! cat %T/result/*.log') + print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results --extract "Base Status" --keep-failed %{{temp}}/result/*.train.csv > %{{temp}}/status || ! cat %{{temp}}/result/*.log') + print(f'RUN: ! grep -E "CE|RE" %{{temp}}/status || ! cat %{{temp}}/result/*.log') # If there were no errors, parse the results into LNT-compatible format and print them. - print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results %T/result/*.train.csv --output-format=lnt > %T/results.lnt') - print(f'RUN: cat %T/results.lnt') + print(f'RUN: %{{libcxx-dir}}/utils/parse-spec-results %{{temp}}/result/*.train.csv --output-format=lnt > %{{temp}}/results.lnt') + print(f'RUN: cat %{{temp}}/results.lnt') diff --git a/libcxx/test/configs/apple-libc++-shared.cfg.in b/libcxx/test/configs/apple-libc++-shared.cfg.in index 5504bfd..a361b2b 100644 --- a/libcxx/test/configs/apple-libc++-shared.cfg.in +++ b/libcxx/test/configs/apple-libc++-shared.cfg.in @@ -38,7 +38,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -lc++ %{apple-system-shims}' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T --env DYLD_LIBRARY_PATH=%{lib-dir} -- ' + '%{executor} --execdir %{temp} --env DYLD_LIBRARY_PATH=%{lib-dir} -- ' )) config.stdlib = 'apple-libc++' diff --git a/libcxx/test/configs/apple-libc++-system.cfg.in b/libcxx/test/configs/apple-libc++-system.cfg.in index b59506f..e87f920 100644 --- a/libcxx/test/configs/apple-libc++-system.cfg.in +++ b/libcxx/test/configs/apple-libc++-system.cfg.in @@ -19,7 +19,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -lc++' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T -- ' + '%{executor} --execdir %{temp} -- ' )) config.stdlib = 'apple-libc++' diff --git a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in index b2669a7..f0782c2 100644 --- a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in +++ b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in @@ -30,7 +30,7 @@ config.executor = ( ' --cpu cortex-m3') config.substitutions.append(('%{exec}', '%{executor}' - ' --execdir %T' + ' --execdir %{temp}' )) import os, site diff --git a/libcxx/test/configs/ibm-libc++-shared.cfg.in b/libcxx/test/configs/ibm-libc++-shared.cfg.in index 0f86e74..c24c729 100644 --- a/libcxx/test/configs/ibm-libc++-shared.cfg.in +++ b/libcxx/test/configs/ibm-libc++-shared.cfg.in @@ -18,7 +18,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -lc++ -lc++abi -latomic -Wl,-bbigtoc' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T --env LIBPATH=%{lib-dir} -- ' + '%{executor} --execdir %{temp} --env LIBPATH=%{lib-dir} -- ' )) # LIBCXX-AIX-FIXME is the feature name used to XFAIL the diff --git a/libcxx/test/configs/llvm-libc++-android.cfg.in b/libcxx/test/configs/llvm-libc++-android.cfg.in index 9362c68..96c952d 100644 --- a/libcxx/test/configs/llvm-libc++-android.cfg.in +++ b/libcxx/test/configs/llvm-libc++-android.cfg.in @@ -36,7 +36,7 @@ config.substitutions.append(('%{link_flags}', config.substitutions.append(('%{exec}', '%{executor}' + ' --job-limit-socket ' + libcxx.test.android.adb_job_limit_socket() + - ' --prepend-path-env LD_LIBRARY_PATH /data/local/tmp/libc++ --execdir %T -- ' + ' --prepend-path-env LD_LIBRARY_PATH /data/local/tmp/libc++ --execdir %{temp} -- ' )) libcxx.test.config.configure( diff --git a/libcxx/test/configs/llvm-libc++-mingw.cfg.in b/libcxx/test/configs/llvm-libc++-mingw.cfg.in index 01c4d58..4473171 100644 --- a/libcxx/test/configs/llvm-libc++-mingw.cfg.in +++ b/libcxx/test/configs/llvm-libc++-mingw.cfg.in @@ -11,7 +11,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -lc++' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- ' + '%{executor} --execdir %{temp} --prepend_env PATH=%{install-prefix}/bin -- ' )) import os, site diff --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in index 5fa99bc..e6186a7 100644 --- a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in +++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in @@ -25,7 +25,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib -L %{lib-dir} -lc++ -l' + cxx_lib )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- ' + '%{executor} --execdir %{temp} --prepend_env PATH=%{install-prefix}/bin -- ' )) import os, site diff --git a/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in b/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in index 649bd31..1b4ddc2 100644 --- a/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in +++ b/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in @@ -12,7 +12,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -Wl,-rpath,%{lib-dir} -lc++ -lm' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T -- ' + '%{executor} --execdir %{temp} -- ' )) import os, site diff --git a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in index e95999d..476c5ca 100644 --- a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in +++ b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in @@ -26,7 +26,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib -L %{lib-dir} -lc++ -l' + cxx_lib )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- ' + '%{executor} --execdir %{temp} --prepend_env PATH=%{install-prefix}/bin -- ' )) import os, site diff --git a/libcxx/test/configs/llvm-libc++-shared.cfg.in b/libcxx/test/configs/llvm-libc++-shared.cfg.in index 0c059f0..6d4a383 100644 --- a/libcxx/test/configs/llvm-libc++-shared.cfg.in +++ b/libcxx/test/configs/llvm-libc++-shared.cfg.in @@ -13,7 +13,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -Wl,-rpath,%{lib-dir} -lc++' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T -- ' + '%{executor} --execdir %{temp} -- ' )) import os, site diff --git a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in index 4b6b3fc..2f2b420 100644 --- a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in +++ b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in @@ -25,7 +25,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib -L %{lib-dir} -llibc++ -l' + cxx_lib )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T -- ' + '%{executor} --execdir %{temp} -- ' )) import os, site diff --git a/libcxx/test/configs/llvm-libc++-static.cfg.in b/libcxx/test/configs/llvm-libc++-static.cfg.in index 097cc4d..45a44c1 100644 --- a/libcxx/test/configs/llvm-libc++-static.cfg.in +++ b/libcxx/test/configs/llvm-libc++-static.cfg.in @@ -13,7 +13,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{lib-dir} -lc++ -lc++abi' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T -- ' + '%{executor} --execdir %{temp} -- ' )) import os, site diff --git a/libcxx/test/configs/stdlib-libstdc++.cfg.in b/libcxx/test/configs/stdlib-libstdc++.cfg.in index 3ff0c54..1a4b47c 100644 --- a/libcxx/test/configs/stdlib-libstdc++.cfg.in +++ b/libcxx/test/configs/stdlib-libstdc++.cfg.in @@ -51,7 +51,7 @@ config.substitutions.append(('%{link_flags}', '-nostdlib++ -L %{libstdcxx-install-prefix}/lib/gcc/%{libstdcxx-version} -Wl,-rpath,%{libstdcxx-install-prefix}/lib/gcc/%{libstdcxx-version} -lstdc++' )) config.substitutions.append(('%{exec}', - '%{executor} --execdir %T -- ' + '%{executor} --execdir %{temp} -- ' )) import os, site diff --git a/libcxx/test/configs/stdlib-native.cfg.in b/libcxx/test/configs/stdlib-native.cfg.in index 3e25c1e..b827155f 100644 --- a/libcxx/test/configs/stdlib-native.cfg.in +++ b/libcxx/test/configs/stdlib-native.cfg.in @@ -11,7 +11,7 @@ config.substitutions.append(('%{flags}', )) config.substitutions.append(('%{compile_flags}', '-I %{libcxx-dir}/test/support')) config.substitutions.append(('%{link_flags}', '')) -config.substitutions.append(('%{exec}', '%{executor} --execdir %T -- ')) +config.substitutions.append(('%{exec}', '%{executor} --execdir %{temp} -- ')) import os, site site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils')) diff --git a/libcxx/test/selftest/dsl/dsl.sh.py b/libcxx/test/selftest/dsl/dsl.sh.py index 6d4406b..93f351f 100644 --- a/libcxx/test/selftest/dsl/dsl.sh.py +++ b/libcxx/test/selftest/dsl/dsl.sh.py @@ -12,7 +12,7 @@ # Note: We prepend arguments with 'x' to avoid thinking there are too few # arguments in case an argument is an empty string. -# RUN: %{python} %s x%S x%T x%{substitutions} +# RUN: %{python} %s x%S x%{temp} x%{substitutions} import base64 import copy diff --git a/libcxx/test/selftest/dsl/lit.local.cfg b/libcxx/test/selftest/dsl/lit.local.cfg index 352719b..dc6887a 100644 --- a/libcxx/test/selftest/dsl/lit.local.cfg +++ b/libcxx/test/selftest/dsl/lit.local.cfg @@ -1,8 +1,8 @@ # Since we try to pass substitutions as-is to some tests, we must "escape" # them in case they contain other substitutions. Otherwise, the substitutions # will be fully expanded when passed to the tests. For example, we want an -# %{exec} substitution that contains `--execdir %T` to be passed as-is, without -# substituting the directory. This way, the test itself can populate %T as it +# %{exec} substitution that contains `--execdir %{temp}` to be passed as-is, without +# substituting the directory. This way, the test itself can populate %{temp} as it # sees fit, and %{exec} will respect it. # # To solve this problem, we pickle the substitutions and base64 encode that diff --git a/libcxx/test/selftest/file_dependencies/absolute-and-relative-paths.sh.cpp b/libcxx/test/selftest/file_dependencies/absolute-and-relative-paths.sh.cpp index ac52f67..68283f6 100644 --- a/libcxx/test/selftest/file_dependencies/absolute-and-relative-paths.sh.cpp +++ b/libcxx/test/selftest/file_dependencies/absolute-and-relative-paths.sh.cpp @@ -9,7 +9,7 @@ // Make sure that FILE_DEPENDENCIES work with relative AND absolute paths. // FILE_DEPENDENCIES: %S/a.txt -// RUN: test -e %T/a.txt +// RUN: test -e %{temp}/a.txt // FILE_DEPENDENCIES: dir/b.txt -// RUN: test -e %T/b.txt +// RUN: test -e %{temp}/b.txt diff --git a/libcxx/test/selftest/file_dependencies/substitute-in-dependencies.sh.cpp b/libcxx/test/selftest/file_dependencies/substitute-in-dependencies.sh.cpp index c63684c..59de718 100644 --- a/libcxx/test/selftest/file_dependencies/substitute-in-dependencies.sh.cpp +++ b/libcxx/test/selftest/file_dependencies/substitute-in-dependencies.sh.cpp @@ -9,4 +9,4 @@ // Make sure that lit substitutions are expanded inside FILE_DEPENDENCIES lines. // FILE_DEPENDENCIES: %s -// RUN: test -e %T/substitute-in-dependencies.sh.cpp +// RUN: test -e %{temp}/substitute-in-dependencies.sh.cpp diff --git a/libcxx/test/selftest/tmpdir-exists.sh.cpp b/libcxx/test/selftest/tmpdir-exists.sh.cpp index 7f9e69d..4edd165 100644 --- a/libcxx/test/selftest/tmpdir-exists.sh.cpp +++ b/libcxx/test/selftest/tmpdir-exists.sh.cpp @@ -6,6 +6,6 @@ // //===----------------------------------------------------------------------===// -// Make sure that the directory represented by %T exists when we run the test. +// Make sure that the directory represented by %{temp} exists when we run the test. -// RUN: test -d %T +// RUN: test -d %{temp} diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp index abd2848..e5c1963 100644 --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp @@ -21,6 +21,7 @@ #include "make_string.h" #include "test_macros.h" #include "asan_testing.h" +#include "type_algorithms.h" template <class S> constexpr void test_appending(std::size_t k, size_t N, size_t new_capacity) { @@ -77,17 +78,30 @@ constexpr bool test() { return true; } -void test_value_categories() { +constexpr bool test_value_categories() { std::string s; s.resize_and_overwrite(10, [](char*&&, std::size_t&&) { return 0; }); LIBCPP_ASSERT(is_string_asan_correct(s)); s.resize_and_overwrite(10, [](char* const&, const std::size_t&) { return 0; }); LIBCPP_ASSERT(is_string_asan_correct(s)); struct RefQualified { - int operator()(char*, std::size_t) && { return 0; } + constexpr int operator()(char*, std::size_t) && { return 0; } }; s.resize_and_overwrite(10, RefQualified{}); LIBCPP_ASSERT(is_string_asan_correct(s)); + return true; +} + +constexpr bool test_integer_like_return_types() { + types::for_each(types::integer_types(), []<typename IntegerType> { + std::string s; + s.resize_and_overwrite(10, [](char* p, std::size_t n) -> IntegerType { + std::fill(p, p + n, 'f'); + return n; + }); + assert(s.size() == 10); + }); + return true; } int main(int, char**) { @@ -105,5 +119,12 @@ int main(int, char**) { test<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>>(); static_assert(test<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>>()); #endif + + test_value_categories(); + test_integer_like_return_types(); + + static_assert(test_value_categories()); + static_assert(test_integer_like_return_types()); + return 0; } diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.verify.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.verify.cpp new file mode 100644 index 0000000..323f49b --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.verify.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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: std-at-least-c++23 + +// <string> + +// template<class Operation> +// void resize_and_overwrite(size_type n, Operation op) + +// Verify that the operation's return type must be integer-like + +#include <string> + +void test_bool_return_type() { + std::string s; + s.resize_and_overwrite(10, [](char*, std::size_t) { + return true; // expected-error-re@*:* {{{{(static_assertion|static assertion)}}{{.*}}integer-like}} + }); +} + +void test_pointer_return_type() { + std::string s; + s.resize_and_overwrite(10, [](char* p, std::size_t) { + return p; // expected-error-re@*:* {{{{(static_assertion|static assertion)}}{{.*}}integer-like}} + // expected-error@*:* {{cannot initialize}} + }); +} + +void test_float_return_type() { + std::string s; + s.resize_and_overwrite(10, [](char*, std::size_t) { + return 5.0f; // expected-error-re@*:* {{{{(static_assertion|static assertion)}}{{.*}}integer-like}} + }); +} |