1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
set(TEST_SYSROOT ${CMAKE_BINARY_DIR}/test-sysroot)
add_custom_target("test_disk_image")
add_custom_command(
PRE_BUILD
TARGET test_disk_image
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gendisktestimg.sh ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_catch2_executable(
NAME vfs-disk
SRCS
${CMAKE_CURRENT_LIST_DIR}/unittest_disk_manager.cpp
LIBS
platform
purefs-paths
DEPS
test_disk_image
USE_FS
)
add_catch2_executable(
NAME vfs-core-fs
SRCS
${CMAKE_CURRENT_LIST_DIR}/unittest_filesystem_core.cpp
LIBS
platform
module-vfs
USE_FS
)
set(LITTLEFS_IMAGE "lfstest.img")
add_custom_target(
${LITTLEFS_IMAGE}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/genlfstestimg.sh 1G ${LITTLEFS_IMAGE} ${TEST_SYSROOT}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS genlittlefs test-assets
)
set(EXT4_IMAGE "ext4test.img")
add_custom_target(
${EXT4_IMAGE}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/genext4diskimg.sh 1G ${EXT4_IMAGE} ${CMAKE_BINARY_DIR}/module-platform/test_dir
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS genlittlefs test-assets
)
add_catch2_executable(
NAME vfs-littlefs
SRCS
${CMAKE_CURRENT_LIST_DIR}/unittest_filesystem_littlefs.cpp
LIBS
platform
module-vfs
DEPS
${LITTLEFS_IMAGE}
USE_FS
)
add_catch2_executable(
NAME vfs-ext4
SRCS
${CMAKE_CURRENT_LIST_DIR}/unittest_filesystem_ext4.cpp
LIBS
platform
module-vfs
DEPS
${EXT4_IMAGE}
USE_FS
)
add_catch2_executable(
NAME vfs-dualmount
SRCS
${CMAKE_CURRENT_LIST_DIR}/unittest_filesystem_dualmount.cpp
LIBS
platform
module-vfs
DEPS
${LITTLEFS_IMAGE}
USE_FS
)
# iosyscalls tests
add_catch2_executable(
NAME
iosyscalls
SRCS
unittest_iosys.cpp
LIBS
module-sys
module-vfs
platform
USE_FS
)
# prepare test assets
set(ASSETS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/test_dir")
set(ASSETS_TARGET_DIR "${CMAKE_BINARY_DIR}/module-platform/test_dir")
file (GLOB_RECURSE ASSETS_LIST
LIST_DIRECTORIES false
RELATIVE ${ASSETS_SOURCE_DIR}
${ASSETS_SOURCE_DIR}/*
)
message ("test assets: ${ASSETS_LIST}")
foreach(ASSET ${ASSETS_LIST})
set(asset_source "${ASSETS_SOURCE_DIR}/${ASSET}")
get_filename_component(filename "${ASSET}" NAME)
get_filename_component(dir "${ASSET}" DIRECTORY)
set(destdir "${ASSETS_TARGET_DIR}/${dir}")
set(outfile "${destdir}/${filename}")
add_custom_command(
COMMENT "Copying tests resources ${ASSET}"
OUTPUT ${outfile}
DEPENDS ${asset_source}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${asset_source}
${outfile}
)
string(REPLACE "/" "_" target_name ${ASSET})
add_custom_target(${target_name} DEPENDS ${ASSET} ${outfile})
add_dependencies(platform ${target_name})
endforeach()