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

Function TestReadError

tensorflow/core/lib/io/recordio_test.cc:307–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307void TestReadError(const RecordWriterOptions& writer_options,
308 const RecordReaderOptions& reader_options) {
309 const string wrote = BigString("well hello there!", 100);
310 string contents;
311 StringDest dst(&contents);
312 TF_ASSERT_OK(RecordWriter(&dst, writer_options).WriteRecord(wrote));
313
314 StringSource file(&contents);
315 RecordReader reader(&file, reader_options);
316
317 uint64 offset = 0;
318 string read;
319 file.force_error();
320 Status status = reader.ReadRecord(&offset, &read);
321 ASSERT_TRUE(errors::IsDataLoss(status));
322 ASSERT_EQ(0, offset);
323
324 // A failed Read() shouldn't update the offset, and thus a retry shouldn't
325 // lose the record.
326 status = reader.ReadRecord(&offset, &read);
327 ASSERT_TRUE(status.ok()) << status;
328 EXPECT_GT(offset, 0);
329 EXPECT_EQ(wrote, read);
330}
331
332TEST_F(RecordioTest, ReadError) {
333 TestReadError(RecordWriterOptions(), RecordReaderOptions());

Callers 1

TEST_FFunction · 0.85

Calls 6

BigStringFunction · 0.85
force_errorMethod · 0.80
RecordWriterClass · 0.70
WriteRecordMethod · 0.45
ReadRecordMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected