mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 00:56:04 +00:00
[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
This commit is contained in:
parent
067c660ac9
commit
e010d1432f
52
clang/utils/analyzer/Dockerfile
Normal file
52
clang/utils/analyzer/Dockerfile
Normal file
@ -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"]
|
52
clang/utils/analyzer/entrypoint.py
Normal file
52
clang/utils/analyzer/entrypoint.py
Normal file
@ -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()
|
Loading…
x
Reference in New Issue
Block a user