public void HybridAOT_WithManualStrippingOfAllLibs_SmokeTest(bool useProjectTags) { MMPTests.RunMMPTest(tmpDir => { TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { CSProjConfig = GetTestConfig(TestType.Hybrid, useProjectTags) }; string buildResults = TI.TestUnifiedExecutable(test).BuildOutput; foreach (var file in GetOutputDirInfo(tmpDir).EnumerateFiles()) { if (IsFileManagedCode(file)) { TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/mono-cil-strip", new [] { file.ToString() }, "Manually strip IL"); } } ValidateAOTStatus(tmpDir, IsFileManagedCode, buildResults); TI.RunEXEAndVerifyGUID(tmpDir, test.guid, GetOutputAppPath(tmpDir)); }); }
public void Unified_HelloWorld_ShouldHaveNoWarnings(bool release, bool full) { RunMMPTest(tmpDir => { TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir); test.Release = release; test.XM45 = full; var rv = TI.TestUnifiedExecutable(test); Console.WriteLine(rv.BuildOutput); if (full && release) { rv.Messages.AssertWarning(5220, "Skipping framework 'QTKit'. It is prohibited (rejected) by the Mac App Store"); // We get the MM5220 twice in the output, once from mmp and once from msbuild repeating what mmp said, so we can't assert that there's exactly 1 warning. // Instead assert that we get no warning but MM5220. Assert.IsFalse(rv.Messages.Messages.Any((v) => v.Number != 5220), "No warnings except MM5220"); } else { rv.Messages.AssertWarningCount(0); } }); }
public void HardenedRuntimeCodesignOption() { // https://github.com/xamarin/xamarin-macios/issues/5653 if (TI.InJenkins) { Assert.Ignore("Requires macOS entitlements on bots."); } RunMMPTest(tmpDir => { TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { CSProjConfig = "<EnableCodeSigning>true</EnableCodeSigning>" }; Func <OutputText, string> findCodesign = o => o.BuildOutput.SplitLines().Last(x => x.Contains("Tool /usr/bin/codesign execution started with arguments")); var baseOutput = TI.TestUnifiedExecutable(test); string baseCodesign = findCodesign(baseOutput); Assert.False(baseCodesign.Contains("-o runtime"), "Base codesign"); test.CSProjConfig += "<UseHardenedRuntime>true</UseHardenedRuntime><CodeSignEntitlements>Entitlements.plist</CodeSignEntitlements>"; const string entitlementText = @"<?xml version=""1.0"" encoding=""UTF-8"" ?> <!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd""> <plist version=""1.0""> <dict> <key>com.apple.security.cs.allow-jit</key> <true/> </dict> </plist>"; File.WriteAllText(Path.Combine(tmpDir, "Entitlements.plist"), entitlementText); var hardenedOutput = TI.TestUnifiedExecutable(test); string hardenedCodesign = findCodesign(hardenedOutput); Assert.True(hardenedCodesign.Contains("-o runtime"), "Hardened codesign"); }); }
public void FilePathCollisionShouldNotFailBuild() { RunMMPTest(tmpDir => { var libraryDirectory = tmpDir + "/UnifiedExample/"; var libraryName = "UnifiedLibrary"; Directory.CreateDirectory(libraryDirectory); TI.UnifiedTestConfig libConfig = new TI.UnifiedTestConfig(libraryDirectory) { ProjectName = libraryName }; string csprojTarget = TI.GenerateUnifiedLibraryProject(libConfig); TI.BuildProject(csprojTarget); string referenceCode = string.Format(@"<Reference Include=""UnifiedLibrary""><HintPath>{0}</HintPath></Reference>", Path.Combine(libraryDirectory, "bin/Debug/", $"{libraryName}.dll")); TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { References = referenceCode }; TI.TestUnifiedExecutable(test); }); }
public void Unified32BitWithXMRequiringLibrary_ShouldReferenceCorrectXM_AndNotCrash() { RunMMPTest(tmpDir => { TI.UnifiedTestConfig libConfig = new TI.UnifiedTestConfig(tmpDir) { ProjectName = "UnifiedLibrary", TestCode = "namespace Library { public static class Foo { public static void Bar () { var v = new Foundation.NSObject (); } } }" }; string csprojTarget = TI.GenerateUnifiedLibraryProject(libConfig); TI.BuildProject(csprojTarget, isUnified: true); string referenceCode = string.Format(@"<Reference Include=""UnifiedLibrary""><HintPath>{0}</HintPath></Reference>", Path.Combine(tmpDir, "bin/Debug/UnifiedLibrary.dll")); TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { CSProjConfig = @"<PlatformTarget>x86</PlatformTarget><XamMacArch>i386</XamMacArch>", ReferencesBeforePlatform = referenceCode, TestCode = "Library.Foo.Bar ();" }; TI.TestUnifiedExecutable(test); }); }
public void ExplictStripOption_ThirdPartyLibrary_AndWarnsIfSo(bool?strip, bool shouldStrip) { MMPTests.RunMMPTest(tmpDir => { string originalLocation = Path.Combine(Configuration.SourceRoot, "tests", "test-libraries", "libtest-fat.macos.dylib"); string newLibraryLocation = Path.Combine(tmpDir, "libTest.dylib"); File.Copy(originalLocation, newLibraryLocation); TI.UnifiedTestConfig test = CreateStripTestConfig(strip, tmpDir, $" --native-reference=\"{newLibraryLocation}\""); test.Release = true; var testOutput = TI.TestUnifiedExecutable(test); string buildOutput = testOutput.BuildOutput; Assert.AreEqual(shouldStrip, DidAnyLipoStrip(buildOutput), "lipo usage did not match expectations"); if (shouldStrip) { testOutput.Messages.AssertWarning(2108, "libTest.dylib was stripped of architectures except x86_64 to comply with App Store restrictions. This could break existing codesigning signatures. Consider stripping the library with lipo or disabling with --optimize=-trim-architectures"); } else { testOutput.Messages.AssertWarningCount(0); } }); }
static void MonoPosixTestCore(string tmpDir, TI.UnifiedTestConfig test) { TI.TestUnifiedExecutable(test, shouldFail: false); Assert.IsTrue(File.Exists(Path.Combine(tmpDir, "bin/Debug/XM45Example.app/Contents/MonoBundle/libMonoPosixHelper.dylib")), String.Format("Does {0}/bin/Debug/XM45Example.app/Contents/MonoBundle/libMonoPosixHelper.dylib to exist?", tmpDir)); }