diff --git a/src/installer/tests/Melanzana.MachO.Tests/Data/a.fat.out b/src/installer/tests/Melanzana.MachO.Tests/Data/a.fat.out deleted file mode 100755 index aabb34acb01cc5..00000000000000 Binary files a/src/installer/tests/Melanzana.MachO.Tests/Data/a.fat.out and /dev/null differ diff --git a/src/installer/tests/Melanzana.MachO.Tests/Data/library.c b/src/installer/tests/Melanzana.MachO.Tests/Data/library.c new file mode 100644 index 00000000000000..2b2d81db0df76d --- /dev/null +++ b/src/installer/tests/Melanzana.MachO.Tests/Data/library.c @@ -0,0 +1,4 @@ +int add(int a, int b) +{ + return a + b; +} \ No newline at end of file diff --git a/src/installer/tests/Melanzana.MachO.Tests/Data/main.c b/src/installer/tests/Melanzana.MachO.Tests/Data/main.c new file mode 100644 index 00000000000000..c810b7d5eeb8af --- /dev/null +++ b/src/installer/tests/Melanzana.MachO.Tests/Data/main.c @@ -0,0 +1,6 @@ +#include + +int main() +{ + printf("Hello world"); +} \ No newline at end of file diff --git a/src/installer/tests/Melanzana.MachO.Tests/ReadTests.cs b/src/installer/tests/Melanzana.MachO.Tests/ReadTests.cs index ea3960d55f133d..415dbd6278f951 100644 --- a/src/installer/tests/Melanzana.MachO.Tests/ReadTests.cs +++ b/src/installer/tests/Melanzana.MachO.Tests/ReadTests.cs @@ -24,25 +24,28 @@ public void ReadExecutable() var segments = objectFile.LoadCommands.OfType().ToArray(); Assert.Equal("__PAGEZERO", segments[0].Name); Assert.Equal("__TEXT", segments[1].Name); - Assert.Equal("__LINKEDIT", segments[2].Name); + Assert.Equal("__DATA_CONST", segments[2].Name); + Assert.Equal("__LINKEDIT", segments[3].Name); var symbolTable = objectFile.LoadCommands.OfType().FirstOrDefault(); Assert.NotNull(symbolTable); var symbols = symbolTable!.Symbols.ToArray(); - Assert.Equal(2, symbols.Length); + Assert.Equal(3, symbols.Length); Assert.Equal("__mh_execute_header", symbols[0].Name); Assert.Equal(0x100000000u, symbols[0].Value); Assert.Equal("_main", symbols[1].Name); - Assert.Equal(0x100003fa4u, symbols[1].Value); + Assert.Equal(0x100003F70u, symbols[1].Value); + Assert.Equal("_printf", symbols[2].Name); + Assert.Equal(0u, symbols[2].Value); var buildVersion = objectFile.LoadCommands.OfType().FirstOrDefault(); Assert.NotNull(buildVersion); Assert.Equal(MachPlatform.MacOS, buildVersion!.Platform); - Assert.Equal("12.0.0", buildVersion!.MinimumPlatformVersion.ToString()); - Assert.Equal("12.0.0", buildVersion!.SdkVersion.ToString()); + Assert.Equal("14.0.0", buildVersion!.MinimumPlatformVersion.ToString()); + Assert.Equal("15.0.0", buildVersion!.SdkVersion.ToString()); Assert.Equal(1, buildVersion!.ToolVersions.Count); Assert.Equal(MachBuildTool.Ld, buildVersion!.ToolVersions[0].BuildTool); - Assert.Equal("711.0.0", buildVersion!.ToolVersions[0].Version.ToString()); + Assert.Equal("1115.7.3", buildVersion!.ToolVersions[0].Version.ToString()); } [Fact] @@ -80,8 +83,8 @@ public void ReadObjectFile() Assert.Equal(0u, symbols[0].Value); Assert.Equal("ltmp1", symbols[1].Name); Assert.Equal(compactUnwindSection, symbols[1].Section); - Assert.Equal(0x18u, symbols[1].Value); - Assert.Equal("_main", symbols[2].Name); + Assert.Equal(0x20u, symbols[1].Value); + Assert.Equal("_add", symbols[2].Name); Assert.Equal(textSection, symbols[2].Section); Assert.Equal(0u, symbols[2].Value); } diff --git a/src/installer/tests/Melanzana.MachO.Tests/RoundtripTests.cs b/src/installer/tests/Melanzana.MachO.Tests/RoundtripTests.cs index 8f80254003046d..36e99845c69200 100644 --- a/src/installer/tests/Melanzana.MachO.Tests/RoundtripTests.cs +++ b/src/installer/tests/Melanzana.MachO.Tests/RoundtripTests.cs @@ -48,13 +48,6 @@ public void BasicRoundtrip() TestRoundtrip(aOutStream); } - [Fact] - public void FatRoundtrip() - { - var aFatOutStream = typeof(RoundtripTests).Assembly.GetManifestResourceStream("Melanzana.MachO.Tests.Data.a.fat.out")!; - TestFatRoundtrip(aFatOutStream); - } - [Fact] public void ObjectFileRoundtrip() { diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs index a419f22a727c11..43f30c59a78ccd 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost/CreateAppHost.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Buffers.Binary; using System.Diagnostics; using System.IO; using System.Linq; @@ -263,32 +262,6 @@ public void ExecutableImage() .Be(expectedPermissions); } - - [Fact] - public void DoesNotCodeSignAppHostByDefault() - { - using (TestArtifact artifact = CreateTestDirectory()) - { - string sourceAppHostMock = PrepareMockMachAppHostFile(artifact.Location); - File.SetAttributes(sourceAppHostMock, FileAttributes.ReadOnly); - string destinationFilePath = Path.Combine(artifact.Location, "DestinationAppHost.exe.mock"); - string appBinaryFilePath = "Test/App/Binary/Path.dll"; - HostWriter.CreateAppHost( - sourceAppHostMock, - destinationFilePath, - appBinaryFilePath, - windowsGraphicalUserInterface: false); - - if (!Codesign.IsAvailable()) - { - return; - } - - var (exitCode, stdErr) = Codesign.Run("-d", destinationFilePath); - stdErr.Should().Contain($"{Path.GetFullPath(destinationFilePath)}: code object is not signed at all"); - } - } - [Theory] [InlineData("")] [InlineData("dir with spaces")] @@ -339,6 +312,32 @@ public void CodeSignMachOAppHost(string subdir) } } } + + [Fact] + public void DoesNotCodeSignAppHostByDefault() + { + using (TestArtifact artifact = CreateTestDirectory()) + { + string sourceAppHostMock = PrepareMockMachAppHostFile(artifact.Location); + File.SetAttributes(sourceAppHostMock, FileAttributes.ReadOnly); + string destinationFilePath = Path.Combine(artifact.Location, "DestinationAppHost.exe.mock"); + string appBinaryFilePath = "Test/App/Binary/Path.dll"; + HostWriter.CreateAppHost( + sourceAppHostMock, + destinationFilePath, + appBinaryFilePath, + windowsGraphicalUserInterface: false); + + if (!Codesign.IsAvailable()) + { + return; + } + + var (exitCode, stdErr) = Codesign.Run("-d", destinationFilePath); + stdErr.Should().Contain($"{Path.GetFullPath(destinationFilePath)}: code object is not signed at all"); + } + } + [Fact] public void CodeSigningFailuresThrow() {