@@ -229,13 +229,13 @@ HWTEST_F(ModuleTest, GivenIncorrectNameWhenCreatingKernelThenResultErrorInvalidA
229229
230230 EXPECT_EQ (ZE_RESULT_ERROR_INVALID_ARGUMENT, res);
231231}
232- template < typename T>
232+
233233struct ModuleSpecConstantsTests : public DeviceFixture ,
234234 public ::testing::Test {
235235 void SetUp () override {
236236 DeviceFixture::SetUp ();
237237
238- mockCompiler = new MockCompilerInterfaceWithSpecConstants<T> (moduleNumSpecConstants);
238+ mockCompiler = new MockCompilerInterfaceWithSpecConstants (moduleNumSpecConstants);
239239 auto rootDeviceEnvironment = neoDevice->getExecutionEnvironment ()->rootDeviceEnvironments [0 ].get ();
240240 rootDeviceEnvironment->compilerInterface .reset (mockCompiler);
241241
@@ -246,72 +246,17 @@ struct ModuleSpecConstantsTests : public DeviceFixture,
246246 DeviceFixture::TearDown ();
247247 }
248248
249- void runTest () {
250- std::string testFile;
251- retrieveBinaryKernelFilenameNoRevision (testFile, binaryFilename + " _" , " .spv" );
252-
253- size_t size = 0 ;
254- auto src = loadDataFromFile (testFile.c_str (), size);
255-
256- ASSERT_NE (0u , size);
257- ASSERT_NE (nullptr , src);
258-
259- ze_module_desc_t moduleDesc = {};
260- moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
261- moduleDesc.pInputModule = reinterpret_cast <const uint8_t *>(src.get ());
262- moduleDesc.inputSize = size;
263-
264- specConstants.numConstants = mockCompiler->moduleNumSpecConstants ;
265- for (uint32_t i = 0 ; i < mockCompiler->moduleNumSpecConstants ; i++) {
266- specConstantsPointerValues.push_back (&mockCompiler->moduleSpecConstantsValues [i]);
267- }
268-
269- specConstants.pConstantIds = mockCompiler->moduleSpecConstantsIds .data ();
270- specConstants.pConstantValues = specConstantsPointerValues.data ();
271- moduleDesc.pConstants = &specConstants;
272-
273- auto module = new Module (device, nullptr , ModuleType::User);
274- module ->translationUnit .reset (mockTranslationUnit);
275-
276- bool success = module ->initialize (&moduleDesc, neoDevice);
277- for (uint32_t i = 0 ; i < mockCompiler->moduleNumSpecConstants ; i++) {
278- EXPECT_EQ (static_cast <T>(module ->translationUnit ->specConstantsValues [i]), mockCompiler->moduleSpecConstantsValues [i]);
279- }
280- EXPECT_TRUE (success);
281- module ->destroy ();
282- }
283-
284249 const uint32_t moduleNumSpecConstants = 4 ;
285250 ze_module_constants_t specConstants;
286251 std::vector<const void *> specConstantsPointerValues;
287252
288253 const std::string binaryFilename = " test_kernel" ;
289254 const std::string kernelName = " test" ;
290- MockCompilerInterfaceWithSpecConstants<T> *mockCompiler;
255+ MockCompilerInterfaceWithSpecConstants *mockCompiler;
291256 MockModuleTranslationUnit *mockTranslationUnit;
292257};
293258
294- using ModuleSpecConstantsLongTests = ModuleSpecConstantsTests<uint64_t >;
295- TEST_F (ModuleSpecConstantsLongTests, givenSpecializationConstantsSetWithLongSizeInDescriptorThenModuleCorrectlyPassesThemToTheCompiler) {
296- runTest ();
297- }
298- using ModuleSpecConstantsCharTests = ModuleSpecConstantsTests<char >;
299- TEST_F (ModuleSpecConstantsCharTests, givenSpecializationConstantsSetWithCharSizeInDescriptorThenModuleCorrectlyPassesThemToTheCompiler) {
300- runTest ();
301- }
302-
303- TEST_F (ModuleSpecConstantsLongTests, givenSpecializationConstantsSetWhenCompilerReturnsErrorThenModuleInitFails) {
304- class FailingMockCompilerInterfaceWithSpecConstants : public MockCompilerInterfaceWithSpecConstants <uint64_t > {
305- public:
306- FailingMockCompilerInterfaceWithSpecConstants (uint32_t moduleNumSpecConstants) : MockCompilerInterfaceWithSpecConstants<uint64_t >(moduleNumSpecConstants) {}
307- NEO::TranslationOutput::ErrorCode getSpecConstantsInfo (const NEO::Device &device,
308- ArrayRef<const char > srcSpirV, NEO::SpecConstantInfo &output) override {
309- return NEO::TranslationOutput::ErrorCode::CompilerNotAvailable;
310- }
311- };
312- mockCompiler = new FailingMockCompilerInterfaceWithSpecConstants (moduleNumSpecConstants);
313- auto rootDeviceEnvironment = neoDevice->getExecutionEnvironment ()->rootDeviceEnvironments [0 ].get ();
314- rootDeviceEnvironment->compilerInterface .reset (mockCompiler);
259+ HWTEST_F (ModuleSpecConstantsTests, givenSpecializationConstantsSetInDescriptorThenModuleCorrectlyPassesThemToTheCompiler) {
315260 std::string testFile;
316261 retrieveBinaryKernelFilenameNoRevision (testFile, binaryFilename + " _" , " .spv" );
317262
@@ -339,7 +284,7 @@ TEST_F(ModuleSpecConstantsLongTests, givenSpecializationConstantsSetWhenCompiler
339284 module ->translationUnit .reset (mockTranslationUnit);
340285
341286 bool success = module ->initialize (&moduleDesc, neoDevice);
342- EXPECT_FALSE (success);
287+ EXPECT_TRUE (success);
343288 module ->destroy ();
344289}
345290
0 commit comments