How to display std::cout output in llvm-lit tests?

I’m having trouble getting std::cout output to display when running libcxx tests (e.g., libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp) with llvm-lit. Here’s what I have done so far:

  1. Built the project in RelWithDebInfo mode with -DLLVM_ENABLE_ASSERTIONS=ON.
  2. Tried running llvm-lit with the -v flag to enable verbose output.

However, the std::cout output from my tests is not appearing in the console. Has anyone encountered a similar issue or have any suggestions on how to make the std::cout output visible when running tests with llvm-lit? Any help would be greatly appreciated!

Thanks in advance!

  -v, --verbose         For failed tests, show all output. For example, each command is printed before it is executed,
                        so the last printed command is the one that failed.

Is your test failing? Otherwise it is expected that -v won’t show the output.

The very next option in the --help output for lit is what you’re looking for I think:

  -a, --show-all        Enable -v, but for all tests not just failed tests.
1 Like

Thank you so much for your help! -a is exactly what I was looking for. Now, I can see the output for all std::cout statements in the .pass.cpp files.

I have a follow-up question: when running llvm-lit to test the STL containers, I added some std::cout statements in the container headers (e.g., vector.h) to aid in my testing and debugging process. However, I couldn’t see these outputs. Is there a way to make these outputs visible when running llvm-lit?

lit is just a python script that executes some commands. You should see the executed command printed with -a, and you can then run the same command without lit.
At this point it’ll be just a question of debugging what’s going on with this binary if you don’t observe what you expect.

Sorry, my bad. The -a option displays all the debug information, no matter where std::cout appears. Thank you so much again for your help!

1 Like