[LTP] [PATCH v3 3/4] tst_timer: Create interface for using multiple timers

Richard Palethorpe rpalethorpe@suse.de
Thu Aug 16 15:06:28 CEST 2018


Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> > +/**
>> > + * Encapsulates a stopwatch timer.
>> > + *
>> > + * Useful when you need to use multiple timers in a single test.
>> > + */
>> > +struct tst_timer {
>> > +	/** The POSIX clock type  */
>> > +	clockid_t clock_id;
>> > +	/** How much time can pass before tst_timer_expired_st() returns true */
>> > +	struct timespec limit;
>> > +	/** Where to start measuring time from */
>> > +	struct timespec start_time;
>> > +};
>
> On a related note, do you really think that we will need nsec resoltion
> for the timeout timers? I would say that keeping the limit as unsigned
> integer holding number of seconds would be more than enough.

I agree that seconds are appropriate for test timeouts, but it is
practically 'free' to use the struct here because of the existing API to
compare timespec structs. Also I might use this interface to time
syscalls and maybe remove some code duplication.

--
Thank you,
Richard.


More information about the ltp mailing list