Skip to content

Fix mutex exit code in test case#1020

Merged
mlim19 merged 4 commits intomasterfrom
fix-mutex-exit-code
Mar 9, 2026
Merged

Fix mutex exit code in test case#1020
mlim19 merged 4 commits intomasterfrom
fix-mutex-exit-code

Conversation

@mlim19
Copy link
Contributor

@mlim19 mlim19 commented Mar 6, 2026

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots

Checklist:

  • I have read the CONTRIBUTING document.
  • I have updated the relevant documentation.
  • I have added tests for new logic.

mlim19 added 3 commits March 6, 2026 11:30
When gProfiler cannot acquire the mutex (because another instance is
running), it should exit with status 1 (error), not status 0 (success).

This fixes test failures in test_preconditions.py where tests expect
the container to fail when the mutex is already held.

The behavior now aligns with other precondition checks (not root,
not host PID) which correctly exit with status 1 on failure.
The test now expects the second gProfiler instance to exit with
status 1 (error) instead of status 0 (success) when the mutex is
already held.

This aligns with the fix in main.py where we changed sys.exit(0)
to sys.exit(1) for the mutex failure case.
Improvements:
- Verify first container is running before starting second
- Add explicit status checks for container states
- Add descriptive assertion messages for better debugging
- Verify first container remains running after second fails
- Add comments explaining each test step

This makes the test less flaky and easier to debug when it fails.
@dkorlovs dkorlovs force-pushed the fix-mutex-exit-code branch from 8975a70 to 87bc112 Compare March 6, 2026 22:45
Changed from exact equality checks to 'contains' checks for stderr
messages. This makes tests resilient to warnings (like the requests
library dependency warning) being prepended to error output.

The tests now check that the expected error message is present in
stderr, rather than requiring stderr to be exactly equal to the
expected message.

Fixes test failures caused by:
  RequestsDependencyWarning: Unable to find acceptable character
  detection dependency (chardet or charset_normalizer)

Signed-off-by: Min Yeol Lim <min.yeol.lim@intel.com>
@dkorlovs dkorlovs force-pushed the fix-mutex-exit-code branch from 87bc112 to bea6706 Compare March 6, 2026 22:48
Copy link

@skamerintel skamerintel left a comment

Choose a reason for hiding this comment

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

approved.

@mlim19 mlim19 merged commit 5f4656f into master Mar 9, 2026
35 checks passed
@mlim19 mlim19 deleted the fix-mutex-exit-code branch March 9, 2026 23:04
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.

2 participants