Skip to content

Commit dbc971f

Browse files
dellis1972grendello
authored andcommitted
[Xamarin.Android.Build.Tests] Fix the tests to pick up the correct runtime. (#685)
There was a change (05aebd7) in the naming of the libmono-android.*.so files. It used to be that the name included the abi. But now we just get files like libmono-android.debug.d.so libmono-android.release.so These were not picking up the right runtime info in the tests. They were getting an arch of 'd' because we expected files like libmono-android.release.armeabi-v7a.so So we need to update the ProjectBuilder which loads the data to take this into account and use the Parent directory name for the abi and to ignore the .d.so files.
1 parent cffc699 commit dbc971f

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.OSS.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ public partial class BuildTest : BaseTest
7272
//new Object [] { true, true },
7373
};
7474

75+
static object [] RuntimeChecks = new object [] {
76+
new object[] {
77+
/* supportedAbi */ new string[] { "armeabi-v7a"},
78+
/* optimize */ true ,
79+
/* expectedResult */ "release",
80+
},
81+
new object[] {
82+
/* supportedAbi */ new string[] { "armeabi-v7a"},
83+
/* optimize */ false ,
84+
/* expectedResult */ "debug",
85+
},
86+
};
87+
7588
static object [] SequencePointChecks = new object [] {
7689
new object[] {
7790
/* isRelease */ false,

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -989,21 +989,6 @@ public void BuildApplicationWithJavaSource (bool isRelease, bool expectedResult)
989989
}
990990
}
991991

992-
#pragma warning disable 414
993-
static object [] RuntimeChecks = new object [] {
994-
new object[] {
995-
/* supportedAbi */ new string[] { "armeabi-v7a"},
996-
/* optimize */ true ,
997-
/* expectedResult */ "release",
998-
},
999-
new object[] {
1000-
/* supportedAbi */ new string[] { "armeabi-v7a"},
1001-
/* optimize */ false ,
1002-
/* expectedResult */ "debug",
1003-
},
1004-
};
1005-
#pragma warning restore 414
1006-
1007992
[Test]
1008993
[TestCaseSource ("RuntimeChecks")]
1009994
public void CheckWhichRuntimeIsIncluded (string [] supportedAbi, bool optimize, string expectedRuntime)
@@ -1024,7 +1009,7 @@ public void CheckWhichRuntimeIsIncluded (string [] supportedAbi, bool optimize,
10241009
Assert.IsNotNull (inApkRuntime, "Could not find the actual runtime used.");
10251010
Assert.AreEqual (runtime.Size, inApkRuntime.Size, "expected {0} got {1}", expectedRuntime, inApkRuntime.Runtime);
10261011
inApk = ZipHelper.ReadFileFromZip (apk, string.Format ("lib/{0}/libmono-profiler-log.so", abi));
1027-
if (!optimize) {
1012+
if (string.Compare (expectedRuntime, "debug", StringComparison.OrdinalIgnoreCase) == 0) {
10281013
Assert.IsNotNull (inApk, "libmono-profiler-log.so should exist in the apk.");
10291014
} else {
10301015
Assert.IsNull (inApk, "libmono-profiler-log.so should not exist in the apk.");

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/ProjectBuilder.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Diagnostics;
@@ -119,17 +119,21 @@ public struct RuntimeInfo
119119
public RuntimeInfo [] GetSupportedRuntimes ()
120120
{
121121
var runtimeInfo = new List<RuntimeInfo> ();
122-
var outdir = FrameworkLibDirectory;
123-
var path = Path.Combine (outdir, RunXBuild ? Path.Combine ("xbuild", "Xamarin", "Android", "lib") : "");
122+
string outdir = FrameworkLibDirectory;
123+
string path = Path.Combine (outdir, RunXBuild ? Path.Combine ("xbuild", "Xamarin", "Android", "lib") : "");
124124
foreach (var file in Directory.EnumerateFiles (path, "libmono-android.*.*.so", SearchOption.AllDirectories)) {
125-
var items = Path.GetFileName (file).Split (new char [] { '.' });
126-
if (items.Length != 4)
125+
string fullFilePath = Path.GetFullPath (file);
126+
DirectoryInfo parentDir = Directory.GetParent (fullFilePath);
127+
if (parentDir == null)
127128
continue;
128-
var fi = new FileInfo (file);
129+
string[] items = Path.GetFileName (fullFilePath).Split ('.' );
130+
if (items.Length != 3)
131+
continue;
132+
var fi = new FileInfo (fullFilePath);
129133
runtimeInfo.Add (new RuntimeInfo () {
130134
Name = "libmonodroid.so",
131135
Runtime = items [1], // release|debug
132-
Abi = items [2], // armaebi|x86|arm64-v8a
136+
Abi = parentDir.Name, // armaebi|x86|arm64-v8a
133137
Size = (int)fi.Length, // int
134138
});
135139
}

0 commit comments

Comments
 (0)