From db760b3601edf2ed1550d4978cd7342d383b3786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Wed, 8 Jun 2022 11:05:25 +0200 Subject: [PATCH] Add integration test --- .../DotnetArchitectureTests.cs | 26 ++++++++++++++ .../Net6Launches32BitsProcess.csproj | 22 ++++++++++++ .../Net6Launches32BitsProcess/Test32Bit.cs | 34 +++++++++++++++++++ test/TestAssets/TestAssets.sln | 32 +++++++++++++++++ test/TestAssets/TestProcess32/Program.cs | 4 +++ .../TestProcess32/TestProcess32.csproj | 11 ++++++ 6 files changed, 129 insertions(+) create mode 100644 test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureTests.cs create mode 100644 test/TestAssets/Net6Launches32BitsProcess/Net6Launches32BitsProcess.csproj create mode 100644 test/TestAssets/Net6Launches32BitsProcess/Test32Bit.cs create mode 100644 test/TestAssets/TestProcess32/Program.cs create mode 100644 test/TestAssets/TestProcess32/TestProcess32.csproj diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureTests.cs new file mode 100644 index 0000000000..f9fff841d2 --- /dev/null +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#if !NETFRAMEWORK + +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Microsoft.TestPlatform.AcceptanceTests; + +[TestClass] +public class DotnetArchitectureTests : AcceptanceTestBase +{ + [TestMethod] + [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)] + public void DotnetTestProjectLaunching32BitsProcess(RunnerInfo runnerInfo) + { + SetTestEnvironment(_testEnvironment, runnerInfo); + + var projectPath = GetTestDllForFramework("Net6Launches32BitsProcess.dll", "net6.0"); + InvokeDotnetTest(projectPath); + + ExitCodeEquals(0); + } +} + +#endif diff --git a/test/TestAssets/Net6Launches32BitsProcess/Net6Launches32BitsProcess.csproj b/test/TestAssets/Net6Launches32BitsProcess/Net6Launches32BitsProcess.csproj new file mode 100644 index 0000000000..de815fc6f5 --- /dev/null +++ b/test/TestAssets/Net6Launches32BitsProcess/Net6Launches32BitsProcess.csproj @@ -0,0 +1,22 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/test/TestAssets/Net6Launches32BitsProcess/Test32Bit.cs b/test/TestAssets/Net6Launches32BitsProcess/Test32Bit.cs new file mode 100644 index 0000000000..4fc87921ad --- /dev/null +++ b/test/TestAssets/Net6Launches32BitsProcess/Test32Bit.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics; + +using Microsoft.VisualStudio.TestTools.UnitTesting; + + +namespace UnitTest; + +[TestClass] +public class Test32Bit +{ + [TestMethod] + public void TheTest() + { + var process = new Process(); + process.StartInfo = new ProcessStartInfo + { + FileName = "TestProcess32.exe", + RedirectStandardError = true, + RedirectStandardOutput = true + }; + + process.Start(); + var stderr = process.StandardError.ReadToEnd(); + var stdout = process.StandardOutput.ReadToEnd(); + + Console.WriteLine($"32bit stdout: {stdout}"); + Console.WriteLine($"32bit err: {stderr}"); + + Assert.IsTrue(string.IsNullOrEmpty(stderr)); + } +} diff --git a/test/TestAssets/TestAssets.sln b/test/TestAssets/TestAssets.sln index 8fae3a203e..a09619c558 100644 --- a/test/TestAssets/TestAssets.sln +++ b/test/TestAssets/TestAssets.sln @@ -124,6 +124,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tools", "Tools\Tools.csproj EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Perfy.TestAdapter", "performance\Perfy.TestAdapter\Perfy.TestAdapter.csproj", "{71BF7EC9-7BEE-4038-8F4E-87032FA4E995}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DOTNET_ROOT", "DOTNET_ROOT", "{C06EFF20-F1EA-42B7-B404-D8AB98AA78C0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProcess32", "TestProcess32\TestProcess32.csproj", "{4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Net6Launches32BitsProcess", "Net6Launches32BitsProcess\Net6Launches32BitsProcess.csproj", "{A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -806,6 +812,30 @@ Global {71BF7EC9-7BEE-4038-8F4E-87032FA4E995}.Release|x64.Build.0 = Release|Any CPU {71BF7EC9-7BEE-4038-8F4E-87032FA4E995}.Release|x86.ActiveCfg = Release|Any CPU {71BF7EC9-7BEE-4038-8F4E-87032FA4E995}.Release|x86.Build.0 = Release|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x64.ActiveCfg = Debug|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x64.Build.0 = Debug|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x86.ActiveCfg = Debug|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Debug|x86.Build.0 = Debug|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|Any CPU.Build.0 = Release|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x64.ActiveCfg = Release|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x64.Build.0 = Release|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x86.ActiveCfg = Release|Any CPU + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506}.Release|x86.Build.0 = Release|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x64.ActiveCfg = Debug|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x64.Build.0 = Debug|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x86.ActiveCfg = Debug|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Debug|x86.Build.0 = Debug|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|Any CPU.Build.0 = Release|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x64.ActiveCfg = Release|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x64.Build.0 = Release|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x86.ActiveCfg = Release|Any CPU + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -826,6 +856,8 @@ Global {10AA955C-B412-41A8-899F-8609AAE19F61} = {2633D125-64A7-456C-AD37-F8A6B56C2403} {E166D337-4033-4209-863F-8F77675EAEE8} = {2633D125-64A7-456C-AD37-F8A6B56C2403} {71BF7EC9-7BEE-4038-8F4E-87032FA4E995} = {0C9CA869-32FD-4A9E-8885-E2E19786C746} + {4FA80E2C-B3D4-4A6B-99D2-12F95F2C0506} = {C06EFF20-F1EA-42B7-B404-D8AB98AA78C0} + {A0F37C16-FB73-4538-8DAF-EBF6EB3251FA} = {C06EFF20-F1EA-42B7-B404-D8AB98AA78C0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D2334DAA-F7B2-450E-ABA4-FBC185152500} diff --git a/test/TestAssets/TestProcess32/Program.cs b/test/TestAssets/TestProcess32/Program.cs new file mode 100644 index 0000000000..3f858c1929 --- /dev/null +++ b/test/TestAssets/TestProcess32/Program.cs @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +Console.WriteLine($"Am I 32bit?: {!Environment.Is64BitProcess}"); diff --git a/test/TestAssets/TestProcess32/TestProcess32.csproj b/test/TestAssets/TestProcess32/TestProcess32.csproj new file mode 100644 index 0000000000..84f88f34b5 --- /dev/null +++ b/test/TestAssets/TestProcess32/TestProcess32.csproj @@ -0,0 +1,11 @@ + + + + x86 + Exe + net6.0 + enable + enable + + +