|
6 | 6 | #include <gtest/gtest.h>
|
7 | 7 | #include <iostream>
|
8 | 8 |
|
9 |
| -#include <simgrid/s4u/Engine.hpp> |
| 9 | +#include <simgrid/s4u/ActivitySet.hpp> |
10 | 10 | #include <simgrid/s4u/Actor.hpp>
|
| 11 | +#include <simgrid/s4u/Engine.hpp> |
11 | 12 |
|
12 | 13 | #include "fsmod/PathUtil.hpp"
|
13 | 14 | #include "fsmod/FileSystem.hpp"
|
@@ -161,6 +162,35 @@ TEST_F(OneDiskStorageTest, SingleAsyncWrite) {
|
161 | 162 | });
|
162 | 163 | }
|
163 | 164 |
|
| 165 | +TEST_F(OneDiskStorageTest, DoubleAsyncAppend) { |
| 166 | + DO_TEST_WITH_FORK([this]() { |
| 167 | + xbt_log_control_set("root.thresh:info"); |
| 168 | + this->setup_platform(); |
| 169 | + sg4::Actor::create("TestActor", host_, [this]() { |
| 170 | + std::shared_ptr<sgfs::File> file; |
| 171 | + sg4::ActivitySet pending_writes; |
| 172 | + XBT_INFO("Create an empty file at /dev/a/foo.txt"); |
| 173 | + ASSERT_NO_THROW(fs_->create_file("/dev/a/foo.txt", "0B")); |
| 174 | + XBT_INFO("Open File '/dev/a/foo.txt' in append mode"); |
| 175 | + ASSERT_NO_THROW(file = fs_->open("/dev/a/foo.txt", "a")); |
| 176 | + XBT_INFO("Asynchronously write 2MB at /dev/a/foo.txt"); |
| 177 | + ASSERT_NO_THROW(pending_writes.push(file->write_async("2MB"))); |
| 178 | + XBT_INFO("Sleep for .1 second"); |
| 179 | + ASSERT_NO_THROW(sg4::this_actor::sleep_for(0.1)); |
| 180 | + XBT_INFO("Asynchronously write another 2MB at /dev/a/foo.txt"); |
| 181 | + ASSERT_NO_THROW(pending_writes.push(file->write_async("2MB"))); |
| 182 | + XBT_INFO("Wait for completion of both write operations"); |
| 183 | + ASSERT_NO_THROW(pending_writes.wait_all()); |
| 184 | + XBT_INFO("Close the file"); |
| 185 | + ASSERT_NO_THROW(fs_->close(file)); |
| 186 | + XBT_INFO("Check the file size, should be 4MB"); |
| 187 | + ASSERT_EQ(fs_->file_size("/dev/a/foo.txt"), 4*1000*1000); |
| 188 | + }); |
| 189 | + // Run the simulation |
| 190 | + ASSERT_NO_THROW(sg4::Engine::get_instance()->run()); |
| 191 | + }); |
| 192 | +} |
| 193 | + |
164 | 194 | TEST_F(OneDiskStorageTest, SingleAppendWrite) {
|
165 | 195 | DO_TEST_WITH_FORK([this]() {
|
166 | 196 | this->setup_platform();
|
|
0 commit comments