summaryrefslogtreecommitdiff
path: root/tsp/scripts
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2016-08-12 11:05:09 (GMT)
committerAleksander Mistewicz <a.mistewicz@samsung.com>2016-12-06 15:37:14 (GMT)
commitd381a234e5645db39205f041000c6d4125db2b55 (patch)
tree05249cee9d4493c1bb2b93b6069f4a99056b7b9a /tsp/scripts
parent28d5f03bd270cc8252afb7ad7c8492ecf1044602 (diff)
downloadmajor-d381a234e5645db39205f041000c6d4125db2b55.zip
major-d381a234e5645db39205f041000c6d4125db2b55.tar.gz
major-d381a234e5645db39205f041000c6d4125db2b55.tar.bz2
Add tsp/scripts/publish_cmp.pyrefs/changes/04/83904/11
"Unclear" is printed in case: * number of tests run is different * prerelease's result is not 'PASS', but snapshot's is "OK" is printed otherwise. Change-Id: Ic01e7652808f62e5d3c63925d1ea4326a2eeef2c Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'tsp/scripts')
-rwxr-xr-xtsp/scripts/publish_cmp.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/tsp/scripts/publish_cmp.py b/tsp/scripts/publish_cmp.py
new file mode 100755
index 0000000..15dac31
--- /dev/null
+++ b/tsp/scripts/publish_cmp.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##
+# @author Aleksander Mistewicz <a.mistewicz@samsung.com>
+
+import argparse
+import logging
+import json
+
+__version__ = "0.0.1"
+__license__ = "APACHE-2.0"
+__author__ = "Aleksander Mistewicz"
+__author_email__ = "a.mistewicz@samsung.com"
+
+USAGE = "%prog <opts> <snapshot> <prerelease>"
+
+AGENT = "%s/%s" % (__name__, __version__)
+
+def compare(snap, pre):
+ with open(snap, 'r') as snap_f:
+ snap_json = json.load(snap_f)
+
+ with open(pre, 'r') as pre_f:
+ pre_json = json.load(pre_f)
+
+ snap_tests = snap_json['tests']
+ pre_tests = pre_json['tests']
+
+ if len(snap_tests) != len(pre_tests):
+ logging.warn("Number of tests run does not match (%d %d)" % (len(snap_tests), len(pre_tests)))
+ print "Unclear"
+ return
+
+ for i in xrange(0, len(snap_tests)):
+ snap_status = snap_tests[i]['status']
+ pre_status = pre_tests[i]['status']
+ logging.info("[%s] " % pre_tests[i]['test']\
+ + "Snapshot: %s " % snap_status\
+ + "Prerelease: %s" % pre_status)
+ if pre_status != 'PASS' and snap_status != pre_status:
+ print "Unclear"
+ return
+ print "OK"
+
+def parse_arguments():
+ """parse_arguments() -> args
+
+ Parse any command-line options given returning both
+ the parsed options and arguments.
+ """
+
+ parser = argparse.ArgumentParser(description="Comparator of avocado test results in JSON format")
+
+ parser.add_argument("snap", metavar='<snap>', type=str,
+ help='Path to json format of results of test run on snapshot')
+
+ parser.add_argument("pre", metavar='<pre>', type=str,
+ help='Path to json format of results of test run on prerelease')
+
+ parser.add_argument("-l", "--log",
+ action="store", dest="loglevel",
+ help="Verbosity level")
+
+ args = parser.parse_args()
+
+ return args
+
+def main():
+ args = parse_arguments()
+ if args.loglevel:
+ numeric_level = getattr(logging, args.loglevel.upper(), None)
+ if not isinstance(numeric_level, int):
+ raise ValueError('Invalid log level: %s' % args.loglevel)
+ logging.basicConfig(format='%(asctime)s %(message)s',level=numeric_level)
+ logging.debug("Begin")
+ if args.snap and args.pre:
+ compare(args.snap, args.pre)
+ logging.debug("End")
+
+if __name__ == '__main__':
+ main()