From 7c750ce843e69781e949e2345376a981e4bc8d00 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 20 Mar 2024 19:08:02 +0200 Subject: [PATCH 1/4] reset device on retries --- unit-tests/run-unit-tests.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/unit-tests/run-unit-tests.py b/unit-tests/run-unit-tests.py index 66e8d89df2..a65482a5f9 100644 --- a/unit-tests/run-unit-tests.py +++ b/unit-tests/run-unit-tests.py @@ -441,10 +441,15 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): global n_tests n_tests += 1 for retry in range( test.config.retries + 1 ): - if test_wrapper_( test, configuration, repetition, retry, sns ): + if test_wrapper_( test, configuration, repetition, retry, sns ) and log.n_errors() == 0: return True log._n_errors -= 1 - time.sleep( 1 ) # small pause between tries + if no_reset: + time.sleep(1) # small pause between tries + elif retry < test.config.retries: + log.d("retry", retry + 1, "out of", test.config.retries) + devices.enable_only(serial_numbers, recycle=True) + log._n_errors += 1 return False @@ -555,6 +560,8 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): test_ok = True for repetition in range(repeat): test_ok = test_wrapper( test, repetition = repetition ) and test_ok + if repetition + 1 < repeat: + log.d("repeating #", repetition + 1) if not test_ok: failed_tests.append( test ) continue @@ -578,6 +585,8 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): log.w( log.red + test.name + log.reset + ': ' + str( e ) ) else: test_ok = test_wrapper( test, configuration, repetition, sns=serial_numbers ) and test_ok + if repetition + 1 < repeat: + log.d("repeating #", repetition + 1) finally: log.debug_unindent() if not test_ok: From f216af95c488e7219692dddb6fd3b90a56b41311 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Thu, 9 May 2024 09:03:03 +0300 Subject: [PATCH 2/4] some changes --- unit-tests/py/rspy/test.py | 1 - unit-tests/run-unit-tests.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/unit-tests/py/rspy/test.py b/unit-tests/py/rspy/test.py index d8c6425869..e513878a5c 100644 --- a/unit-tests/py/rspy/test.py +++ b/unit-tests/py/rspy/test.py @@ -561,7 +561,6 @@ def finish( on_fail=LOG ): log.i("Test passed") test_in_progress = None - def print_separator(): """ For use only in-between test-cases, this will separate them in some visual way so as diff --git a/unit-tests/run-unit-tests.py b/unit-tests/run-unit-tests.py index a65482a5f9..459ed82075 100644 --- a/unit-tests/run-unit-tests.py +++ b/unit-tests/run-unit-tests.py @@ -441,13 +441,13 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): global n_tests n_tests += 1 for retry in range( test.config.retries + 1 ): - if test_wrapper_( test, configuration, repetition, retry, sns ) and log.n_errors() == 0: + if test_wrapper_( test, configuration, repetition, retry, sns ): return True log._n_errors -= 1 if no_reset: time.sleep(1) # small pause between tries elif retry < test.config.retries: - log.d("retry", retry + 1, "out of", test.config.retries) + log.w("retry", retry + 1, "out of", test.config.retries) devices.enable_only(serial_numbers, recycle=True) log._n_errors += 1 From a482695771dd69810899df2c4617895ecb6adc73 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 12 May 2024 20:59:23 +0300 Subject: [PATCH 3/4] move log to inner function --- unit-tests/run-unit-tests.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/unit-tests/run-unit-tests.py b/unit-tests/run-unit-tests.py index 459ed82075..98a136789c 100644 --- a/unit-tests/run-unit-tests.py +++ b/unit-tests/run-unit-tests.py @@ -421,6 +421,8 @@ def test_wrapper_( test, configuration=None, repetition=1, retry=0, sns=None ): if rslog: opts.add( '--rslog' ) try: + if repetition > 0: + log.d("repeat #", repetition + 1) test.run_test( configuration = configuration, log_path = log_path, opts = opts ) except FileNotFoundError as e: log.e( log.red + test.name + log.reset + ':', str( e ) + configuration_str( configuration, repetition, prefix=' ' ) ) @@ -560,8 +562,6 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): test_ok = True for repetition in range(repeat): test_ok = test_wrapper( test, repetition = repetition ) and test_ok - if repetition + 1 < repeat: - log.d("repeating #", repetition + 1) if not test_ok: failed_tests.append( test ) continue @@ -585,8 +585,6 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): log.w( log.red + test.name + log.reset + ': ' + str( e ) ) else: test_ok = test_wrapper( test, configuration, repetition, sns=serial_numbers ) and test_ok - if repetition + 1 < repeat: - log.d("repeating #", repetition + 1) finally: log.debug_unindent() if not test_ok: From 724a8057812890761a04212b4451c3c1da1cf950 Mon Sep 17 00:00:00 2001 From: Eran Date: Mon, 13 May 2024 10:09:06 +0300 Subject: [PATCH 4/4] updates --- unit-tests/run-unit-tests.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/unit-tests/run-unit-tests.py b/unit-tests/run-unit-tests.py index 98a136789c..158e79ad9c 100644 --- a/unit-tests/run-unit-tests.py +++ b/unit-tests/run-unit-tests.py @@ -261,7 +261,7 @@ def configuration_str( configuration, repetition=0, retry=0, sns=None, prefix='' elif sns is not None: s += '[' + serial_numbers_to_string( sns ) + ']' if repetition: - s += '[' + str(repetition+1) + ']' + s += f'[rep {repetition+1}]' if retry: s += f'[retry {retry}]' if s: @@ -421,8 +421,6 @@ def test_wrapper_( test, configuration=None, repetition=1, retry=0, sns=None ): if rslog: opts.add( '--rslog' ) try: - if repetition > 0: - log.d("repeat #", repetition + 1) test.run_test( configuration = configuration, log_path = log_path, opts = opts ) except FileNotFoundError as e: log.e( log.red + test.name + log.reset + ':', str( e ) + configuration_str( configuration, repetition, prefix=' ' ) ) @@ -443,14 +441,18 @@ def test_wrapper( test, configuration=None, repetition=1, sns=None ): global n_tests n_tests += 1 for retry in range( test.config.retries + 1 ): + if retry: + if log.is_debug_on(): + log.debug_unindent() # just to make it stand out a little more + log.d( f' Failed; retry #{retry}' ) + log.debug_indent() + if no_reset: + time.sleep(1) # small pause between tries + else: + devices.enable_only( serial_numbers, recycle=True ) if test_wrapper_( test, configuration, repetition, retry, sns ): return True log._n_errors -= 1 - if no_reset: - time.sleep(1) # small pause between tries - elif retry < test.config.retries: - log.w("retry", retry + 1, "out of", test.config.retries) - devices.enable_only(serial_numbers, recycle=True) log._n_errors += 1 return False