Commit Graph

161 Commits

Author SHA1 Message Date
Martin Åberg 4604c45541 tests: enable and run many tests on RISC-V
This commit enables lots of tests on riscv32 and riscv64 which were
previously disabled.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2021-01-15 13:06:33 -05:00
Dominik Ermel 738bddf765 tests: fs: Add tests for fs_tell/fs_seek ENOTSUP error
The fs_seek and fs_tell are expected to return -ENOTUSP if file system
driver lacks implementation of said funcions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-01-09 08:33:24 -05:00
Kumar Gala 1706bd2b41 tests: convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert tests to DEVICE_{DT_}DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:05:40 -05:00
Meng xianglin 04d8d485e8 test: fs: improve code coverage for file system core
Refine test cases to improve code coverage

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2020-12-15 11:17:54 +01:00
Martin Åberg a13e5d5584 tests/fs/fat: correct format specifiers
Make sure that "%ld" gets a long int argument.

This commit eliminates a couple of compiler warnings of this kind:

test_fat_file.c: In function 'test_file_truncate':
test_fat_file.c:180:11: error: format '%ld' expects argument
  of type 'long int', but argument 2 has type 'off_t' {aka 'int'}
  [-Werror=format=]
  180 |  TC_PRINT("Original size of file = %ld\n", orig_pos);

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-17 18:48:10 -05:00
Martin Åberg cb93c7ed85 tests/fs/fat: enable fat.dual_drive on qemu_leon3
Build and run on a platform where off_t is int.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2020-11-17 18:48:10 -05:00
iva kik 7140c21044 tests: fs: check for arguments NULLness
Before referencing mountp argument, check for it's NULLness

Fixes #29704

Signed-off-by: iva kik <megatheriumiva@gmail.com>
2020-11-17 14:52:39 -06:00
Dominik Ermel 635230c725 tests/fs/fcb: Enable non-0xff erase value tests
Fcb tests have been modified to be able to work on non-0xff erase
value flash devices.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-16 13:39:04 +01:00
Dominik Ermel 53fd687344 tests/fs/fcb: Add support for qemu_x86 platform
Overlays that enable FCB tests on qemu_x86 plaftorm have been added.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-16 13:39:04 +01:00
Dominik Ermel e8fa66f951 tests/fs/fatfs: Add tests for FS_MOUNT_FLAG_*
Adds various tests for mounting ELM FAT FS with FS_MOUNT_FLAG_NO_FORMAT
and FS_MOUNT_FLAG_READ_ONLY, and operations on read-only mounted
file system.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel 5c2a004c0b tests/fs/littlefs: Add tests for FS_MOUNT_FLAG_*
Adds various tests for mounting LittleFS with FS_MOUNT_FLAG_NO_FORMAT
and FS_MOUNT_FLAG_READ_ONLY, and operations on read-only mounted
file system.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel 86dcaebbe7 tests/fs/fs_api: Add API tests fo FS_MOUNT_FLAG_READ_ONLY
The commit adds read-only mount scenario tests to fs_api test
suite.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-11-06 13:10:13 -05:00
Dominik Ermel e7886c6634 fs: fs_unmount will return -ENOTSUP if not implemented by driver
The commit changes error handling by fs_unmount; the function will
return -EINVAL if mount point, described by mp, is not mounted or
-ENNOTSUP when unmounting is not supported by the driver; in the second
case it will also log error.

Additionally to the above changes, checks for correct mnt_path and
mnt_path, within fs_unmount, have been removed as they are not needed;
only the fs_mount_t->fs pointer is needed to decide whether system is
mounted or not.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-10-30 15:54:04 +01:00
Dominik Ermel 5faf3750bc fs: fs_mount parameter verification before mutex locked block
The commit moves fs_mount parameter verification above mutex lock.
The list of mount points is now checked before attempting to obtain
file system API pointer.
All modifications to mount point data structure, given as a parameter
to the fs_mount, are only applied after every other operation needed
have completed successfully, immediately before adding the mount point
to the list of mount points.
The fs_mount will a warning when mounted file system does not support
unmount.
When a file system does not provide mount function, the -ENOTSUP error
will be returned instead of -EINVAL.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-10-30 15:54:04 +01:00
Dominik Ermel 1241e67790 fs: Move fs_file_system_t declaration out of fs.h
The struct fs_file_system_t is only useful when defining file system
drivers and is not required for typical application development,
that is why it has been moved to separate file fs_sys.h.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-10-23 12:55:41 +02:00
Xavier Chapron 824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
Peter A. Bigot 338f0caca0 tests: fs: update for change in capability
FS_TYPE_END is no longer used as there is no hard-coded limit on the
number of file systems.  Replace with the limit used when only in-tree
file systems are enabled.

