From f43330beca912b85ebe969cfc452ef1fcde60860 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Tue, 13 Sep 2022 13:21:12 +0300 Subject: [PATCH 01/10] test-timestamp-damain file created --- unit-tests/live/options/test-timestamp-domain.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 unit-tests/live/options/test-timestamp-domain.py diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py new file mode 100644 index 0000000000..e69de29bb2 From bba99500481386bceb04d8cad91139a55e32db12 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Wed, 21 Sep 2022 14:41:18 +0300 Subject: [PATCH 02/10] test completed --- .../live/options/test-timestamp-domain.py | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index e69de29bb2..f932599398 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -0,0 +1,91 @@ +# License: Apache 2.0. See LICENSE file in root directory. +# Copyright(c) 2021 Intel Corporation. All Rights Reserved. + +# test: device D435i + +import time +import pyrealsense2 as rs +from rspy import test + +# This test check Timestamp toggle option for color and depth sensor + + +def callback(frame): + global expected_time_stamp_domain + test.check_equal(int(frame.get_frame_timestamp_domain()), expected_time_stamp_domain) + + +################################################################################################ +test.start("Start test") + +ENABLE = 1 +DISABLE = 0 + +devices = test.find_first_device_or_exit() + +time.sleep(3) # The device starts at D0 (Operational) state, allow time for it to get into idle state +depth_sensor = devices.first_depth_sensor() +color_sensor = devices.first_color_sensor() + +depth_sensor.get_option(rs.option.global_time_enabled) +color_sensor.get_option(rs.option.global_time_enabled) + +# Using a profile common to both L500 and D400 +depth_profile = next(p for p in depth_sensor.profiles if p.fps() == 30 + and p.stream_type() == rs.stream.depth + and p.format() == rs.format.z16 + and p.as_video_stream_profile().width() == 640 + and p.as_video_stream_profile().height() == 480) + +color_profile = next(p for p in color_sensor.profiles if p.fps() == 30 + and p.stream_type() == rs.stream.color + and p.format() == rs.format.yuyv + and p.as_video_stream_profile().width() == 640 + and p.as_video_stream_profile().height() == 480) + +depth_sensor.open(depth_profile) +depth_sensor.start(callback) + +############################################################################################# +# Test #1 +expected_time_stamp_domain = 0 +depth_sensor.set_option(rs.option.global_time_enabled, DISABLE) +test.check_equal(DISABLE, depth_sensor.get_option(rs.option.global_time_enabled)) +time.sleep(0.2) + +############################################################################################# +# Test #2 +expected_time_stamp_domain = 2 +depth_sensor.set_option(rs.option.global_time_enabled, ENABLE) +test.check_equal(ENABLE, depth_sensor.get_option(rs.option.global_time_enabled)) +time.sleep(0.2) + +############################################################################################# + +depth_sensor.stop() +depth_sensor.close() + +color_sensor.open(color_profile) +color_sensor.start(callback) + +############################################################################################# +# Test #3 +expected_time_stamp_domain = 0 +color_sensor.set_option(rs.option.global_time_enabled, DISABLE) +test.check_equal(DISABLE, color_sensor.get_option(rs.option.global_time_enabled)) +time.sleep(0.2) + +############################################################################################# +# Test #4 +expected_time_stamp_domain = 2 +color_sensor.set_option(rs.option.global_time_enabled, ENABLE) +test.check_equal(ENABLE, color_sensor.get_option(rs.option.global_time_enabled)) +time.sleep(0.2) + +############################################################################################# + +color_sensor.stop() +color_sensor.close() + +test.finish() +test.print_results_and_exit() From 7da602903ae6c3fee9321fe9b70846df74c3dc60 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Wed, 21 Sep 2022 14:42:49 +0300 Subject: [PATCH 03/10] test added to stage --- unit-tests/live/options/test-timestamp-domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index f932599398..8871b27314 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -1,5 +1,5 @@ # License: Apache 2.0. See LICENSE file in root directory. -# Copyright(c) 2021 Intel Corporation. All Rights Reserved. +# Copyright(c) 2022 Intel Corporation. All Rights Reserved. # test: device D435i From 8d2c7c42841d4a3d7d0d286dc8e8c7fa93608056 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Wed, 21 Sep 2022 15:59:56 +0300 Subject: [PATCH 04/10] minors changes --- unit-tests/live/options/test-timestamp-domain.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index 8871b27314..8193912c5d 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -1,16 +1,16 @@ # License: Apache 2.0. See LICENSE file in root directory. # Copyright(c) 2022 Intel Corporation. All Rights Reserved. -# test: device D435i +# test: device D400* import time import pyrealsense2 as rs from rspy import test -# This test check Timestamp toggle option for color and depth sensor +# This test checks Timestamp domain toggle option for color and depth sensor -def callback(frame): +def frame_callback(frame): global expected_time_stamp_domain test.check_equal(int(frame.get_frame_timestamp_domain()), expected_time_stamp_domain) @@ -30,7 +30,6 @@ def callback(frame): depth_sensor.get_option(rs.option.global_time_enabled) color_sensor.get_option(rs.option.global_time_enabled) -# Using a profile common to both L500 and D400 depth_profile = next(p for p in depth_sensor.profiles if p.fps() == 30 and p.stream_type() == rs.stream.depth and p.format() == rs.format.z16 @@ -44,7 +43,7 @@ def callback(frame): and p.as_video_stream_profile().height() == 480) depth_sensor.open(depth_profile) -depth_sensor.start(callback) +depth_sensor.start(frame_callback) ############################################################################################# # Test #1 @@ -66,7 +65,7 @@ def callback(frame): depth_sensor.close() color_sensor.open(color_profile) -color_sensor.start(callback) +color_sensor.start(frame_callback) ############################################################################################# # Test #3 From ae281dc3b8b850f7affa6dfb05d81370c4883ea6 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Thu, 22 Sep 2022 15:37:28 +0300 Subject: [PATCH 05/10] new version with queue --- .../live/options/test-timestamp-domain.py | 152 +++++++++++------- 1 file changed, 91 insertions(+), 61 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index 8193912c5d..5b017e2f62 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -1,90 +1,120 @@ # License: Apache 2.0. See LICENSE file in root directory. # Copyright(c) 2022 Intel Corporation. All Rights Reserved. -# test: device D400* +# test:device D400* import time import pyrealsense2 as rs + from rspy import test -# This test checks Timestamp domain toggle option for color and depth sensor +def get_connected_device(): + """ + Get first connected device + :return: connected device + """ + dev = None + try: + context = rs.context() + dev = context.devices[0] + except: + print('Exception: Failed to find connected device') + return dev + + +def close_resources(sensor): + """ + Stop and Close sensor. + :param: sensor of device + """ + if len(sensor.get_active_streams()) > 0: + sensor.stop() + sensor.close() + + +def start_sensor_test(sensor, global_time_enabled: int): + """ + Perform depth sensor test according given global time + :global_time_enabled int: 1 - time is enabled, 0 - time disabled + """ -def frame_callback(frame): - global expected_time_stamp_domain - test.check_equal(int(frame.get_frame_timestamp_domain()), expected_time_stamp_domain) + if global_time_enabled not in [0, 1]: + raise ValueError(f'Invalid parameter in start depth test: {global_time_enabled}. Only 1 or 0 are valid.') + try: + sensor.set_option(rs.option.global_time_enabled, global_time_enabled) + time.sleep(2) -################################################################################################ -test.start("Start test") + frame = frame_queue.wait_for_frame() -ENABLE = 1 -DISABLE = 0 + if global_time_enabled == 0 and sensor.get_option(rs.option.global_time_enabled) == 0: -devices = test.find_first_device_or_exit() + test.check_equal(frame.get_frame_timestamp_domain(), rs.timestamp_domain.hardware_clock) + print('frame_timestamp_domain: ', int(frame.get_frame_timestamp_domain())) # remove it -time.sleep(3) # The device starts at D0 (Operational) state, allow time for it to get into idle state -depth_sensor = devices.first_depth_sensor() -color_sensor = devices.first_color_sensor() + elif global_time_enabled == 1 and sensor.get_option(rs.option.global_time_enabled) == 1: -depth_sensor.get_option(rs.option.global_time_enabled) -color_sensor.get_option(rs.option.global_time_enabled) + test.check_equal(frame.get_frame_timestamp_domain(), + rs.timestamp_domain.global_time) + print('frame_timestamp_domain: ', int(frame.get_frame_timestamp_domain())) # remove it -depth_profile = next(p for p in depth_sensor.profiles if p.fps() == 30 - and p.stream_type() == rs.stream.depth - and p.format() == rs.format.z16 - and p.as_video_stream_profile().width() == 640 - and p.as_video_stream_profile().height() == 480) + except: + print('Exception: start_depth_sensor_test throw exception with value: ', global_time_enabled) -color_profile = next(p for p in color_sensor.profiles if p.fps() == 30 - and p.stream_type() == rs.stream.color - and p.format() == rs.format.yuyv - and p.as_video_stream_profile().width() == 640 - and p.as_video_stream_profile().height() == 480) -depth_sensor.open(depth_profile) -depth_sensor.start(frame_callback) +depth_sensor = None +color_sensor = None -############################################################################################# -# Test #1 -expected_time_stamp_domain = 0 -depth_sensor.set_option(rs.option.global_time_enabled, DISABLE) -test.check_equal(DISABLE, depth_sensor.get_option(rs.option.global_time_enabled)) -time.sleep(0.2) +try: + device = get_connected_device() + depth_sensor = device.first_depth_sensor() + color_sensor = device.first_color_sensor() -############################################################################################# -# Test #2 -expected_time_stamp_domain = 2 -depth_sensor.set_option(rs.option.global_time_enabled, ENABLE) -test.check_equal(ENABLE, depth_sensor.get_option(rs.option.global_time_enabled)) -time.sleep(0.2) + depth_profile = next(p for p in depth_sensor.profiles if p.fps() == 30 + and p.stream_type() == rs.stream.depth + and p.format() == rs.format.z16 + and p.as_video_stream_profile().width() == 640 + and p.as_video_stream_profile().height() == 480) -############################################################################################# + color_profile = next(p for p in color_sensor.profiles if p.fps() == 30 + and p.stream_type() == rs.stream.color + and p.format() == rs.format.yuyv + and p.as_video_stream_profile().width() == 640 + and p.as_video_stream_profile().height() == 480) -depth_sensor.stop() -depth_sensor.close() + depth_sensor.open(depth_profile) + color_sensor.open(color_profile) + frame_queue = rs.frame_queue(capacity=10, keep_frames=False) -color_sensor.open(color_profile) -color_sensor.start(frame_callback) + depth_sensor.start(frame_queue) -############################################################################################# -# Test #3 -expected_time_stamp_domain = 0 -color_sensor.set_option(rs.option.global_time_enabled, DISABLE) -test.check_equal(DISABLE, color_sensor.get_option(rs.option.global_time_enabled)) -time.sleep(0.2) + # Test #1 + test.start('Start depth sensor test: global time disabled') + start_sensor_test(depth_sensor, 0) + test.finish() -############################################################################################# -# Test #4 -expected_time_stamp_domain = 2 -color_sensor.set_option(rs.option.global_time_enabled, ENABLE) -test.check_equal(ENABLE, color_sensor.get_option(rs.option.global_time_enabled)) -time.sleep(0.2) + # Test #2 + test.start('Start depth sensor test: global time enabled') + start_sensor_test(depth_sensor, 1) + test.finish() -############################################################################################# + close_resources(depth_sensor) + color_sensor.start(frame_queue) -color_sensor.stop() -color_sensor.close() + # Test #3 + test.start('Start color sensor test: global time disabled') + start_sensor_test(color_sensor, 0) + test.finish() -test.finish() -test.print_results_and_exit() + # Test #4 + test.start('Start color sensor test: global time enabled') + start_sensor_test(color_sensor, 1) + test.finish() + +except Exception as e: + print(str(e)) + print("The device found has no depth sensor") +finally: + # close_resources(depth_sensor) + close_resources(color_sensor) From a7598f49ed3c31f3a0776945b9c8f0406c653827 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Thu, 22 Sep 2022 15:43:23 +0300 Subject: [PATCH 06/10] test prints removed --- unit-tests/live/options/test-timestamp-domain.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index 5b017e2f62..3db4920c9a 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -49,15 +49,11 @@ def start_sensor_test(sensor, global_time_enabled: int): frame = frame_queue.wait_for_frame() if global_time_enabled == 0 and sensor.get_option(rs.option.global_time_enabled) == 0: - test.check_equal(frame.get_frame_timestamp_domain(), rs.timestamp_domain.hardware_clock) - print('frame_timestamp_domain: ', int(frame.get_frame_timestamp_domain())) # remove it elif global_time_enabled == 1 and sensor.get_option(rs.option.global_time_enabled) == 1: - test.check_equal(frame.get_frame_timestamp_domain(), rs.timestamp_domain.global_time) - print('frame_timestamp_domain: ', int(frame.get_frame_timestamp_domain())) # remove it except: print('Exception: start_depth_sensor_test throw exception with value: ', global_time_enabled) From b191e67f25484cbf50b55be5f92955ff6d42f828 Mon Sep 17 00:00:00 2001 From: Tamir Yurovskiy Date: Thu, 22 Sep 2022 15:51:54 +0300 Subject: [PATCH 07/10] Excetions was changed --- unit-tests/live/options/test-timestamp-domain.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index 3db4920c9a..56421584fe 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -18,8 +18,8 @@ def get_connected_device(): try: context = rs.context() dev = context.devices[0] - except: - print('Exception: Failed to find connected device') + except Exception as ex: + print('Exception: Failed to find connected device. ', str(ex)) return dev @@ -55,8 +55,8 @@ def start_sensor_test(sensor, global_time_enabled: int): test.check_equal(frame.get_frame_timestamp_domain(), rs.timestamp_domain.global_time) - except: - print('Exception: start_depth_sensor_test throw exception with value: ', global_time_enabled) + except Exception as exc: + print(str(exc)) depth_sensor = None @@ -108,9 +108,10 @@ def start_sensor_test(sensor, global_time_enabled: int): start_sensor_test(color_sensor, 1) test.finish() +except ValueError as v: + print(str(v)) except Exception as e: - print(str(e)) - print("The device found has no depth sensor") + print("The device found has no depth sensor or ", str(e)) finally: # close_resources(depth_sensor) close_resources(color_sensor) From 796ec03c08863165d25a7392c75da1d2fe0e13c5 Mon Sep 17 00:00:00 2001 From: Tamir <1hotlev@gmail.com> Date: Thu, 29 Sep 2022 11:23:24 +0300 Subject: [PATCH 08/10] test changed second time according instructions #10925 --- .../live/options/test-timestamp-domain.py | 97 ++++++++----------- 1 file changed, 38 insertions(+), 59 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index 56421584fe..d26453bbed 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -9,109 +9,88 @@ from rspy import test -def get_connected_device(): - """ - Get first connected device - :return: connected device - """ - dev = None - try: - context = rs.context() - dev = context.devices[0] - except Exception as ex: - print('Exception: Failed to find connected device. ', str(ex)) - return dev - - def close_resources(sensor): """ Stop and Close sensor. - :param: sensor of device + :sensor: sensor of device """ if len(sensor.get_active_streams()) > 0: sensor.stop() sensor.close() -def start_sensor_test(sensor, global_time_enabled: int): +def set_and_verify_timestamp_domain(sensor, global_time_enabled: bool): """ - Perform depth sensor test according given global time - :global_time_enabled int: 1 - time is enabled, 0 - time disabled + Perform sensor (depth or color) test according given global time + :sensor: depth or color sensor in device + :global_time_enabled bool: True - timestamp is enabled otherwise false """ - - if global_time_enabled not in [0, 1]: - raise ValueError(f'Invalid parameter in start depth test: {global_time_enabled}. Only 1 or 0 are valid.') + global frame_queue try: - sensor.set_option(rs.option.global_time_enabled, global_time_enabled) - time.sleep(2) - + sensor.set_option(rs.option.global_time_enabled, 1 if global_time_enabled else 0) + time.sleep(0.7) frame = frame_queue.wait_for_frame() - if global_time_enabled == 0 and sensor.get_option(rs.option.global_time_enabled) == 0: - test.check_equal(frame.get_frame_timestamp_domain(), rs.timestamp_domain.hardware_clock) + if frame_queue is None or frame_queue.size() == 0: + test.fail() + + expected_ts_domain = rs.timestamp_domain.global_time if global_time_enabled else \ + rs.timestamp_domain.hardware_clock - elif global_time_enabled == 1 and sensor.get_option(rs.option.global_time_enabled) == 1: - test.check_equal(frame.get_frame_timestamp_domain(), - rs.timestamp_domain.global_time) + test.check_equal(sensor.get_option(rs.option.global_time_enabled), 1 if global_time_enabled else 0) + test.check_equal(frame.get_frame_timestamp_domain(), expected_ts_domain) except Exception as exc: print(str(exc)) + test.fail() depth_sensor = None color_sensor = None try: - device = get_connected_device() - depth_sensor = device.first_depth_sensor() - color_sensor = device.first_color_sensor() - - depth_profile = next(p for p in depth_sensor.profiles if p.fps() == 30 - and p.stream_type() == rs.stream.depth - and p.format() == rs.format.z16 - and p.as_video_stream_profile().width() == 640 - and p.as_video_stream_profile().height() == 480) - - color_profile = next(p for p in color_sensor.profiles if p.fps() == 30 - and p.stream_type() == rs.stream.color - and p.format() == rs.format.yuyv - and p.as_video_stream_profile().width() == 640 - and p.as_video_stream_profile().height() == 480) + frame_queue = rs.frame_queue(capacity=5, keep_frames=False) + device = test.find_first_device_or_exit() + # Depth sensor test + depth_sensor = device.first_depth_sensor() + depth_profile = next(p for p in depth_sensor.profiles if p.stream_type() == rs.stream.depth) depth_sensor.open(depth_profile) - color_sensor.open(color_profile) - frame_queue = rs.frame_queue(capacity=10, keep_frames=False) - depth_sensor.start(frame_queue) # Test #1 - test.start('Start depth sensor test: global time disabled') - start_sensor_test(depth_sensor, 0) + test.start('Check setting global time domain: depth sensor - timestamp domain is OFF') + set_and_verify_timestamp_domain(depth_sensor, False) test.finish() # Test #2 - test.start('Start depth sensor test: global time enabled') - start_sensor_test(depth_sensor, 1) + test.start('Check setting global time domain: depth sensor - timestamp domain is ON') + set_and_verify_timestamp_domain(depth_sensor, True) test.finish() close_resources(depth_sensor) + + # Color sensor test + color_sensor = device.first_color_sensor() + color_profile = next(p for p in color_sensor.profiles if p.stream_type() == rs.stream.color) + color_sensor.open(color_profile) color_sensor.start(frame_queue) # Test #3 - test.start('Start color sensor test: global time disabled') - start_sensor_test(color_sensor, 0) + test.start('Check setting global time domain: color sensor - timestamp domain is OFF') + set_and_verify_timestamp_domain(color_sensor, False) test.finish() # Test #4 - test.start('Start color sensor test: global time enabled') - start_sensor_test(color_sensor, 1) + test.start('Check setting global time domain: color sensor - timestamp domain is ON') + set_and_verify_timestamp_domain(color_sensor, True) test.finish() -except ValueError as v: - print(str(v)) + test.print_results_and_exit() + except Exception as e: - print("The device found has no depth sensor or ", str(e)) + print(str(e)) + test.fail() finally: - # close_resources(depth_sensor) close_resources(color_sensor) From f8c63a162503728f0d2b2f99a4cba49d090845d9 Mon Sep 17 00:00:00 2001 From: Tamir <1hotlev@gmail.com> Date: Sun, 2 Oct 2022 12:21:40 +0300 Subject: [PATCH 09/10] small changes according Nir --- .../live/options/test-timestamp-domain.py | 93 ++++++++----------- 1 file changed, 40 insertions(+), 53 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index d26453bbed..a72298048f 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -27,70 +27,57 @@ def set_and_verify_timestamp_domain(sensor, global_time_enabled: bool): """ global frame_queue - try: - sensor.set_option(rs.option.global_time_enabled, 1 if global_time_enabled else 0) - time.sleep(0.7) - frame = frame_queue.wait_for_frame() + sensor.set_option(rs.option.global_time_enabled, global_time_enabled) + time.sleep(0.3) # Waiting for new frame from device. Need in case low FPS. + frame = frame_queue.wait_for_frame() - if frame_queue is None or frame_queue.size() == 0: - test.fail() - - expected_ts_domain = rs.timestamp_domain.global_time if global_time_enabled else \ - rs.timestamp_domain.hardware_clock - - test.check_equal(sensor.get_option(rs.option.global_time_enabled), 1 if global_time_enabled else 0) - test.check_equal(frame.get_frame_timestamp_domain(), expected_ts_domain) - - except Exception as exc: - print(str(exc)) + if not frame: test.fail() + expected_ts_domain = rs.timestamp_domain.global_time if global_time_enabled else \ + rs.timestamp_domain.hardware_clock + + test.check_equal(sensor.get_option(rs.option.global_time_enabled), global_time_enabled) + test.check_equal(frame.get_frame_timestamp_domain(), expected_ts_domain) -depth_sensor = None -color_sensor = None -try: - frame_queue = rs.frame_queue(capacity=5, keep_frames=False) - device = test.find_first_device_or_exit() +frame_queue = rs.frame_queue(capacity=1, keep_frames=False) +device = test.find_first_device_or_exit() - # Depth sensor test - depth_sensor = device.first_depth_sensor() - depth_profile = next(p for p in depth_sensor.profiles if p.stream_type() == rs.stream.depth) - depth_sensor.open(depth_profile) - depth_sensor.start(frame_queue) +# Depth sensor test +depth_sensor = device.first_depth_sensor() +depth_profile = next(p for p in depth_sensor.profiles if p.stream_type() == rs.stream.depth) +depth_sensor.open(depth_profile) +depth_sensor.start(frame_queue) - # Test #1 - test.start('Check setting global time domain: depth sensor - timestamp domain is OFF') - set_and_verify_timestamp_domain(depth_sensor, False) - test.finish() +# Test #1 +test.start('Check setting global time domain: depth sensor - timestamp domain is OFF') +set_and_verify_timestamp_domain(depth_sensor, False) +test.finish() - # Test #2 - test.start('Check setting global time domain: depth sensor - timestamp domain is ON') - set_and_verify_timestamp_domain(depth_sensor, True) - test.finish() +# Test #2 +test.start('Check setting global time domain: depth sensor - timestamp domain is ON') +set_and_verify_timestamp_domain(depth_sensor, True) +test.finish() - close_resources(depth_sensor) +close_resources(depth_sensor) - # Color sensor test - color_sensor = device.first_color_sensor() - color_profile = next(p for p in color_sensor.profiles if p.stream_type() == rs.stream.color) - color_sensor.open(color_profile) - color_sensor.start(frame_queue) +# Color sensor test +color_sensor = device.first_color_sensor() +color_profile = next(p for p in color_sensor.profiles if p.stream_type() == rs.stream.color) +color_sensor.open(color_profile) +color_sensor.start(frame_queue) - # Test #3 - test.start('Check setting global time domain: color sensor - timestamp domain is OFF') - set_and_verify_timestamp_domain(color_sensor, False) - test.finish() +# Test #3 +test.start('Check setting global time domain: color sensor - timestamp domain is OFF') +set_and_verify_timestamp_domain(color_sensor, False) +test.finish() - # Test #4 - test.start('Check setting global time domain: color sensor - timestamp domain is ON') - set_and_verify_timestamp_domain(color_sensor, True) - test.finish() +# Test #4 +test.start('Check setting global time domain: color sensor - timestamp domain is ON') +set_and_verify_timestamp_domain(color_sensor, True) +test.finish() - test.print_results_and_exit() +test.print_results_and_exit() -except Exception as e: - print(str(e)) - test.fail() -finally: - close_resources(color_sensor) +close_resources(color_sensor) From f1de5acfe8bfbf9554606181dd023894366303c8 Mon Sep 17 00:00:00 2001 From: Tamir <1hotlev@gmail.com> Date: Sun, 2 Oct 2022 14:04:51 +0300 Subject: [PATCH 10/10] bug unreacheable last line fixed --- unit-tests/live/options/test-timestamp-domain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit-tests/live/options/test-timestamp-domain.py b/unit-tests/live/options/test-timestamp-domain.py index a72298048f..bd58bd813d 100644 --- a/unit-tests/live/options/test-timestamp-domain.py +++ b/unit-tests/live/options/test-timestamp-domain.py @@ -78,6 +78,6 @@ def set_and_verify_timestamp_domain(sensor, global_time_enabled: bool): set_and_verify_timestamp_domain(color_sensor, True) test.finish() -test.print_results_and_exit() - close_resources(color_sensor) + +test.print_results_and_exit()