Esempio n. 1
0
File: qdc-gui.py Progetto: ufwt/qdt
    def load_project_from_file(self, file_name):
        loaded_variables = dict(qdt.__dict__)

        try:
            execfile(file_name, loaded_variables)
        except Exception as e:
            raise e
        else:
            qproj = None
            for v in loaded_variables.values():
                if isinstance(v, GUIProject):
                    break
                elif qproj is None and isinstance(v, QProject):
                    qproj = v
            else:
                if qproj:
                    v = GUIProject.from_qproject(qproj)
                else:
                    raise Exception("No project object was loaded")

            self.set_project(v)
            self.set_current_file_name(file_name)
            self.saved_operation = self.pht.pos
            self.__check_saved_asterisk__()

            if self._user_settings:
                self._user_settings.account_project(file_name)
                self._update_recent_projects()
Esempio n. 2
0
    def load_cache(self):
        if not isfile(self.qvc_path):
            raise Exception("%s does not exists." % self.qvc_path)
        else:
            print("Loading QVC from " + self.qvc_path)
            variables = {}
            context = {
                "QemuVersionCache": QemuVersionCache,
                "QVHDict": QVHDict
            }

            import qemu
            context.update(qemu.__dict__)

            execfile(self.qvc_path, context, variables)

            for v in variables.values():
                if isinstance(v, QemuVersionCache):
                    self.qvc = v
                    break
            else:
                raise Exception(
"No QemuVersionCache was loaded from %s." % self.qvc_path
                )
            self.qvc.version_desc = QVHDict(self.qvc.version_desc)
Esempio n. 3
0
def main():
    ap = ArgumentParser(description="Test helper fot a Git branch.",
                        formatter_class=ArgumentDefaultsHelpFormatter)
    ap.add_argument("-r",
                    "--repo",
                    default=abspath(dirname(dirname(__file__))),
                    type=arg_type_directory,
                    metavar="dir",
                    help="repository location")
    ap.add_argument(
        "-m",
        "--measurements",
        default=3,
        type=int,
        metavar="count",
        help="measurements count, 0 (to only view previous results)")
    ap.add_argument(
        "-s",
        "--script",
        default="project.py",
        type=arg_type_file,
        metavar="file.py",
        help="a script containing definition of a project to generate")
    ap.add_argument("-b",
                    "--qemu-build",
                    default=default("."),
                    type=arg_type_directory,
                    metavar="dir",
                    help="override QEMU build path of the project")
    ap.add_argument(
        "-t",
        "--target-version",
        default=default("master"),
        metavar="<tree-ish>",  # like in Git's docs
        help="assume given version of Qemu"
        " (overrides project's target_version)")
    ap.add_argument("current",
                    nargs='?',
                    default="HEAD",
                    metavar="<current-tree-ish>",
                    help="branch to test")
    ap.add_argument("base",
                    nargs='?',
                    default="master",
                    metavar="<base-tree-ish>",
                    help="base version")

    args = ap.parse_args()

    # TODO: outline QProject loading from qemu_device_creator.py
    script = abspath(args.script)

    loaded = {}
    try:
        execfile(script, dict(qdt.__dict__), loaded)
    except:
        print("Cannot load configuration from '%s'" % script)
        print_exc()
        return -1

    for v in loaded.values():
        if isinstance(v, qdt.QProject):
            project = v
            break
    else:
        print("Script '%s' does not define a project to generate." % script)
        return -1

    if (not isinstance(args.qemu_build, default)
            or not getattr(project, "build_path", None)):
        project.build_path = args.qemu_build

    if (not isinstance(args.target_version, default)
            or not getattr(project, "target_version", None)):
        project.target_version = args.target_version

    repo = Repo(args.repo)

    measurer = QDTMeasurer(repo,
                           args.current,
                           args.base,
                           project,
                           script,
                           caches=project.build_path)

    with CommitsTestResults() as results:
        measurer.results = results
        measurer.measure(m_count=args.measurements)

        # TODO
        # tox_measurements(repo, c, commit_list,
        #     m_count = args.measurements
        # )
        plot_measurements(repo, results, measurer.commit_queue)

    return 0
