mirror of
https://git.busybox.net/buildroot.git
synced 2024-11-23 05:23:39 +08:00
0c5472ace2
This script checks for inconsistencies on symbols declared in Config.in and used in .mk files. Currently it checks only symbols following the pattern BR2_\w+ . The script first gets the list of all files in the repository (using git ls-files like 'make check-flake8' already do). Then it parses all relevant files, searching for symbol definitions and usages, and add entries into a database. At the end, the database is searched for inconsistencies: - symbol that is part of "choice" and is referenced with "select"; - legacy symbol being referenced in packages; - legacy symbol being redefined in packages; - symbol referenced but not defined; - symbol defined but not referenced; - legacy symbol that has a Note stating it is referenced by a package (for legacy handling) but is referenced in the package without a comment "# legacy"; - legacy symbol that has a Note stating it is referenced by a package but it is not actually referenced. There is also a debug parameter --search that dumps any filename or symbol entries from the database that matches a regexp. Sample usages: $ utils/check-symbols $ utils/docker-run utils/check-symbols $ utils/check-symbols --search 'GETTEXT\b|\/openssl' At same time the script is created: - add unit tests for it, they can be run using: utils/docker-run python3 -m pytest -v utils/checksymbolslib/ - add two more GitLab CI jobs: check-symbols (to check current tree using the script) and check-check-symbols (to check the script against its unit tests) Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> [Peter: print warnings to stderr, rename change_current_dir() to change_to_top_dir()] Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
16 lines
1023 B
Python
16 lines
1023 B
Python
def assert_calls(method, expected_calls):
|
|
method.assert_has_calls(expected_calls, any_order=True)
|
|
assert method.call_count == len(expected_calls)
|
|
|
|
|
|
def assert_db_calls(db, expected_calls):
|
|
assert_calls(db.add_symbol_legacy_definition, expected_calls.get('add_symbol_legacy_definition', []))
|
|
assert_calls(db.add_symbol_definition, expected_calls.get('add_symbol_definition', []))
|
|
assert_calls(db.add_symbol_usage_in_legacy, expected_calls.get('add_symbol_usage_in_legacy', []))
|
|
assert_calls(db.add_symbol_usage, expected_calls.get('add_symbol_usage', []))
|
|
assert_calls(db.add_symbol_legacy_usage, expected_calls.get('add_symbol_legacy_usage', []))
|
|
assert_calls(db.add_symbol_select, expected_calls.get('add_symbol_select', []))
|
|
assert_calls(db.add_symbol_helper, expected_calls.get('add_symbol_helper', []))
|
|
assert_calls(db.add_symbol_legacy_note, expected_calls.get('add_symbol_legacy_note', []))
|
|
assert_calls(db.add_symbol_virtual, expected_calls.get('add_symbol_virtual', []))
|