--- /dev/null
+#!/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()