From a8526d28a800fa75982d8be2a98933d1a70dbd33 Mon Sep 17 00:00:00 2001 From: Gleb Natapov <gleb@cloudius-systems.com> Date: Mon, 28 Apr 2014 15:30:25 +0300 Subject: [PATCH] test: add test for renaming of opened file. Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com> Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com> --- tests/tst-rename.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/tst-rename.cc b/tests/tst-rename.cc index c270086da..03abb2d50 100644 --- a/tests/tst-rename.cc +++ b/tests/tst-rename.cc @@ -91,6 +91,19 @@ static void test_rename(const fs::path& src, const fs::path& dst) BOOST_CHECK_MESSAGE(fs::remove(dst), "Sould be possible to remove new file"); } +static void test_rename_from_open_file(const fs::path& src, const fs::path& dst) +{ + prepare_file(src); + + fs::ifstream file(src); + + assert_renames(src, dst); + + check_file(dst); + BOOST_CHECK_MESSAGE(!fs::exists(src), "Old file should not exist"); + BOOST_CHECK_MESSAGE(fs::remove(dst), "Sould be possible to remove new file"); +} + static void test_file_rename_fails(const fs::path& src, const fs::path& dst, std::vector<int> errnos) { prepare_file(src); @@ -107,6 +120,10 @@ BOOST_AUTO_TEST_CASE(test_renaming_in_the_same_directory) dir / "file1", dir / "file2"); + test_rename_from_open_file( + dir / "file1", + dir / "file2"); + test_rename( dir / "a", dir / "aaaaa"); -- GitLab