diff options
authorMarkus Lehtonen <>2016-08-15 13:38:43 +0300
committerRichard Purdie <>2016-08-25 23:03:47 +0100
commit28333b3a2d17a9d623751a6c4daa92beadb8fdb6 (patch)
parent6d9c52fe4b6c8789bb81bbc469c9f418edaef244 (diff)
oe-build-perf-test: pre-check Git repo when using --commit-results
Do a pre-check on the path that is specified with --commit-results before running any tests. The script will create and/or initialize a fresh Git repository if the given directory does not exist or if it is an empty directory. It fails if it finds a non-empty directory that is not a Git repository. (From OE-Core rev: 759357a3bdbe75a3409b9e58979ab8b45d9b6ae8) Signed-off-by: Markus Lehtonen <> Signed-off-by: Ross Burton <> Signed-off-by: Richard Purdie <>
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/oe-build-perf-test b/scripts/oe-build-perf-test
index 390e4c9519..437611c856 100755
--- a/scripts/oe-build-perf-test
+++ b/scripts/oe-build-perf-test
@@ -31,6 +31,7 @@ import oeqa.buildperf
from oeqa.buildperf import (BuildPerfTestLoader, BuildPerfTestResult,
BuildPerfTestRunner, KernelDropCaches)
from oeqa.utils.commands import runCmd
+from oeqa.utils.git import GitRepo, GitError
# Set-up logging
@@ -68,7 +69,30 @@ def pre_run_sanity_check():
if ret.status:
log.error("bitbake command not found")
return False
+ return True
+def init_git_repo(path):
+ """Check/create Git repository where to store results"""
+ path = os.path.abspath(path)
+ if os.path.isfile(path):
+ log.error("Invalid Git repo %s: path exists but is not a directory", path)
+ return False
+ if not os.path.isdir(path):
+ try:
+ os.mkdir(path)
+ except (FileNotFoundError, PermissionError) as err:
+ log.error("Failed to mkdir %s: %s", path, err)
+ return False
+ if not os.listdir(path):
+"Initializing a new Git repo at %s", path)
+ GitRepo.init(path)
+ try:
+ GitRepo(path, is_topdir=True)
+ except GitError:
+ log.error("No Git repository but a non-empty directory found at %s.\n"
+ "Please specify a Git repository, an empty directory or "
+ "a non-existing directory", path)
+ return False
return True
@@ -137,6 +161,9 @@ def main(argv=None):
if not pre_run_sanity_check():
return 1
+ if args.commit_results:
+ if not init_git_repo(args.commit_results):
+ return 1
# Check our capability to drop caches and ask pass if needed