From 6cba32442a0bb33f79e6075ea93c2f77545f9544 Mon Sep 17 00:00:00 2001 From: Henri Casanova Date: Fri, 11 Oct 2024 17:10:39 -1000 Subject: [PATCH] testing++ --- test/file_system_test.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/file_system_test.cpp b/test/file_system_test.cpp index 171d325..de53403 100644 --- a/test/file_system_test.cpp +++ b/test/file_system_test.cpp @@ -322,6 +322,31 @@ TEST_F(FileSystemTest, BadAccessMode) { ASSERT_THROW(file = fs_->open("/dev/a/bar.txt", "r"), sgfs::FileNotFoundException); }); + // Run the simulation + ASSERT_NO_THROW(sg4::Engine::get_instance()->run()); + }); +} + +TEST_F(FileSystemTest, ReadPlusMode) { + DO_TEST_WITH_FORK([this]() { + this->setup_platform(); + // Create one actor (for this test we could likely do it all in the maestro but what the hell) + sg4::Actor::create("TestActor", host_, [this]() { + std::shared_ptr file; + XBT_INFO("Create a 10kB file at /dev/a/foo.txt"); + ASSERT_NO_THROW(fs_->create_file("/dev/a/foo.txt", "10kB")); + XBT_INFO("Open the file in read+ mode ('r+')"); + ASSERT_NO_THROW(file = fs_->open("/dev/a/foo.txt", "r+")); + XBT_INFO("Seek to the mid point of the file"); + ASSERT_NO_THROW(file->seek(-5000, SEEK_END)); + XBT_INFO("Write 10Kb to the file"); + ASSERT_NO_THROW(file->write("10kB")); + XBT_INFO("Close the file"); + ASSERT_NO_THROW(file->close()); + XBT_INFO("Check the file size"); + ASSERT_EQ(fs_->file_size("/dev/a/foo.txt"), 15000); + }); + // Run the simulation ASSERT_NO_THROW(sg4::Engine::get_instance()->run()); });