[U-Boot] [PATCH] test: dm: regmap: Fix the long test delay
Simon Glass
sjg at chromium.org
Tue Dec 11 20:37:12 UTC 2018
Hi Neil,
On Tue, 11 Dec 2018 at 01:27, Neil Armstrong <narmstrong at baylibre.com> wrote:
>
> On 10/12/2018 01:11, Simon Glass wrote:
> > At present one of the regmap tests takes 5 seconds to run since it waits
> > for a timeout. This should be handled using sandbox_timer_add_offset()
> > which advances time for test purposes.
> >
> > This requires a little change to make the regmap_read_poll_timeout()
> > testable.
> >
> > Update the macro and the test.
> >
> > Fixes: ebe3497c9c ("test: regmap: add regmap_read_poll_timeout test")
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > include/regmap.h | 14 +++++++++++++-
> > test/dm/regmap.c | 7 ++++---
> > 2 files changed, 17 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/regmap.h b/include/regmap.h
> > index a3afb72df51..8359c511d25 100644
> > --- a/include/regmap.h
> > +++ b/include/regmap.h
> > @@ -248,6 +248,8 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> > * @cond: Break condition (usually involving @val)
> > * @sleep_us: Maximum time to sleep between reads in us (0 tight-loops).
> > * @timeout_ms: Timeout in ms, 0 means never timeout
> > + * @test_add_time: Used for sandbox testing - amount of time to add after
> > + * starting the loop (0 if not testing)
> > *
> > * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
> > * error return value in case of a error read. In the two former cases,
> > @@ -256,8 +258,12 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
> > *
> > * This is modelled after the regmap_read_poll_timeout macros in linux but
> > * with millisecond timeout.
> > + *
> > + * The _test version is for sandbox testing only. Do not use this in normal
> > + * code as it advances the timer.
> > */
> > -#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_ms) \
> > +#define regmap_read_poll_timeout_test(map, addr, val, cond, sleep_us, \
> > + timeout_ms, test_add_time) \
>
> Can't we use timeout_ms directly here when in SANDBOX mode ?
>
The problem is we don't know if we are in a test, or not. The argument
tells us that. Some sandbox code might actually use this macro as part
of normal non-test code.
Regards,
Simon
More information about the U-Boot
mailing list