Skip to content

Commit

Permalink
Testing++
Browse files Browse the repository at this point in the history
Removal of useless code
  • Loading branch information
henricasanova committed Oct 11, 2024
1 parent a1384c3 commit a21b230
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ namespace simgrid::fsmod {
auto src_size = src_metadata->get_current_size();
auto dst_size = dst_metadata->get_current_size();

if (dst_size < src_size) {
if (src_size - dst_size > this->get_free_space()) {
this->create_space(src_size - dst_size);
}
}
// if (dst_size < src_size) {
// if (src_size - dst_size > this->get_free_space()) {
// this->create_space(src_size - dst_size);
// }
// }

// Update free space
if (dst_size < src_size) {
Expand Down
11 changes: 11 additions & 0 deletions test/file_system_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,23 @@ TEST_F(FileSystemTest, FileMove) {
ASSERT_NO_THROW(fs_->create_file("/dev/a/stuff.txt", "20kB"));
ASSERT_DOUBLE_EQ(fs_->partition_by_name("/dev/a/")->get_free_space(), 70*1000);

// Moving a smaller file to a bigger file (saves space)
XBT_INFO("Move file /dev/a/b/c/foo.txt to /dev/a/stuff.txt");
ASSERT_NO_THROW(fs_->move_file("/dev/a/b/c/foo.txt", "/dev/a/stuff.txt"));
ASSERT_FALSE(fs_->file_exists("/dev/a/b/c/foo.txt"));
ASSERT_TRUE(fs_->file_exists("/dev/a/stuff.txt"));
ASSERT_DOUBLE_EQ(fs_->partition_by_name("/dev/a/")->get_free_space(), 80*1000);

// Moving a bigger file to a smaller file (takes space)
XBT_INFO("Create a 20kB file at /dev/a/big.txt");
ASSERT_NO_THROW(fs_->create_file("/dev/a/big.txt", "20kB"));
ASSERT_DOUBLE_EQ(fs_->partition_by_name("/dev/a/")->get_free_space(), 60*1000);
XBT_INFO("Move file /dev/a/stuff.txt to /dev/a/big.txt");
ASSERT_NO_THROW(fs_->move_file("/dev/a/stuff.txt", "/dev/a/big.txt"));
ASSERT_FALSE(fs_->file_exists("/dev/a/stuff.txt"));
ASSERT_TRUE(fs_->file_exists("/dev/a/big.txt"));
ASSERT_DOUBLE_EQ(fs_->partition_by_name("/dev/a/")->get_free_space(), 70*1000);

auto ods = sgfs::OneDiskStorage::create("my_storage", disk_two_);
XBT_INFO("Mount a new partition");
ASSERT_NO_THROW(fs_->mount_partition("/dev/b/", ods, "100kB"));
Expand Down

0 comments on commit a21b230

Please sign in to comment.