[Nut-upsdev] nut_clock_* unit test ideas
Charles Lepple
clepple at gmail.com
Tue Oct 16 12:15:25 UTC 2012
On Tue, Oct 16, 2012 at 6:34 AM, <VaclavKrpec at eaton.com> wrote:
> Hello Arnaud, Charles,
>
> regarding the nut_clock_* iface unit testing,
> I came to the following conclusion:
>
> 1/ It is IMO generally impossible to do deterministic
> unit test; the problem in question is inherently
> non-deterministic (I mean non-det. by nature).
> Justification: the main reason is that we can't
> perfectly predict the CPU time spent on computation,
> mainly because we have multi-tasking; there might
> be any number of context switches between almost
> any states, so if we measure time with us/ns precisions,
> we can't expect fitting times at that scale.
As I understand it, the more important thing to test is just whether a
timer fires in roughly the correct amount of time, rather than whether
it is precise. A tolerance of +/- 10% for times measured in seconds
should be good enough for catching obvious errors, without being
sensitive to system load.
--
- Charles Lepple
More information about the Nut-upsdev
mailing list