test suite reviews and discussions
 help / color / mirror / Atom feed
From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dts] [PATCH] framework: fix multiple output instances after rerun
Date: Wed, 26 Jul 2017 21:28:09 -0400	[thread overview]
Message-ID: <1501118889-49021-1-git-send-email-yong.liu@intel.com> (raw)

The logger instance will be only create once. When rerun suite, log
instance will be copied.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/dts.py b/framework/dts.py
index 26042cf..f7ab795 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -385,6 +385,7 @@ def dts_run_suite(duts, tester, test_suites, target):
             for test_classname, test_class in get_subclasses(suite_module, TestCase):
 
                 suite_obj = test_class(duts, tester, target, suite_name)
+                suite_obj.init_log()
                 suite_obj.set_requested_cases(requested_tests)
                 suite_obj.set_check_inst(check=check_case_inst, support=support_case_inst)
                 result.nic = suite_obj.nic
diff --git a/framework/logger.py b/framework/logger.py
index 4543ce1..1018674 100644
--- a/framework/logger.py
+++ b/framework/logger.py
@@ -220,9 +220,9 @@ class DTSLOG(BaseLoggerAdapter):
         # add default log file
         fh = logging.FileHandler(self.log_path + "/" + self.dts_log)
         ch = ColorHandler()
-        self.__log_hander(fh, ch)
+        self.__log_handler(fh, ch)
 
-    def __log_hander(self, fh, ch):
+    def __log_handler(self, fh, ch):
         """
         Config stream handler and file handler.
         """
@@ -302,7 +302,7 @@ class DTSLOG(BaseLoggerAdapter):
         log_file = self.log_path + '/' + self.dts_log
         fh = logging.FileHandler(log_file)
         ch = ColorHandler()
-        self.__log_hander(fh, ch)
+        self.__log_handler(fh, ch)
 
         def set_salt(crb, start_flag):
             if LOG_NAME_SEP in crb:
@@ -345,7 +345,12 @@ class DTSLOG(BaseLoggerAdapter):
         log_file = self.log_path + '/' + suitename + '.log'
         fh = logging.FileHandler(log_file)
         ch = ColorHandler()
-        self.__log_hander(fh, ch)
+
+        # exit first
+        self.logger_exit()
+
+        # then add handler
+        self.__log_handler(fh, ch)
 
         if crb == 'dut':
             self.info_lvl = logging.SUITE_DUT_CMD
diff --git a/framework/test_case.py b/framework/test_case.py
index fec17a5..8cddfde 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -56,10 +56,6 @@ class TestCase(object):
         self.tester = tester
         self.target = target
 
-        # get log handler
-        class_name = self.__class__.__name__
-        self.logger = getLogger(class_name)
-        self.logger.config_suite(class_name)
         # local variable
         self._requested_tests = None
         self.drivername = load_global_setting(HOST_DRIVER_SETTING)
@@ -122,6 +118,12 @@ class TestCase(object):
         # create rst format report for this suite
         self._rst_obj = RstReport('rst_report', target, self.nic, self.suite_name, self._enable_perf)
 
+    def init_log(self):
+        # get log handler
+        class_name = self.__class__.__name__
+        self.logger = getLogger(class_name)
+        self.logger.config_suite(class_name)
+
     def _check_and_reconnect(self, crb=None):
         try:
             result = crb.session.check_available()
@@ -336,7 +338,7 @@ class TestCase(object):
         if load_global_setting(FUNC_SETTING) == 'yes':
             for case_obj in self._get_functional_cases():
                 for i in range(self.tester.re_run_time + 1):
-                    ret = self.execute_test_case(case_obj):
+                    ret = self.execute_test_case(case_obj)
 
                     if ret is False:
                         for dutobj in self.duts:
-- 
1.9.3

                 reply	other threads:[~2017-07-27  1:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1501118889-49021-1-git-send-email-yong.liu@intel.com \
    --to=yong.liu@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).