netmodule-wireless-linux/layers/meta-netmodule-legacy-bsp/recipes-kernel/linux/linux-nrsw/verify_config_merge_log.py

45 lines
1.5 KiB
Python
Executable File

#!/usr/bin/python3
def config_merge_log_is_ok(log_file):
import re
str1_pattern = re.compile("^Value requested for (.*) not in final \.config")
requested_pattern = re.compile("^Requested value: (.*)$")
actual_pattern = re.compile("^Actual value: (.*)$")
is_not_set_pattern = re.compile("^# (.*) is not set$")
val, requested = None, None
with open(log_file, "r") as f:
for line in f:
if requested:
match = actual_pattern.match(line)
if not match:
raise ValueError("Can't determine actual config value")
actual = match.group(1)
if (not actual) and is_not_set:
val, requested = None, None
continue
return False
if val:
match = requested_pattern.match(line)
if not match:
raise ValueError("Can't determine requested config value")
requested = match.group(1)
match = is_not_set_pattern.match(requested)
is_not_set = True if match else False
continue
if not val:
match = str1_pattern.match(line)
if not match:
continue
val = match.group(1)
continue
return True
if __name__ == "__main__":
import sys
try:
ret = config_merge_log_is_ok(sys.argv[1])
except Exception as err:
ret = False
if not ret:
sys.exit(1)