Skip to content

Commit

Permalink
chore: update test/vm setup
Browse files Browse the repository at this point in the history
Signed-off-by: Melissa Kilby <[email protected]>
  • Loading branch information
incertum authored and poiana committed Jun 11, 2024
1 parent 8fa129c commit d2bb674
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
5 changes: 3 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Home of falcosecurity/libs test suites. In addition, you can find more traditional unit tests in the respective subfolder of each module within the code base.

- [drivers](drivers/): run unit tests against each driver (kmod, bpf, modern_bpf)
- [e2e](e2e/): e2e libs sinsp functionality tests (Python module)
- [libscap](libscap/): libscap unit tests
- [e2e](e2e/): e2e libs sinsp functionality tests
- [vm](vm/): VM based kernel compatibility and functionality tests
- [libsinsp_e2e](libsinsp_e2e/): additional / new e2e libsinsp functionality tests (C++ module)
- [vm](vm/): VM based kernel compatibility and functionality tests using vagrant (localhost test use cases)

4 changes: 2 additions & 2 deletions test/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(UBUNTU_CONTAINER1 "vm-ubuntu2004:latest")
set(UBUNTU_CONTAINER2 "vm-ubuntu2204:latest")
set(UBUNTU_CONTAINER3 "vm-ubuntu2310:latest")
set(UBUNTU_CONTAINER3 "vm-ubuntu2404:latest")
set(DEBIANBUSTER_CONTAINER "vm-debianbuster:latest")
# TODO In case we have an equivalent upstream supported container, remove the custom modern-falco-builder
set(MODERN_FALCO_BUILDER_CONTAINER "modern-falco-builder:latest")
Expand All @@ -25,7 +25,7 @@ add_custom_target(vm-dependency-check
add_custom_target(vm-container
COMMAND time docker build -f ${CMAKE_CURRENT_SOURCE_DIR}/containers/ubuntu2004.Dockerfile -t ${UBUNTU_CONTAINER1} .;
COMMAND time docker build -f ${CMAKE_CURRENT_SOURCE_DIR}/containers/ubuntu2204.Dockerfile -t ${UBUNTU_CONTAINER2} .;
COMMAND time docker build -f ${CMAKE_CURRENT_SOURCE_DIR}/containers/ubuntu2310.Dockerfile -t ${UBUNTU_CONTAINER3} .;
COMMAND time docker build -f ${CMAKE_CURRENT_SOURCE_DIR}/containers/ubuntu2404.Dockerfile -t ${UBUNTU_CONTAINER3} .;
COMMAND time docker build -f ${CMAKE_CURRENT_SOURCE_DIR}/containers/debianbuster.Dockerfile -t ${DEBIANBUSTER_CONTAINER} .;
COMMAND time docker build -f ${CMAKE_CURRENT_SOURCE_DIR}/containers/modern-falco-builder.Dockerfile -t ${MODERN_FALCO_BUILDER_CONTAINER} .;
)
Expand Down
5 changes: 1 addition & 4 deletions test/vm/containers/debianbuster.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ARG TARGETARCH=amd64
ARG CMAKE_VERSION=3.22.5

RUN cp /etc/skel/.bashrc /root && cp /etc/skel/.profile /root
RUN echo 'deb http://deb.debian.org/debian buster-backports main' >>/etc/apt/sources.list

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -18,7 +17,6 @@ RUN apt-get update \
ca-certificates \
curl \
dkms \
dwarves/buster-backports \
gnupg2 \
gcc \
jq \
Expand All @@ -43,8 +41,7 @@ RUN apt-get update \
zstd \
gawk \
mawk \
git \
&& rm -rf /var/lib/apt/lists/*
git

RUN if [ "$TARGETARCH" = "amd64" ] ; then apt-get install -y --no-install-recommends libmpx2; fi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/library/ubuntu:23.10
FROM docker.io/library/ubuntu:24.04

LABEL maintainer="[email protected]"

Expand Down Expand Up @@ -49,18 +49,20 @@ RUN apt --fix-broken -y install && apt-get install -y \
gcc-10 \
gcc-11 \
gcc-12 \
llvm-13 \
clang-13 \
gcc-13 \
llvm-14 \
clang-14 \
llvm-15 \
clang-15 \
llvm-16 \
clang-16
clang-16 \
llvm-17 \
clang-17 \
llvm-18 \
clang-18

RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 90
RUN update-alternatives --install /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-15 90
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 90
RUN update-alternatives --install /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-16 90
RUN git clone https://github.com/libbpf/bpftool.git --branch v7.2.0 --single-branch && cd bpftool && git submodule update --init && cd src && make && make install

ENTRYPOINT ["/bin/bash", "-c"]
ENTRYPOINT ["/bin/bash", "-c"]
1 change: 1 addition & 0 deletions test/vm/kernels.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{"headers": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-5.10.9-1.el7.elrepo.x86_64.rpm"], "kernels": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-5.10.9-1.el7.elrepo.x86_64.rpm"]}
{"headers": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-5.14.15-1.el7.elrepo.x86_64.rpm"], "kernels": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-5.14.15-1.el7.elrepo.x86_64.rpm"]}
{"headers": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-6.5.8-1.el7.elrepo.x86_64.rpm"], "kernels": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-6.5.8-1.el7.elrepo.x86_64.rpm"]}
{"headers": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-6.9.3-1.el7.elrepo.x86_64.rpm"], "kernels": ["https://linux.cc.iitk.ac.in/mirror/centos/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-6.9.3-1.el7.elrepo.x86_64.rpm"]}
{"headers": ["https://kernel.ubuntu.com/mainline/v4.16.18/linux-headers-4.16.18-041618-generic_4.16.18-041618.201806252030_amd64.deb", "https://kernel.ubuntu.com/mainline/v4.16.18/linux-headers-4.16.18-041618_4.16.18-041618.201806252030_all.deb"], "kernels": ["https://kernel.ubuntu.com/mainline/v4.16.18/linux-image-unsigned-4.16.18-041618-generic_4.16.18-041618.201806252030_amd64.deb", "https://kernel.ubuntu.com/mainline/v4.16.18/linux-modules-4.16.18-041618-generic_4.16.18-041618.201806252030_amd64.deb"]}
{"headers": ["https://kernel.ubuntu.com/mainline/v4.19.296/amd64/linux-headers-4.19.296-0419296-generic_4.19.296-0419296.202310101642_amd64.deb", "https://kernel.ubuntu.com/mainline/v4.19.296/amd64/linux-headers-4.19.296-0419296_4.19.296-0419296.202310101642_all.deb"], "kernels": ["https://kernel.ubuntu.com/mainline/v4.19.296/amd64/linux-image-unsigned-4.19.296-0419296-generic_4.19.296-0419296.202310101642_amd64.deb", "https://kernel.ubuntu.com/mainline/v4.19.296/amd64/linux-modules-4.19.296-0419296-generic_4.19.296-0419296.202310101642_amd64.deb"]}
{"headers": ["https://kernel.ubuntu.com/mainline/v5.19.17/amd64/linux-headers-5.19.17-051917-generic_5.19.17-051917.202210240939_amd64.deb", "https://kernel.ubuntu.com/mainline/v5.19.17/amd64/linux-headers-5.19.17-051917_5.19.17-051917.202210240939_all.deb"], "kernels": ["https://kernel.ubuntu.com/mainline/v5.19.17/amd64/linux-image-unsigned-5.19.17-051917-generic_5.19.17-051917.202210240939_amd64.deb", "https://kernel.ubuntu.com/mainline/v5.19.17/amd64/linux-modules-5.19.17-051917-generic_5.19.17-051917.202210240939_amd64.deb"]}
Expand Down
8 changes: 4 additions & 4 deletions test/vm/scripts/compile_drivers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ if [[ ! -f ${LIBS_TAR_GZ} ]]; then
exit 1
fi

LLC="${1}"; # only needed for eBPF
CLANG="${2}"; # only needed for eBPF
export LLC="${1}"; # only needed for eBPF
export CLANG="${2}"; # only needed for eBPF
GCC="${3}"; # only needed for kmod
KMOD="${4}";
BPF="${5}";
Expand Down Expand Up @@ -70,9 +70,9 @@ for d in "${DIR_EXTRACTED_KERNEL_HEADERS_SUB_DIRS}"/*; do

if [[ "${BPF}" == *"ON"* ]]; then
printf "\n\n[STATUS] IN PROGRESS bpf ${KERNEL_UNAME_R} w/ ${CLANG_VERSION}\n\n";
"${CLANG}" --version;
${CLANG} --version;
rm -f "${LIBS_DIR}/build/driver/bpf/probe.o";
make LLC="${LLC}" CLANG="${CLANG}" \
make LLC=${LLC} CLANG=${CLANG} \
KERNELDIR=${SOURCES} -B -C "${LIBS_DIR}/build/driver/bpf" || true

if [[ -f "${LIBS_DIR}/build/driver/bpf/probe.o" ]]; then
Expand Down
8 changes: 4 additions & 4 deletions test/vm/scripts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
sem = semaphore.NewWeighted(int64(maxWorkers))
ubuntuContainer2004 = "vm-ubuntu2004:latest"
ubuntuContainer2204 = "vm-ubuntu2204:latest"
ubuntuContainer2310 = "vm-ubuntu2310:latest"
ubuntuContainer2404 = "vm-ubuntu2404:latest"
debianbusterContainer = "vm-debianbuster:latest"
)

Expand All @@ -35,14 +35,14 @@ func dockerRunCompileDriver(ctx context.Context, ver [2]string, headers string,
if verNumeric >= 11 {
dockerImage = ubuntuContainer2204
}
if verNumeric >= 15 {
dockerImage = ubuntuContainer2310
if verNumeric >= 14 {
dockerImage = ubuntuContainer2404
}
shArgs = []string{"-c", fmt.Sprintf("docker run -v %s:/vm:z -v %s:/headers:z %s \"/bin/bash /vm/scripts/compile_drivers.sh /usr/bin/llc-%d /usr/bin/clang-%d /usr/bin/gcc-%d OFF ON\"", dir, headers, dockerImage, verNumeric, verNumeric, verNumeric)}
} else if compilerType == "gcc" {
dockerImage = debianbusterContainer
if verNumeric >= 9 {
dockerImage = ubuntuContainer2310
dockerImage = ubuntuContainer2404
}
shArgs = []string{"-c", fmt.Sprintf("docker run -v %s:/vm:z -v %s:/headers:z %s \"/bin/bash /vm/scripts/compile_drivers.sh /usr/bin/llc-%d /usr/bin/clang-%d /usr/bin/gcc-%d ON OFF\"", dir, headers, dockerImage, verNumeric, verNumeric, verNumeric)}
}
Expand Down
7 changes: 4 additions & 3 deletions test/vm/scripts/vm_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ rm -rf ${BASE_DIR}/build/driver || true;
rm -rf ${BASE_DIR}/build/driver_ok || true;

# You have the option to customize the args to the Go launcher script
# -compilerVersionsClang=15
# -compilerVersionsClang=7,9,10,12,14,15,16
# -compilerVersionsClang="15"
# -compilerVersionsClang="7,8,9,10,11,12,13,14,15,16,17,18"
# -compilerVersionsGcc=""
# -compilerVersionsGcc="9,10,11,12,13"
GO111MODULE=off BASE_DIR=${BASE_DIR} bash -c 'go get golang.org/x/sync/semaphore; \
go run ${BASE_DIR}/scripts/main.go -compilerVersionsClang=7,12,14,16 -compilerVersionsGcc=5,9,11,13 \
go run ${BASE_DIR}/scripts/main.go -compilerVersionsClang="7,12,14,16,18" -compilerVersionsGcc="9,12,13" \
-dirExtractedKernelHeaders=${BASE_DIR}/build/headers_extracted/ -dir=${BASE_DIR}'

printf "\n\n[STATUS] Build scap-open userspace binary using build/libs-src.tar.gz as libs source\n\n";
Expand Down

0 comments on commit d2bb674

Please sign in to comment.