1 /*
2 * Copyright (c) 2017 - 2020 Nordic Semiconductor ASA
3 * Copyright (c) 2015 Runtime Inc
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include "fcb_test.h"
9
ZTEST(fcb_test_without_set,test_fcb_init)10 ZTEST(fcb_test_without_set, test_fcb_init)
11 {
12 int rc;
13 struct fcb *fcb;
14
15 fcb = &test_fcb;
16 (void)memset(fcb, 0, sizeof(*fcb));
17 fcb->f_erase_value = fcb_test_erase_value;
18
19 rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb);
20 zassert_true(rc == -EINVAL, "fcb_init call should fail");
21
22 fcb->f_sectors = test_fcb_sector;
23
24 rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb);
25 zassert_true(rc == -EINVAL, "fcb_init call should fail");
26
27 fcb->f_sector_cnt = 2U;
28 fcb->f_magic = 0x12345678;
29 rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb);
30 zassert_true(rc == -ENOMSG, "fcb_init call should fail");
31
32 fcb->f_magic = 0U;
33 rc = fcb_init(TEST_FCB_FLASH_AREA_ID, fcb);
34 zassert_true(rc == 0, "fcb_init call failure");
35 }
36