-
Notifications
You must be signed in to change notification settings - Fork 612
Optimize reboots with Android emulator initialization #5280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jardondiego
wants to merge
14
commits into
master
Choose a base branch
from
optimize-android-reboots
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+71
−13
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d5936d5
Optimize Android emulator initialization by batching reboots
9b88335
Fix reboot_done tracking to ensure device settings are applied
1aecb3a
Revert previous fix and use accumulated state for reboot_done
1482ba7
Invert logic to needs_reboot and use bitwise OR operator to fix state…
f960945
Fix needs_reboot logic so ASan setup clears pending reboots
def65fa
Fix initialization reboot logic to correctly preserve base requirements
ed141f1
Add unit tests for android device reboot logic
a0d418e
Fix formatting issues from linter in device_test.py
53bdbc8
Address PR 5280 comments: Add return types and docstrings
fd28f7b
Rename wait_for_reboot to should_reboot
169b8ae
Update docstrings for test cases
01dc2a9
Simplify initialize_device logic and refactor tests
450b66e
Add descriptive docstring for InitializeEnvironmentTest
2888eab
Add docstring to write_data_to_file
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,13 +13,55 @@ | |
| # limitations under the License. | ||
| """Tests for device functions.""" | ||
|
|
||
| import unittest | ||
|
|
||
| from clusterfuzz._internal.platforms.android import device | ||
| from clusterfuzz._internal.tests.test_libs import android_helpers | ||
|
|
||
|
|
||
| class InitializeEnvironmentTest(android_helpers.AndroidTest): | ||
| """Tests for """ | ||
| """Tests for the device environment initialization process (`initialize_environment`).""" | ||
|
|
||
| def test(self): | ||
| """Ensure that initialize_environment throws no exceptions.""" | ||
| device.initialize_environment() | ||
|
|
||
|
|
||
| class InitializeDeviceRebootLogicTest(unittest.TestCase): | ||
| """Tests the reboot batching logic in initialize_device.""" | ||
|
|
||
| def setUp(self): | ||
| from clusterfuzz._internal.tests.test_libs import helpers | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's move this to the top level, no need to make this import conditional on the test being run? |
||
| helpers.patch(self, [ | ||
| 'clusterfuzz._internal.system.environment.is_engine_fuzzer_job', | ||
| 'clusterfuzz._internal.platforms.android.adb.setup_adb', | ||
| 'clusterfuzz._internal.platforms.android.adb.run_as_root', | ||
| 'clusterfuzz._internal.platforms.android.device.configure_system_build_properties', | ||
| 'clusterfuzz._internal.platforms.android.device.configure_device_settings', | ||
| 'clusterfuzz._internal.platforms.android.device.add_test_accounts_if_needed', | ||
| 'clusterfuzz._internal.platforms.android.sanitizer.setup_asan_if_needed', | ||
| 'clusterfuzz._internal.platforms.android.device.reboot', | ||
| 'clusterfuzz._internal.platforms.android.wifi.configure', | ||
| 'clusterfuzz._internal.platforms.android.device.setup_host_and_device_forwarder_if_needed', | ||
| 'clusterfuzz._internal.platforms.android.settings.change_se_linux_to_permissive_mode', | ||
| 'clusterfuzz._internal.platforms.android.app.wait_until_optimization_complete', | ||
| 'clusterfuzz._internal.platforms.android.ui.clear_notifications', | ||
| 'clusterfuzz._internal.platforms.android.ui.unlock_screen', | ||
| ]) | ||
| self.mock.is_engine_fuzzer_job.return_value = False | ||
|
|
||
| def test_reboot_if_asan_did_not_run(self): | ||
| """Test that `initialize_device()` calls `reboot()` if the ASan setup | ||
| script did not.""" | ||
| self.mock.setup_asan_if_needed.return_value = False | ||
|
|
||
| device.initialize_device() | ||
| self.mock.reboot.assert_called_once() | ||
|
|
||
| def test_no_reboot_if_asan_ran(self): | ||
| """Test that `initialize_device()` skips calling `reboot()` if the ASan | ||
| setup script did.""" | ||
| self.mock.setup_asan_if_needed.return_value = True | ||
|
|
||
| device.initialize_device() | ||
| self.mock.reboot.assert_not_called() | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's explain what a system file is, and no need to repeat the default argument value since that's self-documenting: