test: also verify the generated autosuspend hwdb file
Hint: meson test -C build parse-hwdb -v
This commit is contained in:
parent
79dc5d35dd
commit
aa549ff397
|
@ -1,6 +1,9 @@
|
||||||
# SPDX-License-Identifier: LGPL-2.1+
|
# SPDX-License-Identifier: LGPL-2.1+
|
||||||
|
|
||||||
hwdb_files = files('''
|
# Those files right now are not supported by the grammar. Also,
|
||||||
|
# they are very long but quite repetitive and the parser is not very fast.
|
||||||
|
# So we don't "test" them.
|
||||||
|
hwdb_files_notest = files('''
|
||||||
20-pci-vendor-model.hwdb
|
20-pci-vendor-model.hwdb
|
||||||
20-pci-classes.hwdb
|
20-pci-classes.hwdb
|
||||||
20-usb-vendor-model.hwdb
|
20-usb-vendor-model.hwdb
|
||||||
|
@ -12,6 +15,9 @@ hwdb_files = files('''
|
||||||
20-OUI.hwdb
|
20-OUI.hwdb
|
||||||
20-net-ifname.hwdb
|
20-net-ifname.hwdb
|
||||||
20-vmbus-class.hwdb
|
20-vmbus-class.hwdb
|
||||||
|
'''.split())
|
||||||
|
|
||||||
|
hwdb_files_test = files('''
|
||||||
60-evdev.hwdb
|
60-evdev.hwdb
|
||||||
60-input-id.hwdb
|
60-input-id.hwdb
|
||||||
60-keyboard.hwdb
|
60-keyboard.hwdb
|
||||||
|
@ -23,7 +29,16 @@ hwdb_files = files('''
|
||||||
'''.split())
|
'''.split())
|
||||||
|
|
||||||
if conf.get('ENABLE_HWDB') == 1
|
if conf.get('ENABLE_HWDB') == 1
|
||||||
install_data(hwdb_files,
|
auto_suspend_rules = custom_target(
|
||||||
|
'60-autosuspend-chromiumos.hwdb',
|
||||||
|
output : '60-autosuspend-chromiumos.hwdb',
|
||||||
|
command : make_autosuspend_rules_py,
|
||||||
|
capture : true,
|
||||||
|
install : true,
|
||||||
|
install_dir: udevhwdbdir)
|
||||||
|
|
||||||
|
install_data(hwdb_files_notest,
|
||||||
|
hwdb_files_test,
|
||||||
install_dir : udevhwdbdir)
|
install_dir : udevhwdbdir)
|
||||||
|
|
||||||
meson.add_install_script('sh', '-c',
|
meson.add_install_script('sh', '-c',
|
||||||
|
@ -32,15 +47,15 @@ if conf.get('ENABLE_HWDB') == 1
|
||||||
meson.add_install_script('sh', '-c',
|
meson.add_install_script('sh', '-c',
|
||||||
'test -n "$DESTDIR" || @0@/systemd-hwdb update'
|
'test -n "$DESTDIR" || @0@/systemd-hwdb update'
|
||||||
.format(rootbindir))
|
.format(rootbindir))
|
||||||
endif
|
|
||||||
|
|
||||||
############################################################
|
if want_tests != 'false'
|
||||||
|
parse_hwdb_py = find_program('parse_hwdb.py')
|
||||||
parse_hwdb_py = find_program('parse_hwdb.py')
|
test('parse-hwdb',
|
||||||
if want_tests != 'false'
|
parse_hwdb_py,
|
||||||
test('parse-hwdb',
|
args : [hwdb_files_test,
|
||||||
parse_hwdb_py,
|
auto_suspend_rules],
|
||||||
timeout : 90)
|
timeout : 90)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
@ -52,11 +67,3 @@ run_target(
|
||||||
run_target(
|
run_target(
|
||||||
'autosuspend-update',
|
'autosuspend-update',
|
||||||
command : [autosuspend_update_sh, project_source_root + '/tools/chromiumos'])
|
command : [autosuspend_update_sh, project_source_root + '/tools/chromiumos'])
|
||||||
|
|
||||||
auto_suspend_rules = custom_target(
|
|
||||||
'60-autosuspend-chromiumos.hwdb',
|
|
||||||
output : '60-autosuspend-chromiumos.hwdb',
|
|
||||||
command : make_autosuspend_rules_py,
|
|
||||||
capture : true,
|
|
||||||
install : true,
|
|
||||||
install_dir: udevhwdbdir)
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER))
|
||||||
SIGNED_REAL = Combine(Optional(Word('-+')) + REAL)
|
SIGNED_REAL = Combine(Optional(Word('-+')) + REAL)
|
||||||
UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
|
UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
|
||||||
|
|
||||||
|
# Those patterns are used in type-specific matches
|
||||||
TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'),
|
TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'),
|
||||||
'evdev': ('name', 'atkbd', 'input'),
|
'evdev': ('name', 'atkbd', 'input'),
|
||||||
'id-input': ('modalias'),
|
'id-input': ('modalias'),
|
||||||
|
@ -68,13 +69,27 @@ TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'),
|
||||||
'sensor': ('modalias', ),
|
'sensor': ('modalias', ),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Patterns that are used to set general properties on a device
|
||||||
|
GENERAL_MATCHES = {'acpi',
|
||||||
|
'bluetooth',
|
||||||
|
'usb',
|
||||||
|
'pci',
|
||||||
|
'sdio',
|
||||||
|
'vmbus',
|
||||||
|
'OUI',
|
||||||
|
}
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def hwdb_grammar():
|
def hwdb_grammar():
|
||||||
ParserElement.setDefaultWhitespaceChars('')
|
ParserElement.setDefaultWhitespaceChars('')
|
||||||
|
|
||||||
prefix = Or(category + ':' + Or(conn) + ':'
|
prefix = Or(category + ':' + Or(conn) + ':'
|
||||||
for category, conn in TYPES.items())
|
for category, conn in TYPES.items())
|
||||||
matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL
|
|
||||||
|
matchline_typed = Combine(prefix + Word(printables + ' ' + '®'))
|
||||||
|
matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables))
|
||||||
|
matchline = (matchline_typed | matchline_general) + EOL
|
||||||
|
|
||||||
propertyline = (White(' ', exact=1).suppress() +
|
propertyline = (White(' ', exact=1).suppress() +
|
||||||
Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) +
|
Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) +
|
||||||
EOL)
|
EOL)
|
||||||
|
@ -102,6 +117,7 @@ def property_grammar():
|
||||||
('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER),
|
('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER),
|
||||||
('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
|
('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
|
||||||
('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
|
('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
|
||||||
|
('ID_AUTOSUSPEND', Literal('1')),
|
||||||
('ID_INPUT', Literal('1')),
|
('ID_INPUT', Literal('1')),
|
||||||
('ID_INPUT_ACCELEROMETER', Literal('1')),
|
('ID_INPUT_ACCELEROMETER', Literal('1')),
|
||||||
('ID_INPUT_JOYSTICK', Literal('1')),
|
('ID_INPUT_JOYSTICK', Literal('1')),
|
||||||
|
|
Loading…
Reference in a new issue