]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
tests: add test scripts for namespace functions topic/test-refine
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 19 Jun 2022 11:38:51 +0000 (20:38 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 19 Jun 2022 11:38:51 +0000 (20:38 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
tests/alsactl-functions [new file with mode: 0644]
tests/alsahwdep-functions [new file with mode: 0644]
tests/alsarawmidi-functions [new file with mode: 0644]
tests/alsaseq-functions [new file with mode: 0644]
tests/alsatimer-functions [new file with mode: 0644]
tests/helper.py
tests/meson.build

diff --git a/tests/alsactl-functions b/tests/alsactl-functions
new file mode 100644 (file)
index 0000000..f221ee7
--- /dev/null
@@ -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 (file)
index 0000000..3ec1e01
--- /dev/null
@@ -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 (file)
index 0000000..4f04b8c
--- /dev/null
@@ -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 (file)
index 0000000..3711ae8
--- /dev/null
@@ -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 (file)
index 0000000..ae93513
--- /dev/null
@@ -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)
index 5a42934d906f9b30675c60e0f77cad5510127c8e..a7f9faa8ae284442ea2d9305fe2aaf04d5bd4ca2 100644 (file)
@@ -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
index bc49f0caeb852bb933663efe8a53408f8429df32..394906597ed39803b44300245ed47044fdd3be77 100644 (file)
@@ -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',
   ],
 }