This patch adds a plugin that exercises the virtual and hardware memory read-write API functions added in a previous patch. The plugin takes a target and patch byte sequence, and will overwrite any instruction matching the target byte sequence with the patch. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Rowan Hart <rowanbhart@gmail.com> Message-ID: <20250624175351.440780-8-rowanbhart@gmail.com> [AJB: tweak Makefile, use uintptr_t for pointer stuffing] Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-ID: <20250627112512.1880708-12-alex.bennee@linaro.org>
39 lines
983 B
Python
Executable file
39 lines
983 B
Python
Executable file
#!/usr/bin/env python3
|
|
#
|
|
# validate-patch.py: check the patch applies
|
|
#
|
|
# This program takes two inputs:
|
|
# - the plugin output
|
|
# - the binary output
|
|
#
|
|
# Copyright (C) 2024
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import sys
|
|
from argparse import ArgumentParser
|
|
|
|
def main() -> None:
|
|
"""
|
|
Process the arguments, injest the program and plugin out and
|
|
verify they match up and report if they do not.
|
|
"""
|
|
parser = ArgumentParser(description="Validate patch")
|
|
parser.add_argument('test_output',
|
|
help="The output from the test itself")
|
|
parser.add_argument('plugin_output',
|
|
help="The output from plugin")
|
|
args = parser.parse_args()
|
|
|
|
with open(args.test_output, 'r') as f:
|
|
test_data = f.read()
|
|
with open(args.plugin_output, 'r') as f:
|
|
plugin_data = f.read()
|
|
if "Value: 1" in test_data:
|
|
sys.exit(0)
|
|
else:
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|