test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH 1/1] framework: add a new subtitle paramater
@ 2019-05-03 12:13 Rami Rosen
  2019-05-13  7:49 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: Rami Rosen @ 2019-05-03 12:13 UTC (permalink / raw)
  To: dts; +Cc: Rami Rosen

Add a new subtitle paramater to main. There are use cases when we want 
to add specific details to the rst report, for example, FW version, 
name of the relevant project, setup details, etc. This patch provides this 
ability. With this patch, you can run, for exampe:

./dts -s --config-file=execution.cfg --subtitle=FW_1.8.0

to add FW_1.8.0 in the rst report. 

Signed-off-by: Rami Rosen <ramirose@gmail.com>
---
 framework/dts.py       | 11 ++++++-----
 framework/main.py      |  5 ++++-
 framework/rst.py       |  5 +++++
 framework/test_case.py |  8 ++++++++
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/framework/dts.py b/framework/dts.py
index 19a473d..c622e19 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -351,7 +351,7 @@ def dts_run_prerequisties(duts, tester, pkgName, patch, dts_commands, serializer
         return False
 
 
-def dts_run_target(duts, tester, targets, test_suites):
+def dts_run_target(duts, tester, targets, test_suites, subtitle):
     """
     Run each target in execution targets.
     """
@@ -378,7 +378,7 @@ def dts_run_target(duts, tester, targets, test_suites):
             result.add_failed_target(result.dut, target, str(ex))
             continue
 
-        dts_run_suite(duts, tester, test_suites, target)
+        dts_run_suite(duts, tester, test_suites, target, subtitle)
 
     tester.restore_interfaces()
 
@@ -388,7 +388,7 @@ def dts_run_target(duts, tester, targets, test_suites):
         dutobj.restore_modules()
 
 
-def dts_run_suite(duts, tester, test_suites, target):
+def dts_run_suite(duts, tester, test_suites, target, subtitle):
     """
     Run each suite in test suite list.
     """
@@ -402,6 +402,7 @@ def dts_run_suite(duts, tester, test_suites, target):
                 suite_obj.init_log()
                 suite_obj.set_requested_cases(requested_tests)
                 suite_obj.set_check_inst(check=check_case_inst)
+                suite_obj.set_subtitle(subtitle)
                 result.nic = suite_obj.nic
 
                 dts_log_testsuite(duts, tester, suite_obj, log_handler, test_classname)
@@ -439,7 +440,7 @@ def dts_run_suite(duts, tester, test_suites, target):
 def run_all(config_file, pkgName, git, patch, skip_setup,
             read_cache, project, suite_dir, test_cases,
             base_dir, output_dir, verbose, virttype, debug,
-            debugcase, re_run, commands):
+            debugcase, re_run, commands, subtitle):
     """
     Main process of DTS, it will run all test suites in the config file.
     """
@@ -560,7 +561,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
             dts_crbs_exit(duts, tester)
             continue
 
-        dts_run_target(duts, tester, targets, test_suites)
+        dts_run_target(duts, tester, targets, test_suites, subtitle)
 
         dts_crbs_exit(duts, tester)
 
diff --git a/framework/main.py b/framework/main.py
index 0aa54fd..b91a889 100755
--- a/framework/main.py
+++ b/framework/main.py
@@ -143,6 +143,9 @@ parser.add_argument('--commands',
                     help='run command on tester or dut. The command format is ' +
                     '[commands]:dut|tester:pre-init|post-init:check|ignore')
 
+parser.add_argument('--subtitle',
+                    help='add a subtitle to the rst report')
+
 args = parser.parse_args()
 
 
@@ -159,4 +162,4 @@ dts.run_all(args.config_file, args.snapshot, args.git,
             args.patch, args.skip_setup, args.read_cache,
             args.project, args.suite_dir, args.test_cases,
             args.dir, args.output, args.verbose,args.virttype,
-            args.debug, args.debugcase, args.re_run, args.commands)
+            args.debug, args.debugcase, args.re_run, args.commands, args.subtitle)
diff --git a/framework/rst.py b/framework/rst.py
index ef1825c..2f36ab1 100644
--- a/framework/rst.py
+++ b/framework/rst.py
@@ -107,6 +107,11 @@ class RstReport(object):
             f.write(line)
             f.write('-' * len(line) + '\n')
 
+    def write_subtitle(self):
+	if self._subtitle is not None:
+	    with open(self.rstName, "a") as f:
+		f.write("%s\n" % self._subtitle)
+
     def write_annex_title(self, text):
         """
         write annex to test case title Annex to #Name#
diff --git a/framework/test_case.py b/framework/test_case.py
index 7402631..27d236b 100644
--- a/framework/test_case.py
+++ b/framework/test_case.py
@@ -58,6 +58,7 @@ class TestCase(object):
 
         # local variable
         self._requested_tests = None
+        self._subtitle 		    = None
 
         # check session and reconnect if possible
         for dutobj in self.duts:
@@ -219,6 +220,13 @@ class TestCase(object):
         """
         self._requested_tests = case_list
 
