diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-06-17 17:37:39 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-06-19 18:56:37 +0900 |
commit | 377c6ef9d992c90de00ec984a6c3a72d2c02d523 (patch) | |
tree | 17828e5bc03b5d9a58b11aa574a772eb4d92bce2 | |
parent | be86049aeb6b815e771c5863c712291b3604cf65 (diff) | |
download | libhinoko-377c6ef9d992c90de00ec984a6c3a72d2c02d523.tar.gz |
tests: add test script for Hinoko.CycleTimer boxed structure
The available methods of boxed structure are available by attributes of
object.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | tests/cycle-timer | 21 | ||||
-rw-r--r-- | tests/helper.py | 8 | ||||
-rw-r--r-- | tests/meson.build | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/tests/cycle-timer b/tests/cycle-timer new file mode 100644 index 0000000..0fd8dbb --- /dev/null +++ b/tests/cycle-timer @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +from sys import exit +from errno import ENXIO + +from helper import test_struct + +import gi +gi.require_version('Hinoko', '0.0') +from gi.repository import Hinoko + +target = Hinoko.CycleTimer +methods = ( + 'new', + 'get_timestamp', + 'get_clock_id', + 'get_cycle_timer', +) + +if not test_struct(target, methods): + exit(ENXIO) diff --git a/tests/helper.py b/tests/helper.py index 3a8e6fe..b845a70 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -31,3 +31,11 @@ def test_enums(target_type: object, enumerations: tuple[str]) -> bool: enumeration, target_type)) return False return True + + +def test_struct(target_type: object, methods: tuple[str]) -> bool: + for method in methods: + if not hasattr(target_type, method): + print('Method {0} is not produced.'.format(method)) + return False + return True diff --git a/tests/meson.build b/tests/meson.build index 0ca132f..d90e499 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -5,6 +5,7 @@ tests = [ 'fw-iso-tx', 'fw-iso-resource-auto', 'fw-iso-resource-once', + 'cycle-timer', ] envs = environment() |