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 3/4] framework: add session check function
Date: Thu,  4 Aug 2016 21:18:33 +0800	[thread overview]
Message-ID: <1470316714-14698-4-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1470316714-14698-1-git-send-email-yong.liu@intel.com>

Before running any case, suite module should check dut/tester sessions.
When sessions are not avaiable, raise exception to dts.

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

diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index edb8170..38ab36d 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -84,6 +84,19 @@ class SSHConnection(object):
     def isalive(self):
         return self.session.isalive()
 
+    def check_available(self):
+        MAGIC_STR = "DTS_CHECK_SESSION"
+        out = self.session.send_command('echo %s' % MAGIC_STR, timeout=0.1)
+        # if not avaiable, try to send ^C and check again
+        if MAGIC_STR not in out:
+            self.logger.info("Try to recover session...")
+            self.session.send_command('^C', timeout=TIMEOUT)
+            out = self.session.send_command('echo %s' % MAGIC_STR, timeout=0.1)
+            if MAGIC_STR not in out:
+                return False
+
+        return True
+
     def copy_file_from(self, src, dst=".", password=''):
         self.session.copy_file_from(src, dst, password)
 
diff --git a/framework/test_case.py b/framework/test_case.py
index b603b48..7ace75c 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -54,9 +54,15 @@ class TestCase(object):
         self.tester = tester
         self.target = target
 
+        # make sure session workable
+        for dutobj in duts:
+            self.verify(dutobj.session.check_available(), "DUT session can't work")
+            self.verify(dutobj.alt_session.check_available(), "DUT alt_session can't work")
+        self.verify(tester.session.check_available(), "Tester session can't work!!!")
+        self.verify(tester.alt_session.check_available(), "Tester alt_session can't work!!!")
+
         # get log handler
         class_name = self.__class__.__name__
-        print class_name
         self.logger = getLogger(class_name)
         self.logger.config_suite(class_name)
         # local variable
@@ -138,7 +144,7 @@ class TestCase(object):
         self._rst_obj.report(*args, **kwargs)
 
     def result_table_create(self, header):
-        self._result_table = ResultTable(self.table_header)
+        self._result_table = ResultTable(header)
         self._result_table.set_rst(self._rst_obj)
         self._result_table.set_logger(self.logger)
 
@@ -155,7 +161,7 @@ class TestCase(object):
         """
         Get all functional test cases.
         """
-        return self._get_test_cases(self, r'test_(?!perf_)')
+        return self._get_test_cases(r'test_(?!perf_)')
 
     def _get_performance_cases(self):
         """
@@ -228,14 +234,14 @@ class TestCase(object):
             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(check_case_inst.comments)
+                self._suite_result.test_case_skip(self._check_inst.comments)
                 return
 
         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(support_case_inst.comments)
+                self._suite_result.test_case_skip(self._support_inst.comments)
                 return
 
         if self._enable_perf:
@@ -267,12 +273,13 @@ class TestCase(object):
 
         except VerifyFailure as v:
             self._suite_result.test_case_failed(str(v))
-            self_rst_obj.write_result("FAIL")
+            self._rst_obj.write_result("FAIL")
             self.logger.error('Test Case %s Result FAILED: ' % (case_name) + str(v))
         except KeyboardInterrupt:
             self._suite_result.test_case_blocked("Skipped")
             self.logger.error('Test Case %s SKIPED: ' % (case_name))
-            raise KeyboardInterrupt("Stop DCTS")
+            self.tear_down()
+            raise KeyboardInterrupt("Stop DTS")
         except TimeoutException as e:
             self._rst_obj.write_result("FAIL")
             msg = str(e)
-- 
1.9.3

  parent reply	other threads:[~2016-08-04 13:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 13:18 [dts] [PATCH 0/4] enhance framework and fix some issues Marvin Liu
2016-08-04 13:18 ` [dts] [PATCH 1/4] framework dts: fix program exit when exception raised Marvin Liu
2016-08-04 13:18 ` [dts] [PATCH 2/4] framework: fix cache option not work Marvin Liu
2016-08-04 13:18 ` Marvin Liu [this message]
2016-08-04 13:18 ` [dts] [PATCH 4/4] tests: fix tope issue in suites Marvin Liu

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=1470316714-14698-4-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).