Skip to content

Prevent tests from creating temporary files in the source tree - #3498

Open
justsmth wants to merge 1 commit into
aws:mainfrom
justsmth:fix-test-tmpfile-leak
Open

Prevent tests from creating temporary files in the source tree#3498
justsmth wants to merge 1 commit into
aws:mainfrom
justsmth:fix-test-tmpfile-leak

Conversation

@justsmth

@justsmth justsmth commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Context and motivation

On POSIX systems, createTempFILEpath passed a relative template to mkstemp, causing test runs to accumulate awslcTestTmpFile* files in the source tree. The Unix-domain socket tests were the primary source because they created a file only to obtain a unique name, then used a different path for the socket without removing the original file.

Description of changes

Create POSIX temporary files under TMPDIR, falling back to /tmp. For Unix-domain sockets, use a fixed filename inside the already-unique temporary directory instead of creating an unused file to reserve a name.

Testing

No tests were added because the affected paths are already covered by the existing test suites. Built crypto_test, ssl_test, and tool_openssl_test; all tests completed without failures. Verified that the affected socket and file tests no longer create awslcTestTmpFile* files in the source tree.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

The POSIX branch of createTempFILEpath passed a bare relative template to
mkstemp, so temp files landed in the CWD -- and util/all_tests.go chdirs to the
top of the checkout so tests can find their data files, so runs accumulated
hundreds of awslcTestTmpFile* files there. Build the template under TMPDIR
(falling back to /tmp), matching createTempDirPath and the Windows branch.

prepare_unix_domain_socket leaked most of them: it called createTempFILEpath
only to get a unique name, then used <tempdir>/<name> as the socket path, so
the file mkstemp created was never written or removed. The temp dir is already
unique, so use a fixed leaf name and drop the call. That also drops a latent
assumption that createTempFILEpath returns a relative name, untrue on Windows.
@justsmth
justsmth requested a review from a team as a code owner September 8, 2026 14:43
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.13%. Comparing base (254c4cf) to head (a32026c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crypto/test/test_util.cc 50.00% 2 Missing and 2 partials ⚠️
crypto/bio/bio_socket_test.cc 50.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3498      +/-   ##
==========================================
- Coverage   78.15%   78.13%   -0.03%     
==========================================
  Files         700      700              
  Lines      125599   125606       +7     
  Branches    17374    17375       +1     
==========================================
- Hits        98162    98136      -26     
- Misses      26566    26598      +32     
- Partials      871      872       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants