Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 578e1bb0 authored by Rob Seymour's avatar Rob Seymour Committed by Gerrit Code Review
Browse files

Merge "Add test cases for APEX VINTF."

parents cee4ebf1 9492da59
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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: {
+45 −0
Original line number Diff line number Diff line
@@ -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(
        """<compatibility-matrix version="1.0" level="1" type="framework">
            <hal format="aidl" optional="false" updatable-via-apex="true">
                <name>android.apex.foo</name>
                <version>1</version>
                <interface>
                    <name>IApex</name>
                    <instance>default</instance>
                </interface>
            </hal>
            <sepolicy>
                <sepolicy-version>0.0</sepolicy-version>
                <kernel-sepolicy-version>0</kernel-sepolicy-version>
            </sepolicy>
        </compatibility-matrix>""",
        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)