def testAcpioPartition(self):
        """Validates ACPIO partition using mkdtboimg.py."""
        temp_SSDT_dump = "SSDT.dump"
        temp_SSDT_dump_hashes = []
        current_SSDT = "SSDT"
        current_SSDT_hashes = []

        slot_suffix = str(self.dut.getProp(PROPERTY_SLOT_SUFFIX))
        current_acpio_partition = "acpio" + slot_suffix
        acpio_path = target_file_utils.FindFiles(self.shell, BLOCK_DEV_PATH,
                                                 current_acpio_partition,
                                                 "-type l")
        if not acpio_path:
            asserts.fail("Unable to find path to acpio image on device.")
        logging.debug("ACPIO path %s", acpio_path)
        host_acpio_image = os.path.join(self.temp_dir, "acpio")
        self.adb.pull("%s %s" % (acpio_path[0], host_acpio_image))
        mkdtimg_bin_path = os.path.join("host", "bin", "mkdtboimg.py")
        unpacked_acpio_file = os.path.join(self.temp_dir, temp_SSDT_dump)
        acpio_dump_cmd = [
            "%s" % mkdtimg_bin_path, "dump",
            "%s" % host_acpio_image, "-b",
            "%s" % unpacked_acpio_file
        ]
        try:
            subprocess.check_call(acpio_dump_cmd)
        except Exception as e:
            logging.exception(e)
            asserts.fail("Invalid ACPIO Image")
        asserts.assertTrue(
            acpio_idx_string,
            "Kernel command line missing androidboot.acpio_idx")
        acpio_idx_list = acpio_idx_string.split(",")
        for idx in acpio_idx_list:
            temp_SSDT_dump_file = "SSDT.dump." + idx.rstrip()
            temp_SSDT_dump_file_hash = self.getSha1(
                os.path.join(self.temp_dir, temp_SSDT_dump_file))
            temp_SSDT_dump_hashes.append(temp_SSDT_dump_file_hash)

        SSDT_path = target_file_utils.FindFiles(self.shell, SSDT_PATH, "SSDT*")
        for current_SSDT_file in SSDT_path:
            host_SSDT_file = os.path.join(self.temp_dir, current_SSDT)
            self.adb.pull("%s %s" % (current_SSDT_file, host_SSDT_file))
            SSDT_file_hash = self.getSha1(host_SSDT_file)
            current_SSDT_hashes.append(SSDT_file_hash)
        asserts.assertTrue(current_SSDT_hashes, "No get current SSDT hash.")
        asserts.assertTrue(
            set(temp_SSDT_dump_hashes) & set(current_SSDT_hashes),
            "Hash is not the same.")
 def testCheckDTBOPartition(self):
     """Validates DTBO partition using mkdtboimg.py."""
     try:
         slot_suffix = str(self.dut.getProp(PROPERTY_SLOT_SUFFIX))
     except ValueError as e:
         logging.exception(e)
         slot_suffix = ""
     current_dtbo_partition = "dtbo" + slot_suffix
     dtbo_path = target_file_utils.FindFiles(self.shell, BLOCK_DEV_PATH,
                                             current_dtbo_partition,
                                             "-type l")
     logging.info("DTBO path %s", dtbo_path)
     if not dtbo_path:
         asserts.fail("Unable to find path to dtbo image on device.")
     host_dtbo_image = os.path.join(self.temp_dir, "dtbo")
     self.adb.pull("%s %s" % (dtbo_path[0], host_dtbo_image))
     mkdtboimg_bin_path = os.path.join("host", "bin", "mkdtboimg.py")
     unpacked_dtbo_path = os.path.join(self.temp_dir, "dumped_dtbo")
     dtbo_dump_cmd = [
         "%s" % mkdtboimg_bin_path, "dump",
         "%s" % host_dtbo_image, "-b",
         "%s" % unpacked_dtbo_path
     ]
     try:
         subprocess.check_call(dtbo_dump_cmd)
     except Exception as e:
         logging.exception(e)
         logging.error('dtbo_dump_cmd is: %s', dtbo_dump_cmd)
         asserts.fail("Invalid DTBO Image")
     # TODO(b/109892148) Delete code below once decompress option is enabled for mkdtboimg.py
     self.DecompressDTEntries(host_dtbo_image, unpacked_dtbo_path)
