summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/buildperf/base.py35
-rwxr-xr-xscripts/oe-build-perf-test5
2 files changed, 40 insertions, 0 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index 0e77aae07b..8f7d88cd42 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -188,6 +188,41 @@ class BuildPerfTestResult(unittest.TextTestResult):
188 fobj.write(','.join(values) + '\n') 188 fobj.write(','.join(values) + '\n')
189 189
190 190
191 def git_commit_results(self, repo_path, branch=None):
192 """Commit results into a Git repository"""
193 repo = GitRepo(repo_path, is_topdir=True)
194 if not branch:
195 branch = self.git_branch
196 log.info("Committing test results into %s %s", repo_path, branch)
197 tmp_index = os.path.join(repo_path, '.git', 'index.oe-build-perf')
198 try:
199 # Create new commit object from the new results
200 env_update = {'GIT_INDEX_FILE': tmp_index,
201 'GIT_WORK_TREE': self.out_dir}
202 repo.run_cmd('add .', env_update)
203 tree = repo.run_cmd('write-tree', env_update)
204 parent = repo.rev_parse(branch)
205 msg = "Results of {}:{}\n".format(self.git_branch, self.git_commit)
206 git_cmd = ['commit-tree', tree, '-m', msg]
207 if parent:
208 git_cmd += ['-p', parent]
209 commit = repo.run_cmd(git_cmd, env_update)
210
211 # Update branch head
212 git_cmd = ['update-ref', 'refs/heads/' + branch, commit]
213 if parent:
214 git_cmd.append(parent)
215 repo.run_cmd(git_cmd)
216
217 # Update current HEAD, if we're on branch 'branch'
218 if repo.get_current_branch() == branch:
219 log.info("Updating %s HEAD to latest commit", repo_path)
220 repo.run_cmd('reset --hard')
221 finally:
222 if os.path.exists(tmp_index):
223 os.unlink(tmp_index)
224
225
191class BuildPerfTestCase(unittest.TestCase): 226class BuildPerfTestCase(unittest.TestCase):
192 """Base class for build performance tests""" 227 """Base class for build performance tests"""
193 SYSRES = 'sysres' 228 SYSRES = 'sysres'
diff --git a/scripts/oe-build-perf-test b/scripts/oe-build-perf-test
index 21759c6786..d6ea5ce685 100755
--- a/scripts/oe-build-perf-test
+++ b/scripts/oe-build-perf-test
@@ -109,6 +109,9 @@ def parse_args(argv):
109 help="Output directory for test results") 109 help="Output directory for test results")
110 parser.add_argument('--run-tests', nargs='+', metavar='TEST', 110 parser.add_argument('--run-tests', nargs='+', metavar='TEST',
111 help="List of tests to run") 111 help="List of tests to run")
112 parser.add_argument('--commit-results', metavar='GIT_DIR',
113 type=os.path.abspath,
114 help="Commit result data to a (local) git repository")
112 115
113 return parser.parse_args(argv) 116 return parser.parse_args(argv)
114 117
@@ -158,6 +161,8 @@ def main(argv=None):
158 if result.wasSuccessful(): 161 if result.wasSuccessful():
159 if args.globalres_file: 162 if args.globalres_file:
160 result.update_globalres_file(args.globalres_file) 163 result.update_globalres_file(args.globalres_file)
164 if args.commit_results:
165 result.git_commit_results(args.commit_results)
161 return 0 166 return 0
162 167
163 return 1 168 return 1