From 52e6a1f84f424cb8f4fc23986bd8c47970d92b32 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 30 Aug 2021 00:02:05 -0700 Subject: [PATCH 1/6] WIP --- .../Helpers/BundleHelper.cs | 19 ++++++++++++++++++- ...c316d3428a488197c2e1d291e38c0f.failure.txt | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index 351461e3a170a..0883f64f5e36d 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.DotNet.CoreSetup.Test; +using Microsoft.DotNet.Cli.Build.Framework; using Microsoft.NET.HostModel.Bundle; using System; using System.Collections.Generic; @@ -162,6 +163,9 @@ public static string GenerateBundle(Bundler bundler, string sourceDir, string ou var singleFile = bundler.GenerateBundle(fileSpecs); + // Verify no one has an open handle to the bundle + VerifyNoOpenHandles(singleFile); + if (copyExludedFiles) { foreach (var spec in fileSpecs) @@ -178,10 +182,23 @@ public static string GenerateBundle(Bundler bundler, string sourceDir, string ou return singleFile; } + private static string VerifyNoOpenHandles(string path) + { + if (Environment.OSVersion.Platform == PlatformID.Unix) + { + var result = Command.Create("lsof", path) + .CaptureStdOut() + .CaptureStdErr() + .Execute(); + throw new Exception(result.StdOut + result.StdErr); + } + return ""; + } + // Bundle to a single-file // In several tests, the single-file bundle is created explicitly using Bundle API // instead of the SDK via /p:PublishSingleFile=true. - // This is necessary when the test needs the latest changes in the AppHost, + // This is necessary when the test needs the latest changes in the AppHost, // which may not (yet) be available in the SDK. public static Bundler BundleApp(TestProjectFixture fixture, out string singleFile, diff --git a/src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt b/src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt new file mode 100644 index 0000000000000..88b6882cb6290 --- /dev/null +++ b/src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt @@ -0,0 +1,9 @@ +UNHANDLED EXCEPTIONS FROM PROCESS 31830: +===================== +08/29/2021 12:22:28 +System.IO.IOException: Pipe is broken. + at System.IO.Pipes.NamedPipeServerStream.CheckConnectOperationsServer() + at System.IO.Pipes.NamedPipeServerStream.WaitForConnectionAsync(CancellationToken cancellationToken) + at System.IO.Pipes.NamedPipeServerStream.WaitForConnectionAsync() + at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.PacketPumpProc() +=================== From d81cf5e26713da6f353517360eca1b35eab50250 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 30 Aug 2021 14:54:57 -0700 Subject: [PATCH 2/6] Just grab stdout --- .../tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index 0883f64f5e36d..7baf45eb037d0 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -190,7 +190,7 @@ private static string VerifyNoOpenHandles(string path) .CaptureStdOut() .CaptureStdErr() .Execute(); - throw new Exception(result.StdOut + result.StdErr); + throw new Exception(result.StdOut); } return ""; } From de5cc595fb199aac825f02b8a3da21cb139f9548 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 30 Aug 2021 15:07:01 -0700 Subject: [PATCH 3/6] Remove crash file --- ...id-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt diff --git a/src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt b/src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt deleted file mode 100644 index 88b6882cb6290..0000000000000 --- a/src/tasks/AndroidAppBuilder/MSBuild_Logs/MSBuild_pid-31830_2ec316d3428a488197c2e1d291e38c0f.failure.txt +++ /dev/null @@ -1,9 +0,0 @@ -UNHANDLED EXCEPTIONS FROM PROCESS 31830: -===================== -08/29/2021 12:22:28 -System.IO.IOException: Pipe is broken. - at System.IO.Pipes.NamedPipeServerStream.CheckConnectOperationsServer() - at System.IO.Pipes.NamedPipeServerStream.WaitForConnectionAsync(CancellationToken cancellationToken) - at System.IO.Pipes.NamedPipeServerStream.WaitForConnectionAsync() - at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.PacketPumpProc() -=================== From b1af94852f0b779ec20b629c4073bbae496ddc00 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 30 Aug 2021 19:44:11 -0700 Subject: [PATCH 4/6] Adjust condition --- .../Helpers/BundleHelper.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index 7baf45eb037d0..1f64454bed106 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -182,7 +182,7 @@ public static string GenerateBundle(Bundler bundler, string sourceDir, string ou return singleFile; } - private static string VerifyNoOpenHandles(string path) + private static void VerifyNoOpenHandles(string path) { if (Environment.OSVersion.Platform == PlatformID.Unix) { @@ -190,9 +190,12 @@ private static string VerifyNoOpenHandles(string path) .CaptureStdOut() .CaptureStdErr() .Execute(); - throw new Exception(result.StdOut); + if (result.StdOut.Length > 0) + { + // If anything has a handle to this file, there should be text in the stdout + throw new InvalidOperationException(result.StdOut); + } } - return ""; } // Bundle to a single-file From aca66f157fd85247e42952ec74c119113a7a55ba Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 30 Aug 2021 21:32:18 -0700 Subject: [PATCH 5/6] Out path --- .../Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index 1f64454bed106..e7fd200da7a2f 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -186,14 +186,14 @@ private static void VerifyNoOpenHandles(string path) { if (Environment.OSVersion.Platform == PlatformID.Unix) { - var result = Command.Create("lsof", path) + var result = Command.Create("lsof", $"\"{path}\"") .CaptureStdOut() .CaptureStdErr() .Execute(); if (result.StdOut.Length > 0) { // If anything has a handle to this file, there should be text in the stdout - throw new InvalidOperationException(result.StdOut); + throw new InvalidOperationException("Path: " + path + "\n" + result.StdOut); } } } From e6fd4b2b5fd26dc5ba9f612d05385721dff6db18 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Mon, 30 Aug 2021 22:44:11 -0700 Subject: [PATCH 6/6] Add extra arg parsing --- .../tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index e7fd200da7a2f..69b3bf96d0ac0 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -186,7 +186,7 @@ private static void VerifyNoOpenHandles(string path) { if (Environment.OSVersion.Platform == PlatformID.Unix) { - var result = Command.Create("lsof", $"\"{path}\"") + var result = Command.Create("lsof", $"-f -- \"{path}\"") .CaptureStdOut() .CaptureStdErr() .Execute();