Skip to content

Commit 6c1c742

Browse files
committed
Try to fix some tests
1 parent 2f38764 commit 6c1c742

File tree

3 files changed

+69
-18
lines changed

3 files changed

+69
-18
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public void CheckMonoDebugIsAddedToEnvironment ([Values ("", "Normal", "Offline"
8484
IsRelease = true,
8585
};
8686
proj.SetProperty ("_AndroidSequencePointsMode", sequencePointsMode);
87+
proj.SetProperty ("_AndroidEnableNativeRuntimeLinking", useNativeRuntimeLinkingMode.ToString ());
8788
proj.SetAndroidSupportedAbis (supportedAbis);
8889
using (var b = CreateApkBuilder ()) {
8990
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,29 @@ public void CasingOnJavaLangObject ()
958958
}
959959
}
960960

961+
static object[] GenerateJavaStubsAndAssemblyData () => new object[] {
962+
new object[] {
963+
true, // isRelease
964+
true, // useNativeRuntimeLinkingMode
965+
},
966+
967+
new object[] {
968+
true, // isRelease
969+
false, // useNativeRuntimeLinkingMode
970+
},
971+
972+
new object[] {
973+
false, // isRelease
974+
false, // useNativeRuntimeLinkingMode
975+
},
976+
977+
// Configuration for debug build and native runtime linking is not used, since
978+
// runtime linking happens only in release builds
979+
};
980+
961981
[Test]
962-
public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
982+
[TestCaseSource (nameof (GenerateJavaStubsAndAssemblyData))]
983+
public void GenerateJavaStubsAndAssembly (bool isRelease, bool useNativeRuntimeLinkingMode)
963984
{
964985
var targets = new [] {
965986
"_GenerateJavaStubs",
@@ -968,6 +989,7 @@ public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
968989
var proj = new XamarinAndroidApplicationProject {
969990
IsRelease = isRelease,
970991
};
992+
proj.SetProperty ("_AndroidEnableNativeRuntimeLinking", useNativeRuntimeLinkingMode.ToString ());
971993
proj.SetAndroidSupportedAbis ("armeabi-v7a");
972994
proj.OtherBuildItems.Add (new AndroidItem.AndroidEnvironment ("Foo.txt") {
973995
TextContent = () => "Foo=Bar",
@@ -978,7 +1000,7 @@ public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
9781000
foreach (var target in targets) {
9791001
Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should *not* be skipped!");
9801002
}
981-
AssertAssemblyFilesInFileWrites (proj, b);
1003+
AssertAssemblyFilesInFileWrites (proj, b, useNativeRuntimeLinkingMode);
9821004

9831005
// Change C# file and AndroidEvironment file
9841006
proj.MainActivity += Environment.NewLine + "// comment";
@@ -988,30 +1010,40 @@ public void GenerateJavaStubsAndAssembly ([Values (true, false)] bool isRelease)
9881010
foreach (var target in targets) {
9891011
Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should *not* be skipped!");
9901012
}
991-
AssertAssemblyFilesInFileWrites (proj, b);
1013+
AssertAssemblyFilesInFileWrites (proj, b, useNativeRuntimeLinkingMode);
9921014

9931015
// No changes
9941016
Assert.IsTrue (b.Build (proj), "third build should have succeeded.");
9951017
foreach (var target in targets) {
9961018
Assert.IsTrue (b.Output.IsTargetSkipped (target), $"`{target}` should be skipped!");
9971019
}
998-
AssertAssemblyFilesInFileWrites (proj, b);
1020+
AssertAssemblyFilesInFileWrites (proj, b, useNativeRuntimeLinkingMode);
9991021
}
10001022
}
10011023

1002-
readonly string [] ExpectedAssemblyFiles = new [] {
1003-
Path.Combine ("android", "environment.armeabi-v7a.o"),
1004-
Path.Combine ("android", "environment.armeabi-v7a.ll"),
1005-
Path.Combine ("android", "typemaps.armeabi-v7a.o"),
1006-
Path.Combine ("android", "typemaps.armeabi-v7a.ll"),
1007-
Path.Combine ("app_shared_libraries", "armeabi-v7a", "libxamarin-app.so")
1008-
};
1024+
List<string> GetExpectedAssemblyFiles (bool useNativeRuntimeLinkingMode)
1025+
{
1026+
var ret = new List <string> {
1027+
Path.Combine ("android", "environment.armeabi-v7a.o"),
1028+
Path.Combine ("android", "environment.armeabi-v7a.ll"),
1029+
Path.Combine ("android", "typemaps.armeabi-v7a.o"),
1030+
Path.Combine ("android", "typemaps.armeabi-v7a.ll")
1031+
};
1032+
1033+
if (useNativeRuntimeLinkingMode) {
1034+
ret.Add (Path.Combine ("app_shared_libraries", "armeabi-v7a", "libmonodroid-unified.so"));
1035+
} else {
1036+
ret.Add (Path.Combine ("app_shared_libraries", "armeabi-v7a", "libxamarin-app.so"));
1037+
}
1038+
1039+
return ret;
1040+
}
10091041

1010-
void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, ProjectBuilder b)
1042+
void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, ProjectBuilder b, bool useNativeRuntimeLinkingMode)
10111043
{
10121044
var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
10131045
var lines = File.ReadAllLines (Path.Combine (intermediate, $"{proj.ProjectName}.csproj.FileListAbsolute.txt"));
1014-
foreach (var file in ExpectedAssemblyFiles) {
1046+
foreach (var file in GetExpectedAssemblyFiles (useNativeRuntimeLinkingMode)) {
10151047
var path = Path.Combine (intermediate, file);
10161048
CollectionAssert.Contains (lines, path, $"{file} is not in FileWrites!");
10171049
FileAssert.Exists (path);

tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,23 @@ namespace Xamarin.Android.Build.Tests
1515
public class BundleToolTests : DeviceTest
1616
{
1717
static readonly object[] FixtureArgs = {
18-
new object[] { false },
19-
new object[] { true },
18+
new object[] {
19+
false, // useAssemblyBlobs
20+
false, // useNativeRuntimeLinkingMode
21+
},
22+
23+
new object[] {
24+
true, // useAssemblyBlobs
25+
false, // useNativeRuntimeLinkingMode
26+
},
27+
28+
new object[] {
29+
true, // useAssemblyBlobs
30+
true, // useNativeRuntimeLinkingMode
31+
},
32+
33+
// There's no point in testing further combinations of the two parameters, the tests
34+
// wouldn't actually differ.
2035
};
2136

2237
static readonly string [] Abis = new [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" };
@@ -26,6 +41,7 @@ public class BundleToolTests : DeviceTest
2641
string intermediate;
2742
string bin;
2843
bool usesAssemblyBlobs;
44+
bool useNativeRuntimeLinkingMode;
2945

3046
// Disable split by language
3147
const string BuildConfig = @"{
@@ -46,9 +62,10 @@ public class BundleToolTests : DeviceTest
4662
}
4763
}";
4864

49-
public BundleToolTests (bool usesAssemblyBlobs)
65+
public BundleToolTests (bool usesAssemblyBlobs, bool useNativeRuntimeLinkingMode)
5066
{
5167
this.usesAssemblyBlobs = usesAssemblyBlobs;
68+
this.useNativeRuntimeLinkingMode = useNativeRuntimeLinkingMode;
5269
}
5370

5471
[OneTimeSetUp]
@@ -97,6 +114,7 @@ public void OneTimeSetUp ()
97114
app.SetAndroidSupportedAbis (Abis);
98115
app.SetProperty ("AndroidBundleConfigurationFile", "buildConfig.json");
99116
app.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ());
117+
app.SetProperty ("_AndroidEnableNativeRuntimeLinking", useNativeRuntimeLinkingMode.ToString ());
100118

101119
libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName), cleanupOnDispose: true);
102120
Assert.IsTrue (libBuilder.Build (lib), "Library build should have succeeded.");
@@ -136,7 +154,7 @@ string [] ListArchiveContents (string archive, bool usesAssembliesBlob)
136154
}
137155

138156
[Test]
139-
public void BaseZip ([Values(false, true)] bool useNativeRuntimeLinkingMode)
157+
public void BaseZip ()
140158
{
141159
var baseZip = Path.Combine (intermediate, "android", "bin", "base.zip");
142160
var contents = ListArchiveContents (baseZip, usesAssemblyBlobs);
@@ -197,7 +215,7 @@ public void BaseZip ([Values(false, true)] bool useNativeRuntimeLinkingMode)
197215
}
198216

199217
[Test]
200-
public void AppBundle ([Values(false, true)] bool useNativeRuntimeLinkingMode)
218+
public void AppBundle ()
201219
{
202220
var aab = Path.Combine (intermediate, "android", "bin", $"{app.PackageName}.aab");
203221
FileAssert.Exists (aab);

0 commit comments

Comments
 (0)