Commit Graph

193 Commits (refactor_hal_greentea_cmake)

Author SHA1 Message Date
Robert Walton 7842320ab7 CMake: Add option to enable greentea tests
Add an option to enable the greentea tests independently from the unit
tests.

We can't just use the typical BUILD_TESTING option to enable greentea
tests. BUILD_TESTING enables unit tests and fetches googletest, which
are compiled for the host. Greentea tests are cross compiled and require
a toolchain file. For this reason we add a new option just to enable
greentea tests, preventing build failures triggered by the unit tests
and googletest.
2021-08-10 16:35:11 +01:00
Lingkai Dong a16c2bf173 SFDP: Add unit tests for Sector Map Parameter Table parsing
Add tests for `sfdp_parse_sector_map_table()` which currently (at the
time of this commit) supports flash devices with
* no Sector Map Parameter Table (i.e. the whole flash is uniform and
non-configurable)
* a single descriptor in the Sector Map Parameter Table (i.e. the
flash layout is non-configurable and has multiple regions)

Support and unit tests for flashes with multiple configurable layouts
will be added in the future.

Note: The implementation of `sfdp_parse_sector_map_table()` assumes
the table to be valid if read succeeds, so the SFDP reader callback
needs to ensure it reads data correctly or return an error.
2021-08-06 15:27:28 +01:00
Lingkai Dong f08c3cdfb5 SFDP: TestEraseTypeAlgorithm: Move setup into test case
The test data `struct mbed::sfdp_smptbl_info smptbl` is only relevant
to `TestEraseTypeAlgorithm` and not shared with other test cases.
2021-08-06 14:30:16 +01:00
Lingkai Dong 651099225e SFDP: Set region count to 1 for no sector map
A flash device with no sector map table has uniform sectors, and we
treat the whole flash as one region. In this case the function
`sfdp_parse_sector_map_table()` sets the single region's size and high
boundary accordingly, but it lacks setting of region count to 1, so
users of the SFDP parser may not get the correct number of regions.
This commit fixes the issue.
2021-08-06 14:30:16 +01:00
Lingkai Dong 68694255b5 SFDP: Move handling of no sector map into `if`
When a flash chip's SFDP table has no sector map, we treat the whole
flash as a single region. As an optimization, this should only be
done if there is indeed no sector map.
2021-08-04 14:03:24 +01:00
Lingkai Dong dca2aa79a0 Unit tests: Remove redundant CMake target mbed-headers-base
Individual libraries' `target_h` stub headers have now all been moved
from `mbed-headers-base` to `mbed-headers-<library>`.

Note: Even though headers previously in `target_h` are technically
stubs/fakes too, they are used by not only unit tests but also regular
libraries when compiled for unit tests, because no target-specific HAL
implementation exists in this case. In order for regular library
sources to pick up `target_h` headers, those headers must

* have the same names as regular headers
* appear first in include paths

This is why those headers are part of `mbed-headers-<library>` and not
`mbed-stubs-<library>`. Before this refactoring, `mbed-headers-base`
was the first in unit tests' include paths.
2021-08-02 17:42:43 +01:00
Martin Kojtal 334be7bbf2
Merge pull request #14911 from DDC-NDRS/fatfs_0.14b
FatFs: upgrade to R0.14b
2021-07-30 11:46:42 +01:00
Robert Walton b0c0fc9f66 unittests: Reduce runtime of TDBStoreModuleTest.corrupted_set_deinit_init_get
Instead of performing 10,000 "set, deinit, get" operations, let's just
perform 100. This reduces test time from 4.8s to 0.02s.
2021-07-27 21:09:39 +01:00
Robert Walton a09d08917b CMake: unittests: Show all tests in CTest report
Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that didn't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.
2021-07-27 21:09:39 +01:00
Robert Walton 1e48a61d89 CMake: unittests: Remove trailing whitespace 2021-07-27 21:09:38 +01:00
Martin Kojtal 6827b4275b
Merge pull request #14397 from macronix/macronix_spi_NAND
add SPI NAND Block device driver
2021-07-26 15:24:47 +02:00
ndrs-pst 369ae208ad FATFS: FATFileSystem.cpp migration, according to FatFs version upgrade from R0.13a to R0.14b 2021-07-21 19:39:26 +07:00
Martin Kojtal 11439bf264
Merge pull request #14909 from DDC-NDRS/ndrs-pst
SPIF: fixed _address_size to always initialize as 3_BYTES in ::init()
2021-07-20 09:55:08 +02:00
ndrs-pst 8394988354 SPIF: Moving _address_size = SPIF_ADDR_SIZE_3_BYTES from constructors into ::init() instead 2021-07-19 17:30:00 +07:00
ndrs-pst 9e5f21be16 Update FatFs from R0.13a to R0.14b by manual migration Mbed-OS modification in R0.13a to R0.14b
Since a lot of fixed from upstream (0.13b, 0.13c, 0.14, 0.14a and 0.14b)
@see http://elm-chan.org/fsw/ff/updates.txt
2021-07-10 23:39:31 +07:00
Jaeden Amero b490c67241
Merge pull request #14882 from LDong-Arm/storage_tests_cleanup
Unit tests: storage: Only use headers, sources and definitions needed by each test
2021-07-07 16:12:10 +01:00
Jaeden Amero dc6dd17bb0
Merge pull request #14884 from LDong-Arm/rm_UNITTEST_macro
Remove the `UNITTEST` macro from production code
2021-07-07 15:20:31 +01:00
Martin Kojtal 69d1db9730
Merge pull request #14849 from arduino/pr_spif_namespace
SPIFBlockDevice: Add mbed namespace to BD_ERROR_DEVICE_ERROR
2021-07-07 10:13:21 +02:00
Lingkai Dong 9b8acca136 Remove `#ifdef UNITTEST` from MbedCRC.h
Production code should not contain any test-specific checks. Rather
than checking `UNITTEST`, MbedCRC.h can simply include in all cases
<mstd_type_traits> whose unit test stub exists.

