コード例 #1
0
ファイル: adb_test.py プロジェクト: whiteHat001/clusterfuzz
 def test_regular_file(self):
   """Test that checksum is properly calculated for regular files."""
   adb.write_data_to_file('abcd', '/sdcard/file1')
   self.assertTrue(adb.file_exists('/sdcard/file1'))
   self.assertEqual(
       adb.get_file_checksum('/sdcard/file1'),
       'e2fc714c4727ee9395f324cd2e7f331f')
コード例 #2
0
 def test_remount(self):
     """Tests remount."""
     system_test_file_path = os.path.join('/system', 'a')
     adb.write_data_to_file('data', system_test_file_path)
     self.assertEqual(adb.read_data_from_file(system_test_file_path),
                      'data')
     adb.run_adb_shell_command(['rm', system_test_file_path])
コード例 #3
0
ファイル: device.py プロジェクト: shu858/clusterfuzz
def configure_device_settings():
    """Configures device settings for test environment."""
    # FIXME: We shouldn't need repeat invocation of this. We need to do this
    # in case previous invocations of any of the below commands failed.
    # Write our test environment settings in content database.
    adb.run_as_root()
    set_content_settings('com.google.settings/partner',
                         'use_location_for_services', 0)
    set_content_settings('settings/global', 'assisted_gps_enabled', 0)
    set_content_settings('settings/global', 'development_settings_enabled', 0)
    set_content_settings('settings/global', 'stay_on_while_plugged_in', 3)
    set_content_settings('settings/global', 'send_action_app_error', 0)
    set_content_settings('settings/global', 'verifier_verify_adb_installs', 0)
    set_content_settings('settings/global', 'wifi_scan_always_enabled', 0)
    set_content_settings('settings/secure', 'anr_show_background', 0)
    set_content_settings('settings/secure', 'doze_enabled', 0)
    set_content_settings('settings/secure', 'location_providers_allowed', '')
    set_content_settings('settings/secure', 'lockscreen.disabled', 1)
    set_content_settings('settings/secure', 'screensaver_enabled', 0)
    set_content_settings('settings/system', 'accelerometer_rotation', 0)
    set_content_settings('settings/system', 'auto_time', 0)
    set_content_settings('settings/system', 'auto_timezone', 0)
    set_content_settings('settings/system', 'lockscreen.disabled', 1)
    set_content_settings('settings/system', 'notification_light_pulse', 0)
    set_content_settings('settings/system', 'screen_brightness_mode', 0)
    set_content_settings('settings/system', 'screen_brightness', 1)
    set_content_settings('settings/system', 'user_rotation', 0)

    # The following line filled with magic numbers will set media volume to 0
    # 3 is the 3rd function in the IAudioServiceList and the following
    # i32's specify 32 bit integer arguments to the function
    adb.run_adb_shell_command('service call audio 3 i32 3 i32 0 i32 1')

    # FIXME: We shouldn't need repeat invocation of this. We need to do this
    # in case previous invocations of any of the below commands failed.
    # On certain device/Android configurations we need to disable the lock screen
    # in a different database. Additionally, the password type must be set to 0.
    adb.update_key_in_sqlite_db(LOCKSCREEN_DB, LOCKSCREEN_TABLE_NAME,
                                'lockscreen.disabled', 1)
    adb.update_key_in_sqlite_db(LOCKSCREEN_DB, LOCKSCREEN_TABLE_NAME,
                                'lockscreen.password_type', 0)
    adb.update_key_in_sqlite_db(LOCKSCREEN_DB, LOCKSCREEN_TABLE_NAME,
                                'lockscreen.password_type_alternate', 0)

    adb.disable_packages_that_crash_with_gestures()

    # Create a list of property name and names to be used in local.prop file.
    local_properties_settings_list = copy.deepcopy(LOCAL_PROP_SETTINGS)

    # Add debugging flags to local settings list so that they persist across
    # reboots.
    local_properties_settings_list += get_debug_props_and_values()

    # Write the local properties file settings.
    local_properties_file_contents = '\n'.join(local_properties_settings_list)
    adb.write_data_to_file(local_properties_file_contents, LOCAL_PROP_PATH)
コード例 #4
0
  def test_copy_remote_directory_to_local(self):
    """Tests copy_remote_directory_to_local."""
    adb.write_data_to_file('a', os.path.join(self.device_temp_dir, 'a'))
    adb.create_directory_if_needed(os.path.join(self.device_temp_dir, 'b'))
    adb.write_data_to_file('c', os.path.join(self.device_temp_dir, 'b', 'c'))

    adb.copy_remote_directory_to_local(self.device_temp_dir,
                                       self.local_temp_dir)

    self.assertTrue(os.path.exists(os.path.join(self.local_temp_dir, 'a')))
    self.assertTrue(os.path.isfile(os.path.join(self.local_temp_dir, 'a')))
    self.assertTrue(os.path.exists(os.path.join(self.local_temp_dir, 'b')))
    self.assertTrue(os.path.isdir(os.path.join(self.local_temp_dir, 'b')))
    self.assertTrue(os.path.exists(os.path.join(self.local_temp_dir, 'b', 'c')))
    self.assertTrue(os.path.isfile(os.path.join(self.local_temp_dir, 'b', 'c')))
コード例 #5
0
ファイル: adb_test.py プロジェクト: whiteHat001/clusterfuzz
 def test_regular_file(self):
   """Test that file size is properly calculated for regular files."""
   adb.write_data_to_file('abcd', '/sdcard/file1')
   self.assertTrue(adb.file_exists('/sdcard/file1'))
   self.assertEqual(adb.get_file_size('/sdcard/file1'), 4)
コード例 #6
0
ファイル: adb_test.py プロジェクト: whiteHat001/clusterfuzz
 def test_regular_file(self):
   """Test that file data is written."""
   test_file_path = os.path.join(self.device_temp_dir, 'a')
   adb.write_data_to_file('a' * 5000, test_file_path)
   self.assertEqual(adb.read_data_from_file(test_file_path), 'a' * 5000)
コード例 #7
0
 def test_read_data_from_file_and_write_data_to_file(self):
     """Tests read_data_from_file and write_data_to_file."""
     test_file_path = os.path.join(self.device_temp_dir, 'a')
     self.assertEqual(adb.read_data_from_file(test_file_path), None)
     adb.write_data_to_file('data', test_file_path)
     self.assertEqual(adb.read_data_from_file(test_file_path), 'data')
コード例 #8
0
ファイル: device.py プロジェクト: shu858/clusterfuzz
def set_sanitizer_options_if_needed(sanitizer_tool_name, sanitizer_options):
    """Sets up sanitizer options on the disk file."""
    sanitizer_options_file_path = get_sanitizer_options_file_path(
        sanitizer_tool_name)
    adb.write_data_to_file(sanitizer_options, sanitizer_options_file_path)