Skip to content

Commit f62bdc4

Browse files
authored
Fix additional static analysis issues
Signed-off-by: Jemale Lockett <[email protected]>
1 parent e2944ad commit f62bdc4

File tree

24 files changed

+166
-38
lines changed

24 files changed

+166
-38
lines changed

conformance_tests/core/test_copy/src/test_copy_events.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class zeCommandListEventTests : public ::testing::Test {
2828
ep.create_event(hEvent, ZE_EVENT_SCOPE_FLAG_HOST, 0);
2929
}
3030

31-
~zeCommandListEventTests() { ep.destroy_event(hEvent); }
31+
void TearDown() override { ep.destroy_event(hEvent); }
3232

3333
ze_event_handle_t hEvent;
3434
size_t size = 16;

conformance_tests/core/test_copy/src/test_copy_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class zeCommandListAppendImageCopyTests : public ::testing::Test {
6161
ze_img_dest = lzt::create_ze_image(img_desc);
6262
}
6363

64-
~zeCommandListAppendImageCopyTests() {
64+
void TearDown() override {
6565
if (!(lzt::image_support())) {
6666
return;
6767
}

conformance_tests/core/test_fence/src/test_fence.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class zeFenceTests : public ::testing::Test {
5656
EXPECT_EQ(ZE_RESULT_SUCCESS, zeFenceCreate(cmd_q_, &descriptor, &fence_));
5757
EXPECT_NE(nullptr, fence_);
5858
}
59-
~zeFenceTests() {
59+
60+
void TearDown() override {
6061
EXPECT_EQ(ZE_RESULT_SUCCESS, zeFenceDestroy(fence_));
6162
lzt::destroy_command_queue(cmd_q_);
6263
lzt::destroy_command_list(cmd_list_);

conformance_tests/core/test_ipc/src/test_ipc_event_helper.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ int main() {
264264
lzt::get_default_device(lzt::get_default_driver());
265265
devices.push_back(device);
266266
}
267-
auto context = lzt::create_context_ex(lzt::get_default_driver(), std::move(devices));
267+
auto context =
268+
lzt::create_context_ex(lzt::get_default_driver(), std::move(devices));
268269
ze_event_pool_handle_t hEventPool = 0;
269270
LOG_INFO << "IPC Child open event handle";
270271
lzt::open_ipc_event_handle(context, hIpcEventPool, &hEventPool);
@@ -311,7 +312,11 @@ int main() {
311312
lzt::destroy_context(context);
312313
exit(1);
313314
}
314-
lzt::close_ipc_event_handle(hEventPool);
315+
try {
316+
lzt::close_ipc_event_handle(hEventPool);
317+
} catch (const std::runtime_error &ex) {
318+
LOG_ERROR << "Error closing IPC event handle: " << ex.what();
319+
}
315320
lzt::destroy_context(context);
316321
if (testing::Test::HasFailure()) {
317322
LOG_DEBUG << "IPC Child Failed GTEST Check";

conformance_tests/core/test_ipc/src/test_ipc_memory.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,11 @@ int main(int argc, char **argv) {
178178
std::vector<std::string> command_line(argv + 1, argv + argc);
179179
level_zero_tests::init_logging(command_line);
180180

181-
return RUN_ALL_TESTS();
181+
try {
182+
auto result = RUN_ALL_TESTS();
183+
return result;
184+
} catch (std::runtime_error &e) {
185+
std::cerr << "Test failed with exception: " << e.what() << std::endl;
186+
return 1;
187+
}
182188
}

conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,20 @@ TEST(
257257
// zeInit should be handled with fork(), so each process must call
258258
// zeInit
259259
int main(int argc, char **argv) {
260-
::testing::InitGoogleMock(&argc, argv);
260+
try {
261+
::testing::InitGoogleMock(&argc, argv);
262+
} catch (const std::exception &e) {
263+
LOG_ERROR << "Failed to init google mock: " << e.what();
264+
return 1;
265+
}
261266
std::vector<std::string> command_line(argv + 1, argv + argc);
262267
level_zero_tests::init_logging(command_line);
263268

264-
return RUN_ALL_TESTS();
269+
try {
270+
auto result = RUN_ALL_TESTS();
271+
return result;
272+
} catch (std::runtime_error &e) {
273+
std::cerr << "Test failed with exception: " << e.what() << std::endl;
274+
return 1;
275+
}
265276
}

conformance_tests/core/test_ipc/src/test_ipc_multisubdevice.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,20 @@ TEST(
292292
// zeInit should be handled with fork(), so each process must call
293293
// zeInit
294294
int main(int argc, char **argv) {
295-
::testing::InitGoogleMock(&argc, argv);
295+
try {
296+
::testing::InitGoogleMock(&argc, argv);
297+
} catch (std::exception &e) {
298+
std::cerr << "Failed to initialize GoogleMock: " << e.what() << std::endl;
299+
return 1;
300+
}
296301
std::vector<std::string> command_line(argv + 1, argv + argc);
297302
level_zero_tests::init_logging(command_line);
298303

299-
return RUN_ALL_TESTS();
304+
try {
305+
auto result = RUN_ALL_TESTS();
306+
return result;
307+
} catch (std::runtime_error &e) {
308+
std::cerr << "Test failed with exception: " << e.what() << std::endl;
309+
return 1;
310+
}
300311
}

conformance_tests/core/test_ipc/src/test_ipc_p2p_memory.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,5 +483,11 @@ int main(int argc, char **argv) {
483483
std::vector<std::string> command_line(argv + 1, argv + argc);
484484
level_zero_tests::init_logging(command_line);
485485

486-
return RUN_ALL_TESTS();
486+
try {
487+
auto result = RUN_ALL_TESTS();
488+
return result;
489+
} catch (std::runtime_error &e) {
490+
std::cerr << "Test failed with exception: " << e.what() << std::endl;
491+
return 1;
492+
}
487493
}

conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,20 @@ TEST(
536536
// zeInit should be handled with fork(), so each process must call
537537
// zeInit
538538
int main(int argc, char **argv) {
539-
::testing::InitGoogleMock(&argc, argv);
539+
try {
540+
::testing::InitGoogleMock(&argc, argv);
541+
} catch (std::exception &e) {
542+
std::cerr << "Failed to initialize GoogleMock: " << e.what() << std::endl;
543+
return 1;
544+
}
540545
std::vector<std::string> command_line(argv + 1, argv + argc);
541546
level_zero_tests::init_logging(command_line);
542547

543-
return RUN_ALL_TESTS();
548+
try {
549+
auto result = RUN_ALL_TESTS();
550+
return result;
551+
} catch (std::runtime_error &e) {
552+
std::cerr << "Test failed with exception: " << e.what() << std::endl;
553+
return 1;
554+
}
544555
}

conformance_tests/tools/debug/src/test_debug.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,13 @@ void zetDebugReadWriteRegistersTest::run_read_write_registers_test(
13051305

13061306
for (int i = 0; i < buffer_size; i++) {
13071307
if (static_cast<char>(0xaa) != static_cast<char *>(buffer)[i]) {
1308+
delete[] kernel_buffer;
1309+
auto found_val = static_cast<char *>(buffer)[i];
1310+
lzt::free_memory(buffer);
1311+
lzt::free_memory(buffer_copy);
13081312
FAIL() << "[Debugger] register set " << regSetNumber
13091313
<< " FAILED write test. Expected "
1310-
<< static_cast<char>(0xaa) << " , found "
1311-
<< static_cast<char *>(buffer)[i];
1314+
<< static_cast<char>(0xaa) << " , found " << found_val;
13121315
}
13131316
}
13141317

0 commit comments

Comments
 (0)