From 2956395c83ced766e989a53350293fdc62836178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 22 Nov 2017 12:29:46 +0100 Subject: [PATCH 1/2] rule-test-syntax: modernize syntax and add debug message --- test/rule-syntax-check.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py index 4f27fb015b..7c69c489cb 100755 --- a/test/rule-syntax-check.py +++ b/test/rule-syntax-check.py @@ -32,7 +32,7 @@ else: 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) + print('No rules files given, and {} does not exist, aborting'.format(rules_dir), file=sys.stderr) sys.exit(2) rules_files = glob(os.path.join(rules_dir, '*.rules')) @@ -44,6 +44,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 @@ -66,9 +67,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 From 6b97bf2287a8650987b0a670cb9a8c9d9e3df20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 22 Nov 2017 12:42:28 +0100 Subject: [PATCH 2/2] meson: re-attach rule-syntax-check.py test 39/248 rule-syntax-check OK 0.07 s --- command --- /home/zbyszek/src/systemd-work/test/rule-syntax-check.py \ /home/zbyszek/src/systemd-work/build/../rules/60-block.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-cdrom_id.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-drm.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-evdev.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-input-id.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-alsa.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-input.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-storage.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-storage-tape.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-persistent-v4l.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-sensor.rules \ /home/zbyszek/src/systemd-work/build/../rules/60-serial.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-joystick.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-mouse.rules \ /home/zbyszek/src/systemd-work/build/../rules/70-touchpad.rules \ /home/zbyszek/src/systemd-work/build/../rules/75-net-description.rules \ /home/zbyszek/src/systemd-work/build/../rules/75-probe_mtd.rules \ /home/zbyszek/src/systemd-work/build/../rules/78-sound-card.rules \ /home/zbyszek/src/systemd-work/build/../rules/80-drivers.rules \ /home/zbyszek/src/systemd-work/build/../rules/80-net-setup-link.rules \ /home/zbyszek/src/systemd-work/build/rules/50-udev-default.rules \ /home/zbyszek/src/systemd-work/build/rules/64-btrfs.rules \ /home/zbyszek/src/systemd-work/build/rules/99-systemd.rules --- stdout --- ... ------- It got dropped by mistake in 72cdb3e783174dcf9223a49f03e3b0e2ca95ddb8. --- meson.build | 2 +- rules/meson.build | 3 +++ test/meson.build | 7 +++++++ test/rule-syntax-check.py | 14 +++----------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index 7e997b195a..6317847663 100644 --- a/meson.build +++ b/meson.build @@ -1218,6 +1218,7 @@ subdir('src/sulogin-shell') subdir('src/boot/efi') subdir('src/test') +subdir('rules') subdir('test') ############################################################ @@ -2345,7 +2346,6 @@ subdir('units') subdir('sysctl.d') subdir('sysusers.d') subdir('tmpfiles.d') -subdir('rules') subdir('hwdb') subdir('network') subdir('man') diff --git a/rules/meson.build b/rules/meson.build index 56a270712a..e253b9f591 100644 --- a/rules/meson.build +++ b/rules/meson.build @@ -41,6 +41,8 @@ rules = files(''' install_data(rules, install_dir : udevrulesdir) +all_rules = rules + rules_in = ''' 50-udev-default.rules 64-btrfs.rules @@ -54,4 +56,5 @@ foreach file : rules_in configuration : substs) install_data(gen, install_dir : udevrulesdir) + all_rules += gen endforeach diff --git a/test/meson.build b/test/meson.build index 40605b385f..28b5fcdbca 100644 --- a/test/meson.build +++ b/test/meson.build @@ -188,6 +188,13 @@ endif ############################################################ +rule_syntax_check_py = find_program('rule-syntax-check.py') +test('rule-syntax-check', + rule_syntax_check_py, + args : all_rules) + +############################################################ + if conf.get('HAVE_SYSV_COMPAT') == 1 sysv_generator_test_py = find_program('sysv-generator-test.py') test('sysv-generator-test', diff --git a/test/rule-syntax-check.py b/test/rule-syntax-check.py index 7c69c489cb..e053b027ca 100755 --- a/test/rule-syntax-check.py +++ b/test/rule-syntax-check.py @@ -24,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): - print('No rules files given, and {} does not exist, aborting'.format(rules_dir), file=sys.stderr) - 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*"([^"]*)"$')