spirv: Add skip_os_break_in_debug_build option to use in unit tests

When running in the CI environment, instead of crashing the test
binary, it is preferable to just fail gracefully (in this case return
a NULL shader) like is done in release mode, so other tests continue
to be executed.

For convenience add a variable break_on_failure to the test so the
breaking behavior can be re-enable in individual tests when debugging.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21512>
This commit is contained in:
Caio Oliveira
2023-02-23 19:24:24 -08:00
committed by Marge Bot
parent 8a91a33b7c
commit 5f79e78911
3 changed files with 11 additions and 2 deletions
+6
View File
@@ -120,6 +120,12 @@ struct spirv_to_nir_options {
/* Force texture sampling to be non-uniform. */
bool force_tex_non_uniform;
/* In Debug Builds, instead of emitting an OS break on failure, just return NULL from
* spirv_to_nir(). This is useful for the unit tests that want to report a test failed
* but continue executing other tests.
*/
bool skip_os_break_in_debug_build;
};
bool gl_spirv_validation(const uint32_t *words, size_t word_count,
+2 -1
View File
@@ -203,7 +203,8 @@ _vtn_fail(struct vtn_builder *b, const char *file, unsigned line,
vtn_dump_shader(b, dump_path, "fail");
#ifndef NDEBUG
os_break();
if (!b->options->skip_os_break_in_debug_build)
os_break();
#endif
vtn_longjmp(b->fail_jump, 1);
+3 -1
View File
@@ -30,7 +30,7 @@
class spirv_test : public ::testing::Test {
protected:
spirv_test()
: shader(NULL)
: shader(NULL), break_on_failure(false)
{
glsl_type_singleton_init_or_ref();
}
@@ -54,6 +54,7 @@ protected:
spirv_options.push_const_addr_format = nir_address_format_32bit_offset;
spirv_options.shared_addr_format = nir_address_format_32bit_offset;
spirv_options.task_payload_addr_format = nir_address_format_32bit_offset;
spirv_options.skip_os_break_in_debug_build = !break_on_failure;
nir_shader_compiler_options nir_options;
memset(&nir_options, 0, sizeof(nir_options));
@@ -82,6 +83,7 @@ protected:
}
nir_shader *shader;
bool break_on_failure;
};
#endif /* SPIRV_TEST_HELPERS_H */