Skip to content

Move NVM flash live-context test buffers from static to stack - #557

Closed
kojiws wants to merge 1 commit into
wolfSSL:mainfrom
kojiws:nvm_flash_test_live_buffers_on_stack
Closed

kojiws wants to merge 1 commit into
wolfSSL:mainfrom
kojiws:nvm_flash_test_live_buffers_on_stack

Conversation

@kojiws

@kojiws kojiws commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

simulateFailureWithoutReboot() and simulateReloadFailure() used two static FLASH_RAM_SIZE buffers (2 MB of .bss). Embedded ports that link wh_test_nvm_flash.c only for whTest_Flash() carried this RAM even though these tests never ran there.

Changes

  • Make liveMemory and liveBackup locals in the two functions, like in the neighbouring recovery tests.
  • Peak stack use is unchanged.

Testing

  • make run with NOCRYPTO=1
  • make run with NOCRYPTO=1 ASAN=1 NVM_FLASH_CRC=1

Copilot AI balanced review requested due to automatic review settings November 2, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the flash-test buffer storage change.

No open issues 🎉

What changed in this PR

Moves the live-context flash test buffers from static storage to function-local stack storage, removing 2 MB of persistent .bss usage for embedded ports that link this test file only for whTest_Flash().

Changes:

  • Removes the shared static liveMemory and liveBackup buffers.
  • Adds zero-initialized local buffers to both failure-simulation functions, matching neighboring recovery tests.
File Description
test/​wh_test_nvm_flash.c Moves flash image buffers into simulateFailureWithoutReboot() and simulateReloadFailure().

Review effort: Balanced

@bigbrett

bigbrett commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@kojiws 2MB on the stack probably isn't great either...

Should we instead just split the test up so the whTest_Flash() function is in its own module so it can be consumed by embedded targets if you want to run the test on them?

@bigbrett bigbrett assigned kojiws and unassigned wolfSSL-Bot Nov 4, 2026
@kojiws kojiws closed this Nov 5, 2026
@kojiws
kojiws deleted the nvm_flash_test_live_buffers_on_stack branch November 5, 2026 01:17
@kojiws
kojiws restored the nvm_flash_test_live_buffers_on_stack branch November 5, 2026 01:21
@kojiws

kojiws commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@bigbrett
That looks better. I will create another PR to split whTest_Flash() out.

@kojiws
kojiws deleted the nvm_flash_test_live_buffers_on_stack branch November 5, 2026 01:24
@kojiws kojiws removed their assignment Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants