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

Function VerifyFile

tensorflow/core/util/events_writer_test.cc:64–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void VerifyFile(const string& filename) {
65 CHECK(env()->FileExists(filename).ok());
66 std::unique_ptr<RandomAccessFile> event_file;
67 TF_CHECK_OK(env()->NewRandomAccessFile(filename, &event_file));
68 io::RecordReader* reader = new io::RecordReader(event_file.get());
69
70 uint64 offset = 0;
71
72 Event actual;
73 CHECK(ReadEventProto(reader, &offset, &actual));
74 VLOG(1) << actual.ShortDebugString();
75 // Wall time should be within 5s of now.
76
77 double current_time = env()->NowMicros() / 1000000.0;
78 EXPECT_LT(fabs(actual.wall_time() - current_time), 5);
79 // Should have the current version number.
80 EXPECT_EQ(actual.file_version(),
81 strings::StrCat(EventsWriter::kVersionPrefix,
82 EventsWriter::kCurrentVersion));
83
84 Event expected;
85 CHECK(ReadEventProto(reader, &offset, &actual));
86 VLOG(1) << actual.ShortDebugString();
87 ASSERT_TRUE(protobuf::TextFormat::ParseFromString(
88 "wall_time: 1234 step: 34 "
89 "summary { value { tag: 'foo' simple_value: 3.14159 } }",
90 &expected));
91 // TODO(keveman): Enable this check
92 // EXPECT_THAT(expected, EqualsProto(actual));
93
94 CHECK(ReadEventProto(reader, &offset, &actual));
95 VLOG(1) << actual.ShortDebugString();
96 ASSERT_TRUE(protobuf::TextFormat::ParseFromString(
97 "wall_time: 2345 step: 35 "
98 "summary { value { tag: 'bar' simple_value: -42 } }",
99 &expected));
100 // TODO(keveman): Enable this check
101 // EXPECT_THAT(expected, EqualsProto(actual));
102
103 TF_CHECK_OK(env()->DeleteFile(filename));
104 delete reader;
105}
106
107string GetDirName(const string& suffix) {
108 return io::JoinPath(testing::TmpDir(), suffix);

Callers 1

TESTFunction · 0.85

Calls 10

ReadEventProtoFunction · 0.85
envFunction · 0.70
StrCatFunction · 0.50
okMethod · 0.45
FileExistsMethod · 0.45
NewRandomAccessFileMethod · 0.45
getMethod · 0.45
ShortDebugStringMethod · 0.45
NowMicrosMethod · 0.45
DeleteFileMethod · 0.45

Tested by

no test coverage detected