Also remove the `UNITTEST` macro from CMake definitions of kvstore
unit tests which depend on MbedCRC.h.
2021-07-06 17:29:15 +01:00
Lingkai Dong fcb71fb617 Unit tests: Clean up unused sources and definitions from storage 2021-07-06 16:31:03 +01:00
Lingkai Dong 5c6c08cb75 Unit tests: Make storage tests depend explicitly on headers it uses
The CMake target `mbed-headers` brings in all headers, and we are
gradually moving away from it and explicitly use only headers needed
by each unit test.
2021-07-06 16:20:16 +01:00
Lingkai Dong e1331d5873 Unit tests: Create mbed-headers-kvstore
Create a CMake target mbed-headers-kvstore to separate KVStore headers
from the generic mbed-headers-storage. Update tests to use it.
2021-07-02 16:27:00 +01:00
Lingkai Dong 7c74d31c57 Unit tests: Create mbed-headers-filesystem
Create a CMake target mbed-headers-filesystem to separate FileSystem
headers from the generic mbed-headers-storage. Update tests to use it.
2021-07-02 16:25:43 +01:00
Lingkai Dong 90446a0345 Unit tests: Create mbed-headers-blockdevice
Create a CMake target mbed-headers-blockdevice to separate BlockDevice
headers from the generic mbed-headers-storage. Update tests to use it.
2021-07-02 16:25:00 +01:00
Lingkai Dong 352ad1a55f Unit tests: Limit storage stubs to link what it uses 2021-07-02 13:44:28 +01:00
Lingkai Dong 7e03912587 Unit tests: Do not include mbed.h in storage stubs
The header `mbed.h` pulls in headers from a number of Mbed OS
components that are not necessarily used. It was intended for user
applications only, and libraries and unit tests should explicitly
include library headers it uses to limit dependencies.

This change avoids having to link unnecessary libraries in storage
unit tests' CMake definitions.
2021-07-02 13:44:28 +01:00
Lingkai Dong b1645b2afa Move storage stubs into subdirectories of Mbed OS storage
Move storage stubs from UNITTESTS/stubs into components inside the
top-level storage directory. Specifically,
* storage/blockdevice/tests/UNITTESTS/doubles/ for BlockDevice stubs.
* storage/kvstore/filesystemstore/tests/UNITTESTS/ for a stub used by
the FileSystemStore test. The stub has been renamed from
kv_config_stub.cpp to filesystemstore_kv_config_stub.cpp, to make it
evident why it doesn't go into storage/kvstore/kv_config/.
2021-07-02 13:44:28 +01:00
Lingkai Dong 436291fd89 CMake: storage: Remove trailing whitespaces 2021-07-02 13:44:28 +01:00
giulcioffi 02108ea2b4 Fix missing 'mbed' namespace error in SPIFBlockDevice 2021-07-01 09:57:38 +02:00
Hari Limaye f95052cf6f CMake: Require TEST_SOURCES in greentea CMake file
Assumption that greentea test file is always named main.cpp is
incorrect. Updated mbed_greentea_add_test() macro to make TEST_SOURCES
parameter compulsory, which is used to specify greentea test
file(s). This allows tests to use C, or have a different name.
Therefore also updated all pre-existing greentea test CMake files to
explicity add main.cpp to TEST_SOURCES.
2021-06-29 13:33:42 +01:00
Robert Walton a0befae2d4 CMake: Only build unit tests if Mbed OS is the current project
Typically when adding a unit test directory to a CMake project a check
will be used to ensure the subdirectory is added only if the following
are true:

* The BUILD_TESTING option is set to ON.
* The current CMake project is the top-level project.

The reason being, if a downstream project includes our project they
generally don't want to build our unit tests.

In mbed-os, we do correctly specify the above condition before adding
the central UNITTEST subdirectory, which fetches googletest and adds the
"stub" libraries the unit tests depend on. However, we only check if
CMAKE_CROSSCOMPILING is OFF (or undefined) before actually adding the
unit tests. This mismatched logic would lead to unexpected build
failures in various scenarios. One likely case could be: a downstream
project including mbed-os happens to set CMAKE_CROSSCOMPILING to
OFF/undefined for any reason (possibly to build its own unit tests).
mbed-os would go ahead and attempt to build its tests without fetching
googletest or adding the required stub targets.

