[analyzer] SATest: Make docker interfaces transparent

Summary:
Forward results of every command executed in docker.  The actual commands
and their error codes are more informative than python stacktraces.

Differential Revision: https://reviews.llvm.org/D81593
This commit is contained in:
Valeriy Savchenko 2020-06-05 11:47:35 +03:00
parent 8dc2802773
commit e30706af2e
2 changed files with 28 additions and 20 deletions

View File

@ -11,7 +11,7 @@ import argparse
import sys import sys
import os import os
from subprocess import check_call from subprocess import call
SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__)) SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects") PROJECTS_DIR = os.path.join(SCRIPTS_DIR, "projects")
@ -101,22 +101,25 @@ def docker(parser, args):
def docker_build_image(): def docker_build_image():
check_call("docker build --tag satest-image {}".format(SCRIPTS_DIR), sys.exit(call("docker build --tag satest-image {}".format(SCRIPTS_DIR),
shell=True) shell=True))
def docker_run(args): def docker_run(args):
check_call("docker run --rm --name satest " sys.exit(call("docker run --rm --name satest "
"-v {llvm}:/llvm-project " "-v {llvm}:/llvm-project "
"-v {build}:/build " "-v {build}:/build "
"-v {clang}:/analyzer " "-v {clang}:/analyzer "
"-v {scripts}:/scripts " "-v {scripts}:/scripts "
"-v {projects}:/projects " "-v {projects}:/projects "
"satest-image:latest {args}" "satest-image:latest {args}"
.format(llvm=args.llvm_project_dir, build=args.build_dir, .format(llvm=args.llvm_project_dir,
clang=args.clang_dir, scripts=SCRIPTS_DIR, build=args.build_dir,
projects=PROJECTS_DIR, args=' '.join(args.rest)), clang=args.clang_dir,
shell=True) scripts=SCRIPTS_DIR,
projects=PROJECTS_DIR,
args=' '.join(args.rest)),
shell=True))
def main(): def main():

View File

@ -1,9 +1,10 @@
import argparse import argparse
import os import os
import sys
from typing import List, Tuple from typing import List, Tuple
from subprocess import check_call from subprocess import call, check_call, CalledProcessError
def main(): def main():
@ -12,7 +13,7 @@ def main():
build_llvm() build_llvm()
if settings.build_llvm_only: if settings.build_llvm_only:
return return
test(rest) sys.exit(test(rest))
def parse_arguments() -> Tuple[argparse.Namespace, List[str]]: def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
@ -24,8 +25,12 @@ def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
def build_llvm() -> None: def build_llvm() -> None:
os.chdir('/build') os.chdir('/build')
cmake() try:
ninja() cmake()
ninja()
except CalledProcessError:
print("Build failed!")
sys.exit(1)
CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \ CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
@ -43,9 +48,9 @@ def ninja():
check_call("ninja install", shell=True) check_call("ninja install", shell=True)
def test(args: List[str]): def test(args: List[str]) -> int:
os.chdir("/projects") os.chdir("/projects")
check_call("/scripts/SATest.py " + " ".join(args), shell=True) return call("/scripts/SATest.py " + " ".join(args), shell=True)
if __name__ == '__main__': if __name__ == '__main__':