From: Takashi Sakamoto Date: Sun, 19 Jun 2022 11:38:51 +0000 (+0900) Subject: tests: add test scripts for namespace functions X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=9d2f59e2f7f3a0b473ec7ea260253e0d0de96f55;p=alsa-gobject.git tests: add test scripts for namespace functions Signed-off-by: Takashi Sakamoto --- diff --git a/tests/alsactl-functions b/tests/alsactl-functions new file mode 100644 index 0000000..f221ee7 --- /dev/null +++ b/tests/alsactl-functions @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +import gi +gi.require_version('ALSACtl', '0.0') +from gi.repository import ALSACtl + +from helper import test_functions + +entries = { + ALSACtl: ( + 'get_card_id_list', + 'get_card_sysname', + 'get_control_sysname', + 'get_control_devnode', + ), + ALSACtl.CardError: ( + 'quark', + ), +} + +for target_type, functions in entries.items(): + if not test_functions(target_type, functions): + exit(ENXIO) diff --git a/tests/alsahwdep-functions b/tests/alsahwdep-functions new file mode 100644 index 0000000..3ec1e01 --- /dev/null +++ b/tests/alsahwdep-functions @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +import gi +gi.require_version('ALSAHwdep', '0.0') +from gi.repository import ALSAHwdep + +from helper import test_functions + +entries = { + ALSAHwdep: ( + 'get_device_id_list', + 'get_hwdep_sysname', + 'get_hwdep_devnode', + 'get_device_info', + ), + ALSAHwdep.DeviceCommonError: ( + 'quark', + 'to_label', + ), +} + +for target_type, functions in entries.items(): + if not test_functions(target_type, functions): + exit(ENXIO) diff --git a/tests/alsarawmidi-functions b/tests/alsarawmidi-functions new file mode 100644 index 0000000..4f04b8c --- /dev/null +++ b/tests/alsarawmidi-functions @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +import gi +gi.require_version('ALSARawmidi', '0.0') +from gi.repository import ALSARawmidi + +from helper import test_functions + +entries = { + ALSARawmidi: ( + 'get_device_id_list', + 'get_rawmidi_sysname', + 'get_rawmidi_devnode', + 'get_subdevice_id_list', + 'get_substream_info', + ), + ALSARawmidi.StreamPairError: ( + 'quark', + ), +} + +for target_type, functions in entries.items(): + if not test_functions(target_type, functions): + exit(ENXIO) diff --git a/tests/alsaseq-functions b/tests/alsaseq-functions new file mode 100644 index 0000000..3711ae8 --- /dev/null +++ b/tests/alsaseq-functions @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +import gi +gi.require_version('ALSASeq', '0.0') +from gi.repository import ALSASeq + +from helper import test_functions + +entries = { + ALSASeq: ( + 'get_seq_sysname', + 'get_seq_devnode', + 'get_system_info', + 'get_client_id_list', + 'get_client_info', + 'get_port_id_list', + 'get_port_info', + 'get_client_pool', + 'get_subscription_list', + 'get_queue_id_list', + 'get_queue_info_by_id', + 'get_queue_info_by_name', + 'get_queue_status', + ), + ALSASeq.UserClientError: ( + 'quark', + ), +} + +for target_type, functions in entries.items(): + if not test_functions(target_type, functions): + exit(ENXIO) diff --git a/tests/alsatimer-functions b/tests/alsatimer-functions new file mode 100644 index 0000000..ae93513 --- /dev/null +++ b/tests/alsatimer-functions @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +import gi +gi.require_version('ALSATimer', '0.0') +from gi.repository import ALSATimer + +from helper import test_functions + +entries = { + ALSATimer: ( + 'get_sysname', + 'get_devnode', + 'get_device_id_list', + 'get_device_info', + 'get_device_status', + 'set_device_params', + 'get_tstamp_source', + ), + ALSATimer.UserInstanceError: ( + 'quark', + ), +} + +for target_type, functions in entries.items(): + if not test_functions(target_type, functions): + exit(ENXIO) diff --git a/tests/helper.py b/tests/helper.py index 5a42934..a7f9faa 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -52,3 +52,11 @@ def test_struct(target_type: object, methods: tuple[str]) -> bool: print('Method {0} is not produced.'.format(method)) return False return True + + +def test_functions(target_type: object, functions: tuple[str]) -> bool: + for function in functions: + if not hasattr(target_type, function): + print('Function {0} is not produced.'.format(function)) + return False + return True diff --git a/tests/meson.build b/tests/meson.build index bc49f0c..3949065 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -16,6 +16,7 @@ tests = { 'alsactl-elem-id', 'alsactl-elem-info-common', 'alsactl-elem-info-single-array', + 'alsactl-functions', ], 'timer': [ 'alsatimer-enums', @@ -29,6 +30,7 @@ tests = { 'alsatimer-device-id', 'alsatimer-tick-event', 'alsatimer-tstamp-event', + 'alsatimer-functions', ], 'seq': [ 'alsaseq-enums', @@ -52,11 +54,13 @@ tests = { 'alsaseq-event-data-result', 'alsaseq-remove-filter', 'alsaseq-queue-timer-common', + 'alsaseq-functions', ], 'hwdep': [ 'alsahwdep-enums', 'alsahwdep-device-info', 'alsahwdep-device-common', + 'alsahwdep-functions', ], 'rawmidi': [ 'alsarawmidi-enums', @@ -64,6 +68,7 @@ tests = { 'alsarawmidi-stream-pair', 'alsarawmidi-substream-params', 'alsarawmidi-substream-status', + 'alsarawmidi-functions', ], }