Skip to content

Commit 12d5513

Browse files
Lucjan BryndzaLucjan Bryndza
andauthored
[EGD-4075] Use FATFS in the Linux builds (#843)
* [EGD-4075] Use FAT fs in the emulator Add script for genrate base phone image * [EGD-4075] Use FreeRTOS-FAT in emulator initial commit * [EGD-4075] Thread local storage fix Fixing thread local storage when running on the Linux platform in the test mode * [EGD-4075] Improve image generation Improve image generation script on the linux platform * [EGD-4075] Fix all test with FAT fs image Fix all tests with fatfs image * [EGD-4075] Fix calculator utility test * [EGD-4075] Image dependencies fix * Remove uneeded comments * Missing headers in CR * [EGD-4075] Fixed whitespaces Co-authored-by: Lucjan Bryndza <[email protected]>
1 parent ddffb2a commit 12d5513

File tree

30 files changed

+843
-378
lines changed

30 files changed

+843
-378
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
path = module-utils/magic_enum
5555
url = [email protected]:Neargye/magic_enum.git
5656
[submodule "module-vfs/board/cross/freeRTOS_FAT"]
57-
path = module-vfs/board/cross/freeRTOS_FAT
57+
path = module-vfs/board/freeRTOS_FAT
5858
url = ../Lab-Project-FreeRTOS-FAT.git
5959
[submodule "module-utils/tinyexpr"]
6060
path = module-utils/tinyexpr

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ set_source_files_properties(source/main.cpp PROPERTIES COMPILE_DEFINITIONS "${EN
204204
target_link_options(${PROJECT_NAME} PUBLIC ${TARGET_LINK_OPTIONS})
205205

206206
if (${PROJECT_TARGET} STREQUAL "TARGET_Linux")
207+
208+
set(FAT_IMAGE ${CMAKE_PROJECT_NAME}.img)
209+
add_custom_command(
210+
OUTPUT ${FAT_IMAGE}
211+
DEPENDS assets
212+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate_fatfs_image.sh ${FAT_IMAGE} ${CMAKE_BINARY_DIR}
213+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
214+
COMMENT "Generate ${FAT_IMAGE}"
215+
)
216+
add_custom_target(
217+
${FAT_IMAGE}-target ALL
218+
DEPENDS ${FAT_IMAGE}
219+
)
220+
add_dependencies(check ${FAT_IMAGE}-target)
207221
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION "./")
208222
endif()
209223

generate_fatfs_image.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash -e
2+
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
3+
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
4+
5+
usage() {
6+
cat << ==usage
7+
Usage: $(basename $0) [image_dir] [assets_root_dir]
8+
image_dir Target disk image
9+
asset_root_dir Asset root directory
10+
==usage
11+
}
12+
13+
ASSETS_DIR="assets country-codes.db Luts.bin"
14+
15+
TEST_ITEMS="testfiles"
16+
17+
if [ $# -ne 2 ]; then
18+
echo "Error! Invalid argument count"
19+
usage
20+
exit -1
21+
fi
22+
IMAGE_NAME=$(realpath $1)
23+
SRC_DATA=$(realpath $2)
24+
25+
if [ ! -d "$SRC_DATA" ]; then
26+
echo "Error! asset_root_dir is not a directory"
27+
usage
28+
exit -1
29+
fi
30+
31+
truncate -s 16G $IMAGE_NAME
32+
sfdisk $IMAGE_NAME << ==sfdisk
33+
label: dos
34+
label-id: 0x09650eb4
35+
unit: sectors
36+
37+
/dev/sda1 : start= 2048, size= 28522496, type=b, bootable
38+
/dev/sda2 : start= 28524544, size= 2097152, type=b
39+
==sfdisk
40+
41+
PART1="$IMAGE_NAME@@1048576"
42+
PART2="$IMAGE_NAME@@14604566528"
43+
mformat -i "$PART1" -F -T 28522496 -v PUREOS
44+
mformat -i "$PART2" -F -T 2097152 -v RECOVER
45+
mmd -i "$PART1" ::/current
46+
cd "$SRC_DATA"
47+
for i in $ASSETS_DIR; do
48+
mcopy -s -i "$PART1" $i ::/current/
49+
done
50+
mcopy -s -i "$PART1" user ::
51+
mcopy -s -i "$PART1" .boot.json ::
52+
mcopy -s -i "$PART1" .boot.json.crc32 ::
53+
54+
# Testing parts of files
55+
for i in $TEST_ITEMS; do
56+
mcopy -s -i "$PART1" $i ::/current
57+
done
58+
mcopy -s -i "$PART1" sys/updates ::
59+
60+
cd -

module-apps/application-calculator/tests/CalculatorUtility_tests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
class vfs vfs;
1111

12+
struct vfs_initializer
13+
{
14+
vfs_initializer()
15+
{
16+
vfs.Init();
17+
}
18+
} vfs_initializer;
19+
1220
TEST_CASE("Calculator utilities")
1321
{
1422
auto calculator = Calculator();

module-audio/Audio/test/unittest_audio.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,29 @@
1919

2020
class vfs vfs;
2121

22+
struct vfs_initializer
23+
{
24+
vfs_initializer()
25+
{
26+
vfs.Init();
27+
}
28+
} vfs_init;
29+
2230
TEST_CASE("Test audio tags")
2331
{
24-
std::vector<std::string> testExtensions = {"flac", "wav", "mp3"};
25-
for (auto ext : testExtensions) {
26-
auto dec = audio::decoder::Create(("testfiles/audio." + ext).c_str());
27-
REQUIRE(dec);
28-
auto tags = dec->fetchTags();
29-
REQUIRE(tags);
30-
REQUIRE(tags->title == ext + " Test track title");
31-
REQUIRE(tags->artist == ext + " Test artist name");
32-
REQUIRE(tags->album == ext + " Test album title");
33-
REQUIRE(tags->year == "2020");
32+
SECTION(" Encoder tests ")
33+
{
34+
std::vector<std::string> testExtensions = {"flac", "wav", "mp3"};
35+
for (auto ext : testExtensions) {
36+
auto dec = audio::decoder::Create(("testfiles/audio." + ext).c_str());
37+
REQUIRE(dec);
38+
auto tags = dec->fetchTags();
39+
REQUIRE(tags);
40+
REQUIRE(tags->title == ext + " Test track title");
41+
REQUIRE(tags->artist == ext + " Test artist name");
42+
REQUIRE(tags->album == ext + " Test album title");
43+
REQUIRE(tags->year == "2020");
44+
}
3445
}
3546
}
3647

module-db/tests/unittest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818

1919
class vfs vfs;
2020

21+
struct vfs_initializer
22+
{
23+
vfs_initializer()
24+
{
25+
vfs.Init();
26+
}
27+
} vfs_initializer;
28+
2129
TEST_CASE("Create and destroy simple database")
2230
{
2331

module-gui/test/test-catch-text/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@
88

99
class vfs vfs; // needed for compilation, our vfs is global
1010
utils::i18 localize; // needed to load any keymap - these are stored in i18
11+
12+
struct vfs_initializer
13+
{
14+
vfs_initializer()
15+
{
16+
vfs.Init();
17+
}
18+
} vfs_initializer;

module-gui/test/test-catch/test-gui.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "mock/InitializedFontManager.hpp"
77
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
88

9+
#include <vfs.hpp>
910
#include <memory>
1011
#include <functional>
1112
#include <iostream>
@@ -25,14 +26,21 @@
2526
#include <module-gui/gui/widgets/Label.hpp>
2627
#include <module-gui/gui/widgets/BoxLayout.hpp>
2728
#include <module-gui/gui/widgets/Image.hpp>
28-
#include <vfs.hpp>
2929

3030
#include <mock/TestWindow.hpp>
3131

3232
using namespace std;
3333

3434
class vfs vfs;
3535

36+
struct vfs_initializer
37+
{
38+
vfs_initializer()
39+
{
40+
vfs.Init();
41+
}
42+
} vfs_init;
43+
3644
TEST_CASE("Test BoundingBox intersect")
3745
{
3846
gui::BoundingBox result;

module-services/service-desktop/tests/unittest.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@
1919

2020
class vfs vfs;
2121

22+
struct vfs_initializer
23+
{
24+
vfs_initializer()
25+
{
26+
vfs.Init();
27+
}
28+
} vfs_initializer;
29+
2230
TEST_CASE("System Update Tests")
2331
{
24-
ServiceDesktop serviceDesktop;
25-
vfs.Init();
26-
UpdatePureOS updateOS(&serviceDesktop);
32+
UpdatePureOS updateOS(nullptr);
2733

2834
updateos::UpdateError err = updateOS.prepareTempDirForUpdate();
2935
REQUIRE(err == updateos::UpdateError::NoError);
@@ -39,7 +45,6 @@ TEST_CASE("System Update Tests")
3945

4046
TEST_CASE("Factory Reset Test")
4147
{
42-
vfs.Init();
4348

4449
std::string sysdir = purefs::dir::eMMC_disk;
4550
sysdir += "/factory-test/sys";

module-utils/board/linux/log.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ static void _log_Log(
9494
std::cout << loggerBuffer;
9595
}
9696

97-
void log_Log(logger_level level, const char *file, int line, const char *function, const char *fmt, ...)
97+
__attribute__((weak)) void log_Log(
98+
logger_level level, const char *file, int line, const char *function, const char *fmt, ...)
9899
{
99100
va_list args;
100101
va_start(args, fmt);

0 commit comments

Comments
 (0)