@@ -61,3 +61,46 @@ TEST_P(urLevelZeroKernelNativeHandleTest, OwnedHandleRelease) {
6161 ASSERT_SUCCESS (urKernelRelease (kernel));
6262 ASSERT_SUCCESS (urProgramRelease (program));
6363}
64+
65+ TEST_P (urLevelZeroKernelNativeHandleTest, NullProgram) {
66+ ze_context_handle_t native_context;
67+ urContextGetNativeHandle (context, (ur_native_handle_t *)&native_context);
68+
69+ ze_device_handle_t native_device;
70+ urDeviceGetNativeHandle (device, (ur_native_handle_t *)&native_device);
71+
72+ std::shared_ptr<std::vector<char >> il_binary;
73+ uur::KernelsEnvironment::instance->LoadSource (" foo" , il_binary);
74+
75+ auto kernel_name =
76+ uur::KernelsEnvironment::instance->GetEntryPointNames (" foo" )[0 ];
77+
78+ ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC};
79+ moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
80+ moduleDesc.inputSize = il_binary->size ();
81+ moduleDesc.pInputModule =
82+ reinterpret_cast <const uint8_t *>(il_binary->data ());
83+ moduleDesc.pBuildFlags = " " ;
84+ ze_module_handle_t module ;
85+
86+ ASSERT_EQ (zeModuleCreate (native_context, native_device, &moduleDesc,
87+ &module , NULL ),
88+ ZE_RESULT_SUCCESS);
89+
90+ ze_kernel_desc_t kernelDesc = {ZE_STRUCTURE_TYPE_KERNEL_DESC};
91+ kernelDesc.pKernelName = kernel_name.c_str ();
92+
93+ ze_kernel_handle_t native_kernel;
94+
95+ ASSERT_EQ (zeKernelCreate (module , &kernelDesc, &native_kernel),
96+ ZE_RESULT_SUCCESS);
97+
98+ ur_kernel_native_properties_t kprops = {
99+ UR_STRUCTURE_TYPE_KERNEL_NATIVE_PROPERTIES, nullptr , 1 };
100+
101+ ur_kernel_handle_t kernel;
102+ EXPECT_EQ (urKernelCreateWithNativeHandle ((ur_native_handle_t )native_kernel,
103+ context, nullptr , &kprops,
104+ &kernel),
105+ UR_RESULT_ERROR_INVALID_NULL_HANDLE);
106+ }
0 commit comments