Esempio n. 4
0
File: qdc-gui.py Progetto: ufwt/qdt
def main():
    parser = ArgumentParser()

    parser.add_argument(
        '--qemu-build',
        '-b',
        default=None,
        type=arg_type_directory,
        metavar='path_to_qemu_build',
    )

    parser.add_argument("script",
                        default="project.py",
                        nargs="?",
                        help="Load project from a script.")

    arguments = parser.parse_args()

    root = QDCGUIWindow()

    try:
        root.load_project_from_file(arguments.script)
    except Exception as e:
        print("Project load failed: " + str(e) + "\n")

        project = GUIProject()

        try:
            variables = {}
            execfile("serialize-test.py", qdt.__dict__, variables)

            for v in variables.values():
                if isinstance(v, MachineNode):
                    mach = v
                    break
            else:
                raise Exception(
                    "No MachineNode instance was found in serialize-test.py")
        except Exception as e:
            print("Machine load failed: " + str(e) + "\n")
            mach = Q35MachineNode_2_6_0()

        project.add_description(mach)

        try:
            layout = load_cPickled(open("layout.p", "rb"))
        except Exception as e:
            print("Layout load failed: " + str(e) + "\n")
        else:
            project.layouts.append((mach.name, layout))

        tmp_p = Q35Project_2_6_0()
        for desc in list(tmp_p.descriptions):
            if not isinstance(desc, MachineNode):
                desc.remove_from_project()
                project.add_description(desc)

        root.set_project(project)
        root.set_current_file_name("project.py")

    if arguments.qemu_build is not None:
        load_build_path_list()
        account_build_path(arguments.qemu_build)
        root.pht.set_build_path(arguments.qemu_build)

    with Settings(expanduser(join("~", ".qdt.py"))) as settings:
        root.set_user_settings(settings)

        root.geometry("1000x750")

        root.mainloop()

    root.save_project_to_file("project.py")
Esempio n. 5
0
def main():
    parser = ArgumentParser(
        description = "QEMU Project Generator\n"
        "The tool generates source files inside QEMU source tree according to"
        " settings read from project script."
    )

    parser.add_argument(
        "--qemu-build", "-b",
        default = None,
        type = arg_type_directory,
        metavar = "/path/to/qemu/build/directory",
        help = "Override QEMU build path of the project."
    )
    parser.add_argument(
        "--target-version", "-t",
        default = None,
        metavar = "<tree-ish>", # like in Git's docs
        help = "Assume given version of Qemu."
        " Overrides project's target_version."
    )

    parser.add_argument(
        "--gen-header-tree",
        default = None,
        metavar = "header_tree.gv",
        help = "Output QEMU header inclusion graph in Graphviz format."
    )

    parser.add_argument(
        "--gen-chunk-graphs",
        action = "store_true",
        help = "Generate Graphviz files with graph of chunks per each "
        "generated source."
    )

    parser.add_argument(
        "script",
        help = "A Python script containing definition of a project to generate."
    )

    arguments = parser.parse_args()

    script = arguments.script

    loaded = {}
    try:
        execfile(script, qdt.__dict__, loaded)
    except:
        print("Cannot load configuration from '%s'" % script)
        print_exc()
        return -1

    for v in loaded.values():
        if isinstance(v, qdt.QProject):
            project = v
            break
    else:
        print("Script '%s' does not define a project to generate." % script)
        return -1

    if arguments.qemu_build is None:
        qemu_build_path = getattr(project, "build_path", None)
    else:
        qemu_build_path = arguments.qemu_build
    if not qemu_build_path: # None, empty
        qemu_build_path = "."

    version = arguments.target_version

    if version is None:
        version = project.target_version

    try:
        qvd = qvd_load_with_cache(qemu_build_path, version = version)
    except:
        print("QVD loading failed")
        print_exc()
        return -1

    qvd.use()

    if arguments.gen_header_tree is not None:
        qvd.qvc.stc.gen_header_inclusion_dot_file(arguments.gen_header_tree)

    project.gen_all(qvd.src_path,
        with_chunk_graph = arguments.gen_chunk_graphs
    )

    return 0
