blob: 0cc8d5125fcfcf533477af8f7a7a865641f863c8 [file] [edit]
# Copyright 2026 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import sys
import os
def check_file(file_path, expected_str, should_exist):
if not os.path.exists(file_path):
print(f"File not found: {file_path}")
return False
with open(file_path, 'r') as f:
content = f.read()
found = expected_str in content
if should_exist and not found:
print(f"Expected '{expected_str}' not found in {file_path}")
return False
elif not should_exist and found:
print(f"Unexpected '{expected_str}' found in {file_path}")
return False
return True
def main():
if len(sys.argv) < 3:
print("Usage: verify_autoconf.py <main_autoconf> <helper_autoconf>")
sys.exit(1)
main_autoconf = sys.argv[1]
helper_autoconf = sys.argv[2]
print(f"Checking main autoconf: {main_autoconf}")
print(f"Checking helper autoconf: {helper_autoconf}")
success = True
# Helper should have CONFIG_LOG 1 because of helper_app_CONFIG_LOG=y
success &= check_file(helper_autoconf, "#define CONFIG_LOG 1", True)
# Helper should have CONFIG_POLL 1 because of sysbuild/helper_app.conf overlay
success &= check_file(helper_autoconf, "#define CONFIG_POLL 1", True)
# Helper should NOT have CONFIG_REBOOT 1 anymore
success &= check_file(helper_autoconf, "#define CONFIG_REBOOT 1", False)
# Main should NOT have them
success &= check_file(main_autoconf, "#define CONFIG_LOG 1", False)
success &= check_file(main_autoconf, "#define CONFIG_POLL 1", False)
if not success:
sys.exit(1)
print("Verification successful!")
if __name__ == "__main__":
main()