Commit 844b13a9 authored by Bastien Curutchet (eBPF Foundation)'s avatar Bastien Curutchet (eBPF Foundation) Committed by Alexei Starovoitov
Browse files

selftests/bpf: test_xsk: Don't exit immediately if validate_traffic fails



__testapp_validate_traffic() calls exit_with_error() on failures. This
exits the program immediately. It prevents the following tests from
running and isn't compliant with the CI.

Return TEST_FAILURE instead of calling exit_with_error().
Release the resource of the 1st thread if a failure happens between its
creation and the creation of the second thread.

Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: default avatarBastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
Link: https://lore.kernel.org/r/20251031-xsk-v7-12-39fe486593a3@bootlin.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 5b2a757a
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1772,12 +1772,12 @@ static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *i
	err = test_spec_set_mtu(test, test->mtu);
	if (err) {
		ksft_print_msg("Error, could not set mtu.\n");
		exit_with_error(err);
		return TEST_FAILURE;
	}

	if (ifobj2) {
		if (pthread_barrier_init(&barr, NULL, 2))
			exit_with_error(errno);
			return TEST_FAILURE;
		pkt_stream_reset(ifobj2->xsk->pkt_stream);
	}

@@ -1791,8 +1791,12 @@ static int __testapp_validate_traffic(struct test_spec *test, struct ifobject *i

	if (ifobj2) {
		pthread_barrier_wait(&barr);
		if (pthread_barrier_destroy(&barr))
			exit_with_error(errno);
		if (pthread_barrier_destroy(&barr)) {
			pthread_kill(t0, SIGUSR1);
			clean_sockets(test, ifobj1);
			clean_umem(test, ifobj1, NULL);
			return TEST_FAILURE;
		}

		/*Spawn TX thread */
		pthread_create(&t1, NULL, ifobj2->func_ptr, test);