コード例 #1
0
def artifact_path_to_path(artifact_path: str) -> pathlib.Path:
    """
    Returns |artifact_path| converted to an OS specific path.

    Artifact paths always use '/' to separate paths.
    Artifact paths usually begin with '//' which is the artifact root directory, marked via a ROOT
    file.

    :param artifact_path: an artifact path.
    :return:
    """
    if artifact_path.startswith("//"):
        return util.norm_path(artifact_path_get_root() /
                              pathlib.Path(artifact_path[2:]))

    return util.norm_path(pathlib.Path(artifact_path))
コード例 #2
0
def artifact_path_get_root() -> pathlib.Path:
    root_file_suffix = pathlib.Path(ARTIFACT_ROOT_FILE_NAME)
    fake_file = util.norm_path(pathlib.Path("fake").absolute())
    for parent in fake_file.parents:
        if (parent / root_file_suffix).exists():
            return parent
    raise FileNotFoundError(
        "Could not find root file {}".format(ARTIFACT_ROOT_FILE_NAME))
コード例 #3
0
def artifact_get_inner_file_path(inner_file: str,
                                 artifact_path: str) -> pathlib.Path:
    check(
        not inner_file.startswith("//"),
        AssertionError(
            "bad inner_file argument passed to artifact_get_inner_file_path"),
    )
    # TODO: Consider absolute paths that we might want to support for quick hacks.
    return util.norm_path(
        artifact_get_directory_path(artifact_path) / pathlib.Path(inner_file))
コード例 #4
0
def artifact_path_absolute(artifact_path: str) -> str:
    """
    Returns the absolute |artifact_path| starting with '//'.

    Artifact paths should almost always begin with '//', but for convenience it can be useful to
    use relative paths, especially when calling functions from an IPython shell.
    :param artifact_path: An artifact path.
    :return: absolute |artifact_path| starting with '//'.
    """
    if artifact_path.startswith("//"):
        return artifact_path
    path = util.norm_path(pathlib.Path(artifact_path)).absolute()
    return path_to_artifact_path(path)
コード例 #5
0
def main() -> None:

    # Checklist:
    # - check output_amber
    # - check short_description
    # - check comment_text
    # - check copyright_year
    # - check extra_commands

    bug_dir = util.norm_path(Path(__file__).absolute()).parent

    tool.glsl_shader_job_crash_to_amber_script_for_google_cts(
        source_dir=bug_dir / "reduced_manual",
        output_amber=bug_dir / "name-of-test-TODO.amber",
        work_dir=bug_dir / "work",
        # One sentence, 58 characters max., no period, no line breaks.
        short_description="A fragment shader with TODO",
        comment_text="""The test passes because TODO""",
        copyright_year="2019",
        extra_commands=tool.AMBER_COMMAND_EXPECT_RED,
    )
コード例 #6
0
def main() -> None:

    # Checklist:
    # - check output_amber
    # - check short_description
    # - check comment_text
    # - check copyright_year
    # - check extra_commands

    bug_dir = util.norm_path(Path(__file__).absolute()).parent

    tool.glsl_shader_job_crash_to_amber_script_for_google_cts(
        source_dir=bug_dir / "reduced_1",
        # Look at the "derived_from" field in `reduced_1/test.json` to find the original shader name.
        # If the shader was stable (e.g. "stable_quicksort") then you must prefix the .amber file name
        # with the name of the shader (using dashes instead of underscores).
        # The rest of the test name should describe the DIFFERENCE between the reference and variant shaders.
        # E.g. "stable-quicksort-composite-insert-with-constant.amber".
        # If the original shader was not stable then you should probably not add this test (with a few exceptions).
        # If you still want to add the test then the test name should approximately describe the contents of the variant
        # shader. E.g. "loop-with-early-return-and-function-call.amber".
        output_amber=bug_dir / "test-name-TODO.amber",
        work_dir=bug_dir / "work",
        # One sentence, 58 characters max., no period, no line breaks.
        # Describe the difference between the shaders, as described above for the .amber file name.
        # E.g. Two shaders with diff: composite insert with constant
        short_description="Two shaders with diff: TODO",
        comment_text="""
The test renders two images using semantically equivalent shaders, and then
checks that the images are similar.
The test passes because the shaders have the same semantics and so the images
should be the same.""",
        copyright_year="2020",
        # Pass |tool.AMBER_COMMAND_EXPECT_RED| to check that the shader renders red.
        extra_commands="",
        is_coverage_gap=False,
    )
