| 138 | } |
| 139 | |
| 140 | static void CompareWithGoldenFile( |
| 141 | const string& tensorflow_relative_golden_file_name, |
| 142 | const string& expected_contents) { |
| 143 | // To update the golden file, flip update_golden to true and run the |
| 144 | // following: |
| 145 | // bazel test --test_strategy=local \ |
| 146 | // third_party/tensorflow/compiler/aot:codegen_test |
| 147 | const bool update_golden = false; |
| 148 | const string golden_file_name = io::JoinPath( |
| 149 | testing::TensorFlowSrcRoot(), tensorflow_relative_golden_file_name); |
| 150 | |
| 151 | if (update_golden) { |
| 152 | TF_EXPECT_OK( |
| 153 | WriteStringToFile(Env::Default(), golden_file_name, expected_contents)); |
| 154 | } |
| 155 | |
| 156 | string golden_file_contents; |
| 157 | TF_ASSERT_OK(ReadFileToString(Env::Default(), golden_file_name, |
| 158 | &golden_file_contents)); |
| 159 | EXPECT_EQ(golden_file_contents, expected_contents); |
| 160 | } |
| 161 | |
| 162 | TEST(CodegenTest, Golden) { |
| 163 | // Normally CpuCompiler::CpuCompiler does this, but in this test we've |
no test coverage detected