diff --git a/tests/misc/iterable_sections/sections-ram.ld b/tests/misc/iterable_sections/sections-ram.ld index 6b91983f3cc..4badcbb9e6e 100644 --- a/tests/misc/iterable_sections/sections-ram.ld +++ b/tests/misc/iterable_sections/sections-ram.ld @@ -1 +1,2 @@ ITERABLE_SECTION_RAM(test_ram, 4) +ITERABLE_SECTION_RAM(test_ram2, 4) diff --git a/tests/misc/iterable_sections/sections-rom.ld b/tests/misc/iterable_sections/sections-rom.ld index 11b7bbe94b9..434bf1606bf 100644 --- a/tests/misc/iterable_sections/sections-rom.ld +++ b/tests/misc/iterable_sections/sections-rom.ld @@ -1 +1,2 @@ ITERABLE_SECTION_ROM(test_rom, 4) +ITERABLE_SECTION_ROM(test_rom2, 4) diff --git a/tests/misc/iterable_sections/src/main.c b/tests/misc/iterable_sections/src/main.c index 386e49ca818..caba125e0b2 100644 --- a/tests/misc/iterable_sections/src/main.c +++ b/tests/misc/iterable_sections/src/main.c @@ -20,6 +20,9 @@ STRUCT_SECTION_ITERABLE(test_ram, ram1) = {0x01}; #define RAM_EXPECT 0x01020304 +/* iterable section items can also be static */ +static const STRUCT_SECTION_ITERABLE_ALTERNATE(test_ram2, test_ram, ram5) = {RAM_EXPECT}; + /** * * @brief Test iterable in read write section. @@ -44,6 +47,13 @@ ZTEST(iterable_sections, test_ram) "ram3.i check bit incorrect (got: 0x%x)", ram3.i); zassert_equal(ram4.i & CHECK_BIT, CHECK_BIT, "ram4.i check bit incorrect (got: 0x%x)", ram4.i); + + out = 0; + STRUCT_SECTION_FOREACH_ALTERNATE(test_ram2, test_ram, t) { + out = (out << 8) | t->i; + } + + zassert_equal(out, RAM_EXPECT, "Check value incorrect (got: 0x%08x)", out); } struct test_rom { @@ -58,6 +68,9 @@ const STRUCT_SECTION_ITERABLE(test_rom, rom2) = {0x20}; #define ROM_EXPECT 0x10203040 +/* iterable section items can also be static */ +static const STRUCT_SECTION_ITERABLE_ALTERNATE(test_rom2, test_rom, rom5) = {ROM_EXPECT}; + /** * * @brief Test iterable in read only section. @@ -72,6 +85,13 @@ ZTEST(iterable_sections, test_rom) } zassert_equal(out, ROM_EXPECT, "Check value incorrect (got: 0x%x)", out); + + out = 0; + STRUCT_SECTION_FOREACH_ALTERNATE(test_rom2, test_rom, t) { + out = (out << 8) | t->i; + } + + zassert_equal(out, ROM_EXPECT, "Check value incorrect (got: 0x%x)", out); } ZTEST_SUITE(iterable_sections, NULL, NULL, NULL, NULL, NULL);