Пример #1
0
    def RunTest(self, mode, vts_file_path, source_file_name, file_type="BOTH"):
        """Run vtsc with given mode for the give vts file and compare the
           output results.

        Args:
            mode: the vtsc mode for generated code. e.g. DRIVER / PROFILER.
            vts_file_path: path of the input vts file.
            source_file_name: name of the generated source file.
            file_type: type of file e.g. HEADER / SOURCE / BOTH.
        """
        vtsc_cmd = [
            self._vtsc_path, "-m" + mode, vts_file_path,
            os.path.join(self._output_dir, mode),
            os.path.join(self._output_dir, mode, source_file_name)
        ]
        return_code = cmd_utils.RunCommand(vtsc_cmd)
        if (return_code != 0):
            self.Error("Fail to execute command: %s" % vtsc_cmd)

        if (file_type == "HEADER" or file_type == "BOTH"):
            header_file_name = vts_file_path + ".h"
            canonical_header_file = os.path.join(self._canonical_dir, mode,
                                                 header_file_name)
            output_header_file = os.path.join(self._output_dir, mode,
                                              header_file_name)
            self.CompareOutputFile(output_header_file, canonical_header_file)
        if (file_type == "SOURCE" or file_type == "BOTH"):
            canonical_source_file = os.path.join(self._canonical_dir, mode,
                                                 source_file_name)
            output_source_file = os.path.join(self._output_dir, mode,
                                              source_file_name)
            self.CompareOutputFile(output_source_file, canonical_source_file)
        else:
            self.Error("No such file_type: %s" % file_type)
    def RunFuzzerTest(self, mode, vts_file_path, source_file_name):
        vtsc_cmd = [
            self._vtsc_path, "-m" + mode, vts_file_path,
            os.path.join(self._output_dir, mode),
            os.path.join(self._output_dir, mode, "")
        ]
        return_code = cmd_utils.RunCommand(vtsc_cmd)

        canonical_source_file = os.path.join(self._canonical_dir, mode,
                                             source_file_name)
        output_source_file = os.path.join(self._output_dir, mode,
                                          source_file_name)
        self.CompareOutputFile(output_source_file, canonical_source_file)
Пример #3
0
    def GenerateVtsFile(self, hal_package_name):
        """Run hidl-gen to generate the .vts files for the give hal package.

        Args:
            hal_package_name: name of hal package e.g. [email protected]
        """
        hidl_gen_cmd = [
            self._hidl_gen_path, "-o" + self._temp_dir, "-Lvts",
            "-randroid.hardware:hardware/interfaces",
            "-randroid.hidl:system/libhidl/transport", hal_package_name
        ]
        return_code = cmd_utils.RunCommand(hidl_gen_cmd)
        if (return_code != 0):
            self.Error("Fail to execute command: %s" % hidl_gen_cmd)
        [hal_name, hal_version] = hal_package_name.split("@")
        output_dir = os.path.join(self._temp_dir, hal_name.replace(".", "/"),
                                  hal_version)
        for file in os.listdir(output_dir):
            if file.endswith(".vts"):
                os.rename(os.path.join(output_dir, file),
                          os.path.join(self._temp_dir, file))