blob: 32149e3d3cf491ec4193e8ded9feef0c48de9963 [file] [log] [blame]
Yifan Hong676447a2016-11-15 12:57:23 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "LibHidlTest"
18
19#include <vintf/parse_string.h>
20#include <vintf/parse_xml.h>
21#include <vintf/CompatibilityMatrix.h>
Yifan Honga7201e72017-02-17 10:09:59 -080022#include <vintf/RuntimeInfo.h>
Yifan Hongd2b7e642017-02-17 10:15:32 -080023#include <vintf/HalManifest.h>
Yifan Hong676447a2016-11-15 12:57:23 -080024
25#include <android-base/logging.h>
Yifan Hong3f5489a2017-02-08 11:14:21 -080026#include <android-base/parseint.h>
Yifan Hong676447a2016-11-15 12:57:23 -080027#include <gtest/gtest.h>
28
Yifan Honga9993572017-01-24 19:33:15 -080029namespace android {
30namespace vintf {
Yifan Hong676447a2016-11-15 12:57:23 -080031
Yifan Hong4a5eb7b2017-02-16 18:19:26 -080032extern const XmlConverter<Version> &gVersionConverter;
33extern const XmlConverter<MatrixHal> &gMatrixHalConverter;
34extern const XmlConverter<KernelConfigTypedValue> &gKernelConfigTypedValueConverter;
35extern const XmlConverter<HalImplementation> &gHalImplementationConverter;
Yifan Hongd2b7e642017-02-17 10:15:32 -080036extern const XmlConverter<HalManifest> &gHalManifestConverter;
Yifan Hong4a5eb7b2017-02-16 18:19:26 -080037extern const XmlConverter<CompatibilityMatrix> &gCompatibilityMatrixConverter;
38
Yifan Honga9993572017-01-24 19:33:15 -080039struct LibVintfTest : public ::testing::Test {
Yifan Hong676447a2016-11-15 12:57:23 -080040public:
41 virtual void SetUp() override {
42 }
43 virtual void TearDown() override {
44 }
Yifan Honga9993572017-01-24 19:33:15 -080045 bool add(CompatibilityMatrix &cm, MatrixHal &&hal) {
46 return cm.add(std::move(hal));
47 }
48 bool add(CompatibilityMatrix &cm, MatrixKernel &&kernel) {
49 return cm.add(std::move(kernel));
50 }
Yifan Hongd2b7e642017-02-17 10:15:32 -080051 bool add(HalManifest &vm, ManifestHal &&hal) {
Yifan Honga9993572017-01-24 19:33:15 -080052 return vm.add(std::move(hal));
53 }
Yifan Hong558380a2017-02-09 15:37:32 -080054 void set(CompatibilityMatrix &cm, Sepolicy &&sepolicy) {
Yifan Hongec342862017-02-16 17:57:06 -080055 cm.mSepolicy = sepolicy;
Yifan Hong558380a2017-02-09 15:37:32 -080056 }
Yifan Hongd2b7e642017-02-17 10:15:32 -080057 const ManifestHal *getHal(HalManifest &vm, const std::string &name) {
Yifan Honga9993572017-01-24 19:33:15 -080058 return vm.getHal(name);
59 }
Yifan Hongd2b7e642017-02-17 10:15:32 -080060 ConstMapValueIterable<std::string, ManifestHal> getHals(HalManifest &vm) {
Yifan Honga9993572017-01-24 19:33:15 -080061 return vm.getHals();
62 }
63 bool isEqual(const CompatibilityMatrix &cm1, const CompatibilityMatrix &cm2) {
Yifan Hongec342862017-02-16 17:57:06 -080064 return cm1.mHals == cm2.mHals && cm1.mKernels == cm2.mKernels;
Yifan Honga9993572017-01-24 19:33:15 -080065 }
Yifan Hong5a06ef72017-01-24 19:54:24 -080066 bool isValid(const ManifestHal &mh) {
67 return mh.isValid();
68 }
Yifan Hongd2b7e642017-02-17 10:15:32 -080069 HalManifest testHalManifest() {
70 HalManifest vm;
Yifan Hong2059ffc2017-02-24 11:32:02 -080071 vm.add(ManifestHal{
72 .format = HalFormat::HIDL,
73 .name = "android.hardware.camera",
74 .versions = {Version(2, 0)},
75 .impl = HalImplementation{ImplLevel::SOC, "msm8892"},
76 .transport = Transport::HWBINDER
77 });
78 vm.add(ManifestHal{
79 .format = HalFormat::HIDL,
80 .name = "android.hardware.nfc",
81 .versions = {Version(1, 0)},
82 .impl = HalImplementation{ImplLevel::GENERIC, "generic"},
83 .transport = Transport::PASSTHROUGH
84 });
Yifan Honga9993572017-01-24 19:33:15 -080085
86 return vm;
87 }
Yifan Honga7201e72017-02-17 10:09:59 -080088 RuntimeInfo testRuntimeInfo() {
89 RuntimeInfo info;
Yifan Hongc66ad1e2017-02-08 20:19:45 -080090 info.mOsName = "Linux";
91 info.mNodeName = "localhost";
92 info.mOsRelease = "3.18.31-g936f9a479d0f";
93 info.mKernelVersion = {3, 18, 31};
94 info.mOsVersion = "#4 SMP PREEMPT Wed Feb 1 18:10:52 PST 2017";
95 info.mHardwareId = "aarch64";
96 info.mKernelSepolicyVersion = 30;
Yifan Hongf1af7522017-02-16 18:00:55 -080097 info.mKernelConfigs = {
Yifan Hongc66ad1e2017-02-08 20:19:45 -080098 {"CONFIG_64BIT", "y"},
99 {"CONFIG_ANDROID_BINDER_DEVICES", "\"binder,hwbinder\""},
100 {"CONFIG_ARCH_MMAP_RND_BITS", "24"},
101 {"CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES", "\"\""},
102 {"CONFIG_ILLEGAL_POINTER_VALUE", "0xdead000000000000"}
103 };
104 return info;
105 }
Yifan Hong676447a2016-11-15 12:57:23 -0800106};
107
Yifan Hongef6d4d32017-01-23 14:12:28 -0800108
109TEST_F(LibVintfTest, Stringify) {
Yifan Hongd2b7e642017-02-17 10:15:32 -0800110 HalManifest vm = testHalManifest();
Yifan Hongef6d4d32017-01-23 14:12:28 -0800111 EXPECT_EQ(dump(vm), "hidl/android.hardware.camera/hwbinder/soc/msm8892/2.0:"
112 "hidl/android.hardware.nfc/passthrough/generic/generic/1.0");
Yifan Hong676447a2016-11-15 12:57:23 -0800113
114 EXPECT_EQ(to_string(HalFormat::HIDL), "hidl");
115 EXPECT_EQ(to_string(HalFormat::NATIVE), "native");
116
117 VersionRange v(1, 2, 3);
118 EXPECT_EQ(to_string(v), "1.2-3");
119 VersionRange v2;
120 EXPECT_TRUE(parse("1.2-3", &v2));
121 EXPECT_EQ(v, v2);
122}
123
Yifan Hongd2b7e642017-02-17 10:15:32 -0800124TEST_F(LibVintfTest, HalManifestConverter) {
125 HalManifest vm = testHalManifest();
126 std::string xml = gHalManifestConverter(vm);
Yifan Hong676447a2016-11-15 12:57:23 -0800127 EXPECT_EQ(xml,
128 "<manifest version=\"1.0\">\n"
129 " <hal format=\"hidl\">\n"
Yifan Hongef6d4d32017-01-23 14:12:28 -0800130 " <name>android.hardware.camera</name>\n"
Yifan Hong676447a2016-11-15 12:57:23 -0800131 " <transport>hwbinder</transport>\n"
132 " <impl level=\"soc\">msm8892</impl>\n"
133 " <version>2.0</version>\n"
134 " </hal>\n"
135 " <hal format=\"hidl\">\n"
Yifan Hongef6d4d32017-01-23 14:12:28 -0800136 " <name>android.hardware.nfc</name>\n"
Yifan Hong676447a2016-11-15 12:57:23 -0800137 " <transport>passthrough</transport>\n"
138 " <impl level=\"generic\">generic</impl>\n"
139 " <version>1.0</version>\n"
140 " </hal>\n"
141 "</manifest>\n");
142}
143
144TEST_F(LibVintfTest, VersionConverter) {
145 Version v(3, 6);
146 std::string xml = gVersionConverter(v);
147 EXPECT_EQ(xml, "<version>3.6</version>\n");
148 Version v2;
149 EXPECT_TRUE(gVersionConverter(&v2, xml));
150 EXPECT_EQ(v, v2);
151}
152
153TEST_F(LibVintfTest, HalImplementationConverter) {
154 HalImplementation hl{ImplLevel::SOC, "msm8992"};
155 std::string xml = gHalImplementationConverter(hl);
156 EXPECT_EQ(xml, "<impl level=\"soc\">msm8992</impl>\n");
157 HalImplementation hl2;
158 EXPECT_TRUE(gHalImplementationConverter(&hl2, xml));
159 EXPECT_EQ(hl.impl, hl2.impl);
160 EXPECT_EQ(hl.implLevel, hl2.implLevel);
161}
162
163TEST_F(LibVintfTest, MatrixHalConverter) {
Yifan Hongef6d4d32017-01-23 14:12:28 -0800164 MatrixHal mh{HalFormat::NATIVE, "android.hardware.camera",
Yifan Hong676447a2016-11-15 12:57:23 -0800165 {{VersionRange(1,2,3), VersionRange(4,5,6)}},
166 false /* optional */};
167 std::string xml = gMatrixHalConverter(mh);
168 EXPECT_EQ(xml,
169 "<hal format=\"native\" optional=\"false\">\n"
Yifan Hongef6d4d32017-01-23 14:12:28 -0800170 " <name>android.hardware.camera</name>\n"
Yifan Hong676447a2016-11-15 12:57:23 -0800171 " <version>1.2-3</version>\n"
172 " <version>4.5-6</version>\n"
173 "</hal>\n");
174 MatrixHal mh2;
175 EXPECT_TRUE(gMatrixHalConverter(&mh2, xml));
176 EXPECT_EQ(mh, mh2);
177}
178
Yifan Hong3f5489a2017-02-08 11:14:21 -0800179TEST_F(LibVintfTest, KernelConfigTypedValueConverter) {
180
181 KernelConfigTypedValue converted;
182
183 auto testOne = [] (const KernelConfigTypedValue &original,
184 const std::string &expectXml) {
185 std::string xml;
186 KernelConfigTypedValue converted;
187 xml = gKernelConfigTypedValueConverter(original);
188 EXPECT_EQ(xml, expectXml);
189 EXPECT_TRUE(gKernelConfigTypedValueConverter(&converted, xml));
190 EXPECT_EQ(original, converted);
191 };
192
193 auto testParse = [] (const KernelConfigTypedValue &original,
194 const std::string &xml) {
195 KernelConfigTypedValue converted;
196 EXPECT_TRUE(gKernelConfigTypedValueConverter(&converted, xml));
197 EXPECT_EQ(original, converted);
198 };
199
200 testOne(KernelConfigTypedValue("stringvalue"),
201 "<value type=\"string\">stringvalue</value>\n");
202 testOne(KernelConfigTypedValue(""),
203 "<value type=\"string\"></value>\n");
204
205 testOne(KernelConfigTypedValue(Tristate::YES),
206 "<value type=\"tristate\">y</value>\n");
207 testOne(KernelConfigTypedValue(Tristate::NO),
208 "<value type=\"tristate\">n</value>\n");
209 testOne(KernelConfigTypedValue(Tristate::MODULE),
210 "<value type=\"tristate\">m</value>\n");
211 EXPECT_FALSE(gKernelConfigTypedValueConverter(&converted,
212 "<value type=\"tristate\">q</value>\n"));
213
214 testOne(KernelConfigTypedValue(KernelConfigRangeValue{4, 20}),
215 "<value type=\"range\">4-20</value>\n");
216 testOne(KernelConfigTypedValue(KernelConfigRangeValue{0, UINT64_MAX}),
217 "<value type=\"range\">0-18446744073709551615</value>\n");
218 testParse(KernelConfigTypedValue(KernelConfigRangeValue{0, UINT64_MAX}),
219 "<value type=\"range\">0x0-0xffffffffffffffff</value>\n");
220
221 EXPECT_FALSE(gKernelConfigTypedValueConverter(&converted,
222 "<value type=\"int\">-18446744073709551616</value>\n"));
223
224 testOne(KernelConfigTypedValue(INT64_MIN),
225 "<value type=\"int\">-9223372036854775808</value>\n");
226 testParse(KernelConfigTypedValue(INT64_MIN),
227 "<value type=\"int\">0x8000000000000000</value>\n");
228 testParse(KernelConfigTypedValue(INT64_MIN),
229 "<value type=\"int\">-0X8000000000000000</value>\n");
230
231 testParse(KernelConfigTypedValue(INT64_MIN + 1),
232 "<value type=\"int\">-0X7FFFFFFFFFFFFFFF</value>\n");
233
234 testParse(KernelConfigTypedValue(-0x50),
235 "<value type=\"int\">-0x50</value>\n");
236
237 testOne(KernelConfigTypedValue(0),
238 "<value type=\"int\">0</value>\n");
239
240 // Truncation for underflow.
241 testParse(KernelConfigTypedValue(1),
242 "<value type=\"int\">-0xffffffffffffffff</value>\n");
243 testParse(KernelConfigTypedValue(1),
244 "<value type=\"int\">-18446744073709551615</value>\n");
245
246 testOne(KernelConfigTypedValue(INT64_MAX),
247 "<value type=\"int\">9223372036854775807</value>\n");
248 testParse(KernelConfigTypedValue(INT64_MAX),
249 "<value type=\"int\">0x7FFFFFFFFFFFFFFF</value>\n");
250 // Truncation for underflow.
251 testParse(KernelConfigTypedValue(INT64_MAX),
252 "<value type=\"int\">-9223372036854775809</value>\n");
253
254 testParse(KernelConfigTypedValue(-1),
255 "<value type=\"int\">18446744073709551615</value>\n");
256 testParse(KernelConfigTypedValue(-1),
257 "<value type=\"int\">0xffffffffffffffff</value>\n");
258
259 EXPECT_FALSE(gKernelConfigTypedValueConverter(&converted,
260 "<value type=\"int\">18446744073709551616</value>\n"));
261}
262
Yifan Hong676447a2016-11-15 12:57:23 -0800263TEST_F(LibVintfTest, CompatibilityMatrixCoverter) {
264 CompatibilityMatrix cm;
Yifan Honga9993572017-01-24 19:33:15 -0800265 EXPECT_TRUE(add(cm, MatrixHal{HalFormat::NATIVE, "android.hardware.camera",
Yifan Hong676447a2016-11-15 12:57:23 -0800266 {{VersionRange(1,2,3), VersionRange(4,5,6)}},
Yifan Honga9993572017-01-24 19:33:15 -0800267 false /* optional */}));
268 EXPECT_TRUE(add(cm, MatrixHal{HalFormat::NATIVE, "android.hardware.nfc",
Yifan Hong676447a2016-11-15 12:57:23 -0800269 {{VersionRange(4,5,6), VersionRange(10,11,12)}},
Yifan Honga9993572017-01-24 19:33:15 -0800270 true /* optional */}));
Yifan Hong3f5489a2017-02-08 11:14:21 -0800271 EXPECT_TRUE(add(cm, MatrixKernel{KernelVersion(3, 18, 22),
272 {KernelConfig{"CONFIG_FOO", Tristate::YES}, KernelConfig{"CONFIG_BAR", "stringvalue"}}}));
273 EXPECT_TRUE(add(cm, MatrixKernel{KernelVersion(4, 4, 1),
274 {KernelConfig{"CONFIG_BAZ", 20}, KernelConfig{"CONFIG_BAR", KernelConfigRangeValue{3, 5} }}}));
Yifan Hong558380a2017-02-09 15:37:32 -0800275 set(cm, Sepolicy(30, {1, 3}));
Yifan Hong676447a2016-11-15 12:57:23 -0800276 std::string xml = gCompatibilityMatrixConverter(cm);
277 EXPECT_EQ(xml,
Yifan Hong3f5489a2017-02-08 11:14:21 -0800278 "<compatibility-matrix version=\"1.0\">\n"
279 " <hal format=\"native\" optional=\"false\">\n"
280 " <name>android.hardware.camera</name>\n"
281 " <version>1.2-3</version>\n"
282 " <version>4.5-6</version>\n"
283 " </hal>\n"
284 " <hal format=\"native\" optional=\"true\">\n"
285 " <name>android.hardware.nfc</name>\n"
286 " <version>4.5-6</version>\n"
287 " <version>10.11-12</version>\n"
288 " </hal>\n"
Yifan Hongc3066892017-02-24 10:42:02 -0800289 " <kernel version=\"3.18.22\">\n"
Yifan Hong3f5489a2017-02-08 11:14:21 -0800290 " <config>\n"
291 " <key>CONFIG_FOO</key>\n"
292 " <value type=\"tristate\">y</value>\n"
293 " </config>\n"
294 " <config>\n"
295 " <key>CONFIG_BAR</key>\n"
296 " <value type=\"string\">stringvalue</value>\n"
297 " </config>\n"
298 " </kernel>\n"
Yifan Hongc3066892017-02-24 10:42:02 -0800299 " <kernel version=\"4.4.1\">\n"
Yifan Hong3f5489a2017-02-08 11:14:21 -0800300 " <config>\n"
301 " <key>CONFIG_BAZ</key>\n"
302 " <value type=\"int\">20</value>\n"
303 " </config>\n"
304 " <config>\n"
305 " <key>CONFIG_BAR</key>\n"
306 " <value type=\"range\">3-5</value>\n"
307 " </config>\n"
308 " </kernel>\n"
Yifan Hong558380a2017-02-09 15:37:32 -0800309 " <sepolicy>\n"
310 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
311 " <sepolicy-version>1-3</sepolicy-version>\n"
312 " </sepolicy>\n"
Yifan Hong3f5489a2017-02-08 11:14:21 -0800313 "</compatibility-matrix>\n");
Yifan Hong676447a2016-11-15 12:57:23 -0800314 CompatibilityMatrix cm2;
315 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm2, xml));
Yifan Honga9993572017-01-24 19:33:15 -0800316 EXPECT_TRUE(isEqual(cm, cm2));
Yifan Hong676447a2016-11-15 12:57:23 -0800317}
318
319TEST_F(LibVintfTest, IsValid) {
Yifan Hong5a06ef72017-01-24 19:54:24 -0800320 EXPECT_TRUE(isValid(ManifestHal()));
Yifan Hong676447a2016-11-15 12:57:23 -0800321
Yifan Hong2059ffc2017-02-24 11:32:02 -0800322 ManifestHal invalidHal{
323 .format = HalFormat::HIDL,
324 .name = "android.hardware.camera",
325 .versions = {{Version(2, 0), Version(2, 1)}},
326 .impl = HalImplementation{ImplLevel::SOC, "msm8892"},
327 .transport = Transport::PASSTHROUGH
328 };
329
Yifan Hong5a06ef72017-01-24 19:54:24 -0800330 EXPECT_FALSE(isValid(invalidHal));
Yifan Hongd2b7e642017-02-17 10:15:32 -0800331 HalManifest vm2;
Yifan Hong5a06ef72017-01-24 19:54:24 -0800332 EXPECT_FALSE(add(vm2, std::move(invalidHal)));
Yifan Hong676447a2016-11-15 12:57:23 -0800333}
334
Yifan Hongd2b7e642017-02-17 10:15:32 -0800335TEST_F(LibVintfTest, HalManifestGetHal) {
336 HalManifest vm = testHalManifest();
Yifan Honga9993572017-01-24 19:33:15 -0800337 EXPECT_NE(getHal(vm, "android.hardware.camera"), nullptr);
338 EXPECT_EQ(getHal(vm, "non-existent"), nullptr);
Yifan Hongef6d4d32017-01-23 14:12:28 -0800339
340 std::vector<std::string> arr{"android.hardware.camera", "android.hardware.nfc"};
341 size_t i = 0;
Yifan Honga9993572017-01-24 19:33:15 -0800342 for (const auto &hal : getHals(vm)) {
Yifan Hongef6d4d32017-01-23 14:12:28 -0800343 EXPECT_EQ(hal.name, arr[i++]);
344 }
345}
346
Yifan Honga7201e72017-02-17 10:09:59 -0800347TEST_F(LibVintfTest, RuntimeInfo) {
348 RuntimeInfo ki = testRuntimeInfo();
Yifan Hongc66ad1e2017-02-08 20:19:45 -0800349 using KernelConfigs = std::vector<KernelConfig>;
350 const KernelConfigs configs {
351 KernelConfig{"CONFIG_64BIT", Tristate::YES},
352 KernelConfig{"CONFIG_ANDROID_BINDER_DEVICES", "binder,hwbinder"},
353 KernelConfig{"CONFIG_ARCH_MMAP_RND_BITS", 24},
354 KernelConfig{"CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES", ""},
355 KernelConfig{"CONFIG_ILLEGAL_POINTER_VALUE", 0xdead000000000000},
356 KernelConfig{"CONFIG_NOTEXIST", Tristate::NO},
357 };
358
359 auto testMatrix = [&] (MatrixKernel &&kernel) {
360 CompatibilityMatrix cm;
361 add(cm, std::move(kernel));
362 set(cm, {30, {1, 3}});
363 return cm;
364 };
365
366 std::string error;
367
368 {
369 MatrixKernel kernel(KernelVersion{4, 4, 1}, KernelConfigs(configs));
370 CompatibilityMatrix cm = testMatrix(std::move(kernel));
371 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Kernel version shouldn't match";
372 }
373
374 {
375 MatrixKernel kernel(KernelVersion{3, 18, 22}, KernelConfigs(configs));
376 CompatibilityMatrix cm = testMatrix(std::move(kernel));
377 EXPECT_TRUE(ki.checkCompatibility(cm, &error)) << error;
378 }
379
380 {
381 MatrixKernel kernel(KernelVersion{3, 18, 22}, KernelConfigs(configs));
382 CompatibilityMatrix cm = testMatrix(std::move(kernel));
383 set(cm, Sepolicy{22, {1, 3}});
384 EXPECT_FALSE(ki.checkCompatibility(cm, &error))
385 << "kernel-sepolicy-version shouldn't match";
386 set(cm, Sepolicy{40, {1, 3}});
387 EXPECT_FALSE(ki.checkCompatibility(cm, &error))
388 << "kernel-sepolicy-version shouldn't match";
389 }
390
391 {
392 KernelConfigs newConfigs(configs);
393 newConfigs[0] = KernelConfig{"CONFIG_64BIT", Tristate::NO};
394 MatrixKernel kernel(KernelVersion{3, 18, 22}, std::move(newConfigs));
395 CompatibilityMatrix cm = testMatrix(std::move(kernel));
396 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Value shouldn't match for tristate";
397 }
398
399 {
400 KernelConfigs newConfigs(configs);
401 newConfigs[0] = KernelConfig{"CONFIG_64BIT", 20};
402 MatrixKernel kernel(KernelVersion{3, 18, 22}, std::move(newConfigs));
403 CompatibilityMatrix cm = testMatrix(std::move(kernel));
404 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Type shouldn't match";
405 }
406
407 {
408 KernelConfigs newConfigs(configs);
409 newConfigs[1] = KernelConfig{"CONFIG_ANDROID_BINDER_DEVICES", "binder"};
410 MatrixKernel kernel(KernelVersion{3, 18, 22}, std::move(newConfigs));
411 CompatibilityMatrix cm = testMatrix(std::move(kernel));
412 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Value shouldn't match for string";
413 }
414
415 {
416 KernelConfigs newConfigs(configs);
417 newConfigs[1] = KernelConfig{"CONFIG_ANDROID_BINDER_DEVICES", Tristate::YES};
418 MatrixKernel kernel(KernelVersion{3, 18, 22}, std::move(newConfigs));
419 CompatibilityMatrix cm = testMatrix(std::move(kernel));
420 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Type shouldn't match";
421 }
422
423 {
424 KernelConfigs newConfigs(configs);
425 newConfigs[2] = KernelConfig{"CONFIG_ARCH_MMAP_RND_BITS", 30};
426 MatrixKernel kernel(KernelVersion{3, 18, 22}, std::move(newConfigs));
427 CompatibilityMatrix cm = testMatrix(std::move(kernel));
428 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Value shouldn't match for integer";
429 }
430}
431
Yifan Honga9993572017-01-24 19:33:15 -0800432} // namespace vintf
433} // namespace android
434
Yifan Hong676447a2016-11-15 12:57:23 -0800435int main(int argc, char **argv) {
436 ::testing::InitGoogleTest(&argc, argv);
437 return RUN_ALL_TESTS();
438}