The test for unsupported file systems is no longer valid.  Instead
verify that attempting to register a file system when there is no room
for it fails as expected.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-09-03 21:49:34 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Anas Nashif dca317c730 sanitycheck: inclusive language
change whitelist -> allow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-27 07:04:07 -04:00
Dominik Ermel 71a3cc6a60 tests/nvs: Enable test suite with 0x00 erase value
The NVS tests have been disabled here with commit
 tests: nvs: Disable running the 0x00 test suite
 (22be0d8fd5)
due to problems with flash_simulator.

With introduction of below fixes:
 drivers/flash/flash_simulator: Fix flash_sim_write
 (bec0c7f279)
 drivers/flash/fash_simulator: Fix initialization for non-posix
 (849a5432df)

the tests can be enabled back.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-08-18 15:54:04 -04:00
Meng xianglin 21638f054f test: fs: Test cases for file system interfaces
Focus on file system interfaces implemented in file system core,
not specific file system.

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2020-08-14 15:44:06 -04:00
Jakub Rzeszutko b83e4224e0 shell: correct build-in commands definition
The definition of the help command has been changed
so that it does not accept the arguments.
Thanks to this it cannot be marked by the "select" command.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-07-31 11:54:34 +02:00
Dominik Ermel f2f4ba7452 tests/subsys/fs: Add fs_open flags tests to LittleFS
The addition of support for open flags, within fs_open, requires
addition of new test cases.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-30 16:33:18 +02:00
Dominik Ermel 50aca03eef tests/subsys/fs: Add fs_open flags tests to fat_fs_api
The addition of support for open flags, within fs_open, requires
addition of new test cases to FAT FS back-end tests.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-30 16:33:18 +02:00
Dominik Ermel b0facba483 tests/subsys/fs: Add common fs_open_flags test procedure
Common procedure, to use with fs back-ends, have been added for testing
various fs_open flags combinations.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-30 16:33:18 +02:00
Dominik Ermel cac07629bf subsys/fs: Add open flags parameter to fs_open
The fs_open has been extended with support for open flags.
Currently supported flags are:
  FS_O_READ -- open for read
  FS_O_WRITE -- open for write
  FS_O_CREATE -- create file if it does not exist
  FS_O_APPEND -- move to the end of file before each write

The FAT FS and LittleFS front-ends within the Zephyr has also been
modified to utilize the flags.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-07-30 16:33:18 +02:00
Anas Nashif 0798b85d1c tests: remove obsolete doxygen boilerplate
An old doxygen biolerplate was being copied all over the tests. The
defined groups are not being used anywhere and it does not follow how we
document tests for example in the kernel and other places.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-28 08:14:23 -05:00
Anas Nashif 1fbbfc819a tests/samples: add tags to some tests
Some tests/samples had no tags, fill those..

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-07-20 17:44:16 -04:00
Tobias Svehagen 0171bd9578 tests: fs: nvs: Add two test cases for testing nvs_gc
Add tests for checking that nvs_gc can handle corrupt ate's.

Tests #26407

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2020-06-26 12:07:13 -05:00
Carles Cufi 22be0d8fd5 tests: nvs: Disable running the 0x00 test suite
There is an issue when running the 0x00 erase value test suite, so
disable it temporarily.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-06-25 13:24:07 -05:00
Dominik Ermel 076282a117 subsys/fs/nvs: Use flash_get_parameters() to get erase value
Use new flash API call to obtain erase value instead of relaying on
hardcoded literals.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-06-22 14:35:03 +02:00
Roman Vaughan 0562d9fac6 tests: fs: Ensure file_path includes max file name length
A hardcoded path lenth of 80 will not be able to suppor the full length
of 255 when LFN is enabled. This does produce a compiler error,
thankfully, this is only applicable to the test cases.

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
2020-06-17 17:07:45 +02:00
Roman Vaughan 70df7a87a1 tests: fs: Add test case for LFN with FATFS
Rerun the same test but with CONFIG_FS_FATFS_LFN=Y and
with a long filename.

