Skip to content

Commit 9fda2c6

Browse files
authored
[tests] Add --dlsym:+nunit.framework.dll to all Xamarin.iOS test suites. (dotnet#9349)
This works around a build problem that occurs because NUnit ships with a P/Invoke to a function that doesn't exist on Apple platforms: MTOUCH : error MT5210: Native linking failed, undefined symbol: _GetVersionEx. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. [/Users/xamarinqa/myagent/_work/8/s/xamarin-macios/tests/xharness/tmp-test-dir/monotouch-test58/monotouch-test-tvos.csproj] MTOUCH : error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -fembed-bitcode-marker [/Users/xamarinqa/myagent/_work/8/s/xamarin-macios/tests/xharness/tmp-test-dir/monotouch-test58/monotouch-test-tvos.csproj] clang : error : linker command failed with exit code 1 (use -v to see invocation) [/Users/xamarinqa/myagent/_work/8/s/xamarin-macios/tests/xharness/tmp-test-dir/monotouch-test58/monotouch-test-tvos.csproj] Also fix an issue in mtouch where we would overwrite any previous --dlsym values; they're now accumulative (`--dlsym:foo.dll --dlsym:bar.dll` works as expected) Ref: nunit/nunit#3618
1 parent 90ec0c7 commit 9fda2c6

File tree

10 files changed

+19
-2
lines changed

10 files changed

+19
-2
lines changed

tests/framework-test/framework-test.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<DefineConstants></DefineConstants>
1717
<LangVersion>latest</LangVersion>
1818
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
19+
<RootTestsDirectory>..</RootTestsDirectory>
1920
</PropertyGroup>
2021
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
2122
<DebugSymbols>true</DebugSymbols>
@@ -166,6 +167,7 @@
166167
<Compile Include="AppDelegate.cs" />
167168
<Compile Include="FrameworkTests.cs" />
168169
</ItemGroup>
170+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
169171
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
170172
<ItemGroup>
171173
<ProjectReference Include="..\..\tests\bindings-framework-test\bindings-framework-test.csproj">

tests/fsharp/fsharp.fsproj

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)-unified</IntermediateOutputPath>
1616
<DefineConstants></DefineConstants>
1717
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
18+
<RootTestsDirectory>..</RootTestsDirectory>
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
2021
<DebugSymbols>true</DebugSymbols>
@@ -166,5 +167,6 @@
166167
<Name>Touch.Client-iOS</Name>
167168
</ProjectReference>
168169
</ItemGroup>
170+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
169171
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.FSharp.targets" />
170172
</Project>

tests/interdependent-binding-projects/interdependent-binding-projects.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)-unified</IntermediateOutputPath>
1616
<DefineConstants></DefineConstants>
1717
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
18+
<RootTestsDirectory>..</RootTestsDirectory>
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
2021
<DebugSymbols>True</DebugSymbols>
@@ -142,6 +143,7 @@
142143
<ItemGroup>
143144
<Compile Include="Main.cs" />
144145
</ItemGroup>
146+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
145147
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
146148
<ItemGroup>
147149
<ProjectReference Include="..\bindings-test2\bindings-test2.csproj">

tests/introspection/iOS/introspection-ios.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<DefineConstants></DefineConstants>
1616
<LangVersion>latest</LangVersion>
1717
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
18+
<RootTestsDirectory>..\..</RootTestsDirectory>
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
2021
<DebugSymbols>True</DebugSymbols>
@@ -264,5 +265,6 @@
264265
<Link>simlauncher64-sgen.frameworks</Link>
265266
</BundleResource>
266267
</ItemGroup>
268+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
267269
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
268270
</Project>

tests/linker/ios/dont link/dont link.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)-unified</IntermediateOutputPath>
1515
<DefineConstants></DefineConstants>
1616
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
17+
<RootTestsDirectory>..\..\..</RootTestsDirectory>
1718
</PropertyGroup>
1819
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
1920
<DebugSymbols>True</DebugSymbols>
@@ -174,6 +175,7 @@
174175
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-76%402x.png" />
175176
<ImageAsset Condition="'$(TargetFrameworkIdentifier)' != 'Xamarin.WatchOS'" Include="Assets.xcassets\AppIcons.appiconset\icon-app-83.5%402x.png" />
176177
</ItemGroup>
178+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
177179
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
178180
<ItemGroup>
179181
<Content Include="BoardingPass.pkpass" />

tests/linker/ios/link all/link all.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<DefineConstants></DefineConstants>
1616
<LangVersion>latest</LangVersion>
1717
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
18+
<RootTestsDirectory>..\..\..</RootTestsDirectory>
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
2021
<DebugSymbols>True</DebugSymbols>
@@ -236,5 +237,6 @@
236237
<Name>bindings-test</Name>
237238
</ProjectReference>
238239
</ItemGroup>
240+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
239241
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
240242
</Project>

tests/linker/ios/link sdk/link sdk.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)-unified</IntermediateOutputPath>
1515
<DefineConstants></DefineConstants>
1616
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
17+
<RootTestsDirectory>..\..\..</RootTestsDirectory>
1718
</PropertyGroup>
1819
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
1920
<DebugSymbols>True</DebugSymbols>
@@ -231,5 +232,6 @@
231232
<Name>bindings-test</Name>
232233
</ProjectReference>
233234
</ItemGroup>
235+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
234236
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
235237
</Project>

tests/mono-native/iOS/mono-native.csproj.template

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier>
1616
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)-unified</IntermediateOutputPath>
1717
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
18+
<RootTestsDirectory>..\..</RootTestsDirectory>
1819
</PropertyGroup>
1920
<PropertyGroup>
2021
<MonoNativeMode Condition="'$(TargetFrameworkIdentifier)|$(Configuration)|$(Platform)' == 'Xamarin.iOS|Debug|iPhoneSimulator'">MONO_NATIVE_SYMLINK</MonoNativeMode>
@@ -194,6 +195,7 @@
194195
<Link>MonoNativeConfig.cs</Link>
195196
</Compile>
196197
</ItemGroup>
198+
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
197199
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
198200
</Project>
199201

tests/nunit.framework.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<PropertyGroup>
55
<XmlLinkerFile>$(MSBuildThisFileDirectory)nunit.framework.xml</XmlLinkerFile>
66
<MonoBundlingExtraArgs>--xml=$(XmlLinkerFile) $(MonoBundlingExtraArgs)</MonoBundlingExtraArgs>
7-
<MtouchExtraArgs>--xml=$(XmlLinkerFile) $(MtouchExtraArgs)</MtouchExtraArgs>
7+
<MtouchExtraArgs>--xml=$(XmlLinkerFile) --dlsym:+nunit.framework.dll $(MtouchExtraArgs)</MtouchExtraArgs>
88
</PropertyGroup>
99
</Project>

tools/mtouch/Application.mtouch.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ public void ParseDlsymOptions (string options)
409409
if (Driver.TryParseBool (options, out dlsym)) {
410410
DlsymOptions = dlsym ? DlsymOptions.All : DlsymOptions.None;
411411
} else {
412-
DlsymAssemblies = new List<Tuple<string, bool>> ();
412+
if (DlsymAssemblies == null)
413+
DlsymAssemblies = new List<Tuple<string, bool>> ();
413414

414415
var assemblies = options.Split (',');
415416
foreach (var assembly in assemblies) {

0 commit comments

Comments
 (0)