qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 10/13] tests/microbit-test: Add Tests for nRF


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v4 10/13] tests/microbit-test: Add Tests for nRF51 GPIO
Date: Mon, 5 Nov 2018 16:54:16 +0000

On 2 November 2018 at 17:07, Steffen Görtz <address@hidden> wrote:
> The test suite for the nRF51 GPIO peripheral for now
> only tests initial state. Additionally a set of
> tests testing an implementation detail of the model
> are included.
>
> Signed-off-by: Steffen Görtz <address@hidden>
> Reviewed-by: Stefan Hajnoczi <address@hidden>
> ---
>  tests/microbit-test.c | 137 ++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 131 insertions(+), 6 deletions(-)
>
> diff --git a/tests/microbit-test.c b/tests/microbit-test.c
> index 743f831466..acdb9d1c02 100644
> --- a/tests/microbit-test.c
> +++ b/tests/microbit-test.c
> @@ -20,14 +20,17 @@
>
>  #include "hw/arm/nrf51.h"
>  #include "hw/nvram/nrf51_nvm.h"
> +#include "hw/gpio/nrf51_gpio.h"
>
>  #define FLASH_SIZE          (256 * NRF51_PAGE_SIZE)
>
>  static void fill_and_erase(hwaddr base, hwaddr size, uint32_t address_reg)
>  {
> +    uint64_t i;
> +
>      /* Fill memory */
>      writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x01);
> -    for (hwaddr i = 0; i < size; i++) {
> +    for (i = 0; i < size; i++) {
>          writeb(base + i, i);
>          g_assert_cmpuint(readb(base + i), ==, i & 0xFF);
>      }
> @@ -39,7 +42,7 @@ static void fill_and_erase(hwaddr base, hwaddr size, 
> uint32_t address_reg)
>      writel(NRF51_NVMC_BASE + NRF51_NVMC_CONFIG, 0x00);
>
>      /* Check memory */
> -    for (hwaddr i = 0; i < size; i++) {
> +    for (i = 0; i < size; i++) {
>          g_assert_cmpuint(readb(base + i), ==, 0xFF);
>      }
>  }

Ah, here are the fixes for the initializers. You should all squash these
down into patch 7.


> +static void test_nrf51_gpio(void)
> +{
> +    size_t i;
> +    uint32_t actual, expected;
> +
> +    struct {
> +        hwaddr addr;
> +        uint32_t expected;
> +    } reset_state[] = {
> +        {NRF51_GPIO_REG_OUT, 0x00000000}, {NRF51_GPIO_REG_OUTSET, 
> 0x00000000},
> +        {NRF51_GPIO_REG_OUTCLR, 0x00000000}, {NRF51_GPIO_REG_IN, 0x00000000},
> +        {NRF51_GPIO_REG_DIR, 0x00000000}, {NRF51_GPIO_REG_DIRSET, 
> 0x00000000},
> +        {NRF51_GPIO_REG_DIRCLR, 0x00000000}
> +    };

You could mark this array as const, I think ?


> +    /* Check short-circuit - generates an guest_error which must be checked
> +       manually as long as qtest can not scan qemu_log messages */

Odd multiline comment format again.

thanks
-- PMM



reply via email to

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