Skip to content

testing/sd_stress: Handle stale temporary directories#3499

Open
nightt5879 wants to merge 2 commits into
apache:masterfrom
nightt5879:nightt5879/fix-sdstress-stale-dir-3205
Open

testing/sd_stress: Handle stale temporary directories#3499
nightt5879 wants to merge 2 commits into
apache:masterfrom
nightt5879:nightt5879/fix-sdstress-stale-dir-3205

Conversation

@nightt5879
Copy link
Copy Markdown
Contributor

Summary

Fixes #3205.

This PR makes sdstress recover from temporary directories left behind by an interrupted or failed previous run.

Commit structure:

  • Commit 1 (testing/sd_stress: Handle stale temporary directories) is the strict [BUG] testing/drivers/sd_stress: does not run properly when /sd/stress location exists. #3205 fix. It cleans stale /sd/stress and /sd/moved work directories before starting a new test, but only removes files matching the app-generated tmpNNN pattern. Unexpected entries make the cleanup fail instead of deleting user data. It also fixes create_dir() / remove_dir() to use their path argument.
  • Commit 2 (testing/sd_stress: Harden file creation cleanup) is a logically separable extension. It closes the temp file descriptor on create_files() failures after open(), and releases the read buffer on the path-length failure branch.

The second commit is logically separable and I am happy to drop it if maintainers consider it out of scope for #3205.

Out of scope:

Impact

Users no longer need to manually remove stale sdstress temporary directories before running the test again after an interrupted or failed run.

  • New feature: NO
  • User adaptation required: NO
  • Build process change: NO
  • Hardware/architecture/board change: NO
  • Documentation update required: NO
  • Security impact: NO intended security impact
  • Compatibility impact: NO intended compatibility impact

Testing

Host:

  • Windows with WSL Ubuntu 24.04
  • CPU: x86_64
  • Compiler: GCC 13.3.0

Checks:

  • git diff --check upstream/master..HEAD: pass
  • checkpatch.sh -c -u -m -g HEAD~2..HEAD: pass
  • sim:nsh build with CONFIG_ALLOW_BSD_COMPONENTS=y and CONFIG_TESTING_SD_STRESS=y: pass
    • confirmed Register: sdstress
    • confirmed CC: sd_stress_main.c
    • result: SIM elf with dynamic libs archive in nuttx.tgz

Note: .config printed an expected override warning because the temporary test build appended CONFIG_ALLOW_BSD_COMPONENTS=y / CONFIG_TESTING_SD_STRESS=y after configuring sim:nsh.

Fix apache#3205 by removing stale sdstress work directories left by previous interrupted or failed runs before starting a new test.

The cleanup only removes entries matching the generated tmpNNN file pattern. If the directory contains any unexpected entry, the test fails instead of deleting user data.

Also make create_dir() and remove_dir() use their path argument instead of the fixed temporary directory names.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
Close the temporary file descriptor when create_files() fails after open(), and release the read buffer before returning from the path-length failure branch.

This is logically separable from the apache#3205 stale-directory fix: it does not change how existing /sd/stress is handled, but keeps the same failure paths from leaking resources while the stress test exits after an error.

The scope intentionally stays within sd_stress failure cleanup and does not touch SD/MMC transfer behavior or other testing drivers.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
@nightt5879 nightt5879 marked this pull request as ready for review May 24, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] testing/drivers/sd_stress: does not run properly when /sd/stress location exists.

2 participants