+    def set_subtitle(self, subtitle):
+        """
+        Pass down subtitle for Rst report
+        """
+	self._rst_obj._subtitle = subtitle
+	self._rst_obj.write_subtitle()
+
     def _get_test_cases(self, test_name_regex):
         """
         Return case list which name matched regex.
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH 1/1] framework: add a new subtitle paramater
  2019-05-03 12:13 [dts] [PATCH 1/1] framework: add a new subtitle paramater Rami Rosen
@ 2019-05-13  7:49 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2019-05-13  7:49 UTC (permalink / raw)
  To: Rami Rosen, dts

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Rami Rosen
> Sent: Friday, May 3, 2019 8:13 PM
> To: dts@dpdk.org
> Cc: Rami Rosen <ramirose@gmail.com>
> Subject: [dts] [PATCH 1/1] framework: add a new subtitle paramater
> 
> Add a new subtitle paramater to main. There are use cases when we want to
> add specific details to the rst report, for example, FW version, name of the
> relevant project, setup details, etc. This patch provides this ability. With this
> patch, you can run, for exampe:
> 
> ./dts -s --config-file=execution.cfg --subtitle=FW_1.8.0
> 
> to add FW_1.8.0 in the rst report.
> 
> Signed-off-by: Rami Rosen <ramirose@gmail.com>
> ---
>  framework/dts.py       | 11 ++++++-----
>  framework/main.py      |  5 ++++-
>  framework/rst.py       |  5 +++++
>  framework/test_case.py |  8 ++++++++
>  4 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/framework/dts.py b/framework/dts.py index 19a473d..c622e19
> 100644
> --- a/framework/dts.py
> +++ b/framework/dts.py
> @@ -351,7 +351,7 @@ def dts_run_prerequisties(duts, tester, pkgName,
> patch, dts_commands, serializer
>          return False
> 
> 
> -def dts_run_target(duts, tester, targets, test_suites):
> +def dts_run_target(duts, tester, targets, test_suites, subtitle):
>      """
>      Run each target in execution targets.
>      """
> @@ -378,7 +378,7 @@ def dts_run_target(duts, tester, targets, test_suites):
>              result.add_failed_target(result.dut, target, str(ex))
>              continue
> 
> -        dts_run_suite(duts, tester, test_suites, target)
> +        dts_run_suite(duts, tester, test_suites, target, subtitle)
> 
>      tester.restore_interfaces()
> 
> @@ -388,7 +388,7 @@ def dts_run_target(duts, tester, targets, test_suites):
>          dutobj.restore_modules()
> 
> 
> -def dts_run_suite(duts, tester, test_suites, target):
> +def dts_run_suite(duts, tester, test_suites, target, subtitle):
>      """
>      Run each suite in test suite list.
>      """
> @@ -402,6 +402,7 @@ def dts_run_suite(duts, tester, test_suites, target):
>                  suite_obj.init_log()
>                  suite_obj.set_requested_cases(requested_tests)
>                  suite_obj.set_check_inst(check=check_case_inst)
> +                suite_obj.set_subtitle(subtitle)
>                  result.nic = suite_obj.nic
> 
>                  dts_log_testsuite(duts, tester, suite_obj, log_handler,
> test_classname) @@ -439,7 +440,7 @@ def dts_run_suite(duts, tester,
> test_suites, target):
>  def run_all(config_file, pkgName, git, patch, skip_setup,
>              read_cache, project, suite_dir, test_cases,
>              base_dir, output_dir, verbose, virttype, debug,
> -            debugcase, re_run, commands):
> +            debugcase, re_run, commands, subtitle):
>      """
>      Main process of DTS, it will run all test suites in the config file.
>      """
> @@ -560,7 +561,7 @@ def run_all(config_file, pkgName, git, patch,
> skip_setup,
>              dts_crbs_exit(duts, tester)
>              continue
> 
> -        dts_run_target(duts, tester, targets, test_suites)
> +        dts_run_target(duts, tester, targets, test_suites, subtitle)
> 
>          dts_crbs_exit(duts, tester)
> 
> diff --git a/framework/main.py b/framework/main.py index
> 0aa54fd..b91a889 100755
> --- a/framework/main.py
> +++ b/framework/main.py
> @@ -143,6 +143,9 @@ parser.add_argument('--commands',
>                      help='run command on tester or dut. The command format is ' +
>                      '[commands]:dut|tester:pre-init|post-init:check|ignore')
> 
> +parser.add_argument('--subtitle',
> +                    help='add a subtitle to the rst report')
> +
>  args = parser.parse_args()
> 
> 
> @@ -159,4 +162,4 @@ dts.run_all(args.config_file, args.snapshot, args.git,
>              args.patch, args.skip_setup, args.read_cache,
>              args.project, args.suite_dir, args.test_cases,
>              args.dir, args.output, args.verbose,args.virttype,
> -            args.debug, args.debugcase, args.re_run, args.commands)
> +            args.debug, args.debugcase, args.re_run, args.commands,
> + args.subtitle)
> diff --git a/framework/rst.py b/framework/rst.py index ef1825c..2f36ab1
> 100644
> --- a/framework/rst.py
> +++ b/framework/rst.py
> @@ -107,6 +107,11 @@ class RstReport(object):
>              f.write(line)
>              f.write('-' * len(line) + '\n')
> 
> +    def write_subtitle(self):
> +	if self._subtitle is not None:
> +	    with open(self.rstName, "a") as f:
> +		f.write("%s\n" % self._subtitle)
> +
>      def write_annex_title(self, text):
>          """
>          write annex to test case title Annex to #Name# diff --git
> a/framework/test_case.py b/framework/test_case.py index
> 7402631..27d236b 100644
> --- a/framework/test_case.py
> +++ b/framework/test_case.py
> @@ -58,6 +58,7 @@ class TestCase(object):
> 
>          # local variable
>          self._requested_tests = None
> +        self._subtitle 		    = None
> 
>          # check session and reconnect if possible
>          for dutobj in self.duts:
> @@ -219,6 +220,13 @@ class TestCase(object):
>          """
>          self._requested_tests = case_list
> 
> +    def set_subtitle(self, subtitle):
> +        """
> +        Pass down subtitle for Rst report
> +        """
> +	self._rst_obj._subtitle = subtitle
> +	self._rst_obj.write_subtitle()
> +
>      def _get_test_cases(self, test_name_regex):
>          """
>          Return case list which name matched regex.
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-13  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 12:13 [dts] [PATCH 1/1] framework: add a new subtitle paramater Rami Rosen
2019-05-13  7:49 ` Tu, Lijuan

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).