[vlc-devel] [PATCH 1/2] tests: interrupt: Fix win32 build

Rémi Denis-Courmont remi at remlab.net
Thu Mar 9 14:16:08 CET 2017


On March 9, 2017 12:06:55 PM GMT+02:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> wrote:
>On Wed, Mar 8, 2017, at 06:19 PM, Rémi Denis-Courmont wrote:
>> Le keskiviikkona 8. maaliskuuta 2017, 10.57.16 EET Hugo
>Beauzée-Luyssen a 
>> écrit :
>> > ---
>> >  src/test/interrupt.c | 18 +++++++++++++++++-
>> >  1 file changed, 17 insertions(+), 1 deletion(-)
>> > 
>> > diff --git a/src/test/interrupt.c b/src/test/interrupt.c
>> > index d58b52160c..463ee9dfb6 100644
>> > --- a/src/test/interrupt.c
>> > +++ b/src/test/interrupt.c
>> > @@ -104,17 +104,32 @@ static void *test_thread_cancel(void *data)
>> >      /* Test context clearing on cancellation */
>> >      vlc_interrupt_set(ctx);
>> >      for (;;)
>> > +    {
>> > +#ifndef _WIN32
>> >          pause();
>> > +#else
>> > +        SleepEx(INFINITE, true);
>> > +        vlc_testcancel();
>> > +#endif
>> > +    }
>> > 
>> >      vlc_assert_unreachable();
>> >  }
>> > 
>> > +static void cancel_tests(void* data)
>> > +{
>> > +    (void)data;
>> > +    assert(!"test timedout");
>> > +}
>> > +
>> >  int main (void)
>> >  {
>> >      vlc_interrupt_t *ctx;
>> >      vlc_thread_t th;
>> > +    vlc_timer_t timer;
>> > 
>> > -    alarm(2);
>> > +    assert(vlc_timer_create(&timer, cancel_tests, NULL) == 0);
>> > +    vlc_timer_schedule(timer, false, 2 * CLOCK_FREQ, 0);
>> > 
>> >      ctx = vlc_interrupt_create();
>> >      assert(ctx != NULL);
>> > @@ -139,6 +154,7 @@ int main (void)
>> >      vlc_cancel(th);
>> >      vlc_join(th, NULL);
>> > 
>> > +    vlc_timer_destroy(timer);
>> >      vlc_interrupt_destroy(ctx);
>> >      vlc_sem_destroy(&sem);
>> >      return 0;
>> 
>> We have plenty of users for alarm() and I certainly hope the plan is
>to
>> not 
>> copy-paste the same over and over, regardless of the merits of the 
>> implementation.
>> 
>> Also depending on VLC timer before running the timer test does not
>sound
>> like 
>> such a great idea.
>> 
>
>Fair enough, I was surprised there wasn't so many but that's because
>some tests are failing before we reach libvlc tests, and I forgot to
>check.
>I'm not sure having a compat function for tests is a good idea, I guess
>we could reimplement a minimal wrapper around it in a common header,
>kind of like test/libvlc/test.h
>I agree that we should run the timer test before though (however, my
>attempts at reordering the order of automake tests failed miserably so
>far) as I don't see the point in writing code that would essentially be
>the same as vlc_timer, maybe a bit easier, but still quite similar, and
>untested.
>
>Regards,
>
>
>-- 
>  Hugo Beauzée-Luyssen
>  hugo at beauzee.fr
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

I prefer to keep alarm(). It is much harder to break with a stupid mistake than VLC timers seen as it does not rely on threads and memory. The whole point is as a safety mechanism afterall.
-- 
Rémi Denis-Courmont


More information about the vlc-devel mailing list