/
NdkUtilTests.cs
66 lines (61 loc) · 3 KB
/
NdkUtilTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Xamarin.Android.Tasks;
using Xamarin.Android.Tools;
using Xamarin.ProjectTools;
namespace Xamarin.Android.Build.Tests.Tasks {
[TestFixture]
[Category ("Node-2")]
public class NdkUtilTests : BaseTest {
List<BuildErrorEventArgs> errors;
List<BuildWarningEventArgs> warnings;
MockBuildEngine engine;
[SetUp]
public void Setup ()
{
engine = new MockBuildEngine (TestContext.Out, errors = new List<BuildErrorEventArgs> (), warnings = new List<BuildWarningEventArgs> ());
}
[Test]
public void TestNdkUtil ()
{
var log = new TaskLoggingHelper (engine, TestName);
using (var builder = new Builder ()) {
var ndkDir = AndroidNdkPath;
var sdkDir = AndroidSdkPath;
NdkTools ndk = NdkTools.Create (ndkDir, log);
ndk.OSBinPath = SetUp.OSBinDirectory;
MonoAndroidHelper.AndroidSdk = new AndroidSdkInfo ((arg1, arg2) => { }, sdkDir, ndkDir, AndroidSdkResolver.GetJavaSdkPath ());
var platforms = ndk.GetSupportedPlatforms ();
Assert.AreNotEqual (0, platforms.Count (), "No platforms found");
var arch = AndroidTargetArch.X86;
Assert.IsTrue (ndk.ValidateNdkPlatform (arch, enableLLVM: false));
Assert.AreEqual (0, errors.Count, "NdkTools.ValidateNdkPlatform should not have returned false.");
int level = ndk.GetMinimumApiLevelFor (arch);
int expected = 16;
Assert.AreEqual (expected, level, $"Min Api Level for {arch} should be {expected}.");
var compilerNoQuotes = ndk.GetToolPath (NdkToolKind.CompilerC, arch, level);
Assert.AreEqual (0, errors.Count, "NdkTools.GetToolPath should not have errored.");
Assert.NotNull (compilerNoQuotes, "NdkTools.GetToolPath returned null for NdkToolKind.CompilerC.");
compilerNoQuotes = ndk.GetToolPath (NdkToolKind.CompilerCPlusPlus, arch, level);
Assert.AreEqual (0, errors.Count, "NdkTools.GetToolPath should not have errored.");
Assert.NotNull (compilerNoQuotes, "NdkTools.GetToolPath returned null for NdkToolKind.CompilerCPlusPlus.");
var gas = ndk.GetToolPath (NdkToolKind.Assembler, arch, level);
Assert.AreEqual (0, errors.Count, "NdkTools.GetToolPath should not have errored.");
Assert.NotNull (gas, "NdkTools.GetToolPath returned null for NdkToolKind.Assembler.");
var inc = ndk.GetDirectoryPath (NdkToolchainDir.PlatformInclude, arch, level);
Assert.NotNull (inc, " NdkTools.GetToolPath should not return null for NdkToolchainDir.PlatformInclude");
var libPath = ndk.GetDirectoryPath (NdkToolchainDir.PlatformLib, arch, level);
Assert.NotNull (libPath, "NdkTools.GetDirectoryPath should not return null for NdkToolchainDir.PlatformLib");
string ld = ndk.GetToolPath (NdkToolKind.Linker, arch, level);
Assert.AreEqual (0, errors.Count, "NdkTools.GetToolPath should not have errored.");
Assert.NotNull (ld, "NdkTools.GetToolPath returned null for NdkToolKind.Linker.");
}
}
}
}