@@ -59,3 +59,32 @@ TEST_P(urProgramGetGlobalVariablePointerTest,
5959 &global_variable_size, nullptr ),
6060 UR_RESULT_ERROR_INVALID_NULL_POINTER);
6161}
62+
63+ TEST_P (urProgramGetGlobalVariablePointerTest, InvalidProgramExecutable) {
64+ ur_platform_backend_t backend;
65+ ASSERT_SUCCESS (urPlatformGetInfo (platform, UR_PLATFORM_INFO_BACKEND,
66+ sizeof (ur_platform_backend_t ), &backend,
67+ nullptr ));
68+ if (backend != UR_PLATFORM_BACKEND_LEVEL_ZERO) {
69+ GTEST_SKIP ();
70+ }
71+ // Get IL from the compiled program.
72+ size_t il_size = 0 ;
73+ ASSERT_SUCCESS (
74+ urProgramGetInfo (program, UR_PROGRAM_INFO_IL, 0 , nullptr , &il_size));
75+ ASSERT_GT (il_size, 0 );
76+ std::vector<char > il (il_size);
77+ ASSERT_SUCCESS (urProgramGetInfo (program, UR_PROGRAM_INFO_IL, il_size,
78+ il.data (), nullptr ));
79+ // Create program with IL.
80+ ur_program_handle_t program_with_il;
81+ ASSERT_SUCCESS (urProgramCreateWithIL (context, il.data (), il.size (), nullptr ,
82+ &program_with_il));
83+ // Expect error when trying to get global variable pointer from a program which is not in exe state.
84+ size_t global_variable_size = 0 ;
85+ void *global_variable_pointer;
86+ ASSERT_EQ_RESULT (urProgramGetGlobalVariablePointer (
87+ device, program_with_il, global_var.name .c_str (),
88+ &global_variable_size, &global_variable_pointer),
89+ UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE);
90+ }
0 commit comments