From bdb34439218611b78af0c85bf0fbb453e057f186 Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Wed, 20 Mar 2024 13:19:48 +0200 Subject: [PATCH 1/4] tests: rs-enumerate-devices Referenced-by: [RSDSO-19607] Signed-off-by: Dmitry Perchanov --- .../live/tools/test-enumerate-devices.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 unit-tests/live/tools/test-enumerate-devices.py diff --git a/unit-tests/live/tools/test-enumerate-devices.py b/unit-tests/live/tools/test-enumerate-devices.py new file mode 100644 index 0000000000..8b03ea1ba4 --- /dev/null +++ b/unit-tests/live/tools/test-enumerate-devices.py @@ -0,0 +1,36 @@ +# License: Apache 2.0. See LICENSE file in root directory. +# Copyright(c) 2024 Intel Corporation. All Rights Reserved. + +import pyrealsense2 as rs +from rspy import log, repo, test +from rspy.stopwatch import Stopwatch + +############################################################################################# +# +test.start( "Init" ) +rs_enumerate_devices = repo.find_built_exe( 'tools/enumerate-devices', 'rs-enumerate-devices' ) +test.check(rs_enumerate_devices) +if rs_enumerate_devices: + import subprocess + run_time_stopwatch = Stopwatch() + run_time_threshold = 2 + subprocess.run( [rs_enumerate_devices], + stdout=None, + stderr=subprocess.STDOUT, + universal_newlines=True, + timeout=10, + check=False ) # don't fail on errors + run_time_seconds = run_time_stopwatch.get_elapsed() + if run_time_seconds > run_time_threshold: + log.e('Time elapsed too high!', run_time_seconds, ' > ', run_time_threshold) + test.check(run_time_seconds < run_time_threshold) + run_time_stopwatch.reset() +else: + log.e( 'no rs-enumerate-devices was found!' ) + import sys + log.d( 'sys.path=\n ' + '\n '.join( sys.path ) ) + +test.finish() +# +############################################################################################# +test.print_results_and_exit() From 6f1a2963641116eee5895d79e39c71e3ba1f7056 Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Wed, 20 Mar 2024 16:54:11 +0200 Subject: [PATCH 2/4] test: libci enable live tests for d400 d500 devices Signed-off-by: Dmitry Perchanov --- unit-tests/live/tools/test-enumerate-devices.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unit-tests/live/tools/test-enumerate-devices.py b/unit-tests/live/tools/test-enumerate-devices.py index 8b03ea1ba4..881400b514 100644 --- a/unit-tests/live/tools/test-enumerate-devices.py +++ b/unit-tests/live/tools/test-enumerate-devices.py @@ -1,13 +1,16 @@ # License: Apache 2.0. See LICENSE file in root directory. # Copyright(c) 2024 Intel Corporation. All Rights Reserved. +#test:device each(D400*) +#test:device each(D500*) + import pyrealsense2 as rs from rspy import log, repo, test from rspy.stopwatch import Stopwatch ############################################################################################# # -test.start( "Init" ) +test.start( "Run enumerate-devices runtime test" ) rs_enumerate_devices = repo.find_built_exe( 'tools/enumerate-devices', 'rs-enumerate-devices' ) test.check(rs_enumerate_devices) if rs_enumerate_devices: From e8039470700cfd6a89468c582e5067af60afb588 Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Wed, 20 Mar 2024 17:22:24 +0200 Subject: [PATCH 3/4] test: verify subprocess return value Signed-off-by: Dmitry Perchanov --- unit-tests/live/tools/test-enumerate-devices.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unit-tests/live/tools/test-enumerate-devices.py b/unit-tests/live/tools/test-enumerate-devices.py index 881400b514..2052753a41 100644 --- a/unit-tests/live/tools/test-enumerate-devices.py +++ b/unit-tests/live/tools/test-enumerate-devices.py @@ -17,12 +17,13 @@ import subprocess run_time_stopwatch = Stopwatch() run_time_threshold = 2 - subprocess.run( [rs_enumerate_devices], + p = subprocess.run( [rs_enumerate_devices], stdout=None, stderr=subprocess.STDOUT, universal_newlines=True, timeout=10, check=False ) # don't fail on errors + test.check(p != 0) # verify success return code run_time_seconds = run_time_stopwatch.get_elapsed() if run_time_seconds > run_time_threshold: log.e('Time elapsed too high!', run_time_seconds, ' > ', run_time_threshold) From 86dfa0a8d30fa4fb4ece3ffc6a07ac09d8135236 Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Thu, 28 Mar 2024 15:29:54 +0200 Subject: [PATCH 4/4] test: enumerate: verify process return code. Signed-off-by: Dmitry Perchanov --- unit-tests/live/tools/test-enumerate-devices.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/live/tools/test-enumerate-devices.py b/unit-tests/live/tools/test-enumerate-devices.py index 2052753a41..6636b3a77e 100644 --- a/unit-tests/live/tools/test-enumerate-devices.py +++ b/unit-tests/live/tools/test-enumerate-devices.py @@ -23,7 +23,7 @@ universal_newlines=True, timeout=10, check=False ) # don't fail on errors - test.check(p != 0) # verify success return code + test.check(p.returncode == 0) # verify success return code run_time_seconds = run_time_stopwatch.get_elapsed() if run_time_seconds > run_time_threshold: log.e('Time elapsed too high!', run_time_seconds, ' > ', run_time_threshold)