[lttng-dev] [PATCH lttng-tools] Fix: test code assumes that child process is schedule to run before parent

Anders Wallin wallinux at gmail.com
Wed Mar 31 17:09:42 EDT 2021


Hi Julian,

Neither mine "sleep 0.1" or your version with "while [! -f ............"
are race condition free.
I suggest that we add an option to gen-ust-events to wait before the first
event is generated.
gen_kernel_test_events already have this functionality to wait before the
first event.

Something like this
static struct option long_options[] =
{
/* These options set a flag. */
{"iter", required_argument, 0, 'i'},
{"wait", required_argument, 0, 'w'},
{"sync-after-first-event", required_argument, 0, 'a'},
{"sync-before-last-event", required_argument, 0, 'b'},
{"sync-before-last-event-touch", required_argument, 0, 'c'},
{"sync-before-exit", required_argument, 0, 'd'},
{"sync-before-exit-touch", required_argument, 0, 'e'},
*+ {"sync-before-first-event", required_argument, 0, 'f'},*

{0, 0, 0, 0}
};
....

I will create one or more patches for this tomorrow

Anders Wallin


On Wed, Mar 31, 2021 at 9:25 PM Jonathan Rajotte-Julien <
jonathan.rajotte-julien at efficios.com> wrote:

> > #
> > # SPDX-License-Identifier: GPL-2.0-only
> >
> > -TEST_DESC="LTTng - Event traker test"
> > +TEST_DESC="LTTng - Event tracker test"
> >
> > CURDIR=$(dirname "$0")/
> > TESTDIR="$CURDIR/../../.."
> > @@ -42,6 +42,8 @@ function prepare_ust_app
> >
> >       $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b
> >       "$BEFORE_LAST_PATH" &
> >       CHILD_PID=$!
> > +     # voluntary context switch to start $TESTAPP_BIN
> > +     sleep 0.1
>
> A wait on the $AFTER_FIRST_PATH file would be probably more deterministic
> than a sleep here.
>
>   while [ ! -f "${AFTER_FIRST_PATH}" ]; do
>           sleep 0.1
>   done
>
> I would also expect something similar for the `prepare_kernel_app`
> function considering the same race is most probably present and simply not
> triggered by a chance of luck.
> Seems like gen-kernel-test-events does not expose the same sync
> capabilities here, please use gen-ust-events as an example of how it is
> done.
>
> Let us know how your testing goes.
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.lttng.org/pipermail/lttng-dev/attachments/20210331/e03d9f30/attachment.htm>


More information about the lttng-dev mailing list