diff --git a/samples/zello_world/zello_world.cpp b/samples/zello_world/zello_world.cpp index ba11bb09..2facbd66 100644 --- a/samples/zello_world/zello_world.cpp +++ b/samples/zello_world/zello_world.cpp @@ -196,10 +196,14 @@ int main( int argc, char *argv[] ) zeEventHostSynchronize(event, UINT64_MAX ); std::cout << "Congratulations, the device completed execution!\n"; - zeContextDestroy(context); - zeCommandListDestroy(command_list); - zeEventDestroy(event); - zeEventPoolDestroy(event_pool); + if (!zelCheckIsLoaderInTearDown()) + zeContextDestroy(context); + if (!zelCheckIsLoaderInTearDown()) + zeCommandListDestroy(command_list); + if (!zelCheckIsLoaderInTearDown()) + zeEventDestroy(event); + if (!zelCheckIsLoaderInTearDown()) + zeEventPoolDestroy(event_pool); if (tracing_enabled) { status = zelTracerDestroy(tracer); diff --git a/source/lib/ze_lib.cpp b/source/lib/ze_lib.cpp index 50be7828..43c20927 100644 --- a/source/lib/ze_lib.cpp +++ b/source/lib/ze_lib.cpp @@ -489,7 +489,7 @@ zelCheckIsLoaderInTearDown() { if (ze_lib::destruction || ze_lib::context == nullptr) { return true; } - #ifdef DYNAMIC_LOAD_LOADER + #if defined(DYNAMIC_LOAD_LOADER) && defined(_WIN32) std::promise stabilityPromise; std::future resultFuture = stabilityPromise.get_future(); int result = -1; @@ -497,10 +497,6 @@ zelCheckIsLoaderInTearDown() { // Launch the stability checker thread std::thread stabilityThread(stabilityCheck, std::move(stabilityPromise)); result = resultFuture.get(); // Blocks until the result is available - if (ze_lib::context->debugTraceEnabled) { - std::string message = "Stability checker thread completed with result: " + std::to_string(result); - ze_lib::context->debug_trace_message(message, ""); - } stabilityThread.join(); } catch (const std::exception& e) { if (ze_lib::context->debugTraceEnabled) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9596906b..e124e11b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -97,6 +97,27 @@ endif() add_test(NAME tests_loader_teardown_check COMMAND tests --gtest_filter=*GivenLoaderNotInDestructionStateWhenCallingzelCheckIsLoaderInTearDownThenFalseIsReturned) set_property(TEST tests_loader_teardown_check PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1;ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME test_zello_world_legacy COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts --enable_validation_layer --enable_tracing_layer --enable_tracing_layer_runtime) +set_property(TEST test_zello_world_legacy PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + +add_test(NAME test_zello_world_legacy_intercept COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts) +set_property(TEST test_zello_world_legacy_intercept PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + +add_test(NAME test_zello_world_legacy_validation_layer COMMAND zello_world --enable_legacy_init --enable_null_driver --enable_validation_layer) +set_property(TEST test_zello_world_legacy_validation_layer PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + +add_test(NAME test_zello_world_legacy_tracing COMMAND zello_world --enable_legacy_init --enable_null_driver --enable_tracing_layer) +set_property(TEST test_zello_world_legacy_tracing PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + +add_test(NAME test_zello_world_legacy_dynamic_tracing COMMAND zello_world --enable_legacy_init --enable_null_driver --enable_tracing_layer_runtime) +set_property(TEST test_zello_world_legacy_dynamic_tracing PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + +add_test(NAME test_zello_world_legacy_all_tracing COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts --enable_validation_layer --enable_tracing_layer) +set_property(TEST test_zello_world_legacy_all_tracing PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + +add_test(NAME test_zello_world_legacy_all_tracing_dynamic COMMAND zello_world --enable_legacy_init --enable_null_driver --force_loader_intercepts --enable_validation_layer --enable_tracing_layer_runtime) +set_property(TEST test_zello_world_legacy_all_tracing_dynamic PROPERTY ENVIRONMENT "ZE_ENABLE_LOADER_DEBUG_TRACE=1") + # These tests are currently not supported on Windows. The reason is that the std::cerr is not being redirected to a pipe in Windows to be then checked against the expected output. if(NOT MSVC) add_test(NAME tests_event_deadlock COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeCommandListAppendMemoryCopyWithCircularDependencyOnEventsThenValidationLayerPrintsWarningOfDeadlock*) diff --git a/test/loader_api.cpp b/test/loader_api.cpp index 0d35fc2b..5ed18f0f 100644 --- a/test/loader_api.cpp +++ b/test/loader_api.cpp @@ -374,6 +374,9 @@ TEST( EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); EXPECT_FALSE(zelCheckIsLoaderInTearDown()); + EXPECT_FALSE(zelCheckIsLoaderInTearDown()); + EXPECT_FALSE(zelCheckIsLoaderInTearDown()); + EXPECT_FALSE(zelCheckIsLoaderInTearDown()); } class CaptureOutput {