Пример #3
0
    def _ListDir(self, dir_path, file_type="all"):
        """Lists files in dir_path with specific file_type.

        Args:
            dir_path: The current directory to list content.
            file_type: The file type to list, can be one of "dir", "file",
                "symlink" or "all".

        Returns:
            A set of paths under current directory.
        """
        find_option = "-maxdepth 1"  # Only list current directory.
        find_types = {
            "dir": "d",
            "file": "f",
            "symlink": "l",
        }
        if file_type != "all":
            find_option += " -type %s" % find_types[file_type]

        # FindFiles will include dir_path if file_type is "all" or "dir".
        # Excludes dir_path before return.
        return set(
            target_file_utils.FindFiles(self._shell, dir_path, "*",
                                        find_option)) - set([dir_path])
Пример #4
0
 def testNetMTU(self):
     '''Check for /sys/class/net/*/mtu.'''
     dirlist = target_file_utils.FindFiles(self.shell, '/sys/class/net',
                                           '*', '-maxdepth 1 -type l')
     for entry in dirlist:
         mtufile = entry + "/mtu"
         self.IsReadWrite(mtufile)
         content = target_file_utils.ReadFileContent(mtufile, self.shell)
         self.ConvertToInteger(content)
 def testBootImageHeader(self):
     """Validates boot image header."""
     current_boot_partition = "boot" + str(self.slot_suffix)
     boot_path = target_file_utils.FindFiles(
         self.shell, BLOCK_DEV_PATH, current_boot_partition, "-type l")
     logging.info("Boot path %s", boot_path)
     if not boot_path:
         asserts.fail("Unable to find path to boot image on device.")
     host_boot_path = os.path.join(self.temp_dir, "boot.img")
     self.adb.pull("%s %s" % (boot_path[0], host_boot_path))
     self.CheckImageHeader(host_boot_path)
 def testRecoveryImageHeader(self):
     """Validates recovery image header."""
     asserts.skipIf(self.slot_suffix,
                    "A/B devices do not have a separate recovery partition")
     recovery_path = target_file_utils.FindFiles(self.shell, BLOCK_DEV_PATH,
                                                 "recovery", "-type l")
     logging.info("recovery path %s", recovery_path)
     if not recovery_path:
         asserts.fail("Unable to find path to recovery image on device.")
     host_recovery_path = os.path.join(self.temp_dir, "recovery.img")
     self.adb.pull("%s %s" % (recovery_path[0], host_recovery_path))
     self.CheckImageHeader(host_recovery_path, True)
    def _ListFiles(self, dir_path):
        """Lists all files in a directory except subdirectories.

        Args:
            dir_path: A string, path to the directory on device.

        Returns:
            A list of strings, the file paths in the directory.
        """
        if not target_file_utils.Exists(dir_path, self._shell):
            logging.info("%s not found", dir_path)
            return []
        return target_file_utils.FindFiles(self._shell, dir_path, "*",
                                           "! -type d")
Пример #8
0
 def testRtcHctosys(self):
     '''Check that at least one rtc exists with hctosys = 1.'''
     rtclist = target_file_utils.FindFiles(self.shell, '/sys/class/rtc',
                                           'rtc*', '-maxdepth 1 -type l')
     for entry in rtclist:
         content = target_file_utils.ReadFileContent(
             entry + "/hctosys", self.shell)
         try:
             hctosys = int(content)
         except ValueError as e:
             continue
         if hctosys == 1:
             return
     asserts.fail("No RTC with hctosys=1 present")