mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-24 10:19:07 +08:00
Add a test step to produce a minimal binary using libbpf.
This patch adds a test step to link a minimal program to libbpf library produced, making sure that the library works.
This commit is contained in:
committed by
Andrii Nakryiko
parent
70ad3e8314
commit
6bf8babb33
@@ -48,6 +48,7 @@ for phase in "${PHASES[@]}"; do
|
||||
echo -e "::endgroup::"
|
||||
;;
|
||||
RUN|RUN_CLANG|RUN_GCC10|RUN_ASAN|RUN_CLANG_ASAN|RUN_GCC10_ASAN)
|
||||
CC="cc"
|
||||
if [[ "$phase" = *"CLANG"* ]]; then
|
||||
ENV_VARS="-e CC=clang -e CXX=clang++"
|
||||
CC="clang"
|
||||
@@ -62,7 +63,7 @@ for phase in "${PHASES[@]}"; do
|
||||
CFLAGS="${CFLAGS} -fsanitize=address,undefined"
|
||||
fi
|
||||
docker_exec mkdir build install
|
||||
docker_exec ${CC:-cc} --version
|
||||
docker_exec ${CC} --version
|
||||
info "build"
|
||||
docker_exec make -j$((4*$(nproc))) CFLAGS="${CFLAGS}" -C ./src -B OBJDIR=../build
|
||||
info "ldd build/libbpf.so:"
|
||||
@@ -73,7 +74,8 @@ for phase in "${PHASES[@]}"; do
|
||||
fi
|
||||
info "install"
|
||||
docker_exec make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install
|
||||
docker_exec rm -rf build install
|
||||
info "link binary"
|
||||
docker_exec bash -c "CFLAGS=\"${CFLAGS}\" ./travis-ci/managers/test_compile.sh"
|
||||
;;
|
||||
CLEANUP)
|
||||
info "Cleanup phase"
|
||||
|
||||
14
travis-ci/managers/test_compile.sh
Executable file
14
travis-ci/managers/test_compile.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -euox pipefail
|
||||
|
||||
CFLAGS=${CFLAGS:-}
|
||||
|
||||
cat << EOF > main.c
|
||||
#include <bpf/libbpf.h>
|
||||
int main() {
|
||||
return bpf_object__open(0) < 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
# static linking
|
||||
${CC:-cc} ${CFLAGS} -o main -I./install/usr/include main.c ./build/libbpf.a -lelf -lz
|
||||
@@ -20,4 +20,4 @@ if ! ldd build/libbpf.so | grep -q libelf; then
|
||||
exit 1
|
||||
fi
|
||||
make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install
|
||||
rm -rf build install
|
||||
CFLAGS=${CFLAGS} $(dirname $0)/test_compile.sh
|
||||
|
||||
Reference in New Issue
Block a user