To fix the issue replace the check for CMAKE_CROSSCOMPILING in the unit
tests with the same BUILD_TESTING idiom we use for adding the central
UNITTESTS subdirectory.
2021-06-10 23:34:14 +01:00
rogeryou 4f29d6a643
Update SPINANDBlockDevice.cpp
Fix the spelling issue
2021-06-10 09:47:43 +08:00
rogeryou e66784fc80
Update SPINANDBlockDevice.h
Fix the spelling issue
2021-06-10 09:46:17 +08:00
rogeryou 99a3bb9896
Update CMakeLists.txt
Fix the issue
2021-06-10 09:38:36 +08:00
Martin Kojtal 5fe4dafc34
Merge pull request #14221 from macronix/macronix_rww
Enable the RWW function of Macronix Flash MX25LW51245G in OSPI block device driver
2021-06-02 16:53:59 +02:00
Rajkumar Kanagaraj 50fc85dc44 CMake: Remove all unittest.cmake script from test suite
- Remove redundant cmake script as already added the CMake configuration file
- Remove redundant empty_baseline as it is no longer needed with the help of CMake configuration file
2021-05-26 07:09:14 -07:00
Anna Bridge 4e586a93d3
Merge pull request #14426 from ARMmbed/feature_unittest_refactor
CMake: Refactor UNITTESTS CMake
2021-05-24 13:04:22 +01:00
Rajkumar Kanagaraj 6d4caad83d CMake: Move CMAKE_CROSSCOMPILING check inside library CMake 2021-05-20 06:26:10 -07:00
rogeryou 643a92623b
Update SPINANDBlockDevice.cpp
Modify astyle
2021-05-12 09:37:24 +08:00
harmut01 6b2c133a98 Refactor KVStore config override explanation
The documentation previously referred to a weakly defined function
`storage_configuration`, however, this function was replaced at some
stage by `kv_init_storage_config`. Refactor the explanation on how to
override the default configurations to reflect this. Also, remove
the snippet which was used to show the implentation of
`storage_configuration`.
2021-05-11 17:19:16 +01:00
harmut01 468ee97bdd Deprecate TDB_EXTERNAL_NO_RBP and FILESYSTEM_NO_RBP in kv_config
NO_RBP (no rollback protection) is intended to not require an internal
TDB, however, DeviceKey, which we use to derive SecureStore's
encryption key, still does. Currently, no internal TDB is created with
these two configurations, meaning there's no way to store the DeviceKey
and SecureStore doesn't work.
2021-05-11 17:19:10 +01:00
Rajkumar Kanagaraj 91051cbd4d CMake: fix lifflefs filesystem header include path
- LittleFileSystem.h and LittleFileSystem.cpp refers to the littflefs headers with the complete path like storage/filesystem/littlefs/littlefs/lfs_util.h and fixed the path issue
2021-05-11 03:41:00 -07:00
Rajkumar Kanagaraj 98215d322d CMake: Fix ChainingBlockDevice unittest
- ChainingBlockModuleTest test case compares two strings with EXPECT_EQ
which normally compare strings residing memory address so replaced it with EXPECT_STREQ  to compare strings.
2021-05-11 02:29:56 -07:00
Rajkumar Kanagaraj 4536fff63a CMake: Refactor storage blockdevice and SFDP unittests cmake
- Add CMake configuration file
- Fix the header inclusion in blockdevice unittests
2021-05-11 02:29:56 -07:00
Rajkumar Kanagaraj c0a8fe62f5 CMake: Refactor storage TDBstore and FileSystemStore unittest cmake
- Add CMake configuration file in TDBstore and FileSystemStore unittest.
2021-05-11 02:29:56 -07:00
Rajkumar Kanagaraj ba04c1cf76 CMake: Add add_subdirectory of unittests
- add every libraries unittest directory into respective CMake
  which allows to include unittest source into build based on
  MBED_BUILD_UNITTESTS flag
2021-05-11 02:29:56 -07:00
rogeryou 6d90674546
Update OSPIFBlockDevice.cpp
modify the definition of the tables
2021-05-07 09:27:37 +08:00
plan-do-break-fix 915b45af23 fix(docs): corrects various typos in project documentation 2021-04-23 23:31:11 -05:00
Lingkai Dong 7b763be0e3 TDBStore Whitebox tests: fix memory check
Each block of HeapBlockDevice is only allocated from the heap when
that block is programmed. And erasing a block frees the associated
buffer.

To decide if there is enough heap to run the TDBStore Whitebox tests,
we need to perform a trial program() instead of erase().
2021-04-14 17:19:38 +01:00
Lingkai Dong aedc6009ea TDBStore: call `BlockDevice::erase()` regarless of erase value
From the documentations of `BlockDevice::get_erase_value()`:

    -1 if you can't rely on the value of the erased storage

and `BlockDevice::program()`:

    The blocks must have been erased prior to being programmed

So, `BlockDevice::erase()` should always be called regardless of
erase value.
2021-04-14 17:19:38 +01:00