fix: add more mock time values in test_prime_offload_tester to handle (Bugfix)#2166
Merged
Hook25 merged 1 commit intocanonical:mainfrom Oct 30, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2166 +/- ##
=======================================
Coverage 52.86% 52.86%
=======================================
Files 395 395
Lines 42636 42636
Branches 7906 7906
=======================================
Hits 22538 22538
Misses 19295 19295
Partials 803 803
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hanhsuan
approved these changes
Oct 20, 2025
Contributor
hanhsuan
left a comment
There was a problem hiding this comment.
LGTM, Thanks for finding this bug in the unit test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
add more mock time values in test_prime_offload_tester to handle
The check_offload() method makes 5 time.time() calls in the failure scenario:
Call #1: deadline = time.time() + timeout → returns 0, sets deadline to 1
Call #2: while time.time() < deadline: → returns 0, check 0 < 1 = True, enters loop
Call #3: while time.time() < deadline: → returns 1, check 1 < 1 = False, exits loop
Call #4: self.logger.info("Checking fail:") → LogRecord creation calls time.time() → returns 2 (ref: https://docs.python.org/3/library/logging.html#logrecord-attributes)
Call #5: self.logger.info(" Couldn't find process") → LogRecord creation calls time.time() → returns 3
ref:
python3 -c "import logging, inspect; print(inspect.getsource(logging.LogRecord.__init__))", https://github.com/python/cpython/blob/main/Lib/logging/__init__.py#L283Resolved issues
PR #2162
https://github.com/canonical/checkbox/actions/runs/18641071113/job/53139932346?pr=2162
Documentation
Tests
cherry pick this commit
https://github.com/canonical/checkbox/actions/runs/18641579136/job/53141487716?pr=2162