Skip to content

test: fix test aborts and hardware-dependent failures on single-core machines - #1474

Open
iamjaeholee wants to merge 2 commits into
hermit-os:mainfrom
iamjaeholee:fix/affinity-test-panic
Open

test: fix test aborts and hardware-dependent failures on single-core machines#1474
iamjaeholee wants to merge 2 commits into
hermit-os:mainfrom
iamjaeholee:fix/affinity-test-panic

Conversation

@iamjaeholee

Copy link
Copy Markdown

Resolves #1473

Description

This PR fixes two test suite issues that cause cargo test --bin uhyve to fail prematurely on single-core machines.

Changes Made

1. Fixed graceful exit replacing panic! in affinity validation
The test_affinity_errors_when_lacking_cpu_cores test relies on #[should_panic].
When running on a machine with fewer cores than requested, affinity.validate() fails. However, instead of panicking, clap gracefully terminates the process via app.error().exit().
Fix: Added #[cfg(test)] panic!("{e}"); to the ValueValidation error block to properly satisfy the test harness.

2. Removed hardware-dependent logic from TOML parsing tests
Fixing the above bug exposed a flaw in test_toml_affinity_strings and test_toml_affinity_usize_array. Both tests explicitly request 3 cores (affinity = '0-1,2') and then call get_affinity() to verify logic validation. However, this implicitly triggers the hardware validation check first, which unconditionally panics on single/dual-core machines.
Fix: Removed the get_affinity() calls from these TOML tests, as the TOML deserialization itself is already verified via assert_eq!.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.53%. Comparing base (af7ba88) to head (caeca20).

Files with missing lines Patch % Lines
src/bin/uhyve.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1474      +/-   ##
==========================================
+ Coverage   79.38%   79.53%   +0.14%     
==========================================
  Files          39       39              
  Lines        5592     5589       -3     
==========================================
+ Hits         4439     4445       +6     
+ Misses       1153     1144       -9     

☔ 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.

Tests abort with exit status: 2 on single-core machines (test_affinity_errors_when_lacking_cpu_cores)

1 participant