* [dts] [PATCH] framework: Adding JSON reporter
@ 2017-09-05 15:26 Radoslaw Biernacki
2017-09-06 2:25 ` Jianbo Liu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Radoslaw Biernacki @ 2017-09-05 15:26 UTC (permalink / raw)
To: dts; +Cc: jianbo.liu, herbert.guan, Radoslaw Biernacki
This patch adds the JSON reporter class which puts the results
into output/test_results.json file
Having JSON file format for results is usefull for CI integration.
Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
---
framework/dts.py | 5 ++++
framework/json_reporter.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
create mode 100644 framework/json_reporter.py
diff --git a/framework/dts.py b/framework/dts.py
index 931bf38..b38deb7 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -51,6 +51,7 @@ from test_case import TestCase
from test_result import Result
from stats_reporter import StatsReporter
from excel_reporter import ExcelReporter
+from json_reporter import JSONReporter
from exception import TimeoutException, ConfigParseException, VerifyFailure
from logger import getLogger
import logger
@@ -66,6 +67,7 @@ sys.setdefaultencoding('UTF8')
requested_tests = None
result = None
excel_report = None
+json_report = None
stats_report = None
log_handler = None
@@ -443,6 +445,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
global requested_tests
global result
global excel_report
+ global json_report
global stats_report
global log_handler
global check_case_inst
@@ -506,6 +509,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
# report objects
excel_report = ExcelReporter(output_dir + '/test_results.xls')
+ json_report = JSONReporter(output_dir + '/test_results.json')
stats_report = StatsReporter(output_dir + '/statistics.txt')
result = Result()
@@ -574,6 +578,7 @@ def save_all_results():
Save all result to files.
"""
excel_report.save(result)
+ json_report.save(result)
stats_report.save(result)
diff --git a/framework/json_reporter.py b/framework/json_reporter.py
new file mode 100644
index 0000000..47e6869
--- /dev/null
+++ b/framework/json_reporter.py
@@ -0,0 +1,75 @@
+# BSD LICENSE
+#
+# Copyright(c) 2017 Linaro. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import json
+import os
+
+class JSONReporter(object):
+
+ def __init__(self, filename):
+ self.filename = filename
+
+ def __scan_cases(self, result, dut, target, suite):
+ case_results = {}
+ for case in result.all_test_cases(dut, target, suite):
+ test_result = result.result_for(dut, target, suite, case)
+ case_name = '{}/{}'.format(suite,case)
+ if 'PASSED' in test_result:
+ case_results[case_name] = 'pass'
+ else:
+ case_results[case_name] = 'fail'
+ return case_results
+
+ def __scan_target(self, result, dut, target):
+ if result.is_target_failed(dut, target):
+ return {'Target failed', 'fail'}
+ case_results = {}
+ for suite in result.all_test_suites(dut, target):
+ case_results.update(self.__scan_cases(result, dut, target, suite))
+ abspath = os.path.abspath(self.filename)
+ filename = os.path.basename(abspath)
+ dirname = os.path.dirname(abspath)
+ splitname = os.path.splitext(filename)
+ extfilename = '{}/{}_{}_{}{}'.format(dirname, splitname[0], dut, target, splitname[1])
+ with open(extfilename, 'w') as outfile:
+ json.dump(case_results, outfile, indent=4, separators=(',', ': '), encoding="utf-8", sort_keys=True)
+
+ def __scan_dut(self, result, dut):
+ if result.is_dut_failed(dut):
+ return {'DUT failed', 'fail'}
+ case_results = {}
+ for target in result.all_targets(dut):
+ self.__scan_target(result, dut, target)
+
+ def save(self, result):
+ case_results = {}
+ for dut in result.all_duts():
+ self.__scan_dut(result, dut)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dts] [PATCH] framework: Adding JSON reporter
2017-09-05 15:26 [dts] [PATCH] framework: Adding JSON reporter Radoslaw Biernacki
@ 2017-09-06 2:25 ` Jianbo Liu
2017-09-06 13:28 ` Radoslaw Biernacki
2017-09-06 3:09 ` Liu, Yong
2017-09-06 17:50 ` [dts] [PATCH v2] " Radoslaw Biernacki
2 siblings, 1 reply; 7+ messages in thread
From: Jianbo Liu @ 2017-09-06 2:25 UTC (permalink / raw)
To: Radoslaw Biernacki; +Cc: dts, Herbert Guan
On 5 September 2017 at 23:26, Radoslaw Biernacki
<radoslaw.biernacki@linaro.org> wrote:
> This patch adds the JSON reporter class which puts the results
> into output/test_results.json file
> Having JSON file format for results is usefull for CI integration.
>
> Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
> ---
> framework/dts.py | 5 ++++
> framework/json_reporter.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 80 insertions(+)
> create mode 100644 framework/json_reporter.py
>
> diff --git a/framework/dts.py b/framework/dts.py
> index 931bf38..b38deb7 100644
> --- a/framework/dts.py
> +++ b/framework/dts.py
> @@ -51,6 +51,7 @@ from test_case import TestCase
> from test_result import Result
> from stats_reporter import StatsReporter
> from excel_reporter import ExcelReporter
> +from json_reporter import JSONReporter
> from exception import TimeoutException, ConfigParseException, VerifyFailure
> from logger import getLogger
> import logger
> @@ -66,6 +67,7 @@ sys.setdefaultencoding('UTF8')
> requested_tests = None
> result = None
> excel_report = None
> +json_report = None
> stats_report = None
> log_handler = None
>
> @@ -443,6 +445,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
> global requested_tests
> global result
> global excel_report
> + global json_report
> global stats_report
> global log_handler
> global check_case_inst
> @@ -506,6 +509,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
>
> # report objects
> excel_report = ExcelReporter(output_dir + '/test_results.xls')
> + json_report = JSONReporter(output_dir + '/test_results.json')
> stats_report = StatsReporter(output_dir + '/statistics.txt')
> result = Result()
>
> @@ -574,6 +578,7 @@ def save_all_results():
> Save all result to files.
> """
> excel_report.save(result)
> + json_report.save(result)
> stats_report.save(result)
>
>
> diff --git a/framework/json_reporter.py b/framework/json_reporter.py
> new file mode 100644
> index 0000000..47e6869
> --- /dev/null
> +++ b/framework/json_reporter.py
> @@ -0,0 +1,75 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2017 Linaro. All rights reserved.
> +# All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions
> +# are met:
> +#
> +# * Redistributions of source code must retain the above copyright
> +# notice, this list of conditions and the following disclaimer.
> +# * Redistributions in binary form must reproduce the above copyright
> +# notice, this list of conditions and the following disclaimer in
> +# the documentation and/or other materials provided with the
> +# distribution.
> +# * Neither the name of Intel Corporation nor the names of its
> +# contributors may be used to endorse or promote products derived
> +# from this software without specific prior written permission.
> +#
> +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> +
> +import json
> +import os
> +
> +class JSONReporter(object):
> +
> + def __init__(self, filename):
> + self.filename = filename
> +
> + def __scan_cases(self, result, dut, target, suite):
> + case_results = {}
> + for case in result.all_test_cases(dut, target, suite):
> + test_result = result.result_for(dut, target, suite, case)
> + case_name = '{}/{}'.format(suite,case)
> + if 'PASSED' in test_result:
> + case_results[case_name] = 'pass'
> + else:
> + case_results[case_name] = 'fail'
Is it reasonable to consider "N/A" or "SKIP" as fail?
> + return case_results
> +
> + def __scan_target(self, result, dut, target):
> + if result.is_target_failed(dut, target):
> + return {'Target failed', 'fail'}
> + case_results = {}
> + for suite in result.all_test_suites(dut, target):
> + case_results.update(self.__scan_cases(result, dut, target, suite))
> + abspath = os.path.abspath(self.filename)
> + filename = os.path.basename(abspath)
> + dirname = os.path.dirname(abspath)
> + splitname = os.path.splitext(filename)
> + extfilename = '{}/{}_{}_{}{}'.format(dirname, splitname[0], dut, target, splitname[1])
> + with open(extfilename, 'w') as outfile:
> + json.dump(case_results, outfile, indent=4, separators=(',', ': '), encoding="utf-8", sort_keys=True)
> +
> + def __scan_dut(self, result, dut):
> + if result.is_dut_failed(dut):
> + return {'DUT failed', 'fail'}
> + case_results = {}
> + for target in result.all_targets(dut):
> + self.__scan_target(result, dut, target)
> +
> + def save(self, result):
> + case_results = {}
> + for dut in result.all_duts():
> + self.__scan_dut(result, dut)
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dts] [PATCH] framework: Adding JSON reporter
2017-09-05 15:26 [dts] [PATCH] framework: Adding JSON reporter Radoslaw Biernacki
2017-09-06 2:25 ` Jianbo Liu
@ 2017-09-06 3:09 ` Liu, Yong
2017-09-06 13:28 ` Radoslaw Biernacki
2017-09-06 17:50 ` [dts] [PATCH v2] " Radoslaw Biernacki
2 siblings, 1 reply; 7+ messages in thread
From: Liu, Yong @ 2017-09-06 3:09 UTC (permalink / raw)
To: Radoslaw Biernacki, dts; +Cc: jianbo.liu, herbert.guan
Thanks, Radoslaw. One comment below.
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Radoslaw Biernacki
> Sent: Tuesday, September 05, 2017 11:26 PM
> To: dts@dpdk.org
> Cc: jianbo.liu@linaro.org; herbert.guan@arm.com; Radoslaw Biernacki
> <radoslaw.biernacki@linaro.org>
> Subject: [dts] [PATCH] framework: Adding JSON reporter
>
> This patch adds the JSON reporter class which puts the results
> into output/test_results.json file
> Having JSON file format for results is usefull for CI integration.
>
> Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
> ---
> framework/dts.py | 5 ++++
> framework/json_reporter.py | 75
> ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 80 insertions(+)
> create mode 100644 framework/json_reporter.py
>
> diff --git a/framework/dts.py b/framework/dts.py
> index 931bf38..b38deb7 100644
> --- a/framework/dts.py
> +++ b/framework/dts.py
> @@ -51,6 +51,7 @@ from test_case import TestCase
> from test_result import Result
> from stats_reporter import StatsReporter
> from excel_reporter import ExcelReporter
> +from json_reporter import JSONReporter
> from exception import TimeoutException, ConfigParseException,
> VerifyFailure
> from logger import getLogger
> import logger
> @@ -66,6 +67,7 @@ sys.setdefaultencoding('UTF8')
> requested_tests = None
> result = None
> excel_report = None
> +json_report = None
> stats_report = None
> log_handler = None
>
> @@ -443,6 +445,7 @@ def run_all(config_file, pkgName, git, patch,
> skip_setup,
> global requested_tests
> global result
> global excel_report
> + global json_report
> global stats_report
> global log_handler
> global check_case_inst
> @@ -506,6 +509,7 @@ def run_all(config_file, pkgName, git, patch,
> skip_setup,
>
> # report objects
> excel_report = ExcelReporter(output_dir + '/test_results.xls')
> + json_report = JSONReporter(output_dir + '/test_results.json')
> stats_report = StatsReporter(output_dir + '/statistics.txt')
> result = Result()
>
> @@ -574,6 +578,7 @@ def save_all_results():
> Save all result to files.
> """
> excel_report.save(result)
> + json_report.save(result)
> stats_report.save(result)
>
>
> diff --git a/framework/json_reporter.py b/framework/json_reporter.py
> new file mode 100644
> index 0000000..47e6869
> --- /dev/null
> +++ b/framework/json_reporter.py
> @@ -0,0 +1,75 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2017 Linaro. All rights reserved.
> +# All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions
> +# are met:
> +#
> +# * Redistributions of source code must retain the above copyright
> +# notice, this list of conditions and the following disclaimer.
> +# * Redistributions in binary form must reproduce the above copyright
> +# notice, this list of conditions and the following disclaimer in
> +# the documentation and/or other materials provided with the
> +# distribution.
> +# * Neither the name of Intel Corporation nor the names of its
> +# contributors may be used to endorse or promote products derived
> +# from this software without specific prior written permission.
> +#
> +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> +
> +import json
> +import os
> +
> +class JSONReporter(object):
> +
> + def __init__(self, filename):
> + self.filename = filename
> +
> + def __scan_cases(self, result, dut, target, suite):
> + case_results = {}
> + for case in result.all_test_cases(dut, target, suite):
> + test_result = result.result_for(dut, target, suite, case)
> + case_name = '{}/{}'.format(suite,case)
> + if 'PASSED' in test_result:
> + case_results[case_name] = 'pass'
> + else:
> + case_results[case_name] = 'fail'
> + return case_results
> +
> + def __scan_target(self, result, dut, target):
> + if result.is_target_failed(dut, target):
> + return {'Target failed', 'fail'}
> + case_results = {}
> + for suite in result.all_test_suites(dut, target):
> + case_results.update(self.__scan_cases(result, dut, target,
> suite))
> + abspath = os.path.abspath(self.filename)
> + filename = os.path.basename(abspath)
> + dirname = os.path.dirname(abspath)
> + splitname = os.path.splitext(filename)
> + extfilename = '{}/{}_{}_{}{}'.format(dirname, splitname[0], dut,
> target, splitname[1])
> + with open(extfilename, 'w') as outfile:
> + json.dump(case_results, outfile, indent=4, separators=(',', ':
> '), encoding="utf-8", sort_keys=True)
Look like multiple json report files will be created in just one execution.
This behavior is not align with excel report and may cause confusion.
If there's no special reason, please save all results into one json file.
> +
> + def __scan_dut(self, result, dut):
> + if result.is_dut_failed(dut):
> + return {'DUT failed', 'fail'}
> + case_results = {}
> + for target in result.all_targets(dut):
> + self.__scan_target(result, dut, target)
> +
> + def save(self, result):
> + case_results = {}
> + for dut in result.all_duts():
> + self.__scan_dut(result, dut)
> --
> 1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dts] [PATCH] framework: Adding JSON reporter
2017-09-06 2:25 ` Jianbo Liu
@ 2017-09-06 13:28 ` Radoslaw Biernacki
0 siblings, 0 replies; 7+ messages in thread
From: Radoslaw Biernacki @ 2017-09-06 13:28 UTC (permalink / raw)
To: Jianbo Liu; +Cc: dts, Herbert Guan
[-- Attachment #1: Type: text/plain, Size: 6283 bytes --]
This was initially for our needs.
For general usage it need to be changed so full result will be reported.
I will fix that.
On 6 September 2017 at 04:25, Jianbo Liu <jianbo.liu@linaro.org> wrote:
> On 5 September 2017 at 23:26, Radoslaw Biernacki
> <radoslaw.biernacki@linaro.org> wrote:
> > This patch adds the JSON reporter class which puts the results
> > into output/test_results.json file
> > Having JSON file format for results is usefull for CI integration.
> >
> > Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
> > ---
> > framework/dts.py | 5 ++++
> > framework/json_reporter.py | 75 ++++++++++++++++++++++++++++++
> ++++++++++++++++
> > 2 files changed, 80 insertions(+)
> > create mode 100644 framework/json_reporter.py
> >
> > diff --git a/framework/dts.py b/framework/dts.py
> > index 931bf38..b38deb7 100644
> > --- a/framework/dts.py
> > +++ b/framework/dts.py
> > @@ -51,6 +51,7 @@ from test_case import TestCase
> > from test_result import Result
> > from stats_reporter import StatsReporter
> > from excel_reporter import ExcelReporter
> > +from json_reporter import JSONReporter
> > from exception import TimeoutException, ConfigParseException,
> VerifyFailure
> > from logger import getLogger
> > import logger
> > @@ -66,6 +67,7 @@ sys.setdefaultencoding('UTF8')
> > requested_tests = None
> > result = None
> > excel_report = None
> > +json_report = None
> > stats_report = None
> > log_handler = None
> >
> > @@ -443,6 +445,7 @@ def run_all(config_file, pkgName, git, patch,
> skip_setup,
> > global requested_tests
> > global result
> > global excel_report
> > + global json_report
> > global stats_report
> > global log_handler
> > global check_case_inst
> > @@ -506,6 +509,7 @@ def run_all(config_file, pkgName, git, patch,
> skip_setup,
> >
> > # report objects
> > excel_report = ExcelReporter(output_dir + '/test_results.xls')
> > + json_report = JSONReporter(output_dir + '/test_results.json')
> > stats_report = StatsReporter(output_dir + '/statistics.txt')
> > result = Result()
> >
> > @@ -574,6 +578,7 @@ def save_all_results():
> > Save all result to files.
> > """
> > excel_report.save(result)
> > + json_report.save(result)
> > stats_report.save(result)
> >
> >
> > diff --git a/framework/json_reporter.py b/framework/json_reporter.py
> > new file mode 100644
> > index 0000000..47e6869
> > --- /dev/null
> > +++ b/framework/json_reporter.py
> > @@ -0,0 +1,75 @@
> > +# BSD LICENSE
> > +#
> > +# Copyright(c) 2017 Linaro. All rights reserved.
> > +# All rights reserved.
> > +#
> > +# Redistribution and use in source and binary forms, with or without
> > +# modification, are permitted provided that the following conditions
> > +# are met:
> > +#
> > +# * Redistributions of source code must retain the above copyright
> > +# notice, this list of conditions and the following disclaimer.
> > +# * Redistributions in binary form must reproduce the above copyright
> > +# notice, this list of conditions and the following disclaimer in
> > +# the documentation and/or other materials provided with the
> > +# distribution.
> > +# * Neither the name of Intel Corporation nor the names of its
> > +# contributors may be used to endorse or promote products derived
> > +# from this software without specific prior written permission.
> > +#
> > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> > +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> > +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> > +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> > +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> > +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> > +
> > +import json
> > +import os
> > +
> > +class JSONReporter(object):
> > +
> > + def __init__(self, filename):
> > + self.filename = filename
> > +
> > + def __scan_cases(self, result, dut, target, suite):
> > + case_results = {}
> > + for case in result.all_test_cases(dut, target, suite):
> > + test_result = result.result_for(dut, target, suite, case)
> > + case_name = '{}/{}'.format(suite,case)
> > + if 'PASSED' in test_result:
> > + case_results[case_name] = 'pass'
> > + else:
> > + case_results[case_name] = 'fail'
>
> Is it reasonable to consider "N/A" or "SKIP" as fail?
>
> > + return case_results
> > +
> > + def __scan_target(self, result, dut, target):
> > + if result.is_target_failed(dut, target):
> > + return {'Target failed', 'fail'}
> > + case_results = {}
> > + for suite in result.all_test_suites(dut, target):
> > + case_results.update(self.__scan_cases(result, dut, target,
> suite))
> > + abspath = os.path.abspath(self.filename)
> > + filename = os.path.basename(abspath)
> > + dirname = os.path.dirname(abspath)
> > + splitname = os.path.splitext(filename)
> > + extfilename = '{}/{}_{}_{}{}'.format(dirname, splitname[0],
> dut, target, splitname[1])
> > + with open(extfilename, 'w') as outfile:
> > + json.dump(case_results, outfile, indent=4, separators=(',',
> ': '), encoding="utf-8", sort_keys=True)
> > +
> > + def __scan_dut(self, result, dut):
> > + if result.is_dut_failed(dut):
> > + return {'DUT failed', 'fail'}
> > + case_results = {}
> > + for target in result.all_targets(dut):
> > + self.__scan_target(result, dut, target)
> > +
> > + def save(self, result):
> > + case_results = {}
> > + for dut in result.all_duts():
> > + self.__scan_dut(result, dut)
> > --
> > 1.9.1
> >
>
[-- Attachment #2: Type: text/html, Size: 8094 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dts] [PATCH] framework: Adding JSON reporter
2017-09-06 3:09 ` Liu, Yong
@ 2017-09-06 13:28 ` Radoslaw Biernacki
0 siblings, 0 replies; 7+ messages in thread
From: Radoslaw Biernacki @ 2017-09-06 13:28 UTC (permalink / raw)
To: Liu, Yong; +Cc: dts, jianbo.liu, herbert.guan
[-- Attachment #1: Type: text/plain, Size: 6648 bytes --]
OK will do.
On 6 September 2017 at 05:09, Liu, Yong <yong.liu@intel.com> wrote:
> Thanks, Radoslaw. One comment below.
>
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Radoslaw Biernacki
> > Sent: Tuesday, September 05, 2017 11:26 PM
> > To: dts@dpdk.org
> > Cc: jianbo.liu@linaro.org; herbert.guan@arm.com; Radoslaw Biernacki
> > <radoslaw.biernacki@linaro.org>
> > Subject: [dts] [PATCH] framework: Adding JSON reporter
> >
> > This patch adds the JSON reporter class which puts the results
> > into output/test_results.json file
> > Having JSON file format for results is usefull for CI integration.
> >
> > Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
> > ---
> > framework/dts.py | 5 ++++
> > framework/json_reporter.py | 75
> > ++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 80 insertions(+)
> > create mode 100644 framework/json_reporter.py
> >
> > diff --git a/framework/dts.py b/framework/dts.py
> > index 931bf38..b38deb7 100644
> > --- a/framework/dts.py
> > +++ b/framework/dts.py
> > @@ -51,6 +51,7 @@ from test_case import TestCase
> > from test_result import Result
> > from stats_reporter import StatsReporter
> > from excel_reporter import ExcelReporter
> > +from json_reporter import JSONReporter
> > from exception import TimeoutException, ConfigParseException,
> > VerifyFailure
> > from logger import getLogger
> > import logger
> > @@ -66,6 +67,7 @@ sys.setdefaultencoding('UTF8')
> > requested_tests = None
> > result = None
> > excel_report = None
> > +json_report = None
> > stats_report = None
> > log_handler = None
> >
> > @@ -443,6 +445,7 @@ def run_all(config_file, pkgName, git, patch,
> > skip_setup,
> > global requested_tests
> > global result
> > global excel_report
> > + global json_report
> > global stats_report
> > global log_handler
> > global check_case_inst
> > @@ -506,6 +509,7 @@ def run_all(config_file, pkgName, git, patch,
> > skip_setup,
> >
> > # report objects
> > excel_report = ExcelReporter(output_dir + '/test_results.xls')
> > + json_report = JSONReporter(output_dir + '/test_results.json')
> > stats_report = StatsReporter(output_dir + '/statistics.txt')
> > result = Result()
> >
> > @@ -574,6 +578,7 @@ def save_all_results():
> > Save all result to files.
> > """
> > excel_report.save(result)
> > + json_report.save(result)
> > stats_report.save(result)
> >
> >
> > diff --git a/framework/json_reporter.py b/framework/json_reporter.py
> > new file mode 100644
> > index 0000000..47e6869
> > --- /dev/null
> > +++ b/framework/json_reporter.py
> > @@ -0,0 +1,75 @@
> > +# BSD LICENSE
> > +#
> > +# Copyright(c) 2017 Linaro. All rights reserved.
> > +# All rights reserved.
> > +#
> > +# Redistribution and use in source and binary forms, with or without
> > +# modification, are permitted provided that the following conditions
> > +# are met:
> > +#
> > +# * Redistributions of source code must retain the above copyright
> > +# notice, this list of conditions and the following disclaimer.
> > +# * Redistributions in binary form must reproduce the above copyright
> > +# notice, this list of conditions and the following disclaimer in
> > +# the documentation and/or other materials provided with the
> > +# distribution.
> > +# * Neither the name of Intel Corporation nor the names of its
> > +# contributors may be used to endorse or promote products derived
> > +# from this software without specific prior written permission.
> > +#
> > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> > +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> > +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> > +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> > +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> > +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> > +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> > +
> > +import json
> > +import os
> > +
> > +class JSONReporter(object):
> > +
> > + def __init__(self, filename):
> > + self.filename = filename
> > +
> > + def __scan_cases(self, result, dut, target, suite):
> > + case_results = {}
> > + for case in result.all_test_cases(dut, target, suite):
> > + test_result = result.result_for(dut, target, suite, case)
> > + case_name = '{}/{}'.format(suite,case)
> > + if 'PASSED' in test_result:
> > + case_results[case_name] = 'pass'
> > + else:
> > + case_results[case_name] = 'fail'
> > + return case_results
> > +
> > + def __scan_target(self, result, dut, target):
> > + if result.is_target_failed(dut, target):
> > + return {'Target failed', 'fail'}
> > + case_results = {}
> > + for suite in result.all_test_suites(dut, target):
> > + case_results.update(self.__scan_cases(result, dut, target,
> > suite))
> > + abspath = os.path.abspath(self.filename)
> > + filename = os.path.basename(abspath)
> > + dirname = os.path.dirname(abspath)
> > + splitname = os.path.splitext(filename)
> > + extfilename = '{}/{}_{}_{}{}'.format(dirname, splitname[0],
> dut,
> > target, splitname[1])
> > + with open(extfilename, 'w') as outfile:
> > + json.dump(case_results, outfile, indent=4, separators=(',',
> ':
> > '), encoding="utf-8", sort_keys=True)
>
> Look like multiple json report files will be created in just one execution.
> This behavior is not align with excel report and may cause confusion.
> If there's no special reason, please save all results into one json file.
>
> > +
> > + def __scan_dut(self, result, dut):
> > + if result.is_dut_failed(dut):
> > + return {'DUT failed', 'fail'}
> > + case_results = {}
> > + for target in result.all_targets(dut):
> > + self.__scan_target(result, dut, target)
> > +
> > + def save(self, result):
> > + case_results = {}
> > + for dut in result.all_duts():
> > + self.__scan_dut(result, dut)
> > --
> > 1.9.1
>
>
[-- Attachment #2: Type: text/html, Size: 8701 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dts] [PATCH v2] framework: Adding JSON reporter
2017-09-05 15:26 [dts] [PATCH] framework: Adding JSON reporter Radoslaw Biernacki
2017-09-06 2:25 ` Jianbo Liu
2017-09-06 3:09 ` Liu, Yong
@ 2017-09-06 17:50 ` Radoslaw Biernacki
2017-09-07 10:54 ` Liu, Yong
2 siblings, 1 reply; 7+ messages in thread
From: Radoslaw Biernacki @ 2017-09-06 17:50 UTC (permalink / raw)
To: dts, yong.liu; +Cc: jianbo.liu, herbert.guan, Radoslaw Biernacki
This patch adds the JSON reporter class which puts the results
into output/test_results.json file
Having JSON file format for results is usefull for CI integration.
v2:
- results from all DUT's and targets are now stored in single JSON file
- "N/A" and "BLOCKED" are also used as test result
Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
---
framework/dts.py | 5 +++
framework/json_reporter.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+)
create mode 100644 framework/json_reporter.py
diff --git a/framework/dts.py b/framework/dts.py
index 931bf38..b38deb7 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -51,6 +51,7 @@ from test_case import TestCase
from test_result import Result
from stats_reporter import StatsReporter
from excel_reporter import ExcelReporter
+from json_reporter import JSONReporter
from exception import TimeoutException, ConfigParseException, VerifyFailure
from logger import getLogger
import logger
@@ -66,6 +67,7 @@ sys.setdefaultencoding('UTF8')
requested_tests = None
result = None
excel_report = None
+json_report = None
stats_report = None
log_handler = None
@@ -443,6 +445,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
global requested_tests
global result
global excel_report
+ global json_report
global stats_report
global log_handler
global check_case_inst
@@ -506,6 +509,7 @@ def run_all(config_file, pkgName, git, patch, skip_setup,
# report objects
excel_report = ExcelReporter(output_dir + '/test_results.xls')
+ json_report = JSONReporter(output_dir + '/test_results.json')
stats_report = StatsReporter(output_dir + '/statistics.txt')
result = Result()
@@ -574,6 +578,7 @@ def save_all_results():
Save all result to files.
"""
excel_report.save(result)
+ json_report.save(result)
stats_report.save(result)
diff --git a/framework/json_reporter.py b/framework/json_reporter.py
new file mode 100644
index 0000000..80b6b7e
--- /dev/null
+++ b/framework/json_reporter.py
@@ -0,0 +1,76 @@
+# BSD LICENSE
+#
+# Copyright(c) 2017 Linaro. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import json
+
+class JSONReporter(object):
+
+ def __init__(self, filename):
+ self.filename = filename
+
+ def __scan_cases(self, result, dut, target, suite):
+ case_results = {}
+ for case in result.all_test_cases(dut, target, suite):
+ test_result = result.result_for(dut, target, suite, case)
+ case_name = '{}/{}'.format(suite,case)
+ case_results[case_name] = test_result
+ if 'PASSED' in test_result:
+ case_results[case_name] = 'passed'
+ elif 'N/A' in test_result:
+ case_results[case_name] = 'n/a'
+ elif 'FAILED' in test_result:
+ case_results[case_name] = 'failed'
+ elif 'BLOCKED' in test_result:
+ case_results[case_name] = 'blocked'
+ return case_results
+
+ def __scan_target(self, result, dut, target):
+ if result.is_target_failed(dut, target):
+ return 'fail'
+ case_results = {}
+ for suite in result.all_test_suites(dut, target):
+ case_results.update(self.__scan_cases(result, dut, target, suite))
+ return case_results
+
+ def __scan_dut(self, result, dut):
+ if result.is_dut_failed(dut):
+ return 'fail'
+ target_map = {}
+ for target in result.all_targets(dut):
+ target_map[target] = self.__scan_target(result, dut, target)
+ return target_map
+
+ def save(self, result):
+ result_map = {}
+ for dut in result.all_duts():
+ result_map[dut] = self.__scan_dut(result, dut)
+ with open(self.filename, 'w') as outfile:
+ json.dump(result_map, outfile, indent=4, separators=(',', ': '), encoding="utf-8", sort_keys=True)
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dts] [PATCH v2] framework: Adding JSON reporter
2017-09-06 17:50 ` [dts] [PATCH v2] " Radoslaw Biernacki
@ 2017-09-07 10:54 ` Liu, Yong
0 siblings, 0 replies; 7+ messages in thread
From: Liu, Yong @ 2017-09-07 10:54 UTC (permalink / raw)
To: Radoslaw Biernacki, dts; +Cc: jianbo.liu, herbert.guan
Thanks Radoslaw, applied.
On 09/07/2017 01:50 AM, Radoslaw Biernacki wrote:
> This patch adds the JSON reporter class which puts the results
> into output/test_results.json file
> Having JSON file format for results is usefull for CI integration.
>
> v2:
> - results from all DUT's and targets are now stored in single JSON file
> - "N/A" and "BLOCKED" are also used as test result
>
> Signed-off-by: Radoslaw Biernacki<radoslaw.biernacki@linaro.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-07 2:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 15:26 [dts] [PATCH] framework: Adding JSON reporter Radoslaw Biernacki
2017-09-06 2:25 ` Jianbo Liu
2017-09-06 13:28 ` Radoslaw Biernacki
2017-09-06 3:09 ` Liu, Yong
2017-09-06 13:28 ` Radoslaw Biernacki
2017-09-06 17:50 ` [dts] [PATCH v2] " Radoslaw Biernacki
2017-09-07 10:54 ` Liu, Yong
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).