Lines Matching full:fs

24 #include <zephyr/fs/nvs.h>
41 struct nvs_fs fs; member
58 fixture.fs.offset = TEST_NVS_FLASH_AREA_OFFSET; in setup()
59 err = flash_get_page_info_by_offs(flash_area_get_device(fa), fixture.fs.offset, in setup()
63 fixture.fs.sector_size = info.size; in setup()
64 fixture.fs.sector_count = TEST_SECTOR_COUNT; in setup()
65 fixture.fs.flash_device = flash_area_get_device(fa); in setup()
90 if (fixture->fs.ready) { in after()
93 err = nvs_clear(&fixture->fs); in after()
97 fixture->fs.sector_count = TEST_SECTOR_COUNT; in after()
106 err = nvs_mount(&fixture->fs); in ZTEST_F()
110 static void execute_long_pattern_write(uint16_t id, struct nvs_fs *fs) in execute_long_pattern_write() argument
117 len = nvs_read(fs, id, rd_buf, sizeof(rd_buf)); in execute_long_pattern_write()
125 len = nvs_write(fs, id, wr_buf, sizeof(wr_buf)); in execute_long_pattern_write()
128 len = nvs_read(fs, id, rd_buf, sizeof(rd_buf)); in execute_long_pattern_write()
139 err = nvs_mount(&fixture->fs); in ZTEST_F()
142 execute_long_pattern_write(TEST_DATA_ID, &fixture->fs); in ZTEST_F()
179 err = nvs_mount(&fixture->fs); in ZTEST_F()
182 err = nvs_read(&fixture->fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf)); in ZTEST_F()
190 len = nvs_write(&fixture->fs, TEST_DATA_ID, wr_buf_1, sizeof(wr_buf_1)); in ZTEST_F()
193 len = nvs_read(&fixture->fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf)); in ZTEST_F()
220 *flash_max_write_calls = (fixture->fs.sector_size / in ZTEST_F()
229 len = nvs_write(&fixture->fs, TEST_DATA_ID, wr_buf_2, sizeof(wr_buf_2)); in ZTEST_F()
233 memset(&fixture->fs, 0, sizeof(fixture->fs)); in ZTEST_F()
235 err = nvs_mount(&fixture->fs); in ZTEST_F()
238 len = nvs_read(&fixture->fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf)); in ZTEST_F()
260 fixture->fs.sector_count = 2; in ZTEST_F()
262 err = nvs_mount(&fixture->fs); in ZTEST_F()
271 len = nvs_write(&fixture->fs, id, buf, sizeof(buf)); in ZTEST_F()
276 len = nvs_read(&fixture->fs, id, rd_buf, sizeof(buf)); in ZTEST_F()
289 err = nvs_mount(&fixture->fs); in ZTEST_F()
293 len = nvs_read(&fixture->fs, id, rd_buf, sizeof(buf)); in ZTEST_F()
308 struct nvs_fs *fs) in write_content() argument
319 len = nvs_write(fs, id, buf, sizeof(buf)); in write_content()
324 static void check_content(uint16_t max_id, struct nvs_fs *fs) in check_content() argument
331 len = nvs_read(fs, id, rd_buf, sizeof(buf)); in check_content()
362 fixture->fs.sector_count = 3; in ZTEST_F()
364 err = nvs_mount(&fixture->fs); in ZTEST_F()
366 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 0, in ZTEST_F()
370 write_content(max_id, 0, max_writes, &fixture->fs); in ZTEST_F()
373 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, in ZTEST_F()
375 check_content(max_id, &fixture->fs); in ZTEST_F()
377 err = nvs_mount(&fixture->fs); in ZTEST_F()
380 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, in ZTEST_F()
382 check_content(max_id, &fixture->fs); in ZTEST_F()
385 write_content(max_id, max_writes, max_writes_2, &fixture->fs); in ZTEST_F()
388 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 0, in ZTEST_F()
390 check_content(max_id, &fixture->fs); in ZTEST_F()
392 err = nvs_mount(&fixture->fs); in ZTEST_F()
395 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 0, in ZTEST_F()
397 check_content(max_id, &fixture->fs); in ZTEST_F()
400 write_content(max_id, max_writes_2, max_writes_3, &fixture->fs); in ZTEST_F()
403 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 1, in ZTEST_F()
405 check_content(max_id, &fixture->fs); in ZTEST_F()
407 err = nvs_mount(&fixture->fs); in ZTEST_F()
410 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 1, in ZTEST_F()
412 check_content(max_id, &fixture->fs); in ZTEST_F()
415 write_content(max_id, max_writes_3, max_writes_4, &fixture->fs); in ZTEST_F()
418 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, in ZTEST_F()
420 check_content(max_id, &fixture->fs); in ZTEST_F()
422 err = nvs_mount(&fixture->fs); in ZTEST_F()
425 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, in ZTEST_F()
427 check_content(max_id, &fixture->fs); in ZTEST_F()
488 err = nvs_mount(&fixture->fs); in ZTEST_F()
511 len = nvs_write(&fixture->fs, id, buf, sizeof(buf)); in ZTEST_F()
520 err = nvs_mount(&fixture->fs); in ZTEST_F()
523 check_content(max_id, &fixture->fs); in ZTEST_F()
526 execute_long_pattern_write(max_id, &fixture->fs); in ZTEST_F()
539 fixture->fs.sector_count = 3; in ZTEST_F()
541 err = nvs_mount(&fixture->fs); in ZTEST_F()
545 len = nvs_write(&fixture->fs, filling_id, &filling_id, in ZTEST_F()
556 err = nvs_delete(&fixture->fs, 1); in ZTEST_F()
560 err = nvs_mount(&fixture->fs); in ZTEST_F()
563 len = nvs_write(&fixture->fs, filling_id, &filling_id, sizeof(filling_id)); in ZTEST_F()
568 len = nvs_read(&fixture->fs, i, &data_read, sizeof(data_read)); in ZTEST_F()
591 fixture->fs.sector_count = 3; in ZTEST_F()
593 err = nvs_mount(&fixture->fs); in ZTEST_F()
597 len = nvs_write(&fixture->fs, filling_id, &filling_id, in ZTEST_F()
608 err = nvs_delete(&fixture->fs, filling_id); in ZTEST_F()
611 len = nvs_read(&fixture->fs, filling_id, &data_read, sizeof(data_read)); in ZTEST_F()
617 err = nvs_delete(&fixture->fs, 1); in ZTEST_F()
620 len = nvs_read(&fixture->fs, 1, &data_read, sizeof(data_read)); in ZTEST_F()
624 ate_wra = fixture->fs.ate_wra; in ZTEST_F()
625 data_wra = fixture->fs.data_wra; in ZTEST_F()
628 err = nvs_delete(&fixture->fs, 1); in ZTEST_F()
630 zassert_true(ate_wra == fixture->fs.ate_wra && data_wra == fixture->fs.data_wra, in ZTEST_F()
635 err = nvs_delete(&fixture->fs, filling_id); in ZTEST_F()
637 zassert_true(ate_wra == fixture->fs.ate_wra && data_wra == fixture->fs.data_wra, in ZTEST_F()
660 close_ate.offset = fixture->fs.sector_size - sizeof(struct nvs_ate) * 5; in ZTEST_F()
674 err = flash_write(fixture->fs.flash_device, fixture->fs.offset + fixture->fs.sector_size - in ZTEST_F()
680 err = flash_write(fixture->fs.flash_device, fixture->fs.offset + fixture->fs.sector_size - in ZTEST_F()
686 err = flash_write(fixture->fs.flash_device, fixture->fs.offset, &data, sizeof(data)); in ZTEST_F()
690 err = flash_write(fixture->fs.flash_device, fixture->fs.offset + sizeof(data), &data_crc, in ZTEST_F()
696 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
697 fixture->fs.offset + (2 * fixture->fs.sector_size) - in ZTEST_F()
702 fixture->fs.sector_count = 3; in ZTEST_F()
704 err = nvs_mount(&fixture->fs); in ZTEST_F()
708 len = nvs_read(&fixture->fs, 1, &data, sizeof(data)); in ZTEST_F()
723 close_ate.offset = fixture->fs.sector_size / 2; in ZTEST_F()
734 err = flash_write(fixture->fs.flash_device, fixture->fs.offset + fixture->fs.sector_size - in ZTEST_F()
740 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
741 fixture->fs.offset + (fixture->fs.sector_size / 2), in ZTEST_F()
746 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
747 fixture->fs.offset + (2 * fixture->fs.sector_size) - in ZTEST_F()
752 fixture->fs.sector_count = 3; in ZTEST_F()
754 err = nvs_mount(&fixture->fs); in ZTEST_F()
759 static size_t num_matching_cache_entries(uint32_t addr, bool compare_sector_only, struct nvs_fs *fs) in num_matching_cache_entries() argument
765 if ((fs->lookup_cache[i] & mask) == addr) { in num_matching_cache_entries()
773 static size_t num_occupied_cache_entries(struct nvs_fs *fs) in num_occupied_cache_entries() argument
776 num_matching_cache_entries(NVS_LOOKUP_CACHE_NO_ADDR, false, fs); in num_occupied_cache_entries()
794 fixture->fs.sector_count = 3; in ZTEST_F()
795 err = nvs_mount(&fixture->fs); in ZTEST_F()
798 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
803 ate_addr = fixture->fs.ate_wra; in ZTEST_F()
804 err = nvs_write(&fixture->fs, 1, &data, sizeof(data)); in ZTEST_F()
807 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
810 num = num_matching_cache_entries(ate_addr, false, &fixture->fs); in ZTEST_F()
815 memset(fixture->fs.lookup_cache, 0xAA, sizeof(fixture->fs.lookup_cache)); in ZTEST_F()
816 err = nvs_mount(&fixture->fs); in ZTEST_F()
819 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
822 num = num_matching_cache_entries(ate_addr, false, &fixture->fs); in ZTEST_F()
838 fixture->fs.sector_count = 3; in ZTEST_F()
839 err = nvs_mount(&fixture->fs); in ZTEST_F()
844 err = nvs_write(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
849 err = nvs_read(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
866 fixture->fs.sector_count = 3; in ZTEST_F()
867 err = nvs_mount(&fixture->fs); in ZTEST_F()
872 while (fixture->fs.data_wra + sizeof(data) + sizeof(struct nvs_ate) in ZTEST_F()
873 <= fixture->fs.ate_wra) { in ZTEST_F()
875 err = nvs_write(&fixture->fs, 1, &data, sizeof(data)); in ZTEST_F()
881 num = num_matching_cache_entries(0 << ADDR_SECT_SHIFT, true, &fixture->fs); in ZTEST_F()
886 while ((fixture->fs.ate_wra >> ADDR_SECT_SHIFT) != 2) { in ZTEST_F()
888 err = nvs_write(&fixture->fs, 2, &data, sizeof(data)); in ZTEST_F()
897 num = num_matching_cache_entries(0 << ADDR_SECT_SHIFT, true, &fixture->fs); in ZTEST_F()
900 num = num_matching_cache_entries(2 << ADDR_SECT_SHIFT, true, &fixture->fs); in ZTEST_F()
917 err = nvs_mount(&fixture->fs); in ZTEST_F()
926 err = nvs_write(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
932 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
937 err = nvs_clear(&fixture->fs); in ZTEST_F()
940 err = nvs_mount(&fixture->fs); in ZTEST_F()
949 err = nvs_write(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
955 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
971 err = nvs_mount(&fixture->fs); in ZTEST_F()
977 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
978 fixture->fs.offset + (fixture->fs.sector_size * (i + 1)) - in ZTEST_F()
985 memset(&fixture->fs, 0, sizeof(fixture->fs)); in ZTEST_F()
989 err = nvs_mount(&fixture->fs); in ZTEST_F()
993 execute_long_pattern_write(TEST_DATA_ID, &fixture->fs); in ZTEST_F()
995 err = nvs_mount(&fixture->fs); in ZTEST_F()