Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/clusterfuzz/_internal/base/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,10 @@ def get_task():
for p in enable_fuzz_flag.string_value.split(',')
if p.strip()
]
if (not enable_fuzz_flag.enabled or
environment.platform().lower() not in allowed_platforms):
platform = environment.platform().lower()
base_platform = environment.base_platform(platform)
if (not enable_fuzz_flag.enabled or (platform not in allowed_platforms and
base_platform not in allowed_platforms)):
logs.warning('Fuzzing is disabled for long-lived bots.')
return None

Expand Down
34 changes: 34 additions & 0 deletions src/clusterfuzz/_internal/tests/core/base/tasks/tasks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,37 @@ def test_empty_string_value(self):
mock_flag.return_value = mock_flag_obj
self.assertIsNone(tasks.get_task())
self.mock.get_fuzz_task.assert_not_called()

def test_base_platform_in_string_value(self):
"""Test fuzz task is returned when subqueue base platform matches."""
self.mock.platform.return_value = 'ANDROID:PIXEL6'
mock_flag_obj = mock.MagicMock(enabled=True, string_value='linux,android')
with mock.patch.object(
feature_flags.FeatureFlags, 'flag',
new_callable=mock.PropertyMock) as mock_flag:
mock_flag.return_value = mock_flag_obj
self.assertEqual(tasks.get_task(), self.mock_fuzz_task)
self.mock.get_fuzz_task.assert_called_once()

def test_subqueue_platform_in_string_value(self):
"""Test fuzz task is returned when full subqueue platform matches."""
self.mock.platform.return_value = 'ANDROID:PIXEL6'
mock_flag_obj = mock.MagicMock(
enabled=True, string_value='linux,android:pixel6')
with mock.patch.object(
feature_flags.FeatureFlags, 'flag',
new_callable=mock.PropertyMock) as mock_flag:
mock_flag.return_value = mock_flag_obj
self.assertEqual(tasks.get_task(), self.mock_fuzz_task)
self.mock.get_fuzz_task.assert_called_once()

def test_subqueue_and_base_platform_not_in_string_value(self):
"""Test fuzz task is not returned when neither platform nor base matches."""
self.mock.platform.return_value = 'ANDROID_MTE:PIXEL8'
mock_flag_obj = mock.MagicMock(enabled=True, string_value='linux,android')
with mock.patch.object(
feature_flags.FeatureFlags, 'flag',
new_callable=mock.PropertyMock) as mock_flag:
mock_flag.return_value = mock_flag_obj
self.assertIsNone(tasks.get_task())
self.mock.get_fuzz_task.assert_not_called()
Loading