|
7 | 7 |
|
8 | 8 | #include "level_zero/core/test/unit_tests/experimental/test_graph_export.h" |
9 | 9 |
|
| 10 | +#include "shared/test/common/helpers/stream_capture.h" |
10 | 11 | #include "shared/test/common/mocks/mock_io_functions.h" |
11 | 12 |
|
12 | 13 | #include "level_zero/core/test/unit_tests/fixtures/module_fixture.h" |
@@ -690,26 +691,46 @@ TEST_F(GraphDotExporterFileTest, GivenEmptyGraphWhenExportToFileThenWritesValidD |
690 | 691 | } |
691 | 692 |
|
692 | 693 | TEST_F(GraphDotExporterFileTest, GivenFailedFileOpenWhenExportToFileThenReturnsUnknownError) { |
| 694 | + DebugManagerStateRestore restorer; |
| 695 | + NEO::debugManager.flags.PrintDebugMessages.set(true); |
| 696 | + |
693 | 697 | Graph testGraph{&ctx, true}; |
694 | 698 | setupFailedOpen(); |
695 | 699 |
|
| 700 | + StreamCapture capture; |
| 701 | + capture.captureStderr(); |
| 702 | + |
696 | 703 | auto result = exporter.exportToFile(testGraph, testFilePath.c_str()); |
697 | 704 | EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result); |
698 | 705 |
|
699 | 706 | EXPECT_EQ(mockFopenCalledBefore + 1, NEO::IoFunctions::mockFopenCalled); |
700 | 707 | EXPECT_EQ(mockFwriteCalledBefore, NEO::IoFunctions::mockFwriteCalled); |
| 708 | + |
| 709 | + auto errorMessage = capture.getCapturedStderr(); |
| 710 | + auto expectedErrorMessage = "Failed to open file " + testFilePath + " for writing graph content\n"; |
| 711 | + EXPECT_EQ(expectedErrorMessage, errorMessage); |
701 | 712 | } |
702 | 713 |
|
703 | 714 | TEST_F(GraphDotExporterFileTest, GivenFailedFileWriteWhenExportToFileThenReturnsUnknownError) { |
| 715 | + DebugManagerStateRestore restorer; |
| 716 | + NEO::debugManager.flags.PrintDebugMessages.set(true); |
| 717 | + |
704 | 718 | Graph testGraph{&ctx, true}; |
705 | 719 | setupFailedWrite(); |
706 | 720 |
|
| 721 | + StreamCapture capture; |
| 722 | + capture.captureStderr(); |
| 723 | + |
707 | 724 | auto result = exporter.exportToFile(testGraph, testFilePath.c_str()); |
708 | 725 | EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result); |
709 | 726 |
|
710 | 727 | EXPECT_EQ(mockFopenCalledBefore + 1, NEO::IoFunctions::mockFopenCalled); |
711 | 728 | EXPECT_EQ(mockFwriteCalledBefore + 1, NEO::IoFunctions::mockFwriteCalled); |
712 | 729 | EXPECT_EQ(mockFcloseCalledBefore + 1, NEO::IoFunctions::mockFcloseCalled); |
| 730 | + |
| 731 | + auto errorMessage = capture.getCapturedStderr(); |
| 732 | + auto expectedErrorMessage = "Failed to write graph content to file " + testFilePath + "\n"; |
| 733 | + EXPECT_EQ(expectedErrorMessage, errorMessage); |
713 | 734 | } |
714 | 735 |
|
715 | 736 | TEST(GraphDumpHelperTest, GivenNullptrAndPtrWhenFormatPointerIsCalledThenReturnsFormattedString) { |
|
0 commit comments