Skip to content

Commit 26cbb86

Browse files
ldionnecopybara-github
authored andcommitted
[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 llvm/llvm-project#66842 (comment). NOKEYCHECK=True GitOrigin-RevId: 21f8bc25adba762ab06e26a7dd50da78fcd17528
1 parent 304e227 commit 26cbb86

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// Make sure that the executor pipes standard input to the test-executable being run.
10+
11+
// RUN: %{build}
12+
// RUN: echo "abc" | %{exec} %t.exe
13+
14+
#include <cstdio>
15+
16+
int main(int, char**) {
17+
int input[] = {std::getchar(), std::getchar(), std::getchar()};
18+
19+
if (input[0] == 'a' && input[1] == 'b' && input[2] == 'c')
20+
return 0;
21+
return 1;
22+
}

test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
// TODO: Investigate
1010
// UNSUPPORTED: LIBCXX-AIX-FIXME
1111

12-
// TODO: Make it possible to run this test when cross-compiling and running via a SSH executor
13-
// This is a workaround to silence issues reported in https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639
14-
// XFAIL: buildhost=windows && target={{.+}}-linux-{{.+}}
15-
1612
// <iostream>
1713

1814
// istream cin;

test/std/input.output/iostream.objects/wide.stream.objects/wcin-imbue.sh.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
// TODO: Investigate
1010
// UNSUPPORTED: LIBCXX-AIX-FIXME
1111

12-
// TODO: Make it possible to run this test when cross-compiling and running via a SSH executor
13-
// This is a workaround to silence issues reported in https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639
14-
// XFAIL: buildhost=windows && target={{.+}}-linux-{{.+}}
15-
1612
// <iostream>
1713

1814
// wistream wcin;

test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
// TODO: Investigate
1010
// UNSUPPORTED: LIBCXX-AIX-FIXME
1111

12-
// TODO: Make it possible to run this test when cross-compiling and running via a SSH executor
13-
// This is a workaround to silence issues reported in https://github.com/llvm/llvm-project/pull/66842#issuecomment-1728701639
14-
// XFAIL: buildhost=windows && target={{.+}}-linux-{{.+}}
15-
1612
// <iostream>
1713

1814
// wistream wcin;

utils/ssh.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def runCommand(command, *args_, **kwargs):
6262
ssh("mktemp -d {}/libcxx.XXXXXXXXXX".format(args.tempdir)),
6363
universal_newlines=True,
6464
check=True,
65-
capture_output=True
65+
capture_output=True,
66+
stdin=subprocess.DEVNULL
6667
).stdout.strip()
6768

6869
# HACK:
@@ -80,7 +81,7 @@ def runCommand(command, *args_, **kwargs):
8081
if args.codesign_identity:
8182
for exe in filter(isTestExe, commandLine):
8283
codesign = ["codesign", "-f", "-s", args.codesign_identity, exe]
83-
runCommand(codesign, env={}, check=True)
84+
runCommand(codesign, env={}, check=True, stdin=subprocess.DEVNULL)
8485

8586
# tar up the execution directory (which contains everything that's needed
8687
# to run the test), and copy the tarball over to the remote host.
@@ -93,7 +94,7 @@ def runCommand(command, *args_, **kwargs):
9394
# the temporary file while still open doesn't work on Windows.
9495
tmpTar.close()
9596
remoteTarball = pathOnRemote(tmpTar.name)
96-
runCommand(scp(tmpTar.name, remoteTarball), check=True)
97+
runCommand(scp(tmpTar.name, remoteTarball), check=True, stdin=subprocess.DEVNULL)
9798
finally:
9899
# Make sure we close the file in case an exception happens before
99100
# we've closed it above -- otherwise close() is idempotent.
@@ -130,6 +131,8 @@ def runCommand(command, *args_, **kwargs):
130131
remoteCommands.append(subprocess.list2cmdline(commandLine))
131132

132133
# Finally, SSH to the remote host and execute all the commands.
134+
# Make sure to forward stdin to the process so that the test suite
135+
# can pipe stuff into the executor.
133136
rc = runCommand(ssh(" && ".join(remoteCommands))).returncode
134137
return rc
135138

0 commit comments

Comments
 (0)