Skip to content

Commit

Permalink
selftests/xsk: Make sure single threaded test terminates
Browse files Browse the repository at this point in the history
For single threaded poll tests call pthread_kill() from main thread so
that we are sure worker thread has finished its job and it is possible
to proceed with next test types from test suite. It was observed that on
some platforms it takes a bit longer for worker thread to exit and next
test case sees device as busy in this case.

Signed-off-by: Maciej Fijalkowski <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Magnus Karlsson <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
mfijalko authored and borkmann committed Sep 2, 2022
1 parent a693ff3 commit c29fe88
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/testing/selftests/bpf/xskxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,11 @@ static void testapp_clean_xsk_umem(struct ifobject *ifobj)
munmap(ifobj->umem->buffer, umem_sz);
}

static void handler(int signum)
{
pthread_exit(NULL);
}

static int testapp_validate_traffic_single_thread(struct test_spec *test, struct ifobject *ifobj,
enum test_type type)
{
Expand All @@ -1362,6 +1367,7 @@ static int testapp_validate_traffic_single_thread(struct test_spec *test, struct
test->ifobj_rx->shared_umem = false;
test->ifobj_tx->shared_umem = false;

signal(SIGUSR1, handler);
/* Spawn thread */
pthread_create(&t0, NULL, ifobj->func_ptr, test);

Expand All @@ -1371,6 +1377,7 @@ static int testapp_validate_traffic_single_thread(struct test_spec *test, struct
if (pthread_barrier_destroy(&barr))
exit_with_error(errno);

pthread_kill(t0, SIGUSR1);
pthread_join(t0, NULL);

if (test->total_steps == test->current_step || test->fail) {
Expand Down

0 comments on commit c29fe88

Please sign in to comment.