diff options
author | Vijay Vasudevan <vrv@google.com> | 2016-06-16 18:04:10 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-06-16 19:16:41 -0700 |
commit | 209c006578483460e98c114a69d4b9ed6b95efed (patch) | |
tree | 0d0fa06e6472beea7291a2ea7bedc562e0a7f6dc /tensorflow/core/util/memmapped_file_system_test.cc | |
parent | 92753d80cf09efd6e9b9156e7ad08b3203214cec (diff) |
TensorFlow: minor change functions in Env interface.
Switches to return a std::unique_ptr<> to convey transfer of ownership.
Keeps existing functions temporarily for backwards compatibility.
Change file_system.h interface to switch entirely to the new interface,
change all callers. If this breaks someone in the public, the interface
change should be straightforward.
Change: 125127028
Diffstat (limited to 'tensorflow/core/util/memmapped_file_system_test.cc')
-rw-r--r-- | tensorflow/core/util/memmapped_file_system_test.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tensorflow/core/util/memmapped_file_system_test.cc b/tensorflow/core/util/memmapped_file_system_test.cc index 37408642a3..26e94f99f7 100644 --- a/tensorflow/core/util/memmapped_file_system_test.cc +++ b/tensorflow/core/util/memmapped_file_system_test.cc @@ -76,10 +76,10 @@ TEST(MemmappedFileSystemTest, SimpleTest) { ReadBinaryProto(&memmapped_env, kProtoFileName, &test_graph_def)); EXPECT_EQ(kTestGraphDefVersion, test_graph_def.version()); // Check that we can correctly get a tensor memory. - ReadOnlyMemoryRegion* memory_region; + std::unique_ptr<ReadOnlyMemoryRegion> memory_region; TF_ASSERT_OK(memmapped_env.NewReadOnlyMemoryRegionFromFile(kTensor2FileName, &memory_region)); - std::unique_ptr<ReadOnlyMemoryRegion> mem_region_ptr(memory_region); + // The memory region can be bigger but not less than Tensor size. ASSERT_GE(memory_region->length(), test_tensor.TotalBytes()); EXPECT_EQ(test_tensor.tensor_data(), @@ -103,7 +103,7 @@ TEST(MemmappedFileSystemTest, SimpleTest) { TEST(MemmappedFileSystemTest, NotInitalized) { MemmappedEnv memmapped_env(Env::Default()); - ReadOnlyMemoryRegion* memory_region; + std::unique_ptr<ReadOnlyMemoryRegion> memory_region; EXPECT_EQ( error::FAILED_PRECONDITION, memmapped_env @@ -131,19 +131,17 @@ TEST(MemmappedFileSystemTest, ProxyToDefault) { const string dir = testing::TmpDir(); const string filename = io::JoinPath(dir, "test_file"); // Check that we can create write and read ordinary file. - WritableFile* writable_file; + std::unique_ptr<WritableFile> writable_file; TF_ASSERT_OK(memmapped_env.NewAppendableFile(filename, &writable_file)); - std::unique_ptr<WritableFile> writable_file_ptr(writable_file); const string test_string = "bla-bla-bla"; TF_ASSERT_OK(writable_file->Append(test_string)); TF_ASSERT_OK(writable_file->Close()); uint64 file_length = 0; TF_EXPECT_OK(memmapped_env.GetFileSize(filename, &file_length)); EXPECT_EQ(test_string.length(), file_length); - RandomAccessFile* random_access_file; + std::unique_ptr<RandomAccessFile> random_access_file; TF_ASSERT_OK( memmapped_env.NewRandomAccessFile(filename, &random_access_file)); - delete random_access_file; } } // namespace |