def make_test( base_source_dir: Path, subtest_dir: Path, spirv_opt_args: Optional[List[str]], binary_manager: binaries_util.BinaryManager, ) -> Path: # Create the subtest by copying the base source. util.copy_dir(base_source_dir, test_util.get_source_dir(subtest_dir)) test = Test(spirv_fuzz=TestSpirvFuzz(spirv_opt_args=spirv_opt_args)) fuzz_glsl_test.add_spirv_shader_test_binaries(test, spirv_opt_args, binary_manager) # Write the test metadata. test_util.metadata_write(test, subtest_dir) return subtest_dir
def make_test( base_source_dir: Path, subtest_dir: Path, spirv_opt_args: Optional[List[str]], binary_manager: binaries_util.BinaryManager, ) -> Path: # Create the subtest by copying the base source. util.copy_dir(base_source_dir, test_util.get_source_dir(subtest_dir)) test = Test(glsl=TestGlsl(spirv_opt_args=spirv_opt_args)) test.binaries.extend( [binary_manager.get_binary_by_name(name="glslangValidator")]) add_spirv_shader_test_binaries(test, spirv_opt_args, binary_manager) # Write the test metadata. test_util.metadata_write(test, subtest_dir) return subtest_dir
def make_test( base_source_dir: Path, subtest_dir: Path, spirv_opt_args: Optional[List[str]], binary_manager: binaries_util.BinaryManager, derived_from: Optional[str], stable_shader: bool, common_spirv_args: Optional[List[str]], ) -> Path: source_dir = test_util.get_source_dir(subtest_dir) # Create the subtest by copying the base source. util.copy_dir(base_source_dir, source_dir) test = Test( glsl=TestGlsl(spirv_opt_args=spirv_opt_args), derived_from=derived_from, common_spirv_args=common_spirv_args, ) test.binaries.extend( [binary_manager.get_binary_by_name(name="glslangValidator")]) fuzz_test_util.add_spirv_shader_test_binaries(test, spirv_opt_args, binary_manager) # Write the test metadata. test_util.metadata_write(test, subtest_dir) # If the reference shader is "stable" (with respect to floating-point sensitivity) # then this can be a wrong image test; i.e. we will render the reference and variant shaders # and compare the output images. # Otherwise, we should just render the variant shader and check for crashes; to do this, # we just rename the `reference/` directory to `_reference/` so that the test has no reference shader. if not stable_shader and (source_dir / test_util.REFERENCE_DIR).is_dir(): util.move_dir( source_dir / test_util.REFERENCE_DIR, source_dir / f"_{test_util.REFERENCE_DIR}", ) return subtest_dir
def make_test( base_source_dir: Path, subtest_dir: Path, spirv_opt_args: Optional[List[str]], binary_manager: binaries_util.BinaryManager, ) -> Path: # Create the subtest by copying the base source. util.copy_dir(base_source_dir, test_util.get_source_dir(subtest_dir)) test = Test(spirv_fuzz=TestSpirvFuzz(spirv_opt_args=spirv_opt_args)) test.binaries.extend([binary_manager.get_binary_by_name(name="spirv-dis")]) test.binaries.extend([binary_manager.get_binary_by_name(name="spirv-val")]) if spirv_opt_args: test.binaries.extend( [binary_manager.get_binary_by_name(name="spirv-opt")]) # Write the test metadata. test_util.metadata_write(test, subtest_dir) return subtest_dir
def maybe_add_report( # pylint: disable=too-many-locals; test_dir: Path, reports_dir: Path, device: Device, settings: Settings) -> Optional[Path]: result_output_dir = test_util.get_results_directory(test_dir, device.name) status = result_util.get_status(result_output_dir) report_subdirectory_name = "" if status == fuzz.STATUS_CRASH: report_subdirectory_name = "crashes" elif status == fuzz.STATUS_TOOL_CRASH: report_subdirectory_name = "tool_crashes" elif status == fuzz.STATUS_UNRESPONSIVE: report_subdirectory_name = "unresponsive" if not report_subdirectory_name: return None log_path = result_util.get_log_path(result_output_dir) log_contents = util.file_read_text(log_path) signature = signature_util.get_signature_from_log_contents(log_contents) signature_dir = reports_dir / report_subdirectory_name / signature util.mkdirs_p(signature_dir) # If the signature_dir contains a NOT_INTERESTING file, then don't bother creating a report. if (signature_dir / "NOT_INTERESTING").exists(): return None if signature != signature_util.BAD_IMAGE_SIGNATURE: # If we have reached the maximum number of crashes per signature for this device, don't create a report. num_duplicates = [ report_dir for report_dir in signature_dir.iterdir() if report_dir.is_dir() and report_dir.name.endswith(f"_{device.name}") ] if len(num_duplicates) >= settings.maximum_duplicate_crashes: return None # We include the device name in the directory name because it is possible that this test crashes on two # different devices but gives the same crash signature in both cases (e.g. for generic signatures # like "compile_error"). This would lead to two test copies having the same path. # It also means we can limit duplicates per device using the directory name. test_dir_in_reports = signature_dir / f"{test_dir.name}_{device.name}" util.copy_dir(test_dir, test_dir_in_reports) if signature != signature_util.BAD_IMAGE_SIGNATURE: # If we found a crash, rename the directories for all shaders other than the variant. Thus, only the variant # shader will run. bad_shader_name = result_util.get_status_bad_shader_name( test_util.get_results_directory(test_dir_in_reports, device.name)) # TODO: Could possibly improve this. Could try scanning the Amber log to figure out which shader failed? if not bad_shader_name: log("WARNING: assuming that the bad shader is the variant") bad_shader_name = test_util.VARIANT_DIR shader_jobs = tool.get_shader_jobs( test_util.get_source_dir(test_dir_in_reports)) found_bad_shader = False for shader_job in shader_jobs: if shader_job.name == bad_shader_name: found_bad_shader = True else: shader_job.shader_job.parent.rename( shader_job.shader_job.parent.parent / f"_{shader_job.name}") check( found_bad_shader, AssertionError( f"Could not find bad shader at: {test_util.get_source_dir(test_dir_in_reports) / bad_shader_name}" ), ) test_metadata = test_util.metadata_read(test_dir_in_reports) test_metadata.crash_signature = signature test_metadata.device.CopyFrom(device) test_metadata.expected_status = status test_util.metadata_write(test_metadata, test_dir_in_reports) return test_dir_in_reports