MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/compiler/mlir/tensorflow/utils/error_util_test.cc:30–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28using testing::HasSubstr;
29
30TEST(ErrorUtilTest, StatusScopedDiagnosticHandler) {
31 MLIRContext context;
32 auto id = Identifier::get("test.cc", &context);
33 auto loc = FileLineColLoc::get(id, 0, 0, &context);
34
35 // Test OK without diagnostic gets passed through.
36 {
37 TF_ASSERT_OK(StatusScopedDiagnosticHandler(&context).Combine(Status::OK()));
38 }
39
40 // Verify diagnostics are captured as Unknown status.
41 {
42 StatusScopedDiagnosticHandler handler(&context);
43 emitError(loc) << "Diagnostic message";
44 ASSERT_TRUE(tensorflow::errors::IsUnknown(handler.ConsumeStatus()));
45 }
46
47 // Verify passed in errors are propagated.
48 {
49 Status err = tensorflow::errors::Internal("Passed in error");
50 ASSERT_TRUE(tensorflow::errors::IsInternal(
51 StatusScopedDiagnosticHandler(&context).Combine(err)));
52 }
53
54 // Verify diagnostic reported are append to passed in error.
55 {
56 auto function = [&]() {
57 emitError(loc) << "Diagnostic message reported";
58 emitError(loc) << "Second diagnostic message reported";
59 return tensorflow::errors::Internal("Passed in error");
60 };
61 Status s = StatusScopedDiagnosticHandler(&context).Combine(function());
62 ASSERT_TRUE(tensorflow::errors::IsInternal(s));
63 EXPECT_THAT(s.error_message(), HasSubstr("Passed in error"));
64 EXPECT_THAT(s.error_message(), HasSubstr("Diagnostic message reported"));
65 EXPECT_THAT(s.error_message(),
66 HasSubstr("Second diagnostic message reported"));
67 }
68}
69
70} // namespace
71} // namespace mlir

Callers

nothing calls this directly

Calls 8

IsUnknownFunction · 0.85
InternalFunction · 0.85
ConsumeStatusMethod · 0.80
getFunction · 0.50
functionFunction · 0.50
HasSubstrFunction · 0.50
CombineMethod · 0.45

Tested by

no test coverage detected