blob: 056238ad41bbaf7a417608ccc8387e5747cf2810 [file]
# 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.
"""Post-build verification test for board revision ELF build."""
import os
import sys
from elftools.elf.elffile import ELFFile
def main():
if len(sys.argv) < 2:
print("Usage: verify_board_revision.py <path-to-elf>")
sys.exit(1)
elf_path = sys.argv[1]
if not os.path.exists(elf_path):
print(f"Error: ELF file {elf_path} not found")
sys.exit(1)
with open(elf_path, "rb") as f:
elf = ELFFile(f)
arch = elf.get_machine_arch()
num_sections = elf.num_sections()
assert arch == "ARM", f"Expected ARM architecture, got {arch}"
assert num_sections > 0, "Expected non-empty section header table in ELF"
print(f"Successfully verified ELF file for board revision: {elf_path}")
print(f"Architecture: {arch}, Sections: {num_sections}")
if __name__ == "__main__":
main()