diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a3cce7b2..cecd6832 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ on: jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 @@ -20,7 +20,7 @@ jobs: sudo apt update sudo apt install automake libtool pkg-config libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt install libglib2.0-dev libjson-glib-dev gtk-doc-tools libreadline-dev libncursesw5-dev - sudo apt install libdaemon-dev libjansson-dev python3-pip python3-setuptools libsoup2.4 + sudo apt install libdaemon-dev libjansson-dev python3-pip python3-setuptools libsoup2.4-dev - name: Generate run: ./autogen.sh diff --git a/libgstc/python/pygstc/gstc.py b/libgstc/python/pygstc/gstc.py index 29b42c7f..8d110380 100644 --- a/libgstc/python/pygstc/gstc.py +++ b/libgstc/python/pygstc/gstc.py @@ -28,6 +28,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. +import asyncio import inspect import json import traceback @@ -162,7 +163,7 @@ def __init__( % (self._ip, self._port)) self._ipc = Ipc(self._logger, self._ip, self._port) self._timeout = timeout - self.ping_gstd() + asyncio.ensure_future(self.ping_gstd()) def _check_parameters(self, parameter_list, type_list): """ @@ -200,7 +201,7 @@ def _check_parameters(self, parameter_list, type_list): parameter_string_list += [str(parameter)] return parameter_string_list - def _send_cmd_line(self, cmd_line): + async def _send_cmd_line(self, cmd_line): """ Send a command using an abstract IPC and wait for the response. @@ -223,7 +224,7 @@ def _send_cmd_line(self, cmd_line): """ try: cmd = cmd_line[0] - jresult = self._ipc.send(cmd_line, timeout=self._timeout) + jresult = await self._ipc.send(cmd_line, timeout=self._timeout) result = json.loads(jresult) if result['code'] != GstcErrorCode.GSTC_OK.value: self._logger.error('%s error: %s' % (cmd, @@ -246,7 +247,7 @@ def _send_cmd_line(self, cmd_line): raise GstcError('GstClient time out ocurred', GstcErrorCode.GSTC_TIMEOUT) from e - def ping_gstd(self): + async def ping_gstd(self): """ Test if Gstd responds in the configured address and port @@ -260,7 +261,7 @@ def ping_gstd(self): """ self._logger.info('Sending ping to Gstd') try: - jresult = self._ipc.send(['list_pipelines'], timeout=1) + jresult = await self._ipc.send(['list_pipelines'], timeout=1) # Verify correct data format result = json.loads(jresult) if ('description' in result and @@ -286,7 +287,7 @@ def ping_gstd(self): raise GstcError('GstClient time out ocurred', GstcErrorCode.GSTC_TIMEOUT) from e - def bus_filter(self, pipe_name, filter): + async def bus_filter(self, pipe_name, filter): """ Select the types of message to be read from the bus. Separate with a '+', i.e.: eos+warning+error. @@ -309,9 +310,9 @@ def bus_filter(self, pipe_name, filter): self._logger.info('Setting bus read filter of pipeline %s to %s' % (pipe_name, filter)) parameters = self._check_parameters([pipe_name, filter], [str, str]) - self._send_cmd_line(['bus_filter'] + parameters) + await self._send_cmd_line(['bus_filter'] + parameters) - def bus_read(self, pipe_name): + async def bus_read(self, pipe_name): """ Read the bus and wait. @@ -335,10 +336,10 @@ def bus_read(self, pipe_name): self._logger.info('Reading bus of pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - result = self._send_cmd_line(['bus_read'] + parameters) + result = await self._send_cmd_line(['bus_read'] + parameters) return result['response'] - def bus_timeout(self, pipe_name, timeout): + async def bus_timeout(self, pipe_name, timeout): """ Apply a timeout for the bus polling. Parameters @@ -360,9 +361,9 @@ def bus_timeout(self, pipe_name, timeout): self._logger.info('Setting bus read timeout of pipeline %s to %s' % (pipe_name, timeout)) parameters = self._check_parameters([pipe_name, timeout], [str, int]) - self._send_cmd_line(['bus_timeout'] + parameters) + await self._send_cmd_line(['bus_timeout'] + parameters) - def create( + async def create( self, uri, property, @@ -392,9 +393,9 @@ def create( % (property, uri, value)) parameters = self._check_parameters( [uri, property, value], [str, str, str]) - self._send_cmd_line(['create'] + parameters) + await self._send_cmd_line(['create'] + parameters) - def debug_color(self, colors): + async def debug_color(self, colors): """ Enable/Disable colors in the debug logging. @@ -413,9 +414,9 @@ def debug_color(self, colors): self._logger.info('Enabling/Disabling GStreamer debug colors') parameters = self._check_parameters([colors], [bool]) - self._send_cmd_line(['debug_color'] + parameters) + await self._send_cmd_line(['debug_color'] + parameters) - def debug_enable(self, enable): + async def debug_enable(self, enable): """ Enable/Disable GStreamer debug. @@ -434,9 +435,9 @@ def debug_enable(self, enable): self._logger.info('Enabling/Disabling GStreamer debug') parameters = self._check_parameters([enable], [bool]) - self._send_cmd_line(['debug_enable'] + parameters) + await self._send_cmd_line(['debug_enable'] + parameters) - def debug_reset(self, reset): + async def debug_reset(self, reset): """ Enable/Disable debug threshold reset. @@ -455,9 +456,9 @@ def debug_reset(self, reset): self._logger.info('Enabling/Disabling GStreamer debug threshold reset') parameters = self._check_parameters([reset], [bool]) - self._send_cmd_line(['debug_reset'] + parameters) + await self._send_cmd_line(['debug_reset'] + parameters) - def debug_threshold(self, threshold): + async def debug_threshold(self, threshold): """ The debug filter to apply (as you would use with gst-launch). @@ -486,9 +487,9 @@ def debug_threshold(self, threshold): self._logger.info('Setting GStreamer debug threshold to %s' % threshold) parameters = self._check_parameters([threshold], [str]) - self._send_cmd_line(['debug_threshold'] + parameters) + await self._send_cmd_line(['debug_threshold'] + parameters) - def delete(self, uri, name): + async def delete(self, uri, name): """ Delete the resource held at the given URI with the given name. @@ -509,9 +510,9 @@ def delete(self, uri, name): self._logger.info('Deleting name %s at uri "%s"' % (name, uri)) parameters = self._check_parameters([uri, name], [str, str]) - self._send_cmd_line(['delete'] + parameters) + await self._send_cmd_line(['delete'] + parameters) - def element_get( + async def element_get( self, pipe_name, element, @@ -547,10 +548,10 @@ def element_get( (element, prop, pipe_name)) parameters = self._check_parameters( [pipe_name, element, prop], [str, str, str]) - result = self._send_cmd_line(['element_get'] + parameters) + result = await self._send_cmd_line(['element_get'] + parameters) return result['response']['value'] - def element_set( + async def element_set( self, pipe_name, element, @@ -583,9 +584,9 @@ def element_set( % (element, prop, pipe_name, value)) parameters = self._check_parameters( [pipe_name, element, prop, value], [str, str, str, str]) - self._send_cmd_line(['element_set'] + parameters) + await self._send_cmd_line(['element_set'] + parameters) - def event_eos(self, pipe_name): + async def event_eos(self, pipe_name): """ Send an end-of-stream event. @@ -605,9 +606,9 @@ def event_eos(self, pipe_name): self._logger.info('Sending end-of-stream event to pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - self._send_cmd_line(['event_eos'] + parameters) + await self._send_cmd_line(['event_eos'] + parameters) - def event_flush_start(self, pipe_name): + async def event_flush_start(self, pipe_name): """ Put the pipeline in flushing mode. @@ -627,9 +628,9 @@ def event_flush_start(self, pipe_name): self._logger.info('Putting pipeline %s in flushing mode' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - self._send_cmd_line(['event_flush_start'] + parameters) + await self._send_cmd_line(['event_flush_start'] + parameters) - def event_flush_stop(self, pipe_name, reset=True): + async def event_flush_stop(self, pipe_name, reset=True): """ Take the pipeline out from flushing mode. @@ -651,9 +652,9 @@ def event_flush_stop(self, pipe_name, reset=True): self._logger.info('Taking pipeline %s out of flushing mode' % pipe_name) parameters = self._check_parameters([pipe_name, reset], [str, bool]) - self._send_cmd_line(['event_flush_stop'] + parameters) + await self._send_cmd_line(['event_flush_stop'] + parameters) - def event_seek( + async def event_seek( self, pipe_name, rate=1.0, @@ -702,9 +703,9 @@ def event_seek( end], [ str, float, int, int, int, int, int, int]) - self._send_cmd_line(['event_seek'] + parameters) + await self._send_cmd_line(['event_seek'] + parameters) - def list_elements(self, pipe_name): + async def list_elements(self, pipe_name): """ List the elements in a given pipeline. @@ -728,10 +729,10 @@ def list_elements(self, pipe_name): self._logger.info('Listing elements of pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - result = self._send_cmd_line(['list_elements'] + parameters) + result = await self._send_cmd_line(['list_elements'] + parameters) return result['response']['nodes'] - def list_pipelines(self): + async def list_pipelines(self): """ List the existing pipelines @@ -749,10 +750,10 @@ def list_pipelines(self): """ self._logger.info('Listing pipelines') - result = self._send_cmd_line(['list_pipelines']) + result = await self._send_cmd_line(['list_pipelines']) return result['response']['nodes'] - def list_properties(self, pipe_name, element): + async def list_properties(self, pipe_name, element): """ List the properties of an element in a given pipeline. @@ -779,10 +780,10 @@ def list_properties(self, pipe_name, element): self._logger.info('Listing properties of element %s from pipeline %s' % (element, pipe_name)) parameters = self._check_parameters([pipe_name, element], [str, str]) - result = self._send_cmd_line(['list_properties'] + parameters) + result = await self._send_cmd_line(['list_properties'] + parameters) return result['response']['nodes'] - def list_signals(self, pipe_name, element): + async def list_signals(self, pipe_name, element): """ List the signals of an element in a given pipeline. @@ -809,10 +810,10 @@ def list_signals(self, pipe_name, element): self._logger.info('Listing signals of element %s from pipeline %s' % (element, pipe_name)) parameters = self._check_parameters([pipe_name, element], [str, str]) - result = self._send_cmd_line(['list_signals'] + parameters) + result = await self._send_cmd_line(['list_signals'] + parameters) return result['response']['nodes'] - def pipeline_create(self, pipe_name, pipe_desc): + async def pipeline_create(self, pipe_name, pipe_desc): """ Create a new pipeline based on the name and description. @@ -827,9 +828,9 @@ def pipeline_create(self, pipe_name, pipe_desc): self._logger.info('Creating pipeline %s with description "%s"' % (pipe_name, pipe_desc)) parameters = self._check_parameters([pipe_name, pipe_desc], [str, str]) - self._send_cmd_line(['pipeline_create'] + parameters) + await self._send_cmd_line(['pipeline_create'] + parameters) - def pipeline_delete(self, pipe_name): + async def pipeline_delete(self, pipe_name): """ Delete the pipeline with the given name. @@ -848,9 +849,9 @@ def pipeline_delete(self, pipe_name): self._logger.info('Deleting pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - self._send_cmd_line(['pipeline_delete'] + parameters) + await self._send_cmd_line(['pipeline_delete'] + parameters) - def pipeline_pause(self, pipe_name): + async def pipeline_pause(self, pipe_name): """ Set the pipeline to paused. @@ -869,9 +870,9 @@ def pipeline_pause(self, pipe_name): self._logger.info('Pausing pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - self._send_cmd_line(['pipeline_pause'] + parameters) + await self._send_cmd_line(['pipeline_pause'] + parameters) - def pipeline_play(self, pipe_name): + async def pipeline_play(self, pipe_name): """ Set the pipeline to playing. @@ -890,9 +891,9 @@ def pipeline_play(self, pipe_name): self._logger.info('Playing pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - self._send_cmd_line(['pipeline_play'] + parameters) + await self._send_cmd_line(['pipeline_play'] + parameters) - def pipeline_stop(self, pipe_name): + async def pipeline_stop(self, pipe_name): """ Set the pipeline to null. @@ -911,9 +912,9 @@ def pipeline_stop(self, pipe_name): self._logger.info('Stoping pipeline %s' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - self._send_cmd_line(['pipeline_stop'] + parameters) + await self._send_cmd_line(['pipeline_stop'] + parameters) - def pipeline_get_graph(self, pipe_name): + async def pipeline_get_graph(self, pipe_name): """ Get the pipeline graph. @@ -937,10 +938,10 @@ def pipeline_get_graph(self, pipe_name): self._logger.info('Getting the pipeline %s graph' % pipe_name) parameters = self._check_parameters([pipe_name], [str]) - result = self._send_cmd_line(['pipeline_get_graph'] + parameters) + result = await self._send_cmd_line(['pipeline_get_graph'] + parameters) return result - def pipeline_verbose(self, pipe_name, value): + async def pipeline_verbose(self, pipe_name, value): """ Set the pipeline verbose mode. Only supported on GST Version >= 1.10 @@ -963,9 +964,9 @@ def pipeline_verbose(self, pipe_name, value): self._logger.info('Setting the pipeline %s verbose mode to %s' % (pipe_name, value)) parameters = self._check_parameters([pipe_name, value], [str, bool]) - self._send_cmd_line(['pipeline_verbose'] + parameters) + await self._send_cmd_line(['pipeline_verbose'] + parameters) - def read(self, uri): + async def read(self, uri): """ Read the resource held at the given URI with the given name. @@ -989,10 +990,10 @@ def read(self, uri): self._logger.info('Reading uri %s' % uri) parameters = self._check_parameters([uri], [str]) - result = self._send_cmd_line(['read'] + parameters) + result = await self._send_cmd_line(['read'] + parameters) return result['response'] - def signal_connect( + async def signal_connect( self, pipe_name, element, @@ -1028,10 +1029,10 @@ def signal_connect( (signal, element, pipe_name)) parameters = self._check_parameters( [pipe_name, element, signal], [str, str, str]) - result = self._send_cmd_line(['signal_connect'] + parameters) + result = await self._send_cmd_line(['signal_connect'] + parameters) return result['response'] - def signal_disconnect( + async def signal_disconnect( self, pipe_name, element, @@ -1062,9 +1063,9 @@ def signal_disconnect( (signal, element, pipe_name)) parameters = self._check_parameters( [pipe_name, element, signal], [str, str, str]) - self._send_cmd_line(['signal_disconnect'] + parameters) + await self._send_cmd_line(['signal_disconnect'] + parameters) - def signal_timeout( + async def signal_timeout( self, pipe_name, element, @@ -1099,9 +1100,9 @@ def signal_timeout( timeout %s' % (signal, element, pipe_name, timeout)) parameters = self._check_parameters( [pipe_name, element, signal, timeout], [str, str, str, int]) - self._send_cmd_line(['signal_timeout'] + parameters) + await self._send_cmd_line(['signal_timeout'] + parameters) - def action_emit(self, pipe_name, element, action): + async def action_emit(self, pipe_name, element, action): """ Emits an action with no-parameters @@ -1127,9 +1128,9 @@ def action_emit(self, pipe_name, element, action): action, element, pipe_name)) parameters = self._check_parameters( [pipe_name, element, action], [str, str, str]) - self._send_cmd_line(['action_emit'] + parameters) + await self._send_cmd_line(['action_emit'] + parameters) - def update(self, uri, value): + async def update(self, uri, value): """ Update the resource at the given URI. @@ -1151,4 +1152,4 @@ def update(self, uri, value): self._logger.info('Updating uri %s with value "%s"' % (uri, value)) parameters = self._check_parameters([uri, value], [str, str]) - self._send_cmd_line(['update'] + parameters) + await self._send_cmd_line(['update'] + parameters) diff --git a/libgstc/python/pygstc/tcp.py b/libgstc/python/pygstc/tcp.py index 25219e0f..9c2dbd4f 100644 --- a/libgstc/python/pygstc/tcp.py +++ b/libgstc/python/pygstc/tcp.py @@ -28,9 +28,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. -import json -import select +import asyncio import socket +from contextlib import asynccontextmanager """ GstClient - Ipc Class @@ -54,7 +54,7 @@ def __init__( ip, port, maxsize=None, - terminator='\x00'.encode('utf-8'), + terminator=b'\x00', ): """ Initialize new Ipc @@ -81,7 +81,23 @@ def __init__( self._maxsize = maxsize self._terminator = terminator - def send(self, line, timeout=None): + @asynccontextmanager + async def gstd_conn(self): + kwargs = { + 'host': self._ip, + 'port': self._port + } + if self._maxsize is not None: + kwargs['limit'] = self._maxsize + reader, writer = await asyncio.open_connection(**kwargs) + try: + yield reader, writer + finally: + if not writer.is_closing(): + writer.close() + await writer.wait_closed() + + async def send(self, line, timeout=None): """ Create a socket and sends a message through it @@ -103,87 +119,30 @@ def send(self, line, timeout=None): data : string Decoded JSON string with the response """ - data = None self._logger.debug('GSTD socket sending line: %s' % line) - try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - s.connect((self._ip, self._port)) - s.sendall(' '.join(line).encode('utf-8')) - data = self._recvall(s, timeout) - if not data: - raise socket.error("Socket read error happened") - data = data.decode('utf-8') - s.close() - return data + try: + async with self.gstd_conn() as (reader, writer): + writer.write(' '.join(line).encode('utf-8')) + await writer.drain() + fut = reader.readuntil(separator=self._terminator) + data = await asyncio.wait_for(fut, timeout=timeout) + if not data: + raise socket.error("Socket read error happened") + data = data[:-1].decode('utf-8') + return data except BufferError as e: - s.close() error_msg = 'Server response too long' self._logger.error(error_msg) raise BufferError(error_msg)\ from e except TimeoutError as e: - s.close() error_msg = 'Server took too long to respond' self._logger.error(error_msg) raise TimeoutError(error_msg)\ from e except socket.error as e: - s.close() error_msg = 'Server did not respond. Is it up?' self._logger.error(error_msg) raise ConnectionRefusedError(error_msg)\ from e - - def _recvall(self, sock, timeout): - """ - Wait for a response message from the socket - - Parameters - ---------- - sock : string - The socket to poll - timeout : float - Timeout in seconds to wait for a response. 0: non-blocking, None: blocking - - Raises - ------ - socket.error - Error is triggered when Gstd IPC fails - BufferError - When the incoming buffer is too big. - - Returns - ------- - buf : string - Raw socket response - """ - buf = b'' - newbuf = '' - try: - sock.settimeout(timeout) - except socket.error as e: - raise TimeoutError from e - - while True: - if (self._maxsize and self._maxsize > len(newbuf)): - raise BufferError - - try: - newbuf = sock.recv(self._socket_read_size) - # Raise an exception timeout - except socket.error as e: - raise TimeoutError from e - - # When a connection dies, the socket does not close properly and it - # returns immediately with an empty string. So, check that first. - if len(newbuf) == 0: - break - - if self._terminator in newbuf: - buf += newbuf[:newbuf.find(self._terminator)] - break - else: - buf += newbuf - return buf diff --git a/libgstc/python/setup.py b/libgstc/python/setup.py index 09a57a87..47be929f 100755 --- a/libgstc/python/setup.py +++ b/libgstc/python/setup.py @@ -44,10 +44,10 @@ 'tests']), scripts=[], classifiers=['Development Status :: 3 - Alpha', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7'], - python_requires='>=3.5', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9'], + python_requires='>=3.7', install_requires=[], command_options={}, extras_require={}, diff --git a/tests/libgstc/python/gstd_runner.py b/tests/libgstc/python/gstd_runner.py index 94dc84e3..8d9930c4 100644 --- a/tests/libgstc/python/gstd_runner.py +++ b/tests/libgstc/python/gstd_runner.py @@ -29,13 +29,13 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. +import asyncio import pathlib import socket -import subprocess import unittest -class GstdTestRunner(unittest.TestCase): +class GstdTestRunner(unittest.IsolatedAsyncioTestCase): def get_open_port(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -46,24 +46,30 @@ def get_open_port(self): s.close() return port - def setUp(self): + async def asyncSetUp(self): self.port = self.get_open_port() self.gstd_path = (pathlib.Path(__file__).parent.parent.parent.parent .joinpath('gstd').joinpath('gstd').resolve()) - self.gstd = subprocess.Popen([self.gstd_path, '-p', str(self.port)]) - connected = -1 - while connected != 0: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - connected = sock.connect_ex(("", self.port)) - sock.close() + self.gstd = await asyncio.create_subprocess_exec(self.gstd_path, '-p', str(self.port)) + asyncio.get_event_loop().call_later(5, self.gstd.kill) + connected = False + while not connected: + try: + reader, writer = await asyncio.open_connection(port=self.port) + writer.close() + await writer.wait_closed() + connected = True + except OSError: + pass - def tearDown(self): - self.gstd.terminate() - try: - self.gstd.wait(1) - except subprocess.TimeoutExpired: - self.gstd.kill() - self.gstd.wait() + async def asyncTearDown(self): + if self.gstd.returncode is None: + self.gstd.terminate() + try: + await asyncio.wait_for(self.gstd.wait(), timeout=1.0) + except asyncio.TimeoutError: + self.gstd.kill() + await self.gstd.wait() if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_bus_filter.py b/tests/libgstc/python/test_libgstc_python_bus_filter.py index 68dbdfba..acabe852 100755 --- a/tests/libgstc/python/test_libgstc_python_bus_filter.py +++ b/tests/libgstc/python/test_libgstc_python_bus_filter.py @@ -38,18 +38,18 @@ class TestGstcBusFilterMethods(GstdTestRunner): - def test_bus_filter_eos(self): + async def test_bus_filter_eos(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.event_eos('p0') - self.gstd_client.bus_filter('p0', 'eos') - ret = self.gstd_client.bus_read('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.event_eos('p0') + await self.gstd_client.bus_filter('p0', 'eos') + ret = await self.gstd_client.bus_read('p0') self.assertEqual(ret['type'], 'eos') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_bus_timeout.py b/tests/libgstc/python/test_libgstc_python_bus_timeout.py index 5103c1c4..41efcee6 100755 --- a/tests/libgstc/python/test_libgstc_python_bus_timeout.py +++ b/tests/libgstc/python/test_libgstc_python_bus_timeout.py @@ -38,31 +38,31 @@ class TestGstcBusTimeoutMethods(GstdTestRunner): - def test_bus_timeout_eos(self): + async def test_bus_timeout_eos(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.event_eos('p0') - self.gstd_client.bus_filter('p0', 'eos') - self.gstd_client.bus_timeout('p0', 1000) - ret = self.gstd_client.bus_read('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.event_eos('p0') + await self.gstd_client.bus_filter('p0', 'eos') + await self.gstd_client.bus_timeout('p0', 1000) + ret = await self.gstd_client.bus_read('p0') self.assertEqual(ret['type'], 'eos') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') - def test_bus_timeout_no_response(self): + async def test_bus_timeout_no_response(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.bus_timeout('p0', 1000) - ret = self.gstd_client.bus_read('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.bus_timeout('p0', 1000) + ret = await self.gstd_client.bus_read('p0') self.assertEqual(ret, None) - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_create.py b/tests/libgstc/python/test_libgstc_python_create.py index 36c87b83..26af2057 100755 --- a/tests/libgstc/python/test_libgstc_python_create.py +++ b/tests/libgstc/python/test_libgstc_python_create.py @@ -38,24 +38,24 @@ class TestGstcCreateMethods(GstdTestRunner): - def test_create_pipeline(self): + async def test_create_pipeline(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - ret = self.gstd_client.read('pipelines') + ret = await self.gstd_client.read('pipelines') initial_n_pipes = len(ret['nodes']) - self.gstd_client.create('pipelines', 'p0', pipeline) - ret = self.gstd_client.read('pipelines') + await self.gstd_client.create('pipelines', 'p0', pipeline) + ret = await self.gstd_client.read('pipelines') final_n_pipes = len(ret['nodes']) self.assertEqual(final_n_pipes, initial_n_pipes + 1) - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_delete('p0') - def test_create_bad_pipeline(self): + async def test_create_bad_pipeline(self): pipeline = 'source sink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) with self.assertRaises(GstdError): - self.gstd_client.create('pipelines', 'p0', pipeline) + await self.gstd_client.create('pipelines', 'p0', pipeline) if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_debug_color.py b/tests/libgstc/python/test_libgstc_python_debug_color.py index f0c17803..2fa6ad47 100755 --- a/tests/libgstc/python/test_libgstc_python_debug_color.py +++ b/tests/libgstc/python/test_libgstc_python_debug_color.py @@ -38,15 +38,15 @@ class TestGstcDebugColorMethods(GstdTestRunner): - def test_debug_color_true(self): + async def test_debug_color_true(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_color(True) + await self.gstd_client.debug_color(True) - def test_debug_color_false(self): + async def test_debug_color_false(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_color(False) + await self.gstd_client.debug_color(False) if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_debug_enable.py b/tests/libgstc/python/test_libgstc_python_debug_enable.py index 92f4725c..5be01ddf 100755 --- a/tests/libgstc/python/test_libgstc_python_debug_enable.py +++ b/tests/libgstc/python/test_libgstc_python_debug_enable.py @@ -38,15 +38,15 @@ class TestGstcDebugEnableMethods(GstdTestRunner): - def test_debug_enable_true(self): + async def test_debug_enable_true(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_enable(True) + await self.gstd_client.debug_enable(True) - def test_debug_enable_false(self): + async def test_debug_enable_false(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_enable(False) + await self.gstd_client.debug_enable(False) if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_debug_reset.py b/tests/libgstc/python/test_libgstc_python_debug_reset.py index db1abf64..14016c88 100755 --- a/tests/libgstc/python/test_libgstc_python_debug_reset.py +++ b/tests/libgstc/python/test_libgstc_python_debug_reset.py @@ -38,15 +38,15 @@ class TestGstcDebugResetMethods(GstdTestRunner): - def test_debug_reset_true(self): + async def test_debug_reset_true(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_reset(True) + await self.gstd_client.debug_reset(True) - def test_debug_reset_false(self): + async def test_debug_reset_false(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_reset(False) + await self.gstd_client.debug_reset(False) if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_debug_threshold.py b/tests/libgstc/python/test_libgstc_python_debug_threshold.py index e0a2c4bc..9dafa573 100755 --- a/tests/libgstc/python/test_libgstc_python_debug_threshold.py +++ b/tests/libgstc/python/test_libgstc_python_debug_threshold.py @@ -37,55 +37,55 @@ class TestGstcDebugThresholdMethods(GstdTestRunner): - def test_debug_threshold_none(self): + async def test_debug_threshold_none(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('0') + await self.gstd_client.debug_threshold('0') - def test_debug_threshold_error(self): + async def test_debug_threshold_error(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('1') + await self.gstd_client.debug_threshold('1') - def test_debug_threshold_warning(self): + async def test_debug_threshold_warning(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('2') + await self.gstd_client.debug_threshold('2') - def test_debug_threshold_fixme(self): + async def test_debug_threshold_fixme(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('3') + await self.gstd_client.debug_threshold('3') - def test_debug_threshold_info(self): + async def test_debug_threshold_info(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('4') + await self.gstd_client.debug_threshold('4') - def test_debug_threshold_debug(self): + async def test_debug_threshold_debug(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('5') + await self.gstd_client.debug_threshold('5') - def test_debug_threshold_log(self): + async def test_debug_threshold_log(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('6') + await self.gstd_client.debug_threshold('6') - def test_debug_threshold_trace(self): + async def test_debug_threshold_trace(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('7') + await self.gstd_client.debug_threshold('7') - def test_debug_threshold_memdump(self): + async def test_debug_threshold_memdump(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('8') + await self.gstd_client.debug_threshold('8') - def test_debug_threshold_invalid(self): + async def test_debug_threshold_invalid(self): self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.debug_threshold('9') + await self.gstd_client.debug_threshold('9') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_delete.py b/tests/libgstc/python/test_libgstc_python_delete.py index 67ba4879..9a321e60 100755 --- a/tests/libgstc/python/test_libgstc_python_delete.py +++ b/tests/libgstc/python/test_libgstc_python_delete.py @@ -38,18 +38,18 @@ class TestGstcDeleteMethods(GstdTestRunner): - def test_delete_pipeline(self): + async def test_delete_pipeline(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - ret = self.gstd_client.read('pipelines') + ret = await self.gstd_client.read('pipelines') initial_n_pipes = len(ret['nodes']) - self.gstd_client.create('pipelines', 'p0', pipeline) - ret = self.gstd_client.read('pipelines') + await self.gstd_client.create('pipelines', 'p0', pipeline) + ret = await self.gstd_client.read('pipelines') final_n_pipes = len(ret['nodes']) self.assertEqual(initial_n_pipes + 1, final_n_pipes) - self.gstd_client.delete('pipelines', 'p0') - ret = self.gstd_client.read('pipelines') + await self.gstd_client.delete('pipelines', 'p0') + ret = await self.gstd_client.read('pipelines') final_n_pipes = len(ret['nodes']) self.assertEqual(initial_n_pipes, final_n_pipes) diff --git a/tests/libgstc/python/test_libgstc_python_element_get.py b/tests/libgstc/python/test_libgstc_python_element_get.py index 7c0e4643..f47a1e9a 100755 --- a/tests/libgstc/python/test_libgstc_python_element_get.py +++ b/tests/libgstc/python/test_libgstc_python_element_get.py @@ -38,18 +38,17 @@ class TestGstcElementGetMethods(GstdTestRunner): - def test_element_get_property_value(self): + async def test_element_get_property_value(self): pipeline = 'videotestsrc name=v0 pattern=ball ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.assertEqual( - self.gstd_client.element_get( + await self.gstd_client.pipeline_create('p0', pipeline) + ret = await self.gstd_client.element_get( 'p0', 'v0', - 'pattern'), - 'Moving ball') - self.gstd_client.pipeline_delete('p0') + 'pattern') + self.assertEqual(ret, 'Moving ball') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_element_set.py b/tests/libgstc/python/test_libgstc_python_element_set.py index 7ed59816..0652579e 100755 --- a/tests/libgstc/python/test_libgstc_python_element_set.py +++ b/tests/libgstc/python/test_libgstc_python_element_set.py @@ -38,21 +38,21 @@ class TestGstcElementSetMethods(GstdTestRunner): - def test_element_set_property_value(self): + async def test_element_set_property_value(self): pipeline = 'videotestsrc name=v0 pattern=ball ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_create('p0', pipeline) self.assertEqual( - self.gstd_client.element_get( + await self.gstd_client.element_get( 'p0', 'v0', 'pattern'), 'Moving ball') - self.gstd_client.element_set('p0', 'v0', 'pattern', 'bar') - self.assertEqual(self.gstd_client.element_get('p0', 'v0', - 'pattern'), 'Bar') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.element_set('p0', 'v0', 'pattern', 'bar') + ret = await self.gstd_client.element_get('p0', 'v0', 'pattern') + self.assertEqual(ret, 'Bar') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_event_eos.py b/tests/libgstc/python/test_libgstc_python_event_eos.py index 2fe79393..bda3624c 100755 --- a/tests/libgstc/python/test_libgstc_python_event_eos.py +++ b/tests/libgstc/python/test_libgstc_python_event_eos.py @@ -38,18 +38,18 @@ class TestGstcEventEosMethods(GstdTestRunner): - def test_event_eos(self): + async def test_event_eos(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.event_eos('p0') - self.gstd_client.bus_filter('p0', 'eos') - ret = self.gstd_client.bus_read('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.event_eos('p0') + await self.gstd_client.bus_filter('p0', 'eos') + ret = await self.gstd_client.bus_read('p0') self.assertEqual(ret['type'], 'eos') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_event_flush_start.py b/tests/libgstc/python/test_libgstc_python_event_flush_start.py index 8e9e66a6..a459e412 100755 --- a/tests/libgstc/python/test_libgstc_python_event_flush_start.py +++ b/tests/libgstc/python/test_libgstc_python_event_flush_start.py @@ -38,16 +38,16 @@ class TestGstcEventFlushStartMethods(GstdTestRunner): - def test_event_flush_start(self): + async def test_event_flush_start(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.event_flush_start('p0') - self.gstd_client.event_flush_stop('p0') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.event_flush_start('p0') + await self.gstd_client.event_flush_stop('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_event_seek.py b/tests/libgstc/python/test_libgstc_python_event_seek.py index 89505e64..e0db1e8b 100755 --- a/tests/libgstc/python/test_libgstc_python_event_seek.py +++ b/tests/libgstc/python/test_libgstc_python_event_seek.py @@ -38,15 +38,15 @@ class TestGstcEventSeekMethods(GstdTestRunner): - def test_event_seek(self): + async def test_event_seek(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.event_seek('p0') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.event_seek('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_list_elements.py b/tests/libgstc/python/test_libgstc_python_list_elements.py index edd9613b..42859163 100755 --- a/tests/libgstc/python/test_libgstc_python_list_elements.py +++ b/tests/libgstc/python/test_libgstc_python_list_elements.py @@ -38,14 +38,14 @@ class TestGstcListElementsMethods(GstdTestRunner): - def test_list_elements(self): + async def test_list_elements(self): pipeline = 'videotestsrc name=v0 ! fakesink name=x0' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.assertEqual(self.gstd_client.list_elements('p0'), - [{'name': 'x0'}, {'name': 'v0'}]) - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + ret = await self.gstd_client.list_elements('p0') + self.assertEqual(ret, [{'name': 'x0'}, {'name': 'v0'}]) + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_list_pipelines.py b/tests/libgstc/python/test_libgstc_python_list_pipelines.py index 47cd7c12..df9ddd0e 100755 --- a/tests/libgstc/python/test_libgstc_python_list_pipelines.py +++ b/tests/libgstc/python/test_libgstc_python_list_pipelines.py @@ -38,15 +38,15 @@ class TestGstcListPipelinesMethods(GstdTestRunner): - def test_list_pipelines(self): + async def test_list_pipelines(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - initial_n_pipes = len(self.gstd_client.list_pipelines()) - self.gstd_client.create('pipelines', 'p0', pipeline) - final_n_pipes = len(self.gstd_client.list_pipelines()) + initial_n_pipes = len(await self.gstd_client.list_pipelines()) + await self.gstd_client.create('pipelines', 'p0', pipeline) + final_n_pipes = len(await self.gstd_client.list_pipelines()) self.assertEqual(final_n_pipes, initial_n_pipes + 1) - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_list_properties.py b/tests/libgstc/python/test_libgstc_python_list_properties.py index 52888044..de2cb772 100755 --- a/tests/libgstc/python/test_libgstc_python_list_properties.py +++ b/tests/libgstc/python/test_libgstc_python_list_properties.py @@ -38,7 +38,7 @@ class TestGstcListPropertiesMethods(GstdTestRunner): - def test_list_properties(self): + async def test_list_properties(self): pipeline = \ 'videotestsrc name=v0 ! identity name=i0 ! fakesink name=x0' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') @@ -63,10 +63,10 @@ def test_list_properties(self): {'name': 'signal-handoffs'}, {'name': 'drop-allocation'}, ] - self.gstd_client.pipeline_create('p0', pipeline) - self.assertEqual(self.gstd_client.list_properties('p0', 'i0')[0], - identity_properties[0]) - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + ret = await self.gstd_client.list_properties('p0', 'i0') + self.assertEqual(ret[0], identity_properties[0]) + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_list_signals.py b/tests/libgstc/python/test_libgstc_python_list_signals.py index 1676920c..9d341a43 100755 --- a/tests/libgstc/python/test_libgstc_python_list_signals.py +++ b/tests/libgstc/python/test_libgstc_python_list_signals.py @@ -38,15 +38,15 @@ class TestGstcListSignalsMethods(GstdTestRunner): - def test_list_signals(self): + async def test_list_signals(self): pipeline = \ 'videotestsrc name=v0 ! identity name=i0 ! fakesink name=x0' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.assertTrue({'name': 'handoff'} in - self.gstd_client.list_signals('p0', 'i0')) - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + ret = await self.gstd_client.list_signals('p0', 'i0') + self.assertTrue({'name': 'handoff'} in ret) + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_pipeline_create.py b/tests/libgstc/python/test_libgstc_python_pipeline_create.py index 76ece076..e90d482a 100755 --- a/tests/libgstc/python/test_libgstc_python_pipeline_create.py +++ b/tests/libgstc/python/test_libgstc_python_pipeline_create.py @@ -38,14 +38,14 @@ class TestGstcPipelineCreateMethods(GstdTestRunner): - def test_libgstc_python_pipeline_create(self): + async def test_libgstc_python_pipeline_create(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - ret = self.gstd_client.read('pipelines') + await self.gstd_client.pipeline_create('p0', pipeline) + ret = await self.gstd_client.read('pipelines') self.assertEqual(ret['nodes'][0]['name'], 'p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_pipeline_delete.py b/tests/libgstc/python/test_libgstc_python_pipeline_delete.py index c65c10d0..d553f041 100755 --- a/tests/libgstc/python/test_libgstc_python_pipeline_delete.py +++ b/tests/libgstc/python/test_libgstc_python_pipeline_delete.py @@ -38,15 +38,15 @@ class TestGstcPipelineDeleteMethods(GstdTestRunner): - def test_libgstc_python_pipeline_delete(self): + async def test_libgstc_python_pipeline_delete(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - ret_prev = self.gstd_client.read('pipelines') + await self.gstd_client.pipeline_create('p0', pipeline) + ret_prev = await self.gstd_client.read('pipelines') len_prev = len(ret_prev['nodes']) - self.gstd_client.pipeline_delete('p0') - ret_post = self.gstd_client.read('pipelines') + await self.gstd_client.pipeline_delete('p0') + ret_post = await self.gstd_client.read('pipelines') len_post = len(ret_post['nodes']) self.assertTrue(len_prev > len_post) diff --git a/tests/libgstc/python/test_libgstc_python_pipeline_pause.py b/tests/libgstc/python/test_libgstc_python_pipeline_pause.py index 908e1387..f7167694 100755 --- a/tests/libgstc/python/test_libgstc_python_pipeline_pause.py +++ b/tests/libgstc/python/test_libgstc_python_pipeline_pause.py @@ -38,16 +38,16 @@ class TestGstcPipelinePauseMethods(GstdTestRunner): - def test_libgstc_python_pipeline_pause(self): + async def test_libgstc_python_pipeline_pause(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.pipeline_pause('p0') - self.assertEqual(self.gstd_client.read( - 'pipelines/p0/state')['value'], 'PAUSED') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.pipeline_pause('p0') + ret = await self.gstd_client.read('pipelines/p0/state') + self.assertEqual(ret['value'], 'PAUSED') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_pipeline_play.py b/tests/libgstc/python/test_libgstc_python_pipeline_play.py index 78f5cff6..f7db3995 100755 --- a/tests/libgstc/python/test_libgstc_python_pipeline_play.py +++ b/tests/libgstc/python/test_libgstc_python_pipeline_play.py @@ -29,7 +29,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. -import time +import asyncio import unittest from gstd_runner import GstdTestRunner @@ -39,17 +39,17 @@ class TestGstcPipelinePlayMethods(GstdTestRunner): - def test_libgstc_python_pipeline_play(self): + async def test_libgstc_python_pipeline_play(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - time.sleep(0.1) - self.assertIn(self.gstd_client.read('pipelines/p0/state') - ['value'], ['PLAYING']) - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await asyncio.sleep(0.1) + ret = await self.gstd_client.read('pipelines/p0/state') + self.assertIn(ret['value'], ['PLAYING']) + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_pipeline_stop.py b/tests/libgstc/python/test_libgstc_python_pipeline_stop.py index 9cb81868..c5865d92 100755 --- a/tests/libgstc/python/test_libgstc_python_pipeline_stop.py +++ b/tests/libgstc/python/test_libgstc_python_pipeline_stop.py @@ -38,16 +38,16 @@ class TestGstcPipelineStopMethods(GstdTestRunner): - def test_libgstc_python_pipeline_stop(self): + async def test_libgstc_python_pipeline_stop(self): pipeline = 'videotestsrc name=v0 ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - self.gstd_client.pipeline_stop('p0') - self.assertEqual(self.gstd_client.read( - 'pipelines/p0/state')['value'], 'NULL') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + await self.gstd_client.pipeline_stop('p0') + ret = await self.gstd_client.read('pipelines/p0/state') + self.assertEqual(ret['value'], 'NULL') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_read.py b/tests/libgstc/python/test_libgstc_python_read.py index 0b8b63f3..c060e786 100755 --- a/tests/libgstc/python/test_libgstc_python_read.py +++ b/tests/libgstc/python/test_libgstc_python_read.py @@ -38,16 +38,16 @@ class TestGstcReadMethods(GstdTestRunner): - def test_libgstc_python_read(self): + async def test_libgstc_python_read(self): pipeline = 'videotestsrc name=v0 pattern=ball ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - ret = self.gstd_client.read( + await self.gstd_client.pipeline_create('p0', pipeline) + ret = await self.gstd_client.read( 'pipelines/p0/elements/v0/properties/pattern') self.assertEqual(ret['value'], 'Moving ball') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_signal_connect.py b/tests/libgstc/python/test_libgstc_python_signal_connect.py index 276156c3..75cb82a4 100755 --- a/tests/libgstc/python/test_libgstc_python_signal_connect.py +++ b/tests/libgstc/python/test_libgstc_python_signal_connect.py @@ -38,18 +38,18 @@ class TestGstcSignalConnectMethods(GstdTestRunner): - def test_libgstc_python_signal_connect(self): + async def test_libgstc_python_signal_connect(self): pipeline = \ 'videotestsrc ! identity signal-handoffs=true name=identity ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.pipeline_play('p0') - ret = self.gstd_client.signal_connect('p0', 'identity', + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.pipeline_play('p0') + ret = await self.gstd_client.signal_connect('p0', 'identity', 'handoff') self.assertEqual(ret['name'], 'handoff') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_signal_disconnect.py b/tests/libgstc/python/test_libgstc_python_signal_disconnect.py index 7abc41a3..d3f187fc 100755 --- a/tests/libgstc/python/test_libgstc_python_signal_disconnect.py +++ b/tests/libgstc/python/test_libgstc_python_signal_disconnect.py @@ -29,41 +29,38 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. +import asyncio import unittest -import threading from gstd_runner import GstdTestRunner from pygstc.gstc import * from pygstc.logger import * -import time -import os ret_val = '' -def signal_connect_test(port): +async def signal_connect_test(port): global ret_val gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') gstd_client = GstdClient(port=port, logger=gstd_logger) - ret_val = gstd_client.signal_connect('p0', 'identity', 'handoff') + ret_val = await gstd_client.signal_connect('p0', 'identity', 'handoff') class TestGstcSignalDisconnectMethods(GstdTestRunner): - def test_libgstc_python_signal_disconnect(self): + async def test_libgstc_python_signal_disconnect(self): global ret_val pipeline = 'videotestsrc ! identity name=identity ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - ret_thr = threading.Thread(target=signal_connect_test, args=(self.port,)) - ret_thr.start() - time.sleep(0.1) - self.gstd_client.signal_disconnect('p0', 'identity', 'handoff') - time.sleep(0.1) + await self.gstd_client.pipeline_create('p0', pipeline) + asyncio.ensure_future(signal_connect_test(self.port)) + await asyncio.sleep(0.1) + await self.gstd_client.signal_disconnect('p0', 'identity', 'handoff') + await asyncio.sleep(0.1) self.assertEqual(ret_val, None) - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_signal_timeout.py b/tests/libgstc/python/test_libgstc_python_signal_timeout.py index 297ee336..ecc543d3 100755 --- a/tests/libgstc/python/test_libgstc_python_signal_timeout.py +++ b/tests/libgstc/python/test_libgstc_python_signal_timeout.py @@ -30,7 +30,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. import unittest -import threading from gstd_runner import GstdTestRunner from pygstc.gstc import * @@ -39,17 +38,17 @@ class TestGstcSignalTimeoutMethods(GstdTestRunner): - def test_libgstc_python_signal_timeout(self): + async def test_libgstc_python_signal_timeout(self): pipeline = 'videotestsrc ! identity name=identity ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') - self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.signal_timeout('p0', 'identity', 'handoff', 1) - ret_con = self.gstd_client.signal_connect('p0', 'identity', + self.gstd_client = GstdClient(port=self.port,logger=self.gstd_logger) + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.signal_timeout('p0', 'identity', 'handoff', 1) + ret_con = await self.gstd_client.signal_connect('p0', 'identity', 'handoff') self.assertEqual(ret_con, None) - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_stop_gstd.py b/tests/libgstc/python/test_libgstc_python_stop_gstd.py index b3cfc06f..e8e7bd10 100755 --- a/tests/libgstc/python/test_libgstc_python_stop_gstd.py +++ b/tests/libgstc/python/test_libgstc_python_stop_gstd.py @@ -29,16 +29,17 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. +import asyncio import unittest -import subprocess from gstd_runner import GstdTestRunner class TestGstcStopGstdMethods(GstdTestRunner): - def test_libgstc_python_stop_gstd(self): - subprocess.Popen([self.gstd_path, '-k']) + async def test_libgstc_python_stop_gstd(self): + gstd_k = await asyncio.create_subprocess_exec(self.gstd_path, '-k') + await gstd_k.wait() if __name__ == '__main__': diff --git a/tests/libgstc/python/test_libgstc_python_update.py b/tests/libgstc/python/test_libgstc_python_update.py index c1efd413..f21a2fa9 100755 --- a/tests/libgstc/python/test_libgstc_python_update.py +++ b/tests/libgstc/python/test_libgstc_python_update.py @@ -38,18 +38,18 @@ class TestGstcUpdateMethods(GstdTestRunner): - def test_libgstc_python_update(self): + async def test_libgstc_python_update(self): pipeline = 'videotestsrc name=v0 pattern=snow ! fakesink' self.gstd_logger = CustomLogger('test_libgstc', loglevel='DEBUG') self.gstd_client = GstdClient(port=self.port, logger=self.gstd_logger) - self.gstd_client.pipeline_create('p0', pipeline) - self.gstd_client.update( + await self.gstd_client.pipeline_create('p0', pipeline) + await self.gstd_client.update( 'pipelines/p0/elements/v0/properties/pattern', 'ball') - ret = self.gstd_client.read( + ret = await self.gstd_client.read( 'pipelines/p0/elements/v0/properties/pattern') self.assertEqual(ret['value'], 'Moving ball') - self.gstd_client.pipeline_stop('p0') - self.gstd_client.pipeline_delete('p0') + await self.gstd_client.pipeline_stop('p0') + await self.gstd_client.pipeline_delete('p0') if __name__ == '__main__':