summaryrefslogtreecommitdiff
path: root/test/rule-syntax-check.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/rule-syntax-check.py')
-rw-r--r--test/rule-syntax-check.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py
index 8c0180bd3c..80bbe65bea 100644
--- a/test/rule-syntax-check.py
+++ b/test/rule-syntax-check.py
@@ -18,10 +18,20 @@
import re
import sys
+import os
+from glob import glob
-if len(sys.argv) < 2:
- sys.stderr.write('Usage: %s <rules file> [...]\n' % sys.argv[0])
- sys.exit(2)
+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'))
no_args_tests = re.compile('(ACTION|DEVPATH|KERNELS?|NAME|SYMLINK|SUBSYSTEMS?|DRIVERS?|TAG|RESULT|TEST)\s*(?:=|!)=\s*"([^"]*)"$')
args_tests = re.compile('(ATTRS?|ENV|TEST){([a-zA-Z0-9/_.*%-]+)}\s*(?:=|!)=\s*"([^"]*)"$')
@@ -30,7 +40,7 @@ args_assign = re.compile('(ATTR|ENV|IMPORT|RUN){([a-zA-Z0-9/_.*%-]+)}\s*(=|\+=)\
result = 0
buffer = ''
-for path in sys.argv[1:]:
+for path in rules_files:
lineno = 0
for line in open(path):
lineno += 1