Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test-dds-adapter-depth test #13605

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions unit-tests/dds/adapter/test-depth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2024 Intel Corporation. All Rights Reserved.

#test:donotrun:!dds
#test:device D400*

from rspy import log, repo, test
import time


with test.closure( 'Run rs-dds-adapter', on_fail=test.ABORT ):
adapter_path = repo.find_built_exe( 'tools/dds/dds-adapter', 'rs-dds-adapter' )
if test.check( adapter_path ):
import subprocess, signal
adapter_process = subprocess.Popen( [adapter_path, '--debug', '--domain-id', '123'],
stdout=None,
stderr=subprocess.STDOUT,
universal_newlines=True ) # don't fail on errors

from rspy import librs as rs
if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )

with test.closure( 'Initialize librealsense context', on_fail=test.ABORT ):
context = rs.context( { 'dds': { 'enabled': True, 'domain': 123, 'participant': 'client' }} )

with test.closure( 'Wait for a device', on_fail=test.ABORT ):
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )

with test.closure( 'Get sensor', on_fail=test.ABORT ):
sensor = dev.first_depth_sensor()
test.check( sensor )

with test.closure( 'Find profile', on_fail=test.ABORT ):
for p in sensor.profiles:
log.d( p )
profile = next( p for p in sensor.profiles
if p.fps() == 30
and p.stream_type() == rs.stream.depth )
test.check( profile )

n_frames = 0
start_time = None
def frame_callback( frame ):
global n_frames, start_time
if n_frames == 0:
start_time = time.perf_counter()
n_frames += 1

with test.closure( f'Stream {profile}', on_fail=test.ABORT ):
sensor.open( [profile] )
sensor.start( frame_callback )

with test.closure( 'Let it stream' ):
time.sleep( 3 )
end_time = time.perf_counter()
if test.check( n_frames > 0 ):
test.info( 'start_time', start_time )
test.info( 'end_time', end_time )
test.info( 'n_frames', n_frames )
test.check_approx_abs( n_frames / (end_time-start_time), 30, 1 )

with test.closure( 'Open the same profile while streaming!' ):
test.check_throws( lambda:
sensor.open( [profile] ),
RuntimeError, 'open(...) failed. Software device is streaming!' )

with test.closure( 'Stop streaming' ):
sensor.stop()
sensor.close()

del profile
del sensor
del dev
del context

with test.closure( 'Stop rs-dds-adapter' ):
adapter_process.send_signal( signal.SIGTERM )
adapter_process.wait( timeout=2 )

test.print_results()

2 changes: 1 addition & 1 deletion unit-tests/dds/test-librs-connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import d435i
import d405
import librs as rs
from rspy import librs as rs
if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )
from time import sleep
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/test-librs-device-properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import d435i
import d405
import d455
import librs as rs
from rspy import librs as rs

if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/test-librs-extrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rspy import log, test
log.nested = 'C '

import librs as rs
from rspy import librs as rs
if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )
from time import sleep
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/test-librs-formats-conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#test:retries:gha 2

from rspy import log, test
import librs as rs
from rspy import librs as rs

if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/test-librs-intrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def close_server( instance ):

log.nested = 'C '

import librs as rs
from rspy import librs as rs
if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )

Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/test-librs-options.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _on_set_option( server, option, value ):
###############################################################################################################
# The client is LibRS
#
import librs as rs
from rspy import librs as rs
if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )

Expand Down
2 changes: 1 addition & 1 deletion unit-tests/dds/test-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def __exit__( self, type, value, traceback ):
#############################################################################################
#
with test.closure( "Initialize librs device", on_fail=test.ABORT ):
import librs as rs
from rspy import librs as rs
if log.is_debug_on():
rs.log_to_console( rs.log_severity.debug )
context = rs.context( { 'dds': { 'enabled': True, 'domain': 123, 'participant': 'librs' }} )
Expand Down
File renamed without changes.
Loading