|
| 1 | +using System.Collections.Generic; |
| 2 | +using Microsoft.Android.Build.Tasks; |
| 3 | +using Microsoft.Build.Framework; |
| 4 | +using Microsoft.Build.Utilities; |
| 5 | +using NUnit.Framework; |
| 6 | + |
| 7 | +namespace Microsoft.Android.Build.BaseTasks.Tests |
| 8 | +{ |
| 9 | + [TestFixture] |
| 10 | + public class AndroidRidAbiHelperTests |
| 11 | + { |
| 12 | + static object [] StringValueSource = new object [] { |
| 13 | + new[] { |
| 14 | + /* input */ "armeabi-v7a/libfoo.so", |
| 15 | + /* expected */ "armeabi-v7a" |
| 16 | + }, |
| 17 | + new[] { |
| 18 | + /* input */ "arm64-v8a/libfoo.so", |
| 19 | + /* expected */ "arm64-v8a" |
| 20 | + }, |
| 21 | + new[] { |
| 22 | + /* input */ "x86/libfoo.so", |
| 23 | + /* expected */ "x86" |
| 24 | + }, |
| 25 | + new[] { |
| 26 | + /* input */ "x86_64/libfoo.so", |
| 27 | + /* expected */ "x86_64" |
| 28 | + }, |
| 29 | + new[] { |
| 30 | + /* input */ "android-arm/libfoo.so", |
| 31 | + /* expected */ "armeabi-v7a" |
| 32 | + }, |
| 33 | + new[] { |
| 34 | + /* input */ "android-arm64/libfoo.so", |
| 35 | + /* expected */ "arm64-v8a" |
| 36 | + }, |
| 37 | + new[] { |
| 38 | + /* input */ "android-x86/libfoo.so", |
| 39 | + /* expected */ "x86" |
| 40 | + }, |
| 41 | + new[] { |
| 42 | + /* input */ "android-x64/libfoo.so", |
| 43 | + /* expected */ "x86_64" |
| 44 | + }, |
| 45 | + new[] { |
| 46 | + /* input */ "android-arm/native/libfoo.so", |
| 47 | + /* expected */ "armeabi-v7a" |
| 48 | + }, |
| 49 | + new[] { |
| 50 | + /* input */ "android-arm64/native/libfoo.so", |
| 51 | + /* expected */ "arm64-v8a" |
| 52 | + }, |
| 53 | + new[] { |
| 54 | + /* input */ "android-x86/native/libfoo.so", |
| 55 | + /* expected */ "x86" |
| 56 | + }, |
| 57 | + new[] { |
| 58 | + /* input */ "android-x64/native/libfoo.so", |
| 59 | + /* expected */ "x86_64" |
| 60 | + }, |
| 61 | + new[] { |
| 62 | + /* input */ "android.21-x64/native/libfoo.so", |
| 63 | + /* expected */ "x86_64" |
| 64 | + }, |
| 65 | + new[] { |
| 66 | + /* input */ "packages/sqlitepclraw.lib.e_sqlite3.android/1.1.11/runtimes/android-arm64/native/libe_sqlite3.so", |
| 67 | + /* expected */ "arm64-v8a" |
| 68 | + } |
| 69 | + }; |
| 70 | + |
| 71 | + [Test] |
| 72 | + [TestCaseSource (nameof (StringValueSource))] |
| 73 | + public void StringValue (string input, string expected) |
| 74 | + { |
| 75 | + Assert.AreEqual (expected, AndroidRidAbiHelper.GetNativeLibraryAbi (input)); |
| 76 | + } |
| 77 | + |
| 78 | + static object [] ITaskItemValueSource = new object [] { |
| 79 | + new object [] { |
| 80 | + /* input */ |
| 81 | + new TaskItem("armeabi-v7a/libfoo.so"), |
| 82 | + /* expected */ |
| 83 | + "armeabi-v7a" |
| 84 | + }, |
| 85 | + new object [] { |
| 86 | + /* input */ |
| 87 | + new TaskItem("libabi.so", new Dictionary<string,string> { |
| 88 | + { "Abi", "armeabi-v7a" } |
| 89 | + }), |
| 90 | + /* expected */ |
| 91 | + "armeabi-v7a" |
| 92 | + }, |
| 93 | + new object [] { |
| 94 | + /* input */ |
| 95 | + new TaskItem("librid.so", new Dictionary<string,string> { |
| 96 | + { "RuntimeIdentifier", "android-arm" } |
| 97 | + }), |
| 98 | + /* expected */ |
| 99 | + "armeabi-v7a" |
| 100 | + }, |
| 101 | + new object [] { |
| 102 | + /* input */ |
| 103 | + new TaskItem("liblink.so", new Dictionary<string,string> { |
| 104 | + { "Link", "armeabi-v7a/libfoo.so" } |
| 105 | + }), |
| 106 | + /* expected */ |
| 107 | + "armeabi-v7a" |
| 108 | + }, |
| 109 | + new object [] { |
| 110 | + /* input */ |
| 111 | + new TaskItem("liblink.so", new Dictionary<string,string> { |
| 112 | + { "Link", "x86/libfoo.so" } |
| 113 | + }), |
| 114 | + /* expected */ |
| 115 | + "x86" |
| 116 | + }, |
| 117 | + new object [] { |
| 118 | + /* input */ |
| 119 | + new TaskItem("liblink.so", new Dictionary<string,string> { |
| 120 | + { "Link", "x86_64/libfoo.so" } |
| 121 | + }), |
| 122 | + /* expected */ |
| 123 | + "x86_64" |
| 124 | + }, |
| 125 | + new object [] { |
| 126 | + /* input */ |
| 127 | + new TaskItem("libridlink.so", new Dictionary<string,string> { |
| 128 | + { "Link", "android-arm/libfoo.so" } |
| 129 | + }), |
| 130 | + /* expected */ |
| 131 | + "armeabi-v7a" |
| 132 | + }, |
| 133 | + }; |
| 134 | + |
| 135 | + [Test] |
| 136 | + [TestCaseSource (nameof (ITaskItemValueSource))] |
| 137 | + public void ITaskItemValue (ITaskItem input, string expected) |
| 138 | + { |
| 139 | + Assert.AreEqual (expected, AndroidRidAbiHelper.GetNativeLibraryAbi (input)); |
| 140 | + } |
| 141 | + } |
| 142 | +} |
0 commit comments