Skip to content

Commit

Permalink
Stop buffering traces by default (dotnet#1645)
Browse files Browse the repository at this point in the history
* Stop buffering the traces by default.

* Don't modify stream buffering before we validate that we have a tracing file.
Add test.
  • Loading branch information
mateoatr authored Jan 13, 2020
1 parent 14db363 commit 1c71a5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/installer/corehost/common/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ bool trace::enable()

if (tracefile)
{
setvbuf(tracefile, nullptr, _IONBF, 0);
g_trace_file = tracefile;
}
else
Expand Down
15 changes: 15 additions & 0 deletions src/installer/test/HostActivation.Tests/NativeHosting/Nethost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,21 @@ public void GetHostFxrPath_InvalidParameters()
.And.HaveStdErrContaining("Invalid size for get_hostfxr_parameters");
}

[Fact]
public void TracingNotBufferedByDefault()
{
CommandResult result = Command.Create(sharedState.NativeHostPath, $"{GetHostFxrPath} false nullptr x")
.EnvironmentVariable("COREHOST_TRACE", "1")
.EnvironmentVariable("COREHOST_TRACEFILE", "Tracing.out")
.MultilevelLookup(true)
.DotNetRoot(null)
.Execute();

result.Should().Fail()
.And.FileExists("Tracing.out")
.And.FileContains("Tracing.out", "Tracing enabled");
}

[Fact]
public void TestOnlyDisabledByDefault()
{
Expand Down

0 comments on commit 1c71a5f

Please sign in to comment.