Define the protobuf for OTA metadata
Background in http://go/android-partial-updates. For partial update
(e.g. system-only) or devices with mixed build, the current
fingerprint & device name no longer suffice as the precondition to
install the package.
Therefore, we need to additionally include the per-partition build
props into the ota metadata. We also define a protobuf for the metadata
so it can be extended later. The metadata of the legacy format is also
kept for backward compatibility.
Bug: 151088567
Test: unittest pass, generate an OTA and check the result
Change-Id: I716f7da54a393cd340280dbddc3c92b3460f8ef8
diff --git a/tools/releasetools/test_utils.py b/tools/releasetools/test_utils.py
index 65092d8..7b7f22a 100755
--- a/tools/releasetools/test_utils.py
+++ b/tools/releasetools/test_utils.py
@@ -22,6 +22,7 @@
import logging
import os
import os.path
+import re
import struct
import sys
import unittest
@@ -224,13 +225,26 @@
input_fp.seek(offset)
if entry == 'metadata':
expected = b'META-INF/COM/ANDROID/METADATA'
+ elif entry == 'metadata.pb':
+ expected = b'META-INF/COM/ANDROID/METADATA-PB'
else:
expected = entry.replace('.', '-').upper().encode()
self.assertEqual(expected, input_fp.read(size))
if __name__ == '__main__':
- testsuite = unittest.TestLoader().discover(
- os.path.dirname(os.path.realpath(__file__)))
+ # We only want to run tests from the top level directory. Unfortunately the
+ # pattern option of unittest.discover, internally using fnmatch, doesn't
+ # provide a good API to filter the test files based on directory. So we do an
+ # os walk and load them manually.
+ test_modules = []
+ base_path = os.path.dirname(os.path.realpath(__file__))
+ for dirpath, _, files in os.walk(base_path):
+ for fn in files:
+ if dirpath == base_path and re.match('test_.*\\.py$', fn):
+ test_modules.append(fn[:-3])
+
+ test_suite = unittest.TestLoader().loadTestsFromNames(test_modules)
+
# atest needs a verbosity level of >= 2 to correctly parse the result.
- unittest.TextTestRunner(verbosity=2).run(testsuite)
+ unittest.TextTestRunner(verbosity=2).run(test_suite)