[PATCH 06/13] selftests/bpf: test_xsk: Don't exit immediately when gettimeofday fails

From: Bastien Curutchet (eBPF Foundation)
Date: Thu Mar 13 2025 - 06:49:25 EST


exit_on_error() is called when gettimeofday() fails. This exits the
program immediately and can lead to memory leaks.

Return TEST_FAILURE instead of calling exit_on_error()

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@xxxxxxxxxxx>
---
tools/testing/selftests/bpf/xskxceiver.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index e2c136fc23ce40ff485de78dac18a4d8ba73353d..5b96f6860ff98de3c6160a1b94ae865a12121382 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -1290,7 +1290,7 @@ static int receive_pkts(struct test_spec *test)

ret = gettimeofday(&tv_now, NULL);
if (ret)
- exit_with_error(errno);
+ return TEST_FAILURE;

timeradd(&tv_now, &tv_timeout, &tv_end);

@@ -1306,7 +1306,7 @@ static int receive_pkts(struct test_spec *test)

ret = gettimeofday(&tv_now, NULL);
if (ret)
- exit_with_error(errno);
+ return TEST_FAILURE;

if (timercmp(&tv_now, &tv_end, >)) {
print_msg("ERROR: [%s] Receive loop timed out\n", __func__);
@@ -1449,13 +1449,13 @@ static int wait_for_tx_completion(struct xsk_socket_info *xsk)

ret = gettimeofday(&tv_now, NULL);
if (ret)
- exit_with_error(errno);
+ return TEST_FAILURE;
timeradd(&tv_now, &tv_timeout, &tv_end);

while (xsk->outstanding_tx) {
ret = gettimeofday(&tv_now, NULL);
if (ret)
- exit_with_error(errno);
+ return TEST_FAILURE;
if (timercmp(&tv_now, &tv_end, >)) {
print_msg("ERROR: [%s] Transmission loop timed out\n", __func__);
return TEST_FAILURE;

--
2.48.1