1#!/usr/bin/env python3 2 3# Copyright 2023 Google LLC 4# SPDX-License-Identifier: Apache-2.0 5 6"""Validate the output of check_init_priorities against a test reference.""" 7 8import sys 9 10REFERENCE_OUTPUT = [ 11 "ERROR: Device initialization priority validation failed, the sequence of initialization calls does not match the devicetree dependencies.", 12 "ERROR: /i2c@11112222/test-i2c-dev@10 <NULL> is initialized before its dependency /gpio@ffff <NULL> (PRE_KERNEL_1+0 < PRE_KERNEL_1+1)", 13 "ERROR: /i2c@11112222/test-i2c-dev@10 <NULL> is initialized before its dependency /i2c@11112222 <NULL> (PRE_KERNEL_1+0 < PRE_KERNEL_1+2)", 14 "INFO: /i2c@11112222/test-i2c-dev@11 <NULL> PRE_KERNEL_1+3 > /gpio@ffff <NULL> PRE_KERNEL_1+1", 15 "INFO: /i2c@11112222/test-i2c-dev@11 <NULL> PRE_KERNEL_1+3 > /i2c@11112222 <NULL> PRE_KERNEL_1+2", 16] 17 18if len(sys.argv) != 2: 19 print(f"usage: {sys.argv[0]} FILE_PATH") 20 sys.exit(1) 21 22output = [] 23with open(sys.argv[1], "r") as file: 24 for line in file: 25 if line.startswith("INFO: check_init_priorities"): 26 continue 27 output.append(line.strip()) 28 29if sorted(REFERENCE_OUTPUT) != sorted(output): 30 print("Mismatched otuput") 31 print() 32 print("expected:") 33 print("\n".join(sorted(REFERENCE_OUTPUT))) 34 print() 35 print("got:") 36 print("\n".join(sorted(output))) 37 print("TEST FAILED") 38 sys.exit(1) 39 40print("TEST PASSED") 41sys.exit(0) 42