qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] tests/microbit-test: Check nRF51 UART functi


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v3] tests/microbit-test: Check nRF51 UART functionality
Date: Thu, 8 Nov 2018 10:50:57 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

On Mon, Nov 05, 2018 at 05:54:25PM +0000, Peter Maydell wrote:
> On 5 November 2018 at 10:45, Julia Suvorova <address@hidden> wrote:
> > Some functional tests for:
> >     Basic reception/transmittion
> >     Suspending
> >     INTEN* registers
> >
> > Based-on: <address@hidden>
> > Signed-off-by: Julia Suvorova <address@hidden>
> > ---
> > This patch was part of nRF51 UART patchset, but wasn't included in the 
> > latest
> > revision. Due to upcoming loader fixes, we need this test instead of
> > boot-serial-test, which doesn't support -device loader.
> >
> > v3:
> >     * Fix directory leak [Stefan]
> >
> >  tests/microbit-test.c | 109 +++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 107 insertions(+), 2 deletions(-)
> >
> > diff --git a/tests/microbit-test.c b/tests/microbit-test.c
> > index ab319eb466..23d343cfdd 100644
> > --- a/tests/microbit-test.c
> > +++ b/tests/microbit-test.c
> > @@ -21,9 +21,87 @@
> >  #include "hw/arm/nrf51.h"
> >  #include "hw/nvram/nrf51_nvm.h"
> >  #include "hw/gpio/nrf51_gpio.h"
> > +#include "hw/char/nrf51_uart.h"
> > +
> > +#include <sys/socket.h>
> > +#include <sys/un.h>
> >
> >  #define FLASH_SIZE          (256 * NRF51_PAGE_SIZE)
> >
> > +static bool wait_for_event(uint32_t event_addr)
> > +{
> > +    int i;
> > +
> > +    for (i = 0; i < 1000; i++) {
> > +        if (readl(event_addr) == 1) {
> > +            writel(event_addr, 0x00);
> > +            return true;
> > +        }
> > +        g_usleep(10000);
> 
> Hmm, is this the right way to wait for a device model?
> I thought there was a qtest thing to say "advance the
> time in the QEMU under test" and otherwise its internal
> clock won't tick.

This function is used to wait for QEMU device emulation to report events
triggered by external I/O (the UNIX domain socket).  I think vm_clock is
unrelated to this.

We could rely on the fact that qtest runs in the main loop where the
UNIX domain socket is also processed.  In other words, it shouldn't take
more than a small constant N of event loop iterations (i.e. qtest
commands) before the UNIX domain socket has been processed and the UART
updates its event registers.  g_usleep() seems nicer than making that
assumption though...

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]