]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: tests: add test script for enumerations in ALSACtl namespace
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 18 Nov 2019 04:22:44 +0000 (13:22 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 30 Nov 2019 08:58:41 +0000 (17:58 +0900)
meson.build
tests/alsactl-enums [new file with mode: 0644]
tests/helper.py [new file with mode: 0644]
tests/meson.build [new file with mode: 0644]

index 5136662e07887d4911c6d48ab369f6b5631e1652..9f9ff0bf7067e1accfe88c5399ebcbaa1b7aebf7 100644 (file)
@@ -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 (file)
index 0000000..5abc1c4
--- /dev/null
@@ -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 (file)
index 0000000..35a8d64
--- /dev/null
@@ -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 (file)
index 0000000..5735350
--- /dev/null
@@ -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