[PATCH] D81572: [analyzer] SATest: Add convenience 'docker' command
Valeriy Savchenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 06:32:56 PDT 2020
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.
It provides a simpler interface for testing within docker.
This way the user is not required to no how to use `docker run` and
its options.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81572
Files:
clang/utils/analyzer/SATest.py
Index: clang/utils/analyzer/SATest.py
===================================================================
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -9,6 +9,16 @@
import argparse
import sys
+import os
+
+from subprocess import check_call
+
+SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
+PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
+DEFAULT_LLVM_DIR = os.path.realpath(os.path.join(SCRIPTS_DIR,
+ os.path.pardir,
+ os.path.pardir,
+ os.path.pardir))
def add(parser, args):
@@ -78,6 +88,37 @@
SATestUpdateDiffs.update_reference_results(project)
+def docker(parser, args):
+ if len(args.rest) > 0:
+ if args.rest[0] != "--":
+ parser.error("REST arguments should start with '--'")
+ args.rest = args.rest[1:]
+
+ if args.build_image:
+ docker_build_image()
+ else:
+ docker_run(args)
+
+
+def docker_build_image():
+ check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
+ shell=True)
+
+
+def docker_run(args):
+ check_call("docker run --rm --name satest "
+ "-v {llvm}:/llvm-project "
+ "-v {build}:/build "
+ "-v {clang}:/analyzer "
+ "-v {scripts}:/scripts "
+ "-v {projects}:/projects "
+ "satest-image:latest {args}"
+ .format(llvm=args.llvm_project_dir, build=args.build_dir,
+ clang=args.clang_dir, scripts=SCRIPTS_DIR,
+ projects=PROJECTS_DIR, args=' '.join(args.rest)),
+ shell=True)
+
+
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
@@ -180,6 +221,27 @@
# TODO: add option to decide whether we should use git
upd_parser.set_defaults(func=update)
+ # docker subcommand
+ dock_parser = subparsers.add_parser(
+ "docker",
+ help="Run regression system in the docker.")
+
+ dock_parser.add_argument("--build-image", action="store_true",
+ help="Build docker image for running tests.")
+ dock_parser.add_argument("--llvm-project-dir", action="store",
+ default=DEFAULT_LLVM_DIR,
+ help="Path to LLVM source code. Defaults "
+ "to the repo where this script is located. ")
+ dock_parser.add_argument("--build-dir", action="store", default="",
+ help="Path to a directory where docker should "
+ "build LLVM code.")
+ dock_parser.add_argument("--clang-dir", action="store", default="",
+ help="Path to find/install LLVM installation.")
+ dock_parser.add_argument("rest", nargs=argparse.REMAINDER, default=[],
+ help="Additionall args that will be forwarded "
+ "to the docker's entrypoint.")
+ dock_parser.set_defaults(func=docker)
+
args = parser.parse_args()
args.func(parser, args)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81572.269827.patch
Type: text/x-patch
Size: 3206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200610/9c9debb7/attachment.bin>
More information about the cfe-commits
mailing list