Don't require private types in mapping file.
Private types are not visible to vendor/odm policy, so we don't need mapping
entries for them.
We build platform-only public policy .cil file and give it as input to
treble_sepolicy_tests. Using this public policy the test can now figure out if
the newly added type in public or private.
Bug: 116344577
Test: adding public type triggers mapping test failure, adding private type does
not.
Change-Id: I421f335e37274b24aa73109e260653d7b73788b5
diff --git a/tests/mini_parser.py b/tests/mini_parser.py
index 5dfda06..9182c5d 100644
--- a/tests/mini_parser.py
+++ b/tests/mini_parser.py
@@ -9,12 +9,23 @@
# get the text in the next matching parens
class MiniCilParser:
- types = set() # types declared in mapping
- pubtypes = set()
- typeattributes = set() # attributes declared in mapping
- typeattributesets = {} # sets defined in mapping
- rTypeattributesets = {} # reverse mapping of above sets
- apiLevel = None
+ def __init__(self, policyFile):
+ self.types = set() # types declared in mapping
+ self.pubtypes = set()
+ self.typeattributes = set() # attributes declared in mapping
+ self.typeattributesets = {} # sets defined in mapping
+ self.rTypeattributesets = {} # reverse mapping of above sets
+ self.apiLevel = None
+
+ with open(policyFile, 'r') as infile:
+ s = self._getNextStmt(infile)
+ while s:
+ self._parseStmt(s)
+ s = self._getNextStmt(infile)
+ fn = basename(policyFile)
+ m = re.match(r"(\d+\.\d+).+\.cil", fn)
+ if m:
+ self.apiLevel = m.group(1)
def _getNextStmt(self, infile):
parens = 0
@@ -77,27 +88,8 @@
self._parseTypeattribute(stmt)
elif re.match(r"typeattributeset\s+.+", stmt):
self._parseTypeattributeset(stmt)
- elif re.match(r"expandtypeattribute\s+.+", stmt):
- # To silence the build warnings.
- pass
- else:
- m = re.match(r"(\w+)\s+.+", stmt)
- ret = "Warning: Unknown statement type (" + m.group(1) + ") in "
- ret += "mapping file, perhaps consider adding support for it in "
- ret += "system/sepolicy/tests/mini_parser.py!\n"
- print ret
return
- def __init__(self, policyFile):
- with open(policyFile, 'r') as infile:
- s = self._getNextStmt(infile)
- while s:
- self._parseStmt(s)
- s = self._getNextStmt(infile)
- fn = basename(policyFile)
- m = re.match(r"(\d+\.\d+).+\.cil", fn)
- self.apiLevel = m.group(1)
-
if __name__ == '__main__':
f = sys.argv[1]
p = MiniCilParser(f)