diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp index 29fc771b86..094ffe1f21 100644 --- a/tools/releasetools/Android.bp +++ b/tools/releasetools/Android.bp @@ -598,6 +598,7 @@ python_defaults { "testdata/**/*", ":com.android.apex.compressed.v1", ":com.android.apex.compressed.v1_original", + ":com.android.apex.vendor.foo.with_vintf" ], target: { darwin: { diff --git a/tools/releasetools/test_check_target_files_vintf.py b/tools/releasetools/test_check_target_files_vintf.py index 8725dd6922..7c154d7461 100644 --- a/tools/releasetools/test_check_target_files_vintf.py +++ b/tools/releasetools/test_check_target_files_vintf.py @@ -15,6 +15,7 @@ # import os.path +import shutil import common import test_utils @@ -86,6 +87,28 @@ class CheckTargetFilesVintfTest(test_utils.ReleaseToolsTestCase): return test_dir + # Prepare test dir with required HAL for APEX testing + def prepare_apex_test_dir(self, test_delta_rel_path): + test_dir = self.prepare_test_dir(test_delta_rel_path) + write_string_to_file( + """ + + android.apex.foo + 1 + + IApex + default + + + + 0.0 + 0 + + """, + os.path.join(test_dir, 'SYSTEM/etc/vintf/compatibility_matrix.1.xml')) + + return test_dir + @test_utils.SkipIfExternalToolsUnavailable() def test_CheckVintf_skeleton(self): msg = 'vintf check with skeleton target files failed.' @@ -143,3 +166,25 @@ class CheckTargetFilesVintfTest(test_utils.ReleaseToolsTestCase): os.path.join(test_dir, 'VENDOR/etc/vintf/manifest.xml')) # Should raise an error because a file has invalid format. self.assertRaises(common.ExternalError, CheckVintf, test_dir) + + @test_utils.SkipIfExternalToolsUnavailable() + def test_CheckVintf_apex_compat(self): + apex_file_name = 'com.android.apex.vendor.foo.with_vintf.apex' + msg = 'vintf/apex_compat should be compatible because ' \ + 'APEX %s has the required HALs' % (apex_file_name) + test_dir = self.prepare_apex_test_dir('vintf/apex_compat') + # Copy APEX under VENDOR/apex + apex_file = os.path.join(test_utils.get_current_dir(), apex_file_name) + apex_dir = os.path.join(test_dir, 'VENDOR/apex') + os.makedirs(apex_dir) + shutil.copy(apex_file, apex_dir) + # Should find required HAL via APEX + self.assertTrue(CheckVintf(test_dir), msg=msg) + + @test_utils.SkipIfExternalToolsUnavailable() + def test_CheckVintf_apex_incompat(self): + msg = 'vintf/apex_incompat should be incompatible because ' \ + 'no APEX data' + test_dir = self.prepare_apex_test_dir('vintf/apex_incompat') + # Should not find required HAL + self.assertFalse(CheckVintf(test_dir), msg=msg)