[clang] e010d14 - [analyzer] SATest: Add initial docker infrastructure
Valeriy Savchenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 25 02:28:44 PDT 2020
Author: Valeriy Savchenko
Date: 2020-06-25T12:28:21+03:00
New Revision: e010d1432fa15cff7a6d369f5e372d995e2eba5d
URL: https://github.com/llvm/llvm-project/commit/e010d1432fa15cff7a6d369f5e372d995e2eba5d
DIFF: https://github.com/llvm/llvm-project/commit/e010d1432fa15cff7a6d369f5e372d995e2eba5d.diff
LOG: [analyzer] SATest: Add initial docker infrastructure
Summary:
Static analysis is very sensitive to environment.
OS and libraries installed can affect the results. This fact makes
it extremely hard to have a regression testing system that will
produce stable results.
For this very reason, this commit introduces a new dockerized testing
environment, so that every analyzer developer can check their changes
against previous analysis results.
Differential Revision: https://reviews.llvm.org/D81571
Added:
clang/utils/analyzer/Dockerfile
clang/utils/analyzer/entrypoint.py
Modified:
Removed:
################################################################################
diff --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile
new file mode 100644
index 000000000000..e87377c9eec1
--- /dev/null
+++ b/clang/utils/analyzer/Dockerfile
@@ -0,0 +1,52 @@
+FROM ubuntu:bionic
+
+RUN apt-get update && apt-get install -y \
+ apt-transport-https \
+ ca-certificates \
+ gnupg \
+ software-properties-common \
+ wget
+
+# newer CMake is required by LLVM
+RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
+RUN apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
+
+# test system dependencies
+RUN apt-get update && apt-get install -y \
+ git \
+ gettext \
+ python3 \
+ python3-pip \
+ cmake \
+ ninja-build
+
+# box2d dependencies
+RUN apt-get install -y \
+ libx11-dev \
+ libxrandr-dev \
+ libxinerama-dev \
+ libxcursor-dev \
+ libxi-dev
+
+# symengine dependencies
+RUN apt-get install -y \
+ libgmp10 \
+ libgmp-dev
+
+RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
+
+VOLUME /analyzer
+VOLUME /projects
+VOLUME /llvm-project
+VOLUME /build
+VOLUME /scripts
+
+ENV PATH="/analyzer/bin:${PATH}"
+
+ADD entrypoint.py /entrypoint.py
+
+# Uncomment in case of requirements
+# ADD requirements.txt /requirements.txt
+# RUN pip3 install -r /requirements.txt
+
+ENTRYPOINT ["python", "/entrypoint.py"]
diff --git a/clang/utils/analyzer/entrypoint.py b/clang/utils/analyzer/entrypoint.py
new file mode 100644
index 000000000000..3b85628a9a85
--- /dev/null
+++ b/clang/utils/analyzer/entrypoint.py
@@ -0,0 +1,52 @@
+import argparse
+import os
+
+from typing import List, Tuple
+
+from subprocess import check_call
+
+
+def main():
+ settings, rest = parse_arguments()
+ if settings.build_llvm or settings.build_llvm_only:
+ build_llvm()
+ if settings.build_llvm_only:
+ return
+ test(rest)
+
+
+def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--build-llvm', action='store_true')
+ parser.add_argument('--build-llvm-only', action='store_true')
+ return parser.parse_known_args()
+
+
+def build_llvm() -> None:
+ os.chdir('/build')
+ cmake()
+ ninja()
+
+
+CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
+ "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
+ "-DLLVM_ENABLE_PROJECTS=clang -DLLVM_BUILD_RUNTIME=OFF " \
+ "-DLLVM_ENABLE_TERMINFO=OFF -DCLANG_ENABLE_ARCMT=OFF " \
+ "-DCLANG_ENABLE_STATIC_ANALYZER=ON"
+
+
+def cmake():
+ check_call(CMAKE_COMMAND + ' /llvm-project/llvm', shell=True)
+
+
+def ninja():
+ check_call("ninja install", shell=True)
+
+
+def test(args: List[str]):
+ os.chdir("/projects")
+ check_call("/scripts/SATest.py " + " ".join(args), shell=True)
+
+
+if __name__ == '__main__':
+ main()
More information about the cfe-commits
mailing list