Esempio n. 6
0
 def ex_inplace(self, filename):
     with Path(TDIR):
         with self.log:
             execfile(filename)
Esempio n. 7
0
 def ex(self, filename):
     f = join(TDIR, filename)
     with self.log:
         execfile(f)
     return f
Esempio n. 8
0
def main():
    setpgrp()

    parser = C2TArgumentParser(
        description="QEMU CPU Testing Tool",
        epilog=("supported GDB RSP targets: {rsp}".format(
            rsp=', '.join(archmap.keys()))),
        formatter_class=HelpFormatter)
    parser.add_argument(
        "config",
        type=str,
        help=("configuration file for {prog} (see sample and examples in "
              "{dir})".format(prog=parser.prog, dir=C2T_CONFIGS_DIR)))
    DEFAULT_REGEXPS = testfilter([
        (testfilter.RE_INCLD, ".*\.c"),
    ])
    parser.add_argument("-t",
                        "--include",
                        type=str,
                        metavar="RE_INCLD",
                        action=TestfilterCLI,
                        dest="regexps",
                        default=DEFAULT_REGEXPS,
                        help=("regular expressions to include a test set "
                              "(tests are located in %s)" % C2T_TEST_DIR))
    parser.add_argument("-s",
                        "--exclude",
                        type=str,
                        metavar="RE_EXCLD",
                        action=TestfilterCLI,
                        dest="regexps",
                        default=DEFAULT_REGEXPS,
                        help=("regular expressions to exclude a test set "
                              "(tests are located in %s)" % C2T_TEST_DIR))
    parser.add_argument("-j",
                        "--jobs",
                        type=int,
                        dest="jobs",
                        default=1,
                        help="allow N debugging jobs at once")
    parser.add_argument(
        "-r",
        "--reuse",
        action="store_true",
        help="reuse debug servers after each test (now only QEMU)")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="increase output verbosity")

    args = parser.parse_args()

    config = args.config
    cfg_file = "%s.py" % config if not config.endswith(".py") else config

    config = cfg_file
    if not exists(config):
        config = join(C2T_CONFIGS_DIR, cfg_file)
        if not exists(config):
            config = join(C2T_DIR, cfg_file)
            if not exists(config):
                parser.error("configuration file doesn't exist: " +
                             args.config)

    glob = {
        "C2TConfig": C2TConfig,
        "Run": Run,
        "get_new_rsp": get_new_rsp,
        "DebugClient": DebugClient,
        "DebugServer": DebugServer,
        "TestBuilder": TestBuilder
    }

    # getting `c2t_cfg` configuration for cpu testing tool
    try:
        execfile(config, glob)
    except Exception as e:
        c2t_exit(e, prog=config)
    else:
        global c2t_cfg
        for val in glob.values():
            if isinstance(val, C2TConfig):
                c2t_cfg = val
                break
        else:
            c2t_exit("No `C2TConfig` instance was defined by the config "
                     "(see sample and examples in {dir})".format(
                         dir=C2T_CONFIGS_DIR),
                     prog=config)

    verify_config_components(config)

    incl, regexp, tests = args.regexps.find_files(C2T_TEST_DIR)
    if not tests:
        parser.error("no matches in {dir} with {var} {regexp}".format(
            dir=C2T_TEST_DIR,
            var="inclusive" if incl else "exclusive",
            regexp=cli_repr(regexp)))

    jobs = args.jobs
    if jobs < 1:
        parser.error("wrong number of jobs: %s" % jobs)

    # creates tests subdirectories if they don't exist
    for sub_dir in (C2T_TEST_IR_DIR, C2T_TEST_BIN_DIR):
        if not exists(sub_dir):
            makedirs(sub_dir)

    start_cpu_testing(tests, jobs, args.reuse, args.verbose)
    killpg(0, SIGTERM)