-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[libc++] Add a utility for checking the output of commands #65917
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
base: main
Are you sure you want to change the base?
Conversation
Just use filecheck. |
I'm not OK importing our own version of an LLVM tool that we should just use if we need it. Further, these tests are a second order measure of the thing we're actually trying to measure, which is "what is the performance of this code". Lets say that the code that used to be lowered to Tests should only fail when the property under test is no longer true. For example, microbenchmarks seem like the more appropriate way to test performance. Sure they're noisy, but they're a 1st order derivative of what we're trying to test. |
One challenge with using |
Or if we just want to run this on the bots, we can install it as part of the base setup. However, I don't know that the tests in this PR are tests that provide value to the project. They're going to fail on almost every platform or different compiler version. They don't really test anything that's our responsibility to test. Any added assurance is outweighed by their brittleness. Tests should fail only when the behavior under test changes. I've given a lot of thought to adding these sorts of tests before, but the inherent non-portability and limited utility have always kept me from doing it. Could you more thoroughly explain the value added by these tests and why they can't be established in other ways? |
libcxx/test/libcxx/utilities/utility/utility.intcmp/cmp_equal.codegen.sh.cpp
Outdated
Show resolved
Hide resolved
We've wished that we would have access to I see a lot of value in being able to perform these checks in specific (rather unusual) circumstances. I also agree that it's not ideal to write the tool ourselves when we have
IMO we should look into what's required to do (1). |
What does it mean if that test starts failing? I would argue "not much". We don't care that the functions call memmov, we care about the performance. If the compiler stops lowering to memmov, and instead lowers to faster instructions, do we care? No. Should we have a test that fails if such a change occurs? No. What we're really trying to test is that we don't regress a benchmark. And that's tricky to do, so I understand the motivation to find another way to test that.
Cool, let's look into #1. But I'm pretty opposed to making the build+test iteration speed any slower by default. If we actually come up with a substantial amount of tests that need FileCheck, I would be happy to revisit it's necessity, but we're not there yet. |
In the interest of keeping the review queue small and relevant, I then suggest we close this PR as option (1) is investigated. @philnik777 WDYT? |
I've converted it to a draft for now to clear up the queue. |
Closing per discussion with Nikolas since we will most likely pursue installing |
Since using the real |
d15dd81
to
7fa8cf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for reviving this! I really like this in general, but I do wonder about the value of some of the cmp_less.codegen
tests you added.
libcxx/test/libcxx/utilities/utility/utility.intcmp/cmp_equal.codegen.sh.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx/utilities/utility/utility.unreachable.codegen.sh.cpp
Outdated
Show resolved
Hide resolved
7fa8cf5
to
b8b5c37
Compare
Can you rebase and apply this patch on the PR? That should fix CI and my review comments: diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 5ab843e8c131..f4e577aed57d 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -42,7 +42,6 @@ add_custom_target(install-cxx-test-suite-prefix
cxx
cxx_experimental
cxx-modules
- check_output
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=cxx-headers
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in
index 31ebcfe98215..3bbd1356ad20 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -31,4 +31,4 @@ config.substitutions.append(('%{lib-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIB
config.substitutions.append(('%{module-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_MODULES_DIR@'))
config.substitutions.append(('%{test-tools-dir}', '@LIBCXX_TEST_TOOLS_PATH@'))
config.substitutions.append(('%{benchmark_flags}', '-I @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/include -L @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/lib -L @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/lib64 -l benchmark'))
-config.substitutions.append(('%{check-output}', os.path.join('@CMAKE_BINARY_DIR@', 'bin/check_output') + " %s"))
+config.substitutions.append(('%{check-output}', os.path.join('@LIBCXX_BINARY_DIR@', 'bin/check_output') + " %s"))
diff --git a/libcxx/test/tools/check_output/CMakeLists.txt b/libcxx/test/tools/check_output/CMakeLists.txt
index e1fe1a018e00..aa33b2b1992f 100644
--- a/libcxx/test/tools/check_output/CMakeLists.txt
+++ b/libcxx/test/tools/check_output/CMakeLists.txt
@@ -1,15 +1,6 @@
add_executable(check_output check_output.cpp)
-# Link against libc++
-if (TARGET cxx_shared)
- target_link_libraries(check_output PRIVATE cxx_shared)
-elseif (TARGET cxx_static)
- target_link_libraries(check_output PRIVATE cxx_static)
-else()
- message(FATAL "Neither cxx_shared nor cxx_static are available to be linked against")
-endif()
-
# put the binary into <build>/bin
set_target_properties(check_output PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
@@ -20,3 +11,5 @@ set_target_properties(check_output PROPERTIES
CXX_EXTENSIONS NO)
target_compile_options(check_output PRIVATE -Werror=missing-prototypes)
+
+add_dependencies(cxx-test-depends check_output) |
b8b5c37
to
ab55109
Compare
Looks like you can't use |
4ee73aa
to
a6f8e24
Compare
a6f8e24
to
7477192
Compare
8b35db5
to
5df916d
Compare
5df916d
to
a0d306f
Compare
This allows us to check the output of any tools.
For example, we can
std::copy
with trivial types always calls__builtin_memmove
These kinds of tests are more likely to break because of external tool changes, so they shouldn't be used if there is a different way to test things.
This tool is a strict subset of
FileCheck
in terms of it's functionality. I didn't just make that a dependency because it has quite heavy dependencies itself, which would make it by far the most costly part of building libc++. If we find that we extend this tool a lot (or FileCheck becomes less heavy) we should reconsider whether we should take the dependency hit.