Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): fix tests build warnings (fatal with -Werror) #2053

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/drivers_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
if: needs.paths-filter.outputs.driver == 'true' || needs.paths-filter.outputs.libscap == 'true' || needs.paths-filter.outputs.libpman == 'true'
run: |
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=On -DBUILD_DRIVER=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DBUILD_BPF=On -DBUILD_LIBSCAP_GVISOR=${{ matrix.enable_gvisor }} -DCREATE_TEST_TARGETS=On -DENABLE_LIBSCAP_TESTS=On ../
cd build && cmake -DBUILD_WARNINGS_AS_ERRORS=On -DUSE_BUNDLED_DEPS=On -DBUILD_DRIVER=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DBUILD_BPF=On -DBUILD_LIBSCAP_GVISOR=${{ matrix.enable_gvisor }} -DCREATE_TEST_TARGETS=On -DENABLE_LIBSCAP_TESTS=On ../
Andreagit97 marked this conversation as resolved.
Show resolved Hide resolved
make scap-open driver bpf libscap_test -j6

- name: Run scap-open with modern bpf 🏎️
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
if: needs.paths-filter.outputs.driver == 'true' || needs.paths-filter.outputs.libscap == 'true' || needs.paths-filter.outputs.libpman == 'true'
run: |
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=ON -DENABLE_DRIVERS_TESTS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DBUILD_BPF=True -DBUILD_LIBSCAP_GVISOR=OFF ../
cd build && cmake -DBUILD_WARNINGS_AS_ERRORS=On -DUSE_BUNDLED_DEPS=ON -DENABLE_DRIVERS_TESTS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DBUILD_BPF=True -DBUILD_LIBSCAP_GVISOR=OFF ../
make drivers_test driver bpf -j6

- name: Run drivers_test with modern bpf 🏎️
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
git clone -b $GIT_BRANCH $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git libs
cd libs
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=ON -DENABLE_DRIVERS_TESTS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DBUILD_BPF=True -DBUILD_LIBSCAP_GVISOR=OFF ../
cd build && cmake -DBUILD_WARNINGS_AS_ERRORS=On -DUSE_BUNDLED_DEPS=ON -DENABLE_DRIVERS_TESTS=ON -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DBUILD_BPF=True -DBUILD_LIBSCAP_GVISOR=OFF ../
make drivers_test driver bpf -j6
sudo ./test/drivers/drivers_test -m
rc_modern=$?
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
git config --global --add safe.directory $GITHUB_WORKSPACE
.github/install-deps.sh
mkdir -p build
cd build && cmake -DBUILD_BPF=On -DUSE_BUNDLED_DEPS=OFF -DMODERN_PROBE_INCLUDE="-I/usr/include/s390x-linux-gnu" -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DENABLE_DRIVERS_TESTS=On -DCREATE_TEST_TARGETS=On -DBUILD_LIBSCAP_GVISOR=OFF ../
cd build && cmake -DBUILD_WARNINGS_AS_ERRORS=On -DBUILD_BPF=On -DUSE_BUNDLED_DEPS=OFF -DMODERN_PROBE_INCLUDE="-I/usr/include/s390x-linux-gnu" -DBUILD_LIBSCAP_MODERN_BPF=ON -DMODERN_BPF_DEBUG_MODE=ON -DENABLE_DRIVERS_TESTS=On -DCREATE_TEST_TARGETS=On -DBUILD_LIBSCAP_GVISOR=OFF ../
KERNELDIR=/lib/modules/$(ls /lib/modules)/build make driver bpf drivers_test -j6

build-modern-bpf-skeleton:
Expand Down
22 changes: 13 additions & 9 deletions test/drivers/event_class/event_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ struct fd_poll {

struct send_data {
int syscall_num;
bool greater_snaplen;
bool null_sockaddr;
bool greater_snaplen = false;
bool null_sockaddr = false;
};

struct recv_data {
int syscall_num;
Andreagit97 marked this conversation as resolved.
Show resolved Hide resolved
bool null_sockaddr;
bool null_receiver_buffer;
bool skip_recv_phase;
bool null_sockaddr = false;
bool null_receiver_buffer = false;
bool skip_recv_phase = false;
};

enum protocol_L4 {
Expand Down Expand Up @@ -387,19 +387,23 @@ class event_test {

void client_to_server(send_data send_d, recv_data receive_d, network_config net_config);
void client_to_server_ipv4_tcp(send_data send_d,
recv_data receive_d = {.skip_recv_phase = true},
recv_data receive_d = {.syscall_num = 0,
.skip_recv_phase = true},
int32_t client_port = IP_PORT_CLIENT,
int32_t server_port = IP_PORT_SERVER);
void client_to_server_ipv4_udp(send_data send_d,
recv_data receive_d = {.skip_recv_phase = true},
recv_data receive_d = {.syscall_num = 0,
.skip_recv_phase = true},
int32_t client_port = IP_PORT_CLIENT,
int32_t server_port = IP_PORT_SERVER);
void client_to_server_ipv6_tcp(send_data send_d,
recv_data receive_d = {.skip_recv_phase = true},
recv_data receive_d = {.syscall_num = 0,
.skip_recv_phase = true},
int32_t client_port = IP_PORT_CLIENT,
int32_t server_port = IP_PORT_SERVER);
void client_to_server_ipv6_udp(send_data send_d,
recv_data receive_d = {.skip_recv_phase = true},
recv_data receive_d = {.syscall_num = 0,
.skip_recv_phase = true},
int32_t client_port = IP_PORT_CLIENT,
int32_t server_port = IP_PORT_SERVER);

Expand Down
2 changes: 2 additions & 0 deletions test/drivers/test_suites/syscall_exit_suite/execveat_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,15 @@ TEST(SyscallExit, execveatX_correct_exit) {
"2_ARGUMENT=no",
NULL};

#if defined(__s390x__) || defined(__riscv) || defined(__powerpc64__) || defined(__loongarch64)
FedeDP marked this conversation as resolved.
Show resolved Hide resolved
bool expect_truncated = true;
if(evt_test->is_kmod_engine() && getpagesize() > 4096) {
// for kmod, the size limit is actually PAGE_SIZE;
// see STR_STORAGE_SIZE macro definition in driver/capture_macro.h.
// In case PAGE_SIZE is < 4096, expect NON-truncated args/envs
expect_truncated = false;
}
#endif

int flags = 0;

Expand Down
2 changes: 1 addition & 1 deletion test/drivers/test_suites/syscall_exit_suite/sendto_x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ TEST(SyscallExit, sendtoX_ipv4_tcp_message_not_truncated_DNS_snaplen) {
// The remote port is the DNS one so the snaplen should be increased.
evt_test->client_to_server_ipv4_tcp(
send_data{.syscall_num = __NR_sendto, .greater_snaplen = true},
recv_data{.skip_recv_phase = true},
recv_data{.syscall_num = 0, .skip_recv_phase = true},
IP_PORT_CLIENT,
IP_PORT_DNS);

Expand Down
Loading