Validates the config lists used by the script.

This validation is to help ensure that any usage of custom merge config
files does not accidentally exclude any item that has been added to the
default config lists.

Bug: 124197349
Test: Run merge_target_files with custom merge config files.
Change-Id: I34c51cb75212368146a2944d37621f311060d24d
This commit is contained in:
Daniel Norman 2019-03-19 10:32:03 -07:00
parent e3f9dc6113
commit e596452f03
1 changed files with 37 additions and 0 deletions

View File

@ -199,6 +199,38 @@ def read_config_list(config_file_path):
return config_file.read().splitlines()
def validate_config_lists(system_item_list, other_item_list):
"""Performs validations on the merge config lists.
Args:
system_item_list: The list of items to extract from the partial
system target files package as is.
other_item_list: The list of items to extract from the partial
other target files package as is.
Returns:
False if a validation fails, otherwise true.
"""
default_combined_item_set = set(default_system_item_list)
default_combined_item_set.update(default_other_item_list)
combined_item_set = set(system_item_list)
combined_item_set.update(other_item_list)
# Check that the merge config lists are not missing any item specified
# by the default config lists.
difference = default_combined_item_set.difference(combined_item_set)
if difference:
logger.error('Missing merge config items: %s' % list(difference))
logger.error('Please ensure missing items are in either the '
'system-item-list or other-item-list files provided to '
'this script.')
return False
return True
def process_ab_partitions_txt(
system_target_files_temp_dir,
other_target_files_temp_dir,
@ -671,6 +703,11 @@ def main():
else:
other_item_list = default_other_item_list
if not validate_config_lists(
system_item_list=system_item_list,
other_item_list=other_item_list):
sys.exit(1)
call_func_with_temp_dir(
lambda temp_dir: merge_target_files(
temp_dir=temp_dir,