summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2017-08-28 02:36:46 -0500
committerandroid-build-team Robot2017-08-28 02:36:46 -0500
commit97152a35dad0896acc8554307d5f3e383500e044 (patch)
tree0e530fcdfc9cad6b0a0387b22f9477e707ba77c5
parentf4cc7d50905f972e573594c7484d4d0607e49518 (diff)
parent56ca3bf6179a9c2efcc772ac42ba880b4fd3bb59 (diff)
downloadplatform-system-libvintf-97152a35dad0896acc8554307d5f3e383500e044.tar.gz
platform-system-libvintf-97152a35dad0896acc8554307d5f3e383500e044.tar.xz
platform-system-libvintf-97152a35dad0896acc8554307d5f3e383500e044.zip
release-request-c924aaac-f0a2-4215-8dc4-e314f22460d9-for-git_oc-mr1-release-4301796 snap-temp-L23200000097143969
Change-Id: I9266fe874d08f4ed61b01eadd9360f52c13bc716
-rw-r--r--CompatibilityMatrix.cpp13
-rw-r--r--RuntimeInfo.cpp90
-rw-r--r--assemble_vintf.cpp2
-rw-r--r--include/vintf/CompatibilityMatrix.h3
-rw-r--r--include/vintf/MatrixKernel.h11
-rw-r--r--include/vintf/RuntimeInfo.h10
-rw-r--r--parse_xml.cpp36
-rw-r--r--test/main.cpp367
8 files changed, 487 insertions, 45 deletions
diff --git a/CompatibilityMatrix.cpp b/CompatibilityMatrix.cpp
index 509ca1d..f320861 100644
--- a/CompatibilityMatrix.cpp
+++ b/CompatibilityMatrix.cpp
@@ -36,19 +36,6 @@ bool CompatibilityMatrix::add(MatrixKernel &&kernel) {
36 return true; 36 return true;
37} 37}
38 38
39const MatrixKernel *CompatibilityMatrix::findKernel(const KernelVersion &v) const {
40 if (mType != SchemaType::FRAMEWORK) {
41 return nullptr;
42 }
43 for (const MatrixKernel &matrixKernel : framework.mKernels) {
44 if (matrixKernel.minLts().version == v.version &&
45 matrixKernel.minLts().majorRev == v.majorRev) {
46 return matrixKernel.minLts().minorRev <= v.minorRev ? &matrixKernel : nullptr;
47 }
48 }
49 return nullptr;
50}
51
52SchemaType CompatibilityMatrix::type() const { 39SchemaType CompatibilityMatrix::type() const {
53 return mType; 40 return mType;
54} 41}
diff --git a/RuntimeInfo.cpp b/RuntimeInfo.cpp
index b29a146..0bcb363 100644
--- a/RuntimeInfo.cpp
+++ b/RuntimeInfo.cpp
@@ -69,6 +69,38 @@ const Version &RuntimeInfo::bootAvbVersion() const {
69 return mBootAvbVersion; 69 return mBootAvbVersion;
70} 70}
71 71
72bool RuntimeInfo::matchKernelConfigs(const std::vector<KernelConfig>& matrixConfigs,
73 std::string* error) const {
74 for (const KernelConfig& matrixConfig : matrixConfigs) {
75 const std::string& key = matrixConfig.first;
76 auto it = this->mKernelConfigs.find(key);
77 if (it == this->mKernelConfigs.end()) {
78 // special case: <value type="tristate">n</value> matches if the config doesn't exist.
79 if (matrixConfig.second == KernelConfigTypedValue::gMissingConfig) {
80 continue;
81 }
82 if (error != nullptr) {
83 *error = "Missing config " + key;
84 }
85 return false;
86 }
87 const std::string& kernelValue = it->second;
88 if (!matrixConfig.second.matchValue(kernelValue)) {
89 if (error != nullptr) {
90 *error = "For config " + key + ", value = " + kernelValue + " but required " +
91 to_string(matrixConfig.second);
92 }
93 return false;
94 }
95 }
96 return true;
97}
98
99bool RuntimeInfo::matchKernelVersion(const KernelVersion& minLts) const {
100 return minLts.version == mKernelVersion.version && minLts.majorRev == mKernelVersion.majorRev &&
101 minLts.minorRev <= mKernelVersion.minorRev;
102}
103
72bool RuntimeInfo::checkCompatibility(const CompatibilityMatrix &mat, 104bool RuntimeInfo::checkCompatibility(const CompatibilityMatrix &mat,
73 std::string *error) const { 105 std::string *error) const {
74 if (mat.mType != SchemaType::FRAMEWORK) { 106 if (mat.mType != SchemaType::FRAMEWORK) {
@@ -86,36 +118,46 @@ bool RuntimeInfo::checkCompatibility(const CompatibilityMatrix &mat,
86 return false; 118 return false;
87 } 119 }
88 120
89 // mat.mSepolicy.sepolicyVersion() is checked against static HalManifest.device.mSepolicyVersion 121 // mat.mSepolicy.sepolicyVersion() is checked against static
122 // HalManifest.device.mSepolicyVersion in HalManifest::checkCompatibility.
90 123
91 const MatrixKernel *matrixKernel = mat.findKernel(this->mKernelVersion); 124 bool foundMatchedKernelVersion = false;
92 if (matrixKernel == nullptr) { 125 bool foundMatchedConditions = false;
126 for (const MatrixKernel& matrixKernel : mat.framework.mKernels) {
127 if (!matchKernelVersion(matrixKernel.minLts())) {
128 continue;
129 }
130 foundMatchedKernelVersion = true;
131 // ignore this fragment if not all conditions are met.
132 if (!matchKernelConfigs(matrixKernel.conditions(), error)) {
133 continue;
134 }
135 foundMatchedConditions = true;
136 if (!matchKernelConfigs(matrixKernel.configs(), error)) {
137 return false;
138 }
139 }
140 if (!foundMatchedKernelVersion) {
93 if (error != nullptr) { 141 if (error != nullptr) {
94 *error = "Cannot find suitable kernel entry for " + to_string(mKernelVersion); 142 std::stringstream ss;
143 ss << "Framework is incompatible with kernel version " << mKernelVersion
144 << ", compatible kernel versions are";
145 for (const MatrixKernel& matrixKernel : mat.framework.mKernels)
146 ss << " " << matrixKernel.minLts();
147 *error = ss.str();
95 } 148 }
96 return false; 149 return false;
97 } 150 }
98 for (const KernelConfig &matrixConfig : matrixKernel->configs()) { 151 if (!foundMatchedConditions) {
99 const std::string &key = matrixConfig.first; 152 // This should not happen because first <conditions> for each <kernel> must be
100 auto it = this->mKernelConfigs.find(key); 153 // empty. Reject here for inconsistency.
101 if (it == this->mKernelConfigs.end()) { 154 if (error != nullptr) {
102 // special case: <value type="tristate">n</value> matches if the config doesn't exist. 155 error->insert(0, "Framework match kernel version with unmet conditions:");
103 if (matrixConfig.second == KernelConfigTypedValue::gMissingConfig) {
104 continue;
105 }
106 if (error != nullptr) {
107 *error = "Missing config " + key;
108 }
109 return false;
110 }
111 const std::string &kernelValue = it->second;
112 if (!matrixConfig.second.matchValue(kernelValue)) {
113 if (error != nullptr) {
114 *error = "For config " + key + ", value = " + kernelValue
115 + " but required " + to_string(matrixConfig.second);
116 }
117 return false;
118 } 156 }
157 return false;
158 }
159 if (error != nullptr) {
160 error->clear();
119 } 161 }
120 162
121 const Version &matAvb = mat.framework.mAvbMetaVersion; 163 const Version &matAvb = mat.framework.mAvbMetaVersion;
diff --git a/assemble_vintf.cpp b/assemble_vintf.cpp
index cbfc368..d75e889 100644
--- a/assemble_vintf.cpp
+++ b/assemble_vintf.cpp
@@ -102,6 +102,7 @@ public:
102 ret &= parseFileForKernelConfigs(pathIter, out); 102 ret &= parseFileForKernelConfigs(pathIter, out);
103 pathIter = strtok(NULL, ":"); 103 pathIter = strtok(NULL, ":");
104 } 104 }
105 delete[] modPath;
105 return ret; 106 return ret;
106 } 107 }
107 108
@@ -423,4 +424,3 @@ int main(int argc, char **argv) {
423 424
424 return success ? 0 : 1; 425 return success ? 0 : 1;
425} 426}
426
diff --git a/include/vintf/CompatibilityMatrix.h b/include/vintf/CompatibilityMatrix.h
index 94b8004..36aac51 100644
--- a/include/vintf/CompatibilityMatrix.h
+++ b/include/vintf/CompatibilityMatrix.h
@@ -58,9 +58,6 @@ struct CompatibilityMatrix : public HalGroup<MatrixHal>, public XmlFileGroup<Mat
58 bool add(MatrixHal &&hal); 58 bool add(MatrixHal &&hal);
59 bool add(MatrixKernel &&kernel); 59 bool add(MatrixKernel &&kernel);
60 60
61 // Find a MatrixKernel entry that has version v. nullptr if not found.
62 const MatrixKernel *findKernel(const KernelVersion &v) const;
63
64 status_t fetchAllInformation(const std::string &path); 61 status_t fetchAllInformation(const std::string &path);
65 62
66 friend struct HalManifest; 63 friend struct HalManifest;
diff --git a/include/vintf/MatrixKernel.h b/include/vintf/MatrixKernel.h
index 4b261a6..f0990a8 100644
--- a/include/vintf/MatrixKernel.h
+++ b/include/vintf/MatrixKernel.h
@@ -35,7 +35,8 @@ struct KernelConfigKey : public std::string {
35 35
36using KernelConfig = std::pair<KernelConfigKey, KernelConfigTypedValue>; 36using KernelConfig = std::pair<KernelConfigKey, KernelConfigTypedValue>;
37 37
38// A kernel entry to a compatibility matrix 38// A <kernel> entry to a compatibility matrix represents a fragment of kernel
39// config requirements.
39struct MatrixKernel { 40struct MatrixKernel {
40 41
41 MatrixKernel() {} 42 MatrixKernel() {}
@@ -50,12 +51,18 @@ struct MatrixKernel {
50 // for (const KernelConfig &config : kernel.configs()) {...} 51 // for (const KernelConfig &config : kernel.configs()) {...}
51 const std::vector<KernelConfig> &configs() const { return mConfigs; } 52 const std::vector<KernelConfig> &configs() const { return mConfigs; }
52 53
53private: 54 // Return an iterable on all kernel config conditions. Use it as follows:
55 // for (const KernelConfig &config : kernel.conditions()) {...}
56 const std::vector<KernelConfig>& conditions() const { return mConditions; }
57
58 private:
54 friend struct MatrixKernelConverter; 59 friend struct MatrixKernelConverter;
60 friend struct MatrixKernelConditionsConverter;
55 friend class AssembleVintf; 61 friend class AssembleVintf;
56 62
57 KernelVersion mMinLts; 63 KernelVersion mMinLts;
58 std::vector<KernelConfig> mConfigs; 64 std::vector<KernelConfig> mConfigs;
65 std::vector<KernelConfig> mConditions;
59}; 66};
60 67
61} // namespace vintf 68} // namespace vintf
diff --git a/include/vintf/RuntimeInfo.h b/include/vintf/RuntimeInfo.h
index 4e34f64..6b510fb 100644
--- a/include/vintf/RuntimeInfo.h
+++ b/include/vintf/RuntimeInfo.h
@@ -25,6 +25,9 @@
25 25
26#include <utils/Errors.h> 26#include <utils/Errors.h>
27 27
28#include "MatrixKernel.h"
29#include "Version.h"
30
28namespace android { 31namespace android {
29namespace vintf { 32namespace vintf {
30 33
@@ -79,6 +82,13 @@ private:
79 82
80 status_t fetchAllInformation(); 83 status_t fetchAllInformation();
81 84
85 // mKernelVersion = x'.y'.z', minLts = x.y.z,
86 // match if x == x' , y == y' , and z <= z'.
87 bool matchKernelVersion(const KernelVersion& minLts) const;
88 // return true if all kernel configs in matrixConfigs matches.
89 bool matchKernelConfigs(const std::vector<KernelConfig>& matrixConfigs,
90 std::string* error = nullptr) const;
91
82 // /proc/config.gz 92 // /proc/config.gz
83 // Key: CONFIG_xxx; Value: the value after = sign. 93 // Key: CONFIG_xxx; Value: the value after = sign.
84 std::map<std::string, std::string> mKernelConfigs; 94 std::map<std::string, std::string> mKernelConfigs;
diff --git a/parse_xml.cpp b/parse_xml.cpp
index 5239275..3e495fd 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -244,8 +244,8 @@ struct XmlNodeConverter : public XmlConverter<Object> {
244 std::string attrText; 244 std::string attrText;
245 bool ret = getAttr(root, attrName, &attrText) && ::android::vintf::parse(attrText, attr); 245 bool ret = getAttr(root, attrName, &attrText) && ::android::vintf::parse(attrText, attr);
246 if (!ret) { 246 if (!ret) {
247 mLastError = "Could not find/parse attr with name \"" + attrName + "\" for element <" 247 mLastError = "Could not find/parse attr with name \"" + attrName + "\" and value \"" +
248 + elementName() + ">"; 248 attrText + "\" for element <" + elementName() + ">";
249 } 249 }
250 return ret; 250 return ret;
251 } 251 }
@@ -549,14 +549,31 @@ struct MatrixHalConverter : public XmlNodeConverter<MatrixHal> {
549 549
550const MatrixHalConverter matrixHalConverter{}; 550const MatrixHalConverter matrixHalConverter{};
551 551
552struct MatrixKernelConditionsConverter : public XmlNodeConverter<std::vector<KernelConfig>> {
553 std::string elementName() const override { return "conditions"; }
554 void mutateNode(const std::vector<KernelConfig>& conds, NodeType* root,
555 DocType* d) const override {
556 appendChildren(root, kernelConfigConverter, conds, d);
557 }
558 bool buildObject(std::vector<KernelConfig>* object, NodeType* root) const override {
559 return parseChildren(root, kernelConfigConverter, object);
560 }
561};
562
563const MatrixKernelConditionsConverter matrixKernelConditionsConverter{};
564
552struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> { 565struct MatrixKernelConverter : public XmlNodeConverter<MatrixKernel> {
553 std::string elementName() const override { return "kernel"; } 566 std::string elementName() const override { return "kernel"; }
554 void mutateNode(const MatrixKernel &kernel, NodeType *root, DocType *d) const override { 567 void mutateNode(const MatrixKernel &kernel, NodeType *root, DocType *d) const override {
555 appendAttr(root, "version", kernel.mMinLts); 568 appendAttr(root, "version", kernel.mMinLts);
569 if (!kernel.mConditions.empty()) {
570 appendChild(root, matrixKernelConditionsConverter(kernel.mConditions, d));
571 }
556 appendChildren(root, kernelConfigConverter, kernel.mConfigs, d); 572 appendChildren(root, kernelConfigConverter, kernel.mConfigs, d);
557 } 573 }
558 bool buildObject(MatrixKernel *object, NodeType *root) const override { 574 bool buildObject(MatrixKernel *object, NodeType *root) const override {
559 if (!parseAttr(root, "version", &object->mMinLts) || 575 if (!parseAttr(root, "version", &object->mMinLts) ||
576 !parseOptionalChild(root, matrixKernelConditionsConverter, {}, &object->mConditions) ||
560 !parseChildren(root, kernelConfigConverter, &object->mConfigs)) { 577 !parseChildren(root, kernelConfigConverter, &object->mConfigs)) {
561 return false; 578 return false;
562 } 579 }
@@ -870,6 +887,21 @@ struct CompatibilityMatrixConverter : public XmlNodeConverter<CompatibilityMatri
870 !parseOptionalChild(root, avbConverter, {}, &object->framework.mAvbMetaVersion)) { 887 !parseOptionalChild(root, avbConverter, {}, &object->framework.mAvbMetaVersion)) {
871 return false; 888 return false;
872 } 889 }
890
891 std::set<Version> seenKernelVersions;
892 for (const auto& kernel : object->framework.mKernels) {
893 Version minLts(kernel.minLts().version, kernel.minLts().majorRev);
894 if (seenKernelVersions.find(minLts) != seenKernelVersions.end()) {
895 continue;
896 }
897 if (!kernel.conditions().empty()) {
898 this->mLastError = "First <kernel> for version " + to_string(minLts) +
899 " must have empty <conditions> for backwards compatibility.";
900 return false;
901 }
902 seenKernelVersions.insert(minLts);
903 }
904
873 } else if (object->mType == SchemaType::DEVICE) { 905 } else if (object->mType == SchemaType::DEVICE) {
874 // <vndk> can be missing because it can be determined at build time, not hard-coded 906 // <vndk> can be missing because it can be determined at build time, not hard-coded
875 // in the XML file. 907 // in the XML file.
diff --git a/test/main.cpp b/test/main.cpp
index d8cfaf3..94a4d8e 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -100,6 +100,7 @@ public:
100 bool isValid(const ManifestHal &mh) { 100 bool isValid(const ManifestHal &mh) {
101 return mh.isValid(); 101 return mh.isValid();
102 } 102 }
103 std::vector<MatrixKernel>& getKernels(CompatibilityMatrix& cm) { return cm.framework.mKernels; }
103 104
104 std::map<std::string, HalInterface> testHalInterfaces() { 105 std::map<std::string, HalInterface> testHalInterfaces() {
105 HalInterface intf; 106 HalInterface intf;
@@ -709,6 +710,12 @@ TEST_F(LibVintfTest, RuntimeInfo) {
709 } 710 }
710 711
711 { 712 {
713 MatrixKernel kernel(KernelVersion{3, 18, 60}, KernelConfigs(configs));
714 CompatibilityMatrix cm = testMatrix(std::move(kernel));
715 EXPECT_FALSE(ki.checkCompatibility(cm)) << "Kernel version shouldn't match";
716 }
717
718 {
712 MatrixKernel kernel(KernelVersion{3, 18, 22}, KernelConfigs(configs)); 719 MatrixKernel kernel(KernelVersion{3, 18, 22}, KernelConfigs(configs));
713 CompatibilityMatrix cm = testMatrix(std::move(kernel)); 720 CompatibilityMatrix cm = testMatrix(std::move(kernel));
714 EXPECT_TRUE(ki.checkCompatibility(cm, &error)) << error; 721 EXPECT_TRUE(ki.checkCompatibility(cm, &error)) << error;
@@ -1534,6 +1541,366 @@ TEST_F(LibVintfTest, NetutilsWrapperManifest) {
1534#endif // LIBVINTF_HOST 1541#endif // LIBVINTF_HOST
1535} 1542}
1536 1543
1544TEST_F(LibVintfTest, KernelConfigConditionTest) {
1545 std::string xml =
1546 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1547 " <kernel version=\"3.18.22\"/>\n"
1548 " <kernel version=\"3.18.22\">\n"
1549 " <conditions>\n"
1550 " <config>\n"
1551 " <key>CONFIG_ARM</key>\n"
1552 " <value type=\"tristate\">y</value>\n"
1553 " </config>\n"
1554 " </conditions>\n"
1555 " <config>\n"
1556 " <key>CONFIG_FOO</key>\n"
1557 " <value type=\"tristate\">y</value>\n"
1558 " </config>\n"
1559 " </kernel>\n"
1560 " <sepolicy>\n"
1561 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1562 " <sepolicy-version>25.0</sepolicy-version>\n"
1563 " </sepolicy>\n"
1564 " <avb>\n"
1565 " <vbmeta-version>2.1</vbmeta-version>\n"
1566 " </avb>\n"
1567 "</compatibility-matrix>\n";
1568
1569 CompatibilityMatrix cm;
1570 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1571 << gCompatibilityMatrixConverter.lastError();
1572 const auto& kernels = getKernels(cm);
1573 ASSERT_GE(kernels.size(), 2u);
1574 ASSERT_TRUE(kernels[0].conditions().empty());
1575 const auto& kernel = kernels[1];
1576 const auto& cond = kernel.conditions();
1577 ASSERT_FALSE(cond.empty());
1578 EXPECT_EQ("CONFIG_ARM", cond.begin()->first);
1579 EXPECT_EQ(KernelConfigTypedValue(Tristate::YES), cond.begin()->second);
1580 EXPECT_FALSE(kernel.configs().empty());
1581
1582 EXPECT_EQ(xml, gCompatibilityMatrixConverter(cm));
1583}
1584
1585TEST_F(LibVintfTest, KernelConfigConditionEmptyTest) {
1586 std::string xml =
1587 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1588 " <kernel version=\"4.4.0\"/>\n"
1589 " <kernel version=\"3.18.22\">\n"
1590 " <conditions>\n"
1591 " <config>\n"
1592 " <key>CONFIG_ARM</key>\n"
1593 " <value type=\"tristate\">y</value>\n"
1594 " </config>\n"
1595 " </conditions>\n"
1596 " </kernel>\n"
1597 "</compatibility-matrix>\n";
1598
1599 CompatibilityMatrix cm;
1600 EXPECT_FALSE(gCompatibilityMatrixConverter(&cm, xml))
1601 << "Should not accept first kernel version with non-empty conditions";
1602 EXPECT_EQ(
1603 "First <kernel> for version 3.18 must have empty <conditions> "
1604 "for backwards compatibility.",
1605 gCompatibilityMatrixConverter.lastError());
1606}
1607
1608TEST_F(LibVintfTest, KernelConfigConditionMatch) {
1609 RuntimeInfo runtime = testRuntimeInfo();
1610 std::string error;
1611 std::string xml;
1612 CompatibilityMatrix cm;
1613
1614 xml =
1615 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1616 " <kernel version=\"3.18.22\"/>\n"
1617 " <kernel version=\"3.18.22\">\n"
1618 " <conditions>\n"
1619 " <config>\n"
1620 " <key>CONFIG_64BIT</key>\n"
1621 " <value type=\"tristate\">y</value>\n"
1622 " </config>\n"
1623 " </conditions>\n"
1624 " <config>\n"
1625 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1626 " <value type=\"int\">24</value>\n"
1627 " </config>\n"
1628 " </kernel>\n"
1629 " <sepolicy>\n"
1630 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1631 " </sepolicy>\n"
1632 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1633 "</compatibility-matrix>\n";
1634
1635 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1636 << gCompatibilityMatrixConverter.lastError();
1637 EXPECT_TRUE(runtime.checkCompatibility(cm, &error)) << error;
1638
1639 xml =
1640 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1641 " <kernel version=\"3.18.22\"/>\n"
1642 " <kernel version=\"3.18.22\">\n"
1643 " <conditions>\n"
1644 " <config>\n"
1645 " <key>CONFIG_64BIT</key>\n"
1646 " <value type=\"tristate\">y</value>\n"
1647 " </config>\n"
1648 " </conditions>\n"
1649 " <config>\n"
1650 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1651 " <value type=\"int\">26</value>\n"
1652 " </config>\n"
1653 " </kernel>\n"
1654 " <sepolicy>\n"
1655 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1656 " </sepolicy>\n"
1657 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1658 "</compatibility-matrix>\n";
1659
1660 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1661 << gCompatibilityMatrixConverter.lastError();
1662 EXPECT_FALSE(runtime.checkCompatibility(cm, &error))
1663 << "conditions met, so CONFIG_ARCH_MMAP_RND_BITS should not match";
1664
1665 xml =
1666 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1667 " <kernel version=\"3.18.22\"/>\n"
1668 " <kernel version=\"3.18.22\">\n"
1669 " <conditions>\n"
1670 " <config>\n"
1671 " <key>CONFIG_64BIT</key>\n"
1672 " <value type=\"tristate\">n</value>\n"
1673 " </config>\n"
1674 " </conditions>\n"
1675 " <config>\n"
1676 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1677 " <value type=\"int\">26</value>\n"
1678 " </config>\n"
1679 " </kernel>\n"
1680 " <sepolicy>\n"
1681 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1682 " </sepolicy>\n"
1683 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1684 "</compatibility-matrix>\n";
1685
1686 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1687 << gCompatibilityMatrixConverter.lastError();
1688 EXPECT_TRUE(runtime.checkCompatibility(cm, &error)) << error;
1689 xml =
1690 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1691 " <kernel version=\"3.18.22\"/>\n"
1692 " <kernel version=\"3.18.22\">\n"
1693 " <conditions>\n"
1694 " <config>\n"
1695 " <key>CONFIG_64BIT</key>\n"
1696 " <value type=\"tristate\">y</value>\n"
1697 " </config>\n"
1698 " <config>\n"
1699 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1700 " <value type=\"int\">24</value>\n"
1701 " </config>\n"
1702 " </conditions>\n"
1703 " <config>\n"
1704 " <key>CONFIG_ILLEGAL_POINTER_VALUE</key>\n"
1705 " <value type=\"int\">0xdead000000000000</value>\n"
1706 " </config>\n"
1707 " </kernel>\n"
1708 " <sepolicy>\n"
1709 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1710 " </sepolicy>\n"
1711 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1712 "</compatibility-matrix>\n";
1713
1714 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1715 << gCompatibilityMatrixConverter.lastError();
1716 EXPECT_TRUE(runtime.checkCompatibility(cm, &error));
1717
1718 xml =
1719 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1720 " <kernel version=\"3.18.22\"/>\n"
1721 " <kernel version=\"3.18.22\">\n"
1722 " <conditions>\n"
1723 " <config>\n"
1724 " <key>CONFIG_64BIT</key>\n"
1725 " <value type=\"tristate\">y</value>\n"
1726 " </config>\n"
1727 " <config>\n"
1728 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1729 " <value type=\"int\">24</value>\n"
1730 " </config>\n"
1731 " </conditions>\n"
1732 " <config>\n"
1733 " <key>CONFIG_ILLEGAL_POINTER_VALUE</key>\n"
1734 " <value type=\"int\">0xbeaf000000000000</value>\n"
1735 " </config>\n"
1736 " </kernel>\n"
1737 " <sepolicy>\n"
1738 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1739 " </sepolicy>\n"
1740 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1741 "</compatibility-matrix>\n";
1742
1743 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1744 << gCompatibilityMatrixConverter.lastError();
1745 EXPECT_FALSE(runtime.checkCompatibility(cm, &error))
1746 << "conditions have 'and' relationship, so CONFIG_ILLEGAL_POINTER_VALUE should not match";
1747
1748 xml =
1749 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1750 " <kernel version=\"3.18.22\"/>\n"
1751 " <kernel version=\"3.18.22\">\n"
1752 " <conditions>\n"
1753 " <config>\n"
1754 " <key>CONFIG_64BIT</key>\n"
1755 " <value type=\"tristate\">y</value>\n"
1756 " </config>\n"
1757 " <config>\n"
1758 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1759 " <value type=\"int\">26</value>\n"
1760 " </config>\n"
1761 " </conditions>\n"
1762 " <config>\n"
1763 " <key>CONFIG_ILLEGAL_POINTER_VALUE</key>\n"
1764 " <value type=\"int\">0xbeaf000000000000</value>\n"
1765 " </config>\n"
1766 " </kernel>\n"
1767 " <sepolicy>\n"
1768 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1769 " </sepolicy>\n"
1770 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1771 "</compatibility-matrix>\n";
1772
1773 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1774 << gCompatibilityMatrixConverter.lastError();
1775 EXPECT_TRUE(runtime.checkCompatibility(cm, &error)) << error;
1776
1777 xml =
1778 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1779 " <kernel version=\"3.18.22\">\n"
1780 " <config>\n"
1781 " <key>CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES</key>\n"
1782 " <value type=\"string\"/>\n"
1783 " </config>\n"
1784 " </kernel>\n"
1785 " <kernel version=\"3.18.22\">\n"
1786 " <conditions>\n"
1787 " <config>\n"
1788 " <key>CONFIG_64BIT</key>\n"
1789 " <value type=\"tristate\">y</value>\n"
1790 " </config>\n"
1791 " </conditions>\n"
1792 " <config>\n"
1793 " <key>CONFIG_ILLEGAL_POINTER_VALUE</key>\n"
1794 " <value type=\"int\">0xdead000000000000</value>\n"
1795 " </config>\n"
1796 " </kernel>\n"
1797 " <kernel version=\"3.18.22\">\n"
1798 " <conditions>\n"
1799 " <config>\n"
1800 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1801 " <value type=\"int\">24</value>\n"
1802 " </config>\n"
1803 " </conditions>\n"
1804 " <config>\n"
1805 " <key>CONFIG_ANDROID_BINDER_DEVICES</key>\n"
1806 " <value type=\"string\">binder,hwbinder</value>\n"
1807 " </config>\n"
1808 " </kernel>\n"
1809 " <sepolicy>\n"
1810 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1811 " </sepolicy>\n"
1812 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1813 "</compatibility-matrix>\n";
1814
1815 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1816 << gCompatibilityMatrixConverter.lastError();
1817 EXPECT_TRUE(runtime.checkCompatibility(cm, &error)) << error;
1818
1819 xml =
1820 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1821 " <kernel version=\"3.18.22\">\n"
1822 " <config>\n"
1823 " <key>CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES</key>\n"
1824 " <value type=\"string\"/>\n"
1825 " </config>\n"
1826 " </kernel>\n"
1827 " <kernel version=\"3.18.22\">\n"
1828 " <conditions>\n"
1829 " <config>\n"
1830 " <key>CONFIG_64BIT</key>\n"
1831 " <value type=\"tristate\">y</value>\n"
1832 " </config>\n"
1833 " </conditions>\n"
1834 " <config>\n"
1835 " <key>CONFIG_ILLEGAL_POINTER_VALUE</key>\n"
1836 " <value type=\"int\">0xbeaf000000000000</value>\n"
1837 " </config>\n"
1838 " </kernel>\n"
1839 " <kernel version=\"3.18.22\">\n"
1840 " <conditions>\n"
1841 " <config>\n"
1842 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1843 " <value type=\"int\">24</value>\n"
1844 " </config>\n"
1845 " </conditions>\n"
1846 " <config>\n"
1847 " <key>CONFIG_ANDROID_BINDER_DEVICES</key>\n"
1848 " <value type=\"string\">binder,hwbinder</value>\n"
1849 " </config>\n"
1850 " </kernel>\n"
1851 " <sepolicy>\n"
1852 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1853 " </sepolicy>\n"
1854 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1855 "</compatibility-matrix>\n";
1856
1857 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1858 << gCompatibilityMatrixConverter.lastError();
1859 EXPECT_FALSE(runtime.checkCompatibility(cm, &error)) << "all fragments should be used.";
1860
1861 xml =
1862 "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
1863 " <kernel version=\"3.18.22\">\n"
1864 " <config>\n"
1865 " <key>CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES</key>\n"
1866 " <value type=\"string\"/>\n"
1867 " </config>\n"
1868 " </kernel>\n"
1869 " <kernel version=\"3.18.22\">\n"
1870 " <conditions>\n"
1871 " <config>\n"
1872 " <key>CONFIG_64BIT</key>\n"
1873 " <value type=\"tristate\">y</value>\n"
1874 " </config>\n"
1875 " </conditions>\n"
1876 " <config>\n"
1877 " <key>CONFIG_ILLEGAL_POINTER_VALUE</key>\n"
1878 " <value type=\"int\">0xdead000000000000</value>\n"
1879 " </config>\n"
1880 " </kernel>\n"
1881 " <kernel version=\"3.18.22\">\n"
1882 " <conditions>\n"
1883 " <config>\n"
1884 " <key>CONFIG_ARCH_MMAP_RND_BITS</key>\n"
1885 " <value type=\"int\">24</value>\n"
1886 " </config>\n"
1887 " </conditions>\n"
1888 " <config>\n"
1889 " <key>CONFIG_ANDROID_BINDER_DEVICES</key>\n"
1890 " <value type=\"string\">binder</value>\n"
1891 " </config>\n"
1892 " </kernel>\n"
1893 " <sepolicy>\n"
1894 " <kernel-sepolicy-version>30</kernel-sepolicy-version>\n"
1895 " </sepolicy>\n"
1896 " <avb><vbmeta-version>2.1</vbmeta-version></avb>\n"
1897 "</compatibility-matrix>\n";
1898
1899 EXPECT_TRUE(gCompatibilityMatrixConverter(&cm, xml))
1900 << gCompatibilityMatrixConverter.lastError();
1901 EXPECT_FALSE(runtime.checkCompatibility(cm, &error)) << "all fragments should be used";
1902}
1903
1537// Run KernelConfigParserInvalidTest on processComments = {true, false} 1904// Run KernelConfigParserInvalidTest on processComments = {true, false}
1538class KernelConfigParserInvalidTest : public ::testing::TestWithParam<bool> {}; 1905class KernelConfigParserInvalidTest : public ::testing::TestWithParam<bool> {};
1539 1906