From 257eb74524446a919b3378afad39de37cc470ce4 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 20 Sep 2023 09:33:16 -0400 Subject: [PATCH] [libc++] Simplify how the global stream tests are written (#66842) Instead of relying on Bash, use the builtin Lit commands whenever possible. The motivation is to stop running %t.exe behind Bash, which breaks on macOS 13.5 with SIP enabled because DYLD_LIBRARY_PATH isn't forwarded to the underlying process when running through a protected process. For more details, see [1]. [1]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html --- .../input.output/iostream.format/print.fun/print.sh.cpp | 8 ++------ .../iostream.format/print.fun/vprint_nonunicode.sh.cpp | 8 ++------ .../iostream.format/print.fun/vprint_unicode.sh.cpp | 8 ++------ .../std/input.output/iostream.objects/check-stderr.sh | 4 ---- .../std/input.output/iostream.objects/check-stdout.sh | 4 ---- .../iostream.objects/narrow.stream.objects/cerr.sh.cpp | 6 +++--- .../iostream.objects/narrow.stream.objects/cin.sh.cpp | 7 ++++--- .../iostream.objects/narrow.stream.objects/clog.sh.cpp | 6 +++--- .../iostream.objects/narrow.stream.objects/cout.sh.cpp | 6 +++--- .../test/std/input.output/iostream.objects/send-stdin.sh | 3 --- .../iostream.objects/wide.stream.objects/check-stderr.sh | 5 ----- .../iostream.objects/wide.stream.objects/check-stdout.sh | 5 ----- .../iostream.objects/wide.stream.objects/send-stdin.sh | 4 ---- .../wide.stream.objects/wcerr-imbue.sh.cpp | 6 +++--- .../wide.stream.objects/wcerr-wide-mode.sh.cpp | 6 +++--- .../iostream.objects/wide.stream.objects/wcerr.sh.cpp | 6 +++--- .../wide.stream.objects/wcin-imbue.sh.cpp | 7 ++++--- .../wide.stream.objects/wcin-wide-mode.sh.cpp | 5 ++--- .../iostream.objects/wide.stream.objects/wcin.sh.cpp | 7 ++++--- .../iostream.objects/wide.stream.objects/wclog.sh.cpp | 6 +++--- .../wide.stream.objects/wcout-imbue.sh.cpp | 6 +++--- .../wide.stream.objects/wcout-wide-mode.sh.cpp | 6 +++--- .../iostream.objects/wide.stream.objects/wcout.sh.cpp | 6 +++--- 23 files changed, 50 insertions(+), 85 deletions(-) delete mode 100644 libcxx/test/std/input.output/iostream.objects/check-stderr.sh delete mode 100644 libcxx/test/std/input.output/iostream.objects/check-stdout.sh delete mode 100644 libcxx/test/std/input.output/iostream.objects/send-stdin.sh delete mode 100644 libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stderr.sh delete mode 100644 libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stdout.sh delete mode 100644 libcxx/test/std/input.output/iostream.objects/wide.stream.objects/send-stdin.sh diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/print.sh.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/print.sh.cpp index 8c06050d6b41..d348a3b530be 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/print.sh.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/print.sh.cpp @@ -7,7 +7,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // UNSUPPORTED: no-filesystem -// UNSUPPORTED: executor-has-no-bash // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME // XFAIL: availability-fp_to_chars-missing @@ -29,12 +28,9 @@ // // The testing is based on the testing for std::cout. -// TODO PRINT Use lit builtin echo - -// FILE_DEPENDENCIES: echo.sh // RUN: %{build} -// RUN: %{exec} bash echo.sh -n "1234 一二三四 true 0x0" > %t.expected -// RUN: %{exec} "%t.exe" > %t.actual +// RUN: echo -n "1234 一二三四 true 0x0" > %t.expected +// RUN: %{exec} %t.exe > %t.actual // RUN: diff -u %t.actual %t.expected #include diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.sh.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.sh.cpp index ca7687150b94..63e1d2ad82b7 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.sh.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.sh.cpp @@ -7,7 +7,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // UNSUPPORTED: no-filesystem -// UNSUPPORTED: executor-has-no-bash // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME // XFAIL: availability-fp_to_chars-missing @@ -27,12 +26,9 @@ // // The testing is based on the testing for std::cout. -// TODO PRINT Use lit builtin echo - -// FILE_DEPENDENCIES: echo.sh // RUN: %{build} -// RUN: %{exec} bash echo.sh -n "1234 一二三四 true 0x0" > %t.expected -// RUN: %{exec} "%t.exe" > %t.actual +// RUN: echo -n "1234 一二三四 true 0x0" > %t.expected +// RUN: %{exec} %t.exe > %t.actual // RUN: diff -u %t.actual %t.expected #include diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.sh.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.sh.cpp index 3582293e9e75..a9bcc33d2e01 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.sh.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.sh.cpp @@ -7,7 +7,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // UNSUPPORTED: no-filesystem -// UNSUPPORTED: executor-has-no-bash // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME // XFAIL: availability-fp_to_chars-missing @@ -27,12 +26,9 @@ // // The testing is based on the testing for std::cout. -// TODO PRINT Use lit builtin echo - -// FILE_DEPENDENCIES: echo.sh // RUN: %{build} -// RUN: %{exec} bash echo.sh -n "1234 一二三四 true 0x0" > %t.expected -// RUN: %{exec} "%t.exe" > %t.actual +// RUN: echo -n "1234 一二三四 true 0x0" > %t.expected +// RUN: %{exec} %t.exe > %t.actual // RUN: diff -u %t.actual %t.expected #include diff --git a/libcxx/test/std/input.output/iostream.objects/check-stderr.sh b/libcxx/test/std/input.output/iostream.objects/check-stderr.sh deleted file mode 100644 index bc800aa9a6bb..000000000000 --- a/libcxx/test/std/input.output/iostream.objects/check-stderr.sh +++ /dev/null @@ -1,4 +0,0 @@ -program=${1} -expected_stderr=${2} -${program} 2>stderr.log >stdout.log -[ "${expected_stderr}" == "$(cat stderr.log)" ] diff --git a/libcxx/test/std/input.output/iostream.objects/check-stdout.sh b/libcxx/test/std/input.output/iostream.objects/check-stdout.sh deleted file mode 100644 index e86f8cc43a92..000000000000 --- a/libcxx/test/std/input.output/iostream.objects/check-stdout.sh +++ /dev/null @@ -1,4 +0,0 @@ -program=${1} -expected_stdout=${2} -${program} 2>stderr.log >stdout.log -[ "${expected_stdout}" == "$(cat stdout.log)" ] diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp index 4df76091e13b..b9e274af7334 100644 --- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp @@ -10,10 +10,10 @@ // ostream cerr; -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stderr.sh // RUN: %{build} -// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234" +// RUN: %{exec} %t.exe 2> %t.actual +// RUN: echo -n 1234 > %t.expected +// RUN: diff %t.expected %t.actual #include #include diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp index c394c1b00f3e..b39cd57ab212 100644 --- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp @@ -6,14 +6,15 @@ // //===----------------------------------------------------------------------===// +// TODO: Investigate +// UNSUPPORTED: LIBCXX-AIX-FIXME + // // istream cin; -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../send-stdin.sh // RUN: %{build} -// RUN: %{exec} bash send-stdin.sh "%t.exe" "1234" +// RUN: echo -n 1234 | %{exec} %t.exe #include #include diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp index 0ac99ba99256..476addba050d 100644 --- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp @@ -10,10 +10,10 @@ // ostream clog; -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stderr.sh // RUN: %{build} -// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234" +// RUN: %{exec} %t.exe 2> %t.actual +// RUN: echo -n 1234 > %t.expected +// RUN: diff %t.expected %t.actual #include diff --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp index 43388501d6f9..b8d319385ca1 100644 --- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp @@ -10,10 +10,10 @@ // ostream cout; -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stdout.sh // RUN: %{build} -// RUN: %{exec} bash check-stdout.sh "%t.exe" "1234" +// RUN: %{exec} %t.exe > %t.actual +// RUN: echo -n 1234 > %t.expected +// RUN: diff %t.expected %t.actual #include diff --git a/libcxx/test/std/input.output/iostream.objects/send-stdin.sh b/libcxx/test/std/input.output/iostream.objects/send-stdin.sh deleted file mode 100644 index 2f93f2dfa422..000000000000 --- a/libcxx/test/std/input.output/iostream.objects/send-stdin.sh +++ /dev/null @@ -1,3 +0,0 @@ -program=${1} -input=${2} -echo -n ${input} | ${program} diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stderr.sh b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stderr.sh deleted file mode 100644 index 7edd63be08ba..000000000000 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stderr.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Check that the stderr of the executed program matches a reference file. -program=${1} -expected_file=${2} -${program} 2>stderr.log >stdout.log -cmp stderr.log "${expected_file}" diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stdout.sh b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stdout.sh deleted file mode 100644 index 996cae539e72..000000000000 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/check-stdout.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Check that the stdout of the executed program matches a reference file. -program=${1} -expected_file=${2} -${program} 2>stderr.log >stdout.log -cmp stdout.log "${expected_file}" diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/send-stdin.sh b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/send-stdin.sh deleted file mode 100644 index 70a2a6fafe32..000000000000 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/send-stdin.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Pass a reference file as stdin to a test executable. -program=${1} -input=${2} -cat ${input} | ${program} diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-imbue.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-imbue.sh.cpp index 2b9802b9b304..ec4c8a009ba0 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-imbue.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-imbue.sh.cpp @@ -12,10 +12,10 @@ // UNSUPPORTED: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stderr.sh // RUN: %{build} -// RUN: %{exec} bash check-stderr.sh "%t.exe" "zzzz" +// RUN: %{exec} %t.exe 2> %t.actual +// RUN: echo -n zzzz > %t.expected +// RUN: diff %t.expected %t.actual #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-wide-mode.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-wide-mode.sh.cpp index 0abb55fd2059..f23fbee92afd 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-wide-mode.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr-wide-mode.sh.cpp @@ -13,10 +13,10 @@ // UNSUPPORTED: no-wide-characters // REQUIRES: target={{.+}}-windows-{{.+}} -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: check-stderr.sh, test.dat +// FILE_DEPENDENCIES: test.dat // RUN: %{build} -// RUN: %{exec} bash check-stderr.sh "%t.exe" "test.dat" +// RUN: %{exec} %t.exe 2> %t.actual +// RUN: diff test.dat %t.actual // Check that wcerr works, preserving the unicode characters, after switching // stderr to wide mode. diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp index d6e77614f94a..db1917c635c3 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp @@ -12,10 +12,10 @@ // XFAIL: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stderr.sh // RUN: %{build} -// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234" +// RUN: %{exec} %t.exe 2> %t.actual +// RUN: echo -n 1234 > %t.expected +// RUN: diff %t.expected %t.actual #include #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-imbue.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-imbue.sh.cpp index 88b00840e64e..6bdffc93f3b6 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-imbue.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-imbue.sh.cpp @@ -6,16 +6,17 @@ // //===----------------------------------------------------------------------===// +// TODO: Investigate +// UNSUPPORTED: LIBCXX-AIX-FIXME + // // wistream wcin; // UNSUPPORTED: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../send-stdin.sh // RUN: %{build} -// RUN: %{exec} bash send-stdin.sh "%t.exe" "1234" +// RUN: echo -n 1234 | %{exec} %t.exe #include #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-wide-mode.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-wide-mode.sh.cpp index b7c45d686f83..e13d79605f11 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-wide-mode.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-wide-mode.sh.cpp @@ -13,10 +13,9 @@ // UNSUPPORTED: no-wide-characters // REQUIRES: target={{.+}}-windows-{{.+}} -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: send-stdin.sh, test.dat +// FILE_DEPENDENCIES: test.dat // RUN: %{build} -// RUN: %{exec} bash send-stdin.sh "%t.exe" "test.dat" +// RUN: cat test.dat | %{exec} %t.exe // Check that wcin works, preserving the unicode characters, after switching // stdin to wide mode. diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp index 88147cfbe2e9..9b08d2385816 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp @@ -6,16 +6,17 @@ // //===----------------------------------------------------------------------===// +// TODO: Investigate +// UNSUPPORTED: LIBCXX-AIX-FIXME + // // wistream wcin; // XFAIL: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../send-stdin.sh // RUN: %{build} -// RUN: %{exec} bash send-stdin.sh "%t.exe" "1234" +// RUN: echo -n 1234 | %{exec} %t.exe #include #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp index 03de942d447c..89e178248ae5 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp @@ -12,10 +12,10 @@ // XFAIL: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stderr.sh // RUN: %{build} -// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234" +// RUN: %{exec} %t.exe 2> %t.actual +// RUN: echo -n 1234 > %t.expected +// RUN: diff %t.expected %t.actual #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-imbue.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-imbue.sh.cpp index 17de670e1bb3..87fc167a20b3 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-imbue.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-imbue.sh.cpp @@ -12,10 +12,10 @@ // UNSUPPORTED: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stdout.sh // RUN: %{build} -// RUN: %{exec} bash check-stdout.sh "%t.exe" "zzzz" +// RUN: %{exec} %t.exe > %t.actual +// RUN: echo -n zzzz > %t.expected +// RUN: diff %t.expected %t.actual #include diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-wide-mode.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-wide-mode.sh.cpp index 16f2b329ad94..9908ea0e64db 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-wide-mode.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout-wide-mode.sh.cpp @@ -13,10 +13,10 @@ // UNSUPPORTED: no-wide-characters // REQUIRES: target={{.+}}-windows-{{.+}} -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: check-stdout.sh, test.dat +// FILE_DEPENDENCIES: test.dat // RUN: %{build} -// RUN: %{exec} bash check-stdout.sh "%t.exe" "test.dat" +// RUN: %{exec} %t.exe > %t.actual +// RUN: diff test.dat %t.actual // Check that wcout works, preserving the unicode characters, after switching // stdout to wide mode. diff --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp index bfc699722404..1f7257abb47f 100644 --- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp +++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp @@ -12,10 +12,10 @@ // XFAIL: no-wide-characters -// UNSUPPORTED: executor-has-no-bash -// FILE_DEPENDENCIES: ../check-stdout.sh // RUN: %{build} -// RUN: %{exec} bash check-stdout.sh "%t.exe" "1234" +// RUN: %{exec} %t.exe > %t.actual +// RUN: echo -n 1234 > %t.expected +// RUN: diff %t.expected %t.actual #include