aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/compiler_wrapper_test.go
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-08-16 11:47:00 -0700
committerTobias Bosch <tbosch@google.com>2019-08-20 17:48:54 +0000
commita50a9c16b6a3b2522bea3b6562d023a7b87dbd49 (patch)
tree4d17d8e02962ba4e62c66e49f520cb1b310adc7d /compiler_wrapper/compiler_wrapper_test.go
parent36c19215f13c983c2ae0096ed9170fd064744622 (diff)
downloadtoolchain-utils-a50a9c16b6a3b2522bea3b6562d023a7b87dbd49.tar.gz
Forward os.Stdin to child processes.
BUG=chromium:773875 TEST=unit tests, build glibc with compiler wrapper Change-Id: I0b5c1f5adaee18499b72747cd6042b00a9d52c1d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1760973 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Tobias Bosch <tbosch@google.com>
Diffstat (limited to 'compiler_wrapper/compiler_wrapper_test.go')
-rw-r--r--compiler_wrapper/compiler_wrapper_test.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler_wrapper/compiler_wrapper_test.go b/compiler_wrapper/compiler_wrapper_test.go
index 57bef951..71cd36df 100644
--- a/compiler_wrapper/compiler_wrapper_test.go
+++ b/compiler_wrapper/compiler_wrapper_test.go
@@ -58,7 +58,7 @@ func TestLogGeneralExecError(t *testing.T) {
ctx.cfg.oldWrapperPath = testOldWrapperPath
// Note: No need to write the old wrapper as we don't execute
// it due to the general error from the new error.
- ctx.cmdMock = func(cmd *command, stdout io.Writer, stderr io.Writer) error {
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
return errors.New("someerror")
}
stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
@@ -75,6 +75,20 @@ func TestLogGeneralExecError(t *testing.T) {
})
}
+func TestForwardStdin(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ io.WriteString(&ctx.stdinBuffer, "someinput")
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
+ stdinStr := ctx.readAllString(stdin)
+ if stdinStr != "someinput" {
+ return fmt.Errorf("unexpected stdin. Got: %s", stdinStr)
+ }
+ return nil
+ }
+ ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, "-", mainCc)))
+ })
+}
+
func TestLogMissingCCacheExecError(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
ctx.cfg.useCCache = true
@@ -87,7 +101,7 @@ func TestLogMissingCCacheExecError(t *testing.T) {
ctx.cfg.oldWrapperPath = testOldWrapperPath
// Note: No need to write the old wrapper as we don't execute
// it due to the general error from the new error.
- ctx.cmdMock = func(cmd *command, stdout io.Writer, stderr io.Writer) error {
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
return syscall.ENOENT
}
ctx.stderrBuffer.Reset()
@@ -104,7 +118,7 @@ func TestLogExitCodeErrorWhenComparingToOldWrapper(t *testing.T) {
ctx.cfg.mockOldWrapperCmds = false
ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper")
- ctx.cmdMock = func(cmd *command, stdout io.Writer, stderr io.Writer) error {
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
writePythonMockWrapper(ctx, &mockWrapperConfig{
Cmds: []*mockWrapperCmd{
{