test suite reviews and discussions
 help / color / mirror / Atom feed
From: "xu,huilong" <huilongx.xu@intel.com>
To: dts@dpdk.org
Cc: "xu,huilong" <huilongx.xu@intel.com>
Subject: [dts] [PATCH V1 2/3] update exec case function
Date: Fri, 23 Jun 2017 13:56:33 +0800	[thread overview]
Message-ID: <1498197394-16220-2-git-send-email-huilongx.xu@intel.com> (raw)
In-Reply-To: <1498197394-16220-1-git-send-email-huilongx.xu@intel.com>

when test case run failed, failed case will re run some times. if have passed result, this case will passed.

Signed-off-by: xu,huilong <huilongx.xu@intel.com>
---
 framework/test_case.py | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/framework/test_case.py b/framework/test_case.py
index d97d898..4f49fe4 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -36,6 +36,7 @@ import re
 import debugger
 import traceback
 import signal
+import time
 
 from exception import VerifyFailure, TimeoutException
 from settings import DRIVERS, NICS, get_nic_name, load_global_setting
@@ -44,7 +45,6 @@ from rst import RstReport
 from test_result import ResultTable, Result
 from logger import getLogger
 
-
 class TestCase(object):
 
     def __init__(self, duts, tester, target, suitename):
@@ -244,20 +244,20 @@ class TestCase(object):
         self._suite_result.test_case = case_obj.__name__
 
         self._rst_obj.write_title("Test Case: " + case_name)
-
+        case_result = True
         if self._check_inst is not None:
             if self._check_inst.case_skip(case_name[len("test_"):]):
                 self.logger.info('Test Case %s Result SKIPED:' % case_name)
                 self._rst_obj.write_result("N/A")
                 self._suite_result.test_case_skip(self._check_inst.comments)
-                return
+                return case_result
 
         if self._support_inst is not None:
             if not self._support_inst.case_support(case_name[len("test_"):]):
                 self.logger.info('Test Case %s Result SKIPED:' % case_name)
                 self._rst_obj.write_result("N/A")
                 self._suite_result.test_case_skip(self._support_inst.comments)
-                return
+                return case_result
 
         if self._enable_perf:
             self._rst_obj.write_annex_title("Annex: " + case_name)
@@ -287,6 +287,7 @@ class TestCase(object):
             self.logger.info('Test Case %s Result PASSED:' % case_name)
 
         except VerifyFailure as v:
+            case_result = False
             self._suite_result.test_case_failed(str(v))
             self._rst_obj.write_result("FAIL")
             self.logger.error('Test Case %s Result FAILED: ' % (case_name) + str(v))
@@ -296,25 +297,37 @@ class TestCase(object):
             self.tear_down()
             raise KeyboardInterrupt("Stop DTS")
         except TimeoutException as e:
+            case_result = False
             self._rst_obj.write_result("FAIL")
-            msg = str(e)
-            self._suite_result.test_case_failed(msg)
-            self.logger.error('Test Case %s Result FAILED: ' % (case_name) + msg)
+            self._suite_result.test_case_failed(str(e))
+            self.logger.error('Test Case %s Result FAILED: ' % (case_name) + str(e))
             self.logger.error('%s' % (e.get_output()))
         except Exception:
+            case_result = False
             trace = traceback.format_exc()
             self._suite_result.test_case_failed(trace)
             self.logger.error('Test Case %s Result ERROR: ' % (case_name) + trace)
         finally:
             self.tear_down()
+            return case_result
 
     def execute_test_cases(self):
         """
         Execute all test cases in one suite.
         """
+
         if load_global_setting(FUNC_SETTING) == 'yes':
             for case_obj in self._get_functional_cases():
-                self._execute_test_case(case_obj)
+                for i in range(self.tester.re_run_time):
+                    if self._execute_test_case(case_obj):
+                        break
+                    else:
+                        for dutobj in self.duts:
+                            dutobj.get_session_output(timeout = 0.5 * (i + 1))
+                        self.tester.get_session_output(timeout = 0.5 * (i + 1))
+                        time.sleep(i + 1)
+                        self.logger.info(" Test case %s re-run %d time" % (case_obj.__name__, i + 1))
+
         if load_global_setting(PERF_SETTING) == 'yes':
             for case_obj in self._get_performance_cases():
                 self._execute_test_case(case_obj)
-- 
1.9.3

  reply	other threads:[~2017-06-23  5:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23  5:56 [dts] [PATCH V1 1/3] add re_run parameter xu,huilong
2017-06-23  5:56 ` xu,huilong [this message]
2017-06-23  5:56 ` [dts] [PATCH V1 3/3] update case result write function xu,huilong
2017-06-23 17:05   ` Liu, Yong
2017-06-28  5:41     ` Xu, HuilongX
2017-06-23 16:42 ` [dts] [PATCH V1 1/3] add re_run parameter Liu, Yong
2017-06-28  5:38   ` Xu, HuilongX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498197394-16220-2-git-send-email-huilongx.xu@intel.com \
    --to=huilongx.xu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).