44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7- /*
8- * This test is designed to be run using flash-simulator which provide
9- * functionality for flash property customization and emulating errors in
10- * flash operation in parallel to regular flash API.
11- * Test should be run on qemu_x86 or native_sim target.
12- */
13-
14- #if !defined(CONFIG_BOARD_QEMU_X86 ) && !defined(CONFIG_ARCH_POSIX )
15- #error "Run only on qemu_x86 or a posix architecture based target (for ex. native_sim)"
16- #endif
17-
187#include <stdio.h>
198#include <string.h>
209#include <zephyr/ztest.h>
@@ -37,8 +26,10 @@ static const struct device *const flash_dev = TEST_ZMS_AREA_DEV;
3726
3827struct zms_fixture {
3928 struct zms_fs fs ;
29+ #ifdef CONFIG_TEST_ZMS_SIMULATOR
4030 struct stats_hdr * sim_stats ;
4131 struct stats_hdr * sim_thresholds ;
32+ #endif /* CONFIG_TEST_ZMS_SIMULATOR */
4233};
4334
4435static void * setup (void )
@@ -66,22 +57,26 @@ static void *setup(void)
6657
6758static void before (void * data )
6859{
60+ #ifdef CONFIG_TEST_ZMS_SIMULATOR
6961 struct zms_fixture * fixture = (struct zms_fixture * )data ;
7062
7163 fixture -> sim_stats = stats_group_find ("flash_sim_stats" );
7264 fixture -> sim_thresholds = stats_group_find ("flash_sim_thresholds" );
65+ #endif /* CONFIG_TEST_ZMS_SIMULATOR */
7366}
7467
7568static void after (void * data )
7669{
7770 struct zms_fixture * fixture = (struct zms_fixture * )data ;
7871
72+ #ifdef CONFIG_TEST_ZMS_SIMULATOR
7973 if (fixture -> sim_stats ) {
8074 stats_reset (fixture -> sim_stats );
8175 }
8276 if (fixture -> sim_thresholds ) {
8377 stats_reset (fixture -> sim_thresholds );
8478 }
79+ #endif /* CONFIG_TEST_ZMS_SIMULATOR */
8580
8681 /* Clear ZMS */
8782 if (fixture -> fs .ready ) {
@@ -137,6 +132,7 @@ ZTEST_F(zms, test_zms_write)
137132 execute_long_pattern_write (TEST_DATA_ID , & fixture -> fs );
138133}
139134
135+ #ifdef CONFIG_TEST_ZMS_SIMULATOR
140136static int flash_sim_write_calls_find (struct stats_hdr * hdr , void * arg , const char * name ,
141137 uint16_t off )
142138{
@@ -453,6 +449,7 @@ ZTEST_F(zms, test_zms_corrupted_sector_close_operation)
453449 /* Ensure that the ZMS is able to store new content. */
454450 execute_long_pattern_write (max_id , & fixture -> fs );
455451}
452+ #endif /* CONFIG_TEST_ZMS_SIMULATOR */
456453
457454/**
458455 * @brief Test case when storage become full, so only deletion is possible.
@@ -562,6 +559,7 @@ ZTEST_F(zms, test_delete)
562559#endif
563560}
564561
562+ #ifdef CONFIG_TEST_ZMS_SIMULATOR
565563/*
566564 * Test that garbage-collection can recover all ate's even when the last ate,
567565 * ie close_ate, is corrupt. In this test the close_ate is set to point to the
@@ -639,6 +637,7 @@ ZTEST_F(zms, test_zms_gc_corrupt_close_ate)
639637 zassert_true (len == sizeof (data ), "zms_read should have read %d bytes" , sizeof (data ));
640638 zassert_true (data == 0xaa55aa55 , "unexpected value %d" , data );
641639}
640+ #endif /* CONFIG_TEST_ZMS_SIMULATOR */
642641
643642/*
644643 * Test that garbage-collection correctly handles corrupt ate's.
0 commit comments