[PATCH 3/3] test/threads: add unit test for thread API
Dmitry Kozlyuk
dmitry.kozliuk at gmail.com
Tue Apr 12 00:52:58 CEST 2022
2022-04-09 01:56 (UTC-0700), Tyler Retzlaff:
> On Fri, Apr 08, 2022 at 05:01:45PM +0300, Dmitry Kozlyuk wrote:
> > 2022-04-01 06:29 (UTC-0700), Tyler Retzlaff:
> > [...]
> > > +static int
> > > +test_thread_affinity(void)
> > > +{
> > > + pthread_t id;
> > > + rte_thread_t thread_id;
> > > +
> > > + RTE_TEST_ASSERT(pthread_create(&id, NULL, thread_main, NULL) == 0,
> > > + "Failed to create thread");
> > > + thread_id.opaque_id = id;
> >
> > The need for this hack means that the new API is unusable in practice.
> > I think functions to get the current thread ID and to compare IDs
> > must be the part of this series to accept this unit test patch.
>
> are you proposing adding rte_thread_self and rte_thread_equals to this
> series? i'm not sure i understand how that helps? while maybe the unit
> test could be re-written in some fashion to use rte_thread_self it still
> wouldn't do much for practically using the api outside of the test.
Just rte_thread_self() should be enough; see below.
How this helps: the series becomes complete, because there is enough API to
verify it works without assumptions about implementation.
[...]
> if there is an absolute need to start using the api introduced in this
> series outside of the unit test we could as a part of the __experimental
> apis offer a function that formalizes the conversion to rte_thread_t from
> pthread_t. the function would only be kept as long as needed and removed
> when no longer necessary.
I rather meant this:
main thread:
init barrier
create thread
enter barrier (wait)
use shared thread ID
thread:
init shared thread ID from rte_thread_self()
enter barrier (will unblock)
After you will add rte_thread_create() in the subsequent series,
the same logic will suit for checking that rte_thread_self()
returns the proper ID.
More information about the dev
mailing list