[libcxx-commits] [libcxx] 21f8bc2 - [libc++] Make sure we forward stdin through executors (#67064)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 25 06:50:11 PDT 2023
Author: Louis Dionne
Date: 2023-09-25T09:50:07-04:00
New Revision: 21f8bc25adba762ab06e26a7dd50da78fcd17528
URL: https://github.com/llvm/llvm-project/commit/21f8bc25adba762ab06e26a7dd50da78fcd17528
DIFF: https://github.com/llvm/llvm-project/commit/21f8bc25adba762ab06e26a7dd50da78fcd17528.diff
LOG: [libc++] Make sure we forward stdin through executors (#67064)
This allows running tests like the ones for std::cin even on SSH
executors. This was originally reported as
https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639.
Added:
libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp
Modified:
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-imbue.sh.cpp
libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
libcxx/utils/ssh.py
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp b/libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp
new file mode 100644
index 000000000000000..ffd10631c6a67d4
--- /dev/null
+++ b/libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure that the executor pipes standard input to the test-executable being run.
+
+// RUN: %{build}
+// RUN: echo "abc" | %{exec} %t.exe
+
+#include <cstdio>
+
+int main(int, char**) {
+ int input[] = {std::getchar(), std::getchar(), std::getchar()};
+
+ if (input[0] == 'a' && input[1] == 'b' && input[2] == 'c')
+ return 0;
+ return 1;
+}
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 8fe98f9064d2ee6..b39cd57ab212f1d 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
@@ -9,10 +9,6 @@
// TODO: Investigate
// UNSUPPORTED: LIBCXX-AIX-FIXME
-// TODO: Make it possible to run this test when cross-compiling and running via a SSH executor
-// This is a workaround to silence issues reported in https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639
-// XFAIL: buildhost=windows && target={{.+}}-linux-{{.+}}
-
// <iostream>
// istream cin;
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 27c9b0cf7adac58..6bdffc93f3b6693 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
@@ -9,10 +9,6 @@
// TODO: Investigate
// UNSUPPORTED: LIBCXX-AIX-FIXME
-// TODO: Make it possible to run this test when cross-compiling and running via a SSH executor
-// This is a workaround to silence issues reported in https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639
-// XFAIL: buildhost=windows && target={{.+}}-linux-{{.+}}
-
// <iostream>
// wistream wcin;
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 3780be1d5cbf226..c0f2c3258b540f6 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
@@ -9,10 +9,6 @@
// TODO: Investigate
// UNSUPPORTED: LIBCXX-AIX-FIXME
-// TODO: Make it possible to run this test when cross-compiling and running via a SSH executor
-// This is a workaround to silence issues reported in https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639
-// XFAIL: buildhost=windows && target={{.+}}-linux-{{.+}}
-
// <iostream>
// wistream wcin;
diff --git a/libcxx/utils/ssh.py b/libcxx/utils/ssh.py
index e1eaa5aae067e79..ec16efc3165ab1b 100755
--- a/libcxx/utils/ssh.py
+++ b/libcxx/utils/ssh.py
@@ -62,7 +62,8 @@ def runCommand(command, *args_, **kwargs):
ssh("mktemp -d {}/libcxx.XXXXXXXXXX".format(args.tempdir)),
universal_newlines=True,
check=True,
- capture_output=True
+ capture_output=True,
+ stdin=subprocess.DEVNULL
).stdout.strip()
# HACK:
@@ -80,7 +81,7 @@ def runCommand(command, *args_, **kwargs):
if args.codesign_identity:
for exe in filter(isTestExe, commandLine):
codesign = ["codesign", "-f", "-s", args.codesign_identity, exe]
- runCommand(codesign, env={}, check=True)
+ runCommand(codesign, env={}, check=True, stdin=subprocess.DEVNULL)
# tar up the execution directory (which contains everything that's needed
# to run the test), and copy the tarball over to the remote host.
@@ -93,7 +94,7 @@ def runCommand(command, *args_, **kwargs):
# the temporary file while still open doesn't work on Windows.
tmpTar.close()
remoteTarball = pathOnRemote(tmpTar.name)
- runCommand(scp(tmpTar.name, remoteTarball), check=True)
+ runCommand(scp(tmpTar.name, remoteTarball), check=True, stdin=subprocess.DEVNULL)
finally:
# Make sure we close the file in case an exception happens before
# we've closed it above -- otherwise close() is idempotent.
@@ -130,6 +131,8 @@ def runCommand(command, *args_, **kwargs):
remoteCommands.append(subprocess.list2cmdline(commandLine))
# Finally, SSH to the remote host and execute all the commands.
+ # Make sure to forward stdin to the process so that the test suite
+ # can pipe stuff into the executor.
rc = runCommand(ssh(" && ".join(remoteCommands))).returncode
return rc
More information about the libcxx-commits
mailing list