From 44e019f53b8d642c9c081025611d1521cadc65ae Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 18 Nov 2019 13:22:44 +0900 Subject: [PATCH] ctl: tests: add test script for enumerations in ALSACtl namespace --- meson.build | 1 + tests/alsactl-enums | 67 +++++++++++++++++++++++++++++++++++++++++++++ tests/helper.py | 20 ++++++++++++++ tests/meson.build | 23 ++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 tests/alsactl-enums create mode 100644 tests/helper.py create mode 100644 tests/meson.build diff --git a/meson.build b/meson.build index 5136662..9f9ff0b 100644 --- a/meson.build +++ b/meson.build @@ -6,3 +6,4 @@ project('alsa-gobject', 'c', gnome = import('gnome') subdir('src') +subdir('tests') diff --git a/tests/alsactl-enums b/tests/alsactl-enums new file mode 100644 index 0000000..5abc1c4 --- /dev/null +++ b/tests/alsactl-enums @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 + +from sys import exit +import gi +gi.require_version('ALSACtl', '0.0') +from gi.repository import ALSACtl + +elem_types = ( + 'NONE', + 'BOOLEAN', + 'INTEGER', + 'ENUMERATED', + 'BYTES', + 'IEC60958', + 'INTEGER64', +) + +elem_iface_types = ( + 'CARD', + 'HWDEP', + 'MIXER', + 'PCM', + 'RAWMIDI', + 'TIMER', + 'SEQUENCER', +) + +elem_access_flags = ( + 'READ', + 'WRITE', + 'VOLATILE', + 'TLV_READ', + 'TLV_WRITE', + 'TLV_COMMAND', + 'INACTIVE', + 'LOCK', + 'OWNER', + 'TLV_CALLBACK', + 'USER', +) + +event_types = ( + 'ELEM', +) + +event_mask_flags = ( + 'VALUE', + 'INFO', + 'ADD', + 'TLV', + 'REMOVE', +) + +types = { + ALSACtl.ElemType: elem_types, + ALSACtl.ElemIfaceType: elem_iface_types, + ALSACtl.ElemAccessFlag: elem_access_flags, + ALSACtl.ElemAccessFlag: elem_access_flags, + ALSACtl.EventType: event_types, + ALSACtl.EventMaskFlag: event_mask_flags, +} + +for obj, types in types.items(): + for t in types: + if not hasattr(obj, t): + print('Enumerator {0} is not produced.'.format(t)) + exit(1) diff --git a/tests/helper.py b/tests/helper.py new file mode 100644 index 0000000..35a8d64 --- /dev/null +++ b/tests/helper.py @@ -0,0 +1,20 @@ +import gi +gi.require_version('GObject', '2.0') +from gi.repository import GObject + +def test(target, props, methods, signals) ->bool: + labels = [prop.name for prop in target.props] + for prop in props: + if prop not in labels: + print('Property {0} is not produced.'.format(prop)) + return False + for method in methods: + if not hasattr(target, method): + print('Method {0} is not produced.'.format(method)) + return False + labels = GObject.signal_list_names(target) + for signal in signals: + if signal not in labels: + print('Signal {0} is not produced.'.format(signal)) + return False + return True diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..5735350 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,23 @@ +# Each entry includes: +# key: the name of test script +# value: namespace for metadata of gobject introspection +tests = { + 'ctl': [ + 'alsactl-enums', + ], +} + +foreach path, scripts: tests + objdir = join_paths(meson.build_root(), 'src', path) + + env = environment() + env.append('LD_LIBRARY_PATH', objdir, separator : ':') + env.append('GI_TYPELIB_PATH', objdir, separator : ':') + + foreach script: scripts + prog = find_program(script) + test(script, prog, + env: env, + ) + endforeach +endforeach -- 2.47.3