summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-02-05 02:20:33 -0600
committerandroid-build-team Robot2018-02-05 02:20:33 -0600
commite03c5168e8b168d48c52a0e2e8ffcd2a54ca74c6 (patch)
treef1828e361c11ed4cac84ef68280eeb542bb4d2e2
parent3b8ad86ff726eb9cefadab2725458510d3771189 (diff)
parent8dc9be49a0b77b3c164c47eb6c8d88c57b65deed (diff)
downloadplatform-system-libvintf-e03c5168e8b168d48c52a0e2e8ffcd2a54ca74c6.tar.gz
platform-system-libvintf-e03c5168e8b168d48c52a0e2e8ffcd2a54ca74c6.tar.xz
platform-system-libvintf-e03c5168e8b168d48c52a0e2e8ffcd2a54ca74c6.zip
Snap for 4585119 from 8dc9be49a0b77b3c164c47eb6c8d88c57b65deed to pi-release
Change-Id: I1425589f63a868c5b3a7ebf9d5d4ece648132086
-rw-r--r--Android.bp3
-rw-r--r--parse_xml.cpp18
-rw-r--r--test/Android.bp6
-rw-r--r--test/LibVintfTest.cpp27
4 files changed, 39 insertions, 15 deletions
diff --git a/Android.bp b/Android.bp
index 8a11dab..375246c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -67,9 +67,6 @@ cc_library {
67 srcs: [ 67 srcs: [
68 "RuntimeInfo-host.cpp" 68 "RuntimeInfo-host.cpp"
69 ], 69 ],
70 cflags: [
71 "-DLIBVINTF_HOST",
72 ],
73 }, 70 },
74 android: { 71 android: {
75 shared_libs: [ 72 shared_libs: [
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 5900f27..7abbc55 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -513,7 +513,7 @@ struct MatrixHalConverter : public XmlNodeConverter<MatrixHal> {
513 } 513 }
514 } 514 }
515// Do not check for target-side libvintf to avoid restricting ability for upgrade accidentally. 515// Do not check for target-side libvintf to avoid restricting ability for upgrade accidentally.
516#ifdef LIBVINTF_HOST 516#ifndef LIBVINTF_TARGET
517 if (!checkAdditionalRestrictionsOnHal(*object)) { 517 if (!checkAdditionalRestrictionsOnHal(*object)) {
518 return false; 518 return false;
519 } 519 }
@@ -521,7 +521,7 @@ struct MatrixHalConverter : public XmlNodeConverter<MatrixHal> {
521 return true; 521 return true;
522 } 522 }
523 523
524#ifdef LIBVINTF_HOST 524#ifndef LIBVINTF_TARGET
525 private: 525 private:
526 bool checkAdditionalRestrictionsOnHal(const MatrixHal& hal) const { 526 bool checkAdditionalRestrictionsOnHal(const MatrixHal& hal) const {
527 if (hal.getName() == "netutils-wrapper") { 527 if (hal.getName() == "netutils-wrapper") {
@@ -650,7 +650,7 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
650 return false; 650 return false;
651 } 651 }
652// Do not check for target-side libvintf to avoid restricting upgrade accidentally. 652// Do not check for target-side libvintf to avoid restricting upgrade accidentally.
653#ifdef LIBVINTF_HOST 653#ifndef LIBVINTF_TARGET
654 if (!checkAdditionalRestrictionsOnHal(*object)) { 654 if (!checkAdditionalRestrictionsOnHal(*object)) {
655 return false; 655 return false;
656 } 656 }
@@ -658,7 +658,7 @@ struct ManifestHalConverter : public XmlNodeConverter<ManifestHal> {
658 return true; 658 return true;
659 } 659 }
660 660
661#ifdef LIBVINTF_HOST 661#ifndef LIBVINTF_TARGET
662 private: 662 private:
663 bool checkAdditionalRestrictionsOnHal(const ManifestHal& hal) const { 663 bool checkAdditionalRestrictionsOnHal(const ManifestHal& hal) const {
664 if (hal.getName() == "netutils-wrapper") { 664 if (hal.getName() == "netutils-wrapper") {
@@ -866,6 +866,16 @@ struct HalManifestConverter : public XmlNodeConverter<HalManifest> {
866 return false; 866 return false;
867 } 867 }
868 868
869 std::set<std::string> vendorNdkVersions;
870 for (const auto& vendorNdk : object->framework.mVendorNdks) {
871 if (vendorNdkVersions.find(vendorNdk.version()) != vendorNdkVersions.end()) {
872 this->mLastError =
873 "Duplicated manifest.vendor-ndk.version " + vendorNdk.version();
874 return false;
875 }
876 vendorNdkVersions.insert(vendorNdk.version());
877 }
878
869 if (!parseOptionalChild(root, systemSdkConverter, {}, &object->framework.mSystemSdk)) { 879 if (!parseOptionalChild(root, systemSdkConverter, {}, &object->framework.mSystemSdk)) {
870 return false; 880 return false;
871 } 881 }
diff --git a/test/Android.bp b/test/Android.bp
index d2121c6..6777ca3 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -39,9 +39,9 @@ cc_test {
39 "-Wno-deprecated-declarations", 39 "-Wno-deprecated-declarations",
40 ], 40 ],
41 target: { 41 target: {
42 host: { 42 android: {
43 cflags: ["-DLIBVINTF_HOST"], 43 cflags: ["-DLIBVINTF_TARGET"],
44 } 44 },
45 } 45 }
46} 46}
47 47
diff --git a/test/LibVintfTest.cpp b/test/LibVintfTest.cpp
index e7a609a..ef19a4c 100644
--- a/test/LibVintfTest.cpp
+++ b/test/LibVintfTest.cpp
@@ -44,7 +44,7 @@ static bool In(const std::string& sub, const std::string& str) {
44} 44}
45#define EXPECT_IN(sub, str) EXPECT_TRUE(In((sub), (str))) << (str); 45#define EXPECT_IN(sub, str) EXPECT_TRUE(In((sub), (str))) << (str);
46 46
47#ifdef LIBVINTF_HOST 47#ifndef LIBVINTF_TARGET
48#define EXPECT_CONTAINS(str, sub) EXPECT_IN(sub, str); 48#define EXPECT_CONTAINS(str, sub) EXPECT_IN(sub, str);
49#endif 49#endif
50 50
@@ -1598,7 +1598,7 @@ TEST_F(LibVintfTest, NetutilsWrapperMatrix) {
1598 << gCompatibilityMatrixConverter.lastError(); 1598 << gCompatibilityMatrixConverter.lastError();
1599 1599
1600// only host libvintf hardcodes netutils-wrapper version requirements 1600// only host libvintf hardcodes netutils-wrapper version requirements
1601#ifdef LIBVINTF_HOST 1601#ifndef LIBVINTF_TARGET
1602 1602
1603 matrixXml = 1603 matrixXml =
1604 "<compatibility-matrix version=\"1.0\" type=\"device\">" 1604 "<compatibility-matrix version=\"1.0\" type=\"device\">"
@@ -1640,7 +1640,7 @@ TEST_F(LibVintfTest, NetutilsWrapperMatrix) {
1640 "netutils-wrapper HAL must specify exactly one version x.0, but multiple <version> element " 1640 "netutils-wrapper HAL must specify exactly one version x.0, but multiple <version> element "
1641 "is specified."); 1641 "is specified.");
1642 1642
1643#endif // LIBVINTF_HOST 1643#endif // LIBVINTF_TARGET
1644} 1644}
1645 1645
1646TEST_F(LibVintfTest, NetutilsWrapperManifest) { 1646TEST_F(LibVintfTest, NetutilsWrapperManifest) {
@@ -1658,7 +1658,7 @@ TEST_F(LibVintfTest, NetutilsWrapperManifest) {
1658 EXPECT_TRUE(gHalManifestConverter(&manifest, manifestXml)) << gHalManifestConverter.lastError(); 1658 EXPECT_TRUE(gHalManifestConverter(&manifest, manifestXml)) << gHalManifestConverter.lastError();
1659 1659
1660// only host libvintf hardcodes netutils-wrapper version requirements 1660// only host libvintf hardcodes netutils-wrapper version requirements
1661#ifdef LIBVINTF_HOST 1661#ifndef LIBVINTF_TARGET
1662 1662
1663 manifestXml = 1663 manifestXml =
1664 "<manifest version=\"1.0\" type=\"framework\">" 1664 "<manifest version=\"1.0\" type=\"framework\">"
@@ -1687,7 +1687,7 @@ TEST_F(LibVintfTest, NetutilsWrapperManifest) {
1687 "netutils-wrapper HAL must specify exactly one version x.0, but multiple <version> element " 1687 "netutils-wrapper HAL must specify exactly one version x.0, but multiple <version> element "
1688 "is specified."); 1688 "is specified.");
1689 1689
1690#endif // LIBVINTF_HOST 1690#endif // LIBVINTF_TARGET
1691} 1691}
1692 1692
1693TEST_F(LibVintfTest, KernelConfigConditionTest) { 1693TEST_F(LibVintfTest, KernelConfigConditionTest) {
@@ -2410,6 +2410,23 @@ TEST_F(LibVintfTest, MissingVendorNdkInMatrix) {
2410 } 2410 }
2411} 2411}
2412 2412
2413TEST_F(LibVintfTest, DuplicatedVendorNdkVersion) {
2414 std::string error;
2415 HalManifest manifest;
2416 std::string xml =
2417 "<manifest version=\"1.0\" type=\"framework\">\n"
2418 " <vendor-ndk>\n"
2419 " <version>27</version>\n"
2420 " </vendor-ndk>\n"
2421 " <vendor-ndk>\n"
2422 " <version>27</version>\n"
2423 " </vendor-ndk>\n"
2424 "</manifest>\n";
2425
2426 EXPECT_FALSE(gHalManifestConverter(&manifest, xml));
2427 EXPECT_EQ("Duplicated manifest.vendor-ndk.version 27", gHalManifestConverter.lastError());
2428}
2429
2413TEST_F(LibVintfTest, ManifestHalOverride) { 2430TEST_F(LibVintfTest, ManifestHalOverride) {
2414 HalManifest manifest; 2431 HalManifest manifest;
2415 std::string xml = 2432 std::string xml =