Lines Matching refs:fs
39 struct zms_fs fs; member
56 fixture.fs.offset = TEST_ZMS_AREA_OFFSET; in setup()
57 err = flash_get_page_info_by_offs(flash_area_get_device(fa), fixture.fs.offset, &info); in setup()
60 fixture.fs.sector_size = info.size; in setup()
61 fixture.fs.sector_count = TEST_SECTOR_COUNT; in setup()
62 fixture.fs.flash_device = flash_area_get_device(fa); in setup()
87 if (fixture->fs.ready) { in after()
90 err = zms_clear(&fixture->fs); in after()
94 fixture->fs.sector_count = TEST_SECTOR_COUNT; in after()
103 err = zms_mount(&fixture->fs); in ZTEST_F()
107 static void execute_long_pattern_write(uint32_t id, struct zms_fs *fs) in execute_long_pattern_write() argument
114 len = zms_read(fs, id, rd_buf, sizeof(rd_buf)); in execute_long_pattern_write()
122 len = zms_write(fs, id, wr_buf, sizeof(wr_buf)); in execute_long_pattern_write()
125 len = zms_read(fs, id, rd_buf, sizeof(rd_buf)); in execute_long_pattern_write()
134 err = zms_mount(&fixture->fs); in ZTEST_F()
137 execute_long_pattern_write(TEST_DATA_ID, &fixture->fs); in ZTEST_F()
174 err = zms_mount(&fixture->fs); in ZTEST_F()
177 err = zms_read(&fixture->fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf)); in ZTEST_F()
185 len = zms_write(&fixture->fs, TEST_DATA_ID, wr_buf_1, sizeof(wr_buf_1)); in ZTEST_F()
188 len = zms_read(&fixture->fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf)); in ZTEST_F()
211 len = zms_write(&fixture->fs, TEST_DATA_ID, wr_buf_2, sizeof(wr_buf_2)); in ZTEST_F()
215 memset(&fixture->fs, 0, sizeof(fixture->fs)); in ZTEST_F()
217 err = zms_mount(&fixture->fs); in ZTEST_F()
220 len = zms_read(&fixture->fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf)); in ZTEST_F()
240 fixture->fs.sector_count = 2; in ZTEST_F()
242 err = zms_mount(&fixture->fs); in ZTEST_F()
251 len = zms_write(&fixture->fs, id, buf, sizeof(buf)); in ZTEST_F()
256 len = zms_read(&fixture->fs, id, rd_buf, sizeof(buf)); in ZTEST_F()
267 err = zms_mount(&fixture->fs); in ZTEST_F()
271 len = zms_read(&fixture->fs, id, rd_buf, sizeof(buf)); in ZTEST_F()
283 static void write_content(uint32_t max_id, uint32_t begin, uint32_t end, struct zms_fs *fs) in write_content() argument
294 len = zms_write(fs, id, buf, sizeof(buf)); in write_content()
299 static void check_content(uint32_t max_id, struct zms_fs *fs) in check_content() argument
306 len = zms_read(fs, id, rd_buf, sizeof(buf)); in check_content()
334 fixture->fs.sector_count = 3; in ZTEST_F()
336 err = zms_mount(&fixture->fs); in ZTEST_F()
338 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 0, "unexpected write sector"); in ZTEST_F()
341 write_content(max_id, 0, max_writes, &fixture->fs); in ZTEST_F()
344 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, "unexpected write sector"); in ZTEST_F()
345 check_content(max_id, &fixture->fs); in ZTEST_F()
347 err = zms_mount(&fixture->fs); in ZTEST_F()
350 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, "unexpected write sector"); in ZTEST_F()
351 check_content(max_id, &fixture->fs); in ZTEST_F()
354 write_content(max_id, max_writes, max_writes_2, &fixture->fs); in ZTEST_F()
357 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 0, "unexpected write sector"); in ZTEST_F()
358 check_content(max_id, &fixture->fs); in ZTEST_F()
360 err = zms_mount(&fixture->fs); in ZTEST_F()
363 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 0, "unexpected write sector"); in ZTEST_F()
364 check_content(max_id, &fixture->fs); in ZTEST_F()
367 write_content(max_id, max_writes_2, max_writes_3, &fixture->fs); in ZTEST_F()
370 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 1, "unexpected write sector"); in ZTEST_F()
371 check_content(max_id, &fixture->fs); in ZTEST_F()
373 err = zms_mount(&fixture->fs); in ZTEST_F()
376 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 1, "unexpected write sector"); in ZTEST_F()
377 check_content(max_id, &fixture->fs); in ZTEST_F()
380 write_content(max_id, max_writes_3, max_writes_4, &fixture->fs); in ZTEST_F()
383 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, "unexpected write sector"); in ZTEST_F()
384 check_content(max_id, &fixture->fs); in ZTEST_F()
386 err = zms_mount(&fixture->fs); in ZTEST_F()
389 zassert_equal(fixture->fs.ate_wra >> ADDR_SECT_SHIFT, 2, "unexpected write sector"); in ZTEST_F()
390 check_content(max_id, &fixture->fs); in ZTEST_F()
420 err = zms_mount(&fixture->fs); in ZTEST_F()
440 len = zms_write(&fixture->fs, id, buf, sizeof(buf)); in ZTEST_F()
448 err = zms_mount(&fixture->fs); in ZTEST_F()
451 check_content(max_id, &fixture->fs); in ZTEST_F()
454 execute_long_pattern_write(max_id, &fixture->fs); in ZTEST_F()
467 fixture->fs.sector_count = 3; in ZTEST_F()
469 err = zms_mount(&fixture->fs); in ZTEST_F()
473 len = zms_write(&fixture->fs, filling_id, &filling_id, sizeof(filling_id)); in ZTEST_F()
482 err = zms_delete(&fixture->fs, 1); in ZTEST_F()
486 err = zms_mount(&fixture->fs); in ZTEST_F()
489 len = zms_write(&fixture->fs, filling_id, &filling_id, sizeof(filling_id)); in ZTEST_F()
494 len = zms_read(&fixture->fs, i, &data_read, sizeof(data_read)); in ZTEST_F()
516 fixture->fs.sector_count = 3; in ZTEST_F()
518 err = zms_mount(&fixture->fs); in ZTEST_F()
522 len = zms_write(&fixture->fs, filling_id, &filling_id, sizeof(filling_id)); in ZTEST_F()
531 err = zms_delete(&fixture->fs, filling_id); in ZTEST_F()
534 len = zms_read(&fixture->fs, filling_id, &data_read, sizeof(data_read)); in ZTEST_F()
539 err = zms_delete(&fixture->fs, 1); in ZTEST_F()
542 len = zms_read(&fixture->fs, 1, &data_read, sizeof(data_read)); in ZTEST_F()
545 ate_wra = fixture->fs.ate_wra; in ZTEST_F()
546 data_wra = fixture->fs.data_wra; in ZTEST_F()
550 err = zms_delete(&fixture->fs, 1); in ZTEST_F()
552 zassert_true(ate_wra == fixture->fs.ate_wra && data_wra == fixture->fs.data_wra, in ZTEST_F()
557 err = zms_delete(&fixture->fs, filling_id); in ZTEST_F()
559 zassert_true(ate_wra == fixture->fs.ate_wra && data_wra == fixture->fs.data_wra, in ZTEST_F()
583 close_ate.offset = fixture->fs.sector_size - sizeof(struct zms_ate) * 5; in ZTEST_F()
608 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
609 fixture->fs.offset + fixture->fs.sector_size - sizeof(struct zms_ate), in ZTEST_F()
614 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
615 fixture->fs.offset + fixture->fs.sector_size - 2 * sizeof(struct zms_ate), in ZTEST_F()
620 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
621 fixture->fs.offset + fixture->fs.sector_size - 6 * sizeof(struct zms_ate), in ZTEST_F()
626 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
627 fixture->fs.offset + (2 * fixture->fs.sector_size) - in ZTEST_F()
632 fixture->fs.sector_count = 3; in ZTEST_F()
634 err = zms_mount(&fixture->fs); in ZTEST_F()
638 len = zms_read(&fixture->fs, 1, &data, sizeof(data)); in ZTEST_F()
653 close_ate.offset = fixture->fs.sector_size / 2; in ZTEST_F()
665 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
666 fixture->fs.offset + fixture->fs.sector_size - 2 * sizeof(struct zms_ate), in ZTEST_F()
671 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
672 fixture->fs.offset + (fixture->fs.sector_size / 2), &corrupt_ate, in ZTEST_F()
677 err = flash_write(fixture->fs.flash_device, in ZTEST_F()
678 fixture->fs.offset + (2 * fixture->fs.sector_size) - in ZTEST_F()
683 fixture->fs.sector_count = 3; in ZTEST_F()
685 err = zms_mount(&fixture->fs); in ZTEST_F()
690 static size_t num_matching_cache_entries(uint64_t addr, bool compare_sector_only, struct zms_fs *fs) in num_matching_cache_entries() argument
696 if ((fs->lookup_cache[i] & mask) == addr) { in num_matching_cache_entries()
704 static size_t num_occupied_cache_entries(struct zms_fs *fs) in num_occupied_cache_entries() argument
707 num_matching_cache_entries(ZMS_LOOKUP_CACHE_NO_ADDR, false, fs); in num_occupied_cache_entries()
725 fixture->fs.sector_count = 3; in ZTEST_F()
726 err = zms_mount(&fixture->fs); in ZTEST_F()
729 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
734 ate_addr = fixture->fs.ate_wra; in ZTEST_F()
735 err = zms_write(&fixture->fs, 1, &data, sizeof(data)); in ZTEST_F()
738 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
741 num = num_matching_cache_entries(ate_addr, false, &fixture->fs); in ZTEST_F()
746 memset(fixture->fs.lookup_cache, 0xAA, sizeof(fixture->fs.lookup_cache)); in ZTEST_F()
747 err = zms_mount(&fixture->fs); in ZTEST_F()
750 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
753 num = num_matching_cache_entries(ate_addr, false, &fixture->fs); in ZTEST_F()
768 fixture->fs.sector_count = 4; in ZTEST_F()
769 err = zms_mount(&fixture->fs); in ZTEST_F()
774 err = zms_write(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
779 err = zms_read(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
796 fixture->fs.sector_count = 3; in ZTEST_F()
797 err = zms_mount(&fixture->fs); in ZTEST_F()
802 while (fixture->fs.data_wra + sizeof(data) + sizeof(struct zms_ate) <= in ZTEST_F()
803 fixture->fs.ate_wra) { in ZTEST_F()
805 err = zms_write(&fixture->fs, 1, &data, sizeof(data)); in ZTEST_F()
811 num = num_matching_cache_entries(0ULL << ADDR_SECT_SHIFT, true, &fixture->fs); in ZTEST_F()
816 while ((fixture->fs.ate_wra >> ADDR_SECT_SHIFT) != 2) { in ZTEST_F()
818 err = zms_write(&fixture->fs, 2, &data, sizeof(data)); in ZTEST_F()
827 num = num_matching_cache_entries(0ULL << ADDR_SECT_SHIFT, true, &fixture->fs); in ZTEST_F()
830 num = num_matching_cache_entries(2ULL << ADDR_SECT_SHIFT, true, &fixture->fs); in ZTEST_F()
847 err = zms_mount(&fixture->fs); in ZTEST_F()
856 err = zms_write(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
862 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()
867 err = zms_clear(&fixture->fs); in ZTEST_F()
870 err = zms_mount(&fixture->fs); in ZTEST_F()
879 err = zms_write(&fixture->fs, id, &data, sizeof(data)); in ZTEST_F()
885 num = num_occupied_cache_entries(&fixture->fs); in ZTEST_F()