File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
tests/drivers/flash/common/src Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,25 @@ ZTEST(flash_driver, test_flash_erase)
307307 zassert_not_equal (expected [0 ], erase_value , "These values shall be different" );
308308}
309309
310+ ZTEST (flash_driver , test_mmap )
311+ {
312+ int rc ;
313+ uint64_t size ;
314+ uint8_t * p ;
315+
316+ rc = flash_mmap (flash_dev , (void * * )& p , & size , FLASH_MMAP_F_READ );
317+ if (rc == - ENOTSUP || rc == - ENOSYS ) {
318+ ztest_test_skip ();
319+ } else {
320+ const static uint8_t out [] = "Hello World!!!\n" ;
321+ struct flash_pages_info fp ;
322+
323+ zassert_ok (flash_get_page_info_by_offs (flash_dev , size - 1 , & fp ));
324+ zassert_ok (flash_erase (flash_dev , fp .start_offset , fp .size ));
325+ zassert_ok (flash_write (flash_dev , fp .start_offset , out , sizeof (out )));
326+ zassert_ok (memcmp (p + fp .start_offset , out , sizeof (out )));
327+ }
328+ }
310329struct test_cb_data_type {
311330 uint32_t page_counter ; /* used to count how many pages was iterated */
312331 uint32_t exit_page ; /* terminate iteration when this page is reached */
You can’t perform that action at this time.
0 commit comments