diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 52e53b11a1..ccd9241104 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn // Run the test (write something to the console so people know this will take a while...) _logger.LogInformation("Now launching Autobahn Test Suite. This will take a while."); - var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile, cancellationToken); + var exitCode = await Wstest.Default.ExecAsync("-m fuzzingclient -s " + specFile, cancellationToken, _loggerFactory.CreateLogger("wstest")); if (exitCode != 0) { throw new Exception("wstest failed"); diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs index 41b798303e..e012a13dc2 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/Executable.cs @@ -4,6 +4,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn { @@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn return null; } - public async Task ExecAsync(string args, CancellationToken cancellationToken) + public async Task ExecAsync(string args, CancellationToken cancellationToken, ILogger logger) { var process = new Process() { @@ -40,6 +41,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn FileName = _path, Arguments = args, UseShellExecute = false, + RedirectStandardError = true, + RedirectStandardOutput = true }, EnableRaisingEvents = true }; @@ -48,13 +51,26 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn using (cancellationToken.Register(() => Cancel(process, tcs))) { process.Exited += (_, __) => tcs.TrySetResult(process.ExitCode); + process.OutputDataReceived += (_, a) => LogIfNotNull(logger.LogInformation, "stdout: {0}", a.Data); + process.ErrorDataReceived += (_, a) => LogIfNotNull(logger.LogError, "stderr: {0}", a.Data); process.Start(); + process.BeginErrorReadLine(); + process.BeginOutputReadLine(); + return await tcs.Task; } } + private void LogIfNotNull(Action logger, string message, string data) + { + if (!string.IsNullOrEmpty(data)) + { + logger(message, new[] { data }); + } + } + private static void Cancel(Process process, TaskCompletionSource tcs) { if (process != null && !process.HasExited)