コード例 #7
0
ファイル: test_large.py プロジェクト: arjav2002/graphicsfuzz
def fuzz_and_reduce_bug(
    active_device: str,
    seed: int,
    check_result: Callable[[], None],
    settings: Optional[Settings] = None,
    ignored_signatures: Optional[List[str]] = None,
) -> None:
    """
    Fuzz, find a bug, reduce it.

    Linux only.
    """
    # Test only works on Linux.
    if util.get_platform() != "Linux":
        return

    here = util.norm_path(Path(__file__).absolute()).parent
    temp_dir: Path = here.parent / "temp"

    assert temp_dir.is_dir()

    os.chdir(temp_dir)

    # Create ROOT file in temp/ if needed.
    fuzz.try_get_root_file()

    work_dir = temp_dir / fuzz.get_random_name()[:8]
    util.mkdir_p_new(work_dir)
    os.chdir(work_dir)

    log(f"Changed to {str(work_dir)}")

    if settings is None:
        settings = Settings()
        settings.CopyFrom(settings_util.DEFAULT_SETTINGS)

    settings.device_list.CopyFrom(
        DeviceList(
            active_device_names=[active_device],
            devices=[
                Device(
                    name="amdllpc",
                    shader_compiler=DeviceShaderCompiler(
                        binary="amdllpc",
                        args=[
                            "-gfxip=9.0.0", "-verify-ir", "-auto-layout-desc"
                        ],
                    ),
                    binaries=[
                        Binary(
                            name="amdllpc",
                            tags=["Release"],
                            version="c21d76dceaf26361f9b6b3838a955ec3301506b5",
                        ),
                    ],
                ),
                Device(
                    name="swift_shader",
                    swift_shader=DeviceSwiftShader(),
                    binaries=[
                        Binary(
                            name="swift_shader_icd",
                            tags=["Release"],
                            version="6d69aae0e1ab49190ea46cd1c999fd3d02e016b9",
                        ),
                    ],
                    ignored_crash_signatures=ignored_signatures,
                ),
            ],
        ))

    spirv_tools_version = "983b5b4fccea17cab053de24d51403efb4829158"

    settings.latest_binary_versions.extend([
        Binary(
            name="glslangValidator",
            tags=["Release"],
            version="1afa2b8cc57b92c6b769eb44a6854510b6921a0b",
        ),
        Binary(name="spirv-opt", tags=["Release"],
               version=spirv_tools_version),
        Binary(name="spirv-dis", tags=["Release"],
               version=spirv_tools_version),
        Binary(name="spirv-as", tags=["Release"], version=spirv_tools_version),
        Binary(name="spirv-val", tags=["Release"],
               version=spirv_tools_version),
        Binary(name="spirv-fuzz",
               tags=["Release"],
               version=spirv_tools_version),
        Binary(name="spirv-reduce",
               tags=["Release"],
               version=spirv_tools_version),
        Binary(
            name="graphicsfuzz-tool",
            tags=[],
            version="7b143bcb3ad38b64ddc17d132886636b229b6684",
        ),
    ])
    # Add default binaries; the ones above have priority.
    settings.latest_binary_versions.extend(binaries_util.DEFAULT_BINARIES)

    settings.extra_graphics_fuzz_generate_args.append("--small")
    settings.extra_graphics_fuzz_generate_args.append("--single-pass")

    settings.extra_graphics_fuzz_reduce_args.append("--max-steps")
    settings.extra_graphics_fuzz_reduce_args.append("2")

    settings_util.write(settings, settings_util.DEFAULT_SETTINGS_FILE_PATH)

    # Add shaders.
    binary_manager = binaries_util.get_default_binary_manager(settings)
    graphicsfuzz_tool = binary_manager.get_binary_path_by_name(
        "graphicsfuzz-tool")
    sample_shaders_path: Path = graphicsfuzz_tool.path.parent.parent.parent / "shaders" / "samples" / "310es"
    util.copy_dir(sample_shaders_path, Path() / fuzz.REFERENCES_DIR)
    util.copy_dir(sample_shaders_path, Path() / fuzz.DONORS_DIR)

    fuzz.main_helper(
        settings_path=settings_util.DEFAULT_SETTINGS_FILE_PATH,
        iteration_seed_override=seed,
        override_sigint=False,
        use_amber_vulkan_loader=True,
    )

    check_result()

    os.chdir(here)
    shutil.rmtree(work_dir)