Skip to content

Commit 5041d7e

Browse files
Fixed coroutine filesystem tests #17
1 parent df06039 commit 5041d7e

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

Firmware/filesystem/filesystem/filesystem_holder.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <utils/MetaUtils.hpp>
1212

1313
#include <spdlog/spdlog.h>
14+
#include <cassert>
1415

1516
namespace Platform::Fs
1617
{
@@ -58,6 +59,7 @@ template <typename TBlockDeviceEntity> class Holder
5859
}
5960
CoroUtils::Task<File<This_t>> openFile(std::string_view path) noexcept
6061
{
62+
assert(!path.empty());
6163
File<This_t> retFile{&m_fsInstance};
6264
auto error = co_await lfs_file_open(
6365
&m_fsInstance,

Firmware/firmware_tests/filesystem/filesystem_in_memory_test.cpp

+15-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include <gtest/gtest.h>
44
#include <utils/coroutine/SyncWait.hpp>
55

6-
7-
constexpr auto HelloWorldData = FilesystemParamInterfaceData{ .fileData = "Hello world!", .filename = "helloworld.txt" };
6+
constexpr auto HelloWorldData =
7+
FilesystemParamInterfaceData{.fileData = "Hello world!", .filename = "helloworld.txt"};
88

99
constexpr auto kNmeaDataExample = std::string_view{
1010
"$GPGSA,A,1,,,,,,,,,,,,,,,* 1E\n"
@@ -40,35 +40,36 @@ constexpr auto kNmeaDataExample = std::string_view{
4040

4141
};
4242

43-
constexpr auto NmeaData = FilesystemParamInterfaceData{ .fileData = kNmeaDataExample,.filename = "nmea_data.txt" };
44-
43+
constexpr auto NmeaData =
44+
FilesystemParamInterfaceData{.fileData = kNmeaDataExample, .filename = "nmea_data.txt"};
4545

4646
TEST_P(FilesystemTopLevelTestFixture, CheckFileReadWriteProcedure)
4747
{
48-
spdlog::warn("simpleRwTest begin");
4948
auto lfs = m_testFilesystem.fsInstance();
5049
{
51-
auto filename = std::move(CoroUtils::syncWait(m_testFilesystem.openFile(GetParam().filename)));
52-
CoroUtils::syncWait(filename.write(
53-
std::span(reinterpret_cast<const std::uint8_t*>(GetParam().fileData.data()), GetParam().fileData.size())));
50+
auto filePath = GetParam().filename;
51+
auto filename = std::move(CoroUtils::syncWait(m_testFilesystem.openFile(filePath)));
52+
CoroUtils::syncWait(filename.write(std::span(
53+
reinterpret_cast<const std::uint8_t*>(GetParam().fileData.data()),
54+
GetParam().fileData.size())));
5455
}
5556

5657
std::vector<std::uint8_t> readFrom;
5758
readFrom.resize(GetParam().fileData.size());
5859

5960
{
60-
auto holdedFile = std::move(CoroUtils::syncWait(m_testFilesystem.openFile(GetParam().filename)));
61-
auto resultRead = CoroUtils::syncWait( holdedFile.read(std::span(readFrom.data(), GetParam().fileData.size())));
61+
auto holdedFile =
62+
std::move(CoroUtils::syncWait(m_testFilesystem.openFile(GetParam().filename)));
63+
auto resultRead = CoroUtils::syncWait(
64+
holdedFile.read(std::span(readFrom.data(), GetParam().fileData.size())));
6265
}
6366

6467
auto kCompareStringView{
65-
std::string_view{reinterpret_cast<const char*>(readFrom.data()), readFrom.size()} };
68+
std::string_view{reinterpret_cast<const char*>(readFrom.data()), readFrom.size()}};
6669
EXPECT_EQ(kCompareStringView, GetParam().fileData);
6770
}
6871

69-
7072
INSTANTIATE_TEST_SUITE_P(
7173
FilesystemTopLevelTesting,
7274
FilesystemTopLevelTestFixture,
73-
::testing::Values(
74-
FilesystemParamInterfaceData{}));
75+
::testing::Values(HelloWorldData, NmeaData));

0 commit comments

Comments
 (0)