Signed-off-by: Roman Vaughan <nzsmartie@gmail.com>
2020-06-17 17:07:45 +02:00
Maciej Perkowski bd14a9d493 tests: littlefs: Increase timeout to 180s
The test takes ~175s to end on nrf5284dk_nrf52840 and was failing
due to too short default timeout (60s).

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
2020-06-15 16:45:38 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Kumar Gala ff579a3af3 flash: Convert DT_FLASH_AREA to FLASH_AREA macros
Convert with a combo of scripts and by hand fixups:

git grep -l DT_FLASH_AREA_.*_ID | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/'

git grep -l DT_FLASH_AREA_.*_OFFSET | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/'

git grep -l DT_FLASH_AREA_.*_SIZE | \
 xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-13 21:22:53 +02:00
Anas Nashif ad82b38b8f tests: ztest: prefix tests with test_
Tests should always start with test_, otherwise detection of subtests
will not work through sanitycheck.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-05-13 18:16:07 +02:00
Kumar Gala 7a15afc1d4 drivers: flash: replace DT_FLASH_DEV_NAME with DT macro
Replace DT_FLASH_DEV_NAME with DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL.
We now set zephyr,flash-controller in the chosen node of the device
tree to the flash controller device.

NOTE: For a SoCs with on die flash, this points to the controller and
      not the 'soc-nv-flash' node.  Typically the controller is the
      parent of the 'soc-nv-flash' node).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-27 18:43:20 -05:00
Dominik Ermel c8e3b1f68b tests/subsys/fs/fcb: Fix flash_area_write failure on NRF
The commit fixes problem with test attempting to perform 1 byte writes
to flash, which are not emulated by default.

GH issue: #24207

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-04-17 10:23:47 +02:00
Carles Cufi 6656214af2 boards: nrf52_pca10040: Rename to nrf52dk_nrf52832
The board name for the nRF52 DK, so far known as nrf52_pca10040, is
renamed to nrf52dk_nrf52832.  Its documentation and all references
to its name in the tree are updated accordingly. Overlay and
configuration files specific to this board are also renamed, to
match the new board name.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-04-06 13:09:07 +02:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Andrzej Głąbek 4253eae005 boards: nrf52840_pca10056: Rename board to nrf52840dk_nrf52840
The nRF52840 DK board target, so far known as nrf52840_pca10056,
is renamed to nrf52840dk_nrf52840.
Its documentation and all references to its name in the tree are
updated accordingly. Overlay and configuration files specific to
this board are also renamed, to match the new board name.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-27 09:14:08 +01:00
Ioannis Glaropoulos f3807f19dc boards: arm: nrf51_pca10028: rename board to nrf51dk_nrf51422
We rename the nRF51 Dev Kit board target (nrf51_pca10028)
to nrf51dk_nrf51422. We update all associated references
in the supportive documentation and all nRF51-related
cofigurations and overlay files in the samples and tests
in the tree.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2020-03-24 11:45:27 +01:00
Dominik Ermel dd41b12250 tests/subsys/fs/fat: Incorrect mount path has been tested
While testing statvfs operation, same mount path has been tested twice,
instead of two different mount points as intended.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-02-27 11:37:25 +02:00
Brooks Prumo e426c0c4e1 tests: Remove erroneous # before extern "C"
A few test header files have C++ guards around them, but are incorrect.
Those files had a leading `#` placed before `extern`, which is
incorrect.  This commit simply removes those leading `#` characters.

Signed-off-by: Brooks Prumo <brooks@prumo.org>
2020-02-06 19:45:21 -05:00
Peter A. Bigot 046bae60b6 samples: drivers: spi_flash: switch nrf52840_pca10056 to Nordic QSPI
Adjust the configuration file, disable the SPI
driver and enable the QSPI driver and flash node.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Signed-off-by: Kamil Lazowski <Kamil.Lazowski@nordicsemi.no>
2020-01-29 15:15:49 +01:00
Dominik Ermel 9c0fb144ee tests/fs: NFFS has been replaced with Littlefs in multifs tests
With removal of NFFS from Zaphyr it would be no longer possible to
test multifs with NFFS and LittleFS will be now used instead.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-01-21 17:30:03 +01:00
Andrzej Puzdrowski cc81e02e17 tests/subsys/fs/multi-fs: suppres kconfig issue
This patch is for suppress CI Kconfig issues caused
by temporary dead code in this test-suie.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-21 15:32:47 +01:00
Andrzej Puzdrowski b61e6d3787 tests/fs: remove nffs testsuite
NFFS was removed, so it tests need to be removed too.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-01-21 15:32:47 +01:00