Skip to content

[libc++] Make sure we forward stdin through executors #67064

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

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions libcxx/utils/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down