summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/buildperf/base.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index c0318a18e0..e10cbf4572 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -22,6 +22,7 @@ import traceback
22from datetime import datetime, timedelta 22from datetime import datetime, timedelta
23 23
24from oeqa.utils.commands import runCmd, get_bb_vars 24from oeqa.utils.commands import runCmd, get_bb_vars
25from oeqa.utils.git import GitError, GitRepo
25 26
26# Get logger for this module 27# Get logger for this module
27log = logging.getLogger('build-perf') 28log = logging.getLogger('build-perf')
@@ -85,10 +86,41 @@ class BuildPerfTestRunner(object):
85 if not os.path.exists(self.out_dir): 86 if not os.path.exists(self.out_dir):
86 os.makedirs(self.out_dir) 87 os.makedirs(self.out_dir)
87 88
89 # Get Git parameters
90 try:
91 self.repo = GitRepo('.')
92 except GitError:
93 self.repo = None
94 self.git_rev, self.git_branch = self.get_git_revision()
95 log.info("Using Git branch:revision %s:%s", self.git_branch,
96 self.git_rev)
97
98 def get_git_revision(self):
99 """Get git branch and revision under testing"""
100 rev = os.getenv('OE_BUILDPERFTEST_GIT_REVISION')
101 branch = os.getenv('OE_BUILDPERFTEST_GIT_BRANCH')
102 if not self.repo and (not rev or not branch):
103 log.info("The current working directory doesn't seem to be a Git "
104 "repository clone. You can specify branch and revision "
105 "used in test results with OE_BUILDPERFTEST_GIT_REVISION "
106 "and OE_BUILDPERFTEST_GIT_BRANCH environment variables")
107 else:
108 if not rev:
109 rev = self.repo.run_cmd(['rev-parse', 'HEAD'])
110 if not branch:
111 try:
112 # Strip 11 chars, i.e. 'refs/heads' from the beginning
113 branch = self.repo.run_cmd(['symbolic-ref', 'HEAD'])[11:]
114 except GitError:
115 log.debug('Currently on detached HEAD')
116 branch = None
117 return str(rev), str(branch)
88 118
89 def run_tests(self): 119 def run_tests(self):
90 """Method that actually runs the tests""" 120 """Method that actually runs the tests"""
91 self.results['schema_version'] = 1 121 self.results['schema_version'] = 1
122 self.results['git_revision'] = self.git_rev
123 self.results['git_branch'] = self.git_branch
92 self.results['tester_host'] = socket.gethostname() 124 self.results['tester_host'] = socket.gethostname()
93 start_time = datetime.utcnow() 125 start_time = datetime.utcnow()
94 self.results['start_time'] = start_time 126 self.results['start_time'] = start_time