diff options
author | Michael Biebl <biebl@debian.org> | 2017-12-14 23:22:02 +0100 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2017-12-14 23:22:02 +0100 |
commit | 52ad194e0b816b8273dd8d0fea3e6d467f6ca34e (patch) | |
tree | 1a3b3117e015f200ca0ce23f5ad27be6d0a7b0fb /test/rule-syntax-check.py | |
parent | f5e65279187b6aa0c0c5a00b14dca9eab441ffb2 (diff) | |
download | systemd-52ad194e0b816b8273dd8d0fea3e6d467f6ca34e.tar.gz |
New upstream version 236
Diffstat (limited to 'test/rule-syntax-check.py')
-rwxr-xr-x | test/rule-syntax-check.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py index 14739df493..e053b027ca 100755 --- a/test/rule-syntax-check.py +++ b/test/rule-syntax-check.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1+ +# # Simple udev rules syntax checker # # (C) 2010 Canonical Ltd. @@ -22,17 +24,9 @@ import sys import os from glob import glob -if len(sys.argv) > 1: - # explicit rule file list - rules_files = sys.argv[1:] -else: - # take them from the build dir - root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - rules_dir = os.path.join(os.environ.get('top_srcdir', root_dir), 'rules') - if not os.path.isdir(rules_dir): - sys.stderr.write('No rules files given, and %s does not exist, aborting' % rules_dir) - sys.exit(2) - rules_files = glob(os.path.join(rules_dir, '*.rules')) +rules_files = sys.argv[1:] +if not rules_files: + sys.exit('Specify files to test as arguments') no_args_tests = re.compile(r'(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|RESULT|TEST)\s*(?:=|!)=\s*"([^"]*)"$') args_tests = re.compile(r'(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*"([^"]*)"$') @@ -42,6 +36,7 @@ args_assign = re.compile(r'(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=) result = 0 buffer = '' for path in rules_files: + print('# looking at {}'.format(path)) lineno = 0 for line in open(path): lineno += 1 @@ -64,9 +59,9 @@ for path in rules_files: if not (no_args_tests.match(clause) or args_tests.match(clause) or no_args_assign.match(clause) or args_assign.match(clause)): - print('Invalid line %s:%i: %s' % (path, lineno, line)) - print(' clause: %s' % clause) - print('') + print('Invalid line {}:{}: {}'.format(path, lineno, line)) + print(' clause:', clause) + print() result = 1 break |