tests: subsys: fs: move fcb to new ztest API

Move fcb to new ztest API.

Signed-off-by: Yinfang Wang <yinfang.wang@intel.com>
This commit is contained in:
Yinfang Wang 2022-08-13 00:34:13 +08:00 committed by Fabio Baltieri
commit 8a8ead3f90
16 changed files with 21 additions and 66 deletions

View file

@ -6,3 +6,4 @@ CONFIG_FLASH_MAP=y
CONFIG_ARM_MPU=n CONFIG_ARM_MPU=n
CONFIG_FCB=y CONFIG_FCB=y
CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
CONFIG_ZTEST_NEW_API=y

View file

@ -4,3 +4,4 @@ CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y CONFIG_FLASH_MAP=y
CONFIG_FCB=y CONFIG_FCB=y
CONFIG_ZTEST_NEW_API=y

View file

@ -4,3 +4,4 @@ CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y CONFIG_FLASH_MAP=y
CONFIG_FCB=y CONFIG_FCB=y
CONFIG_ZTEST_NEW_API=y

View file

@ -9,3 +9,4 @@ CONFIG_FCB=y
CONFIG_MAIN_STACK_SIZE=4096 CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_ZTEST_NEW_API=y

View file

@ -5,3 +5,4 @@ CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y CONFIG_FLASH_MAP=y
CONFIG_FCB=y CONFIG_FCB=y
CONFIG_FLASH_SIMULATOR_UNALIGNED_READ=y CONFIG_FLASH_SIMULATOR_UNALIGNED_READ=y
CONFIG_ZTEST_NEW_API=y

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_append(void) ZTEST(fcb_test_with_2sectors_set, test_fcb_append)
{ {
int rc; int rc;
struct fcb *fcb; struct fcb *fcb;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_append_fill(void) ZTEST(fcb_test_with_2sectors_set, test_fcb_append_fill)
{ {
struct fcb *fcb; struct fcb *fcb;
int rc; int rc;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void (test_fcb_append_too_big(void)) ZTEST(fcb_test_with_2sectors_set, test_fcb_append_too_big)
{ {
struct fcb *fcb; struct fcb *fcb;
int rc; int rc;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_empty_walk(void) ZTEST(fcb_test_with_2sectors_set, test_fcb_empty_walk)
{ {
int rc; int rc;
struct fcb *fcb; struct fcb *fcb;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_init(void) ZTEST(fcb_test_without_set, test_fcb_init)
{ {
int rc; int rc;
struct fcb *fcb; struct fcb *fcb;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_last_of_n(void) ZTEST(fcb_test_with_4sectors_set, test_fcb_last_of_n)
{ {
const uint8_t ENTRIES = 5U; const uint8_t ENTRIES = 5U;
struct fcb *fcb; struct fcb *fcb;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_len(void) ZTEST(fcb_test_with_2sectors_set, test_fcb_len)
{ {
uint8_t buf[3]; uint8_t buf[3];
uint16_t len; uint16_t len;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_multi_scratch(void) ZTEST(fcb_test_with_4sectors_set, test_fcb_multi_scratch)
{ {
struct fcb *fcb; struct fcb *fcb;
int rc; int rc;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_reset(void) ZTEST(fcb_test_with_2sectors_set, test_fcb_reset)
{ {
struct fcb *fcb; struct fcb *fcb;
int rc; int rc;

View file

@ -7,7 +7,7 @@
#include "fcb_test.h" #include "fcb_test.h"
void test_fcb_rotate(void) ZTEST(fcb_test_with_2sectors_set, test_fcb_rotate)
{ {
struct fcb *fcb; struct fcb *fcb;
int rc; int rc;

View file

@ -128,26 +128,22 @@ void fcb_tc_pretest(int sectors)
} }
} }
void fcb_pretest_2_sectors(void) static void fcb_pretest_2_sectors(void *data)
{ {
fcb_tc_pretest(2); fcb_tc_pretest(2);
} }
void fcb_pretest_4_sectors(void) static void fcb_pretest_4_sectors(void *data)
{ {
fcb_tc_pretest(4); fcb_tc_pretest(4);
} }
void teardown_nothing(void)
{
}
/* /*
* This actually is not a test; the function gets erase value from flash * This actually is not a test; the function gets erase value from flash
* parameters, of the flash device that is used by tests, and stores it in * parameters, of the flash device that is used by tests, and stores it in
* global fcb_test_erase_value. * global fcb_test_erase_value.
*/ */
void test_get_flash_erase_value(void) ZTEST(fcb_test_without_set, test_get_flash_erase_value)
{ {
const struct flash_area *fa; const struct flash_area *fa;
const struct flash_parameters *fp; const struct flash_parameters *fp;
@ -168,52 +164,6 @@ void test_get_flash_erase_value(void)
fcb_test_erase_value = fp->erase_value; fcb_test_erase_value = fp->erase_value;
} }
void test_fcb_len(void); ZTEST_SUITE(fcb_test_without_set, NULL, NULL, NULL, NULL, NULL);
void test_fcb_init(void); ZTEST_SUITE(fcb_test_with_2sectors_set, NULL, NULL, fcb_pretest_2_sectors, NULL, NULL);
void test_fcb_empty_walk(void); ZTEST_SUITE(fcb_test_with_4sectors_set, NULL, NULL, fcb_pretest_4_sectors, NULL, NULL);
void test_fcb_append(void);
void test_fcb_append_too_big(void);
void test_fcb_append_fill(void);
void test_fcb_reset(void);
void test_fcb_rotate(void);
void test_fcb_multi_scratch(void);
void test_fcb_last_of_n(void);
void test_main(void)
{
ztest_test_suite(test_fcb,
ztest_unit_test(test_get_flash_erase_value),
ztest_unit_test_setup_teardown(test_fcb_len,
fcb_pretest_2_sectors,
teardown_nothing),
ztest_unit_test(test_fcb_init),
ztest_unit_test_setup_teardown(test_fcb_empty_walk,
fcb_pretest_2_sectors,
teardown_nothing),
ztest_unit_test_setup_teardown(test_fcb_append,
fcb_pretest_2_sectors,
teardown_nothing),
ztest_unit_test_setup_teardown(test_fcb_append_too_big,
fcb_pretest_2_sectors,
teardown_nothing),
ztest_unit_test_setup_teardown(test_fcb_append_fill,
fcb_pretest_2_sectors,
teardown_nothing),
ztest_unit_test_setup_teardown(test_fcb_rotate,
fcb_pretest_2_sectors,
teardown_nothing),
ztest_unit_test_setup_teardown(test_fcb_multi_scratch,
fcb_pretest_4_sectors,
teardown_nothing),
ztest_unit_test_setup_teardown(test_fcb_last_of_n,
fcb_pretest_4_sectors,
teardown_nothing),
/* Finally, run one that leaves behind a
* flash.bin file without any random content */
ztest_unit_test_setup_teardown(test_fcb_reset,
fcb_pretest_2_sectors,
teardown_nothing)
);
ztest_run_test_suite(test_fcb);
}