summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-27 11:59:54 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-27 18:04:14 +0000
commitd8f276b2cb6636f9e089cfb09b0f614f3ee42634 (patch)
tree873f9124e0d4a92a5a25efc6cc08440f45e3aae7 /scripts/lib
parent0b188e98c8a4efd0ceb1edcb044e0d95f3077b55 (diff)
downloadpoky-d8f276b2cb6636f9e089cfb09b0f614f3ee42634.tar.gz
resulttool/store: Handle results files for multiple revisions
Currently we cant store results if the results files span multiple different build revisons. Remove this limitation by iterating. (From OE-Core rev: 4da12c00963b02508056b87ce9b972528ce3a1be) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/resulttool/store.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/scripts/lib/resulttool/store.py b/scripts/lib/resulttool/store.py
index 6744fb3c05..43e57b913c 100644
--- a/scripts/lib/resulttool/store.py
+++ b/scripts/lib/resulttool/store.py
@@ -29,7 +29,7 @@ def store(args, logger):
29 try: 29 try:
30 results = {} 30 results = {}
31 logger.info('Reading files from %s' % args.source) 31 logger.info('Reading files from %s' % args.source)
32 for root, dirs, files in os.walk(args.source): 32 for root, dirs, files in os.walk(args.source):
33 for name in files: 33 for name in files:
34 f = os.path.join(root, name) 34 f = os.path.join(root, name)
35 if name == "testresults.json": 35 if name == "testresults.json":
@@ -38,7 +38,8 @@ def store(args, logger):
38 dst = f.replace(args.source, tempdir + "/") 38 dst = f.replace(args.source, tempdir + "/")
39 os.makedirs(os.path.dirname(dst), exist_ok=True) 39 os.makedirs(os.path.dirname(dst), exist_ok=True)
40 shutil.copyfile(f, dst) 40 shutil.copyfile(f, dst)
41 resultutils.save_resultsdata(results, tempdir) 41
42 revisions = {}
42 43
43 if not results and not args.all: 44 if not results and not args.all:
44 if args.allow_empty: 45 if args.allow_empty:
@@ -47,26 +48,32 @@ def store(args, logger):
47 logger.error("No results found to store") 48 logger.error("No results found to store")
48 return 1 49 return 1
49 50
50 keywords = {'branch': None, 'commit': None, 'commit_count': None}
51
52 # Find the branch/commit/commit_count and ensure they all match 51 # Find the branch/commit/commit_count and ensure they all match
53 for suite in results: 52 for suite in results:
54 for result in results[suite]: 53 for result in results[suite]:
55 config = results[suite][result]['configuration']['LAYERS']['meta'] 54 config = results[suite][result]['configuration']['LAYERS']['meta']
56 for k in keywords: 55 revision = (config['commit'], config['branch'], str(config['commit_count']))
57 if keywords[k] is None: 56 if revision not in revisions:
58 keywords[k] = config.get(k) 57 revisions[revision] = {}
59 if config.get(k) != keywords[k]: 58 if suite not in revisions[revision]:
60 logger.error("Mismatched source commit/branch/count: %s vs %s" % (config.get(k), keywords[k])) 59 revisions[revision][suite] = {}
61 return 1 60 revisions[revision][suite] = results[suite][result]
61
62 logger.info("Found %d revisions to store" % len(revisions))
63
64 for r in revisions:
65 results = revisions[r]
66 keywords = {'commit': r[0], 'branch': r[1], "commit_count": r[2]}
67 subprocess.check_call(["find", tempdir, "!", "-path", "./.git/*", "-delete"])
68 resultutils.save_resultsdata(results, tempdir)
62 69
63 logger.info('Storing test result into git repository %s' % args.git_dir) 70 logger.info('Storing test result into git repository %s' % args.git_dir)
64 71
65 gitarchive.gitarchive(tempdir, args.git_dir, False, False, 72 gitarchive.gitarchive(tempdir, args.git_dir, False, False,
66 "Results of {branch}:{commit}", "branch: {branch}\ncommit: {commit}", "{branch}", 73 "Results of {branch}:{commit}", "branch: {branch}\ncommit: {commit}", "{branch}",
67 False, "{branch}/{commit_count}-g{commit}/{tag_number}", 74 False, "{branch}/{commit_count}-g{commit}/{tag_number}",
68 'Test run #{tag_number} of {branch}:{commit}', '', 75 'Test run #{tag_number} of {branch}:{commit}', '',
69 [], [], False, keywords, logger) 76 [], [], False, keywords, logger)
70 77
71 finally: 78 finally:
72 subprocess.check_call(["rm", "-rf", tempdir]) 79 subprocess.check_call(["rm", "-rf", tempdir])