| 134 | } // anonymous namespace |
| 135 | #if MGB_VERBOSE_TYPEINFO_NAME |
| 136 | TEST(TestOprIODump, Text) { |
| 137 | auto fname_base = output_file("test_opr_iodump"); |
| 138 | std::array<std::string, 3> fnames; |
| 139 | auto make_plugin = [&](ComputingGraph* graph, int level) { |
| 140 | fnames.at(level) = ssprintf("%s-%d.txt", fname_base.c_str(), level); |
| 141 | auto ret = std::make_unique<TextOprIODump>(graph, fnames[level].c_str()); |
| 142 | ret->print_addr(false); |
| 143 | return ret; |
| 144 | }; |
| 145 | |
| 146 | auto check_result = [&]() { |
| 147 | for (int level = 0; level < 3; ++level) { |
| 148 | std::ifstream inp_get{fnames[level]}; |
| 149 | std::istringstream inp_expect{EXPECTED_TEXT_OUT_REC[level]}; |
| 150 | |
| 151 | auto lines_get = getlines(inp_get), lines_expect = getlines(inp_expect, 1); |
| 152 | ASSERT_EQ(lines_expect.size(), lines_get.size()); |
| 153 | for (size_t i = 0; i < lines_expect.size(); ++i) { |
| 154 | ASSERT_EQ(lines_expect[i], lines_get[i]) << "fail on line " << i; |
| 155 | } |
| 156 | } |
| 157 | for (auto&& i : fnames) { |
| 158 | // clear the content to test if next run does not produce any output |
| 159 | debug::write_to_file(i.c_str(), "Lorem ipsum"); |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | run_test(make_plugin, check_result); |
| 164 | } |
| 165 | #endif |
| 166 | |
| 167 | TEST(TestOprIODump, StdErr) { |
nothing calls this directly
no test coverage detected