Reviewed-by: Glenn Miles <[email protected]>

Thanks,

Glenn

On Mon, 2026-10-12 at 16:32 +0200, Emmanuel Blot via qemu development
wrote:
> Verify that without a calibration value the current and power
> registers read zero, whichever channels the mode converts.
> 
> Signed-off-by: Emmanuel Blot <[email protected]>
> ---
>  tests/qtest/ina230-test.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/tests/qtest/ina230-test.c b/tests/qtest/ina230-test.c
> index 591927e551..5749b0bd46 100644
> --- a/tests/qtest/ina230-test.c
> +++ b/tests/qtest/ina230-test.c
> @@ -301,6 +301,30 @@ static void test_zero_cal(void *obj, void *data, 
> QGuestAllocator *alloc)
>      g_assert_cmphex(i2c_get16(dev, REG_POWER), ==, 0x0000);
>  }
>  
> +/* Clearing the Calibration zeroes both derived registers in any mode */
> +static void test_zero_cal_channels(void *obj, void *data,
> +                                   QGuestAllocator *alloc)
> +{
> +    QI2CDevice *dev = (QI2CDevice *)obj;
> +    static const uint8_t modes[] = { 0x5, 0x6, 0x7 };
> +    size_t idx;
> +
> +    for (idx = 0; idx < ARRAY_SIZE(modes); idx++) {
> +        i2c_set16(dev, REG_CONFIG, CONFIG_RST);
> +        i2c_set16(dev, REG_CALIBRATION, 0x0A00);
> +        qmp_ina230_set("shunt-voltage", 20000000);
> +        qmp_ina230_set("bus-voltage", 11980000);
> +        g_assert_cmphex(i2c_get16(dev, REG_CURRENT), !=, 0x0000);
> +        g_assert_cmphex(i2c_get16(dev, REG_POWER), !=, 0x0000);
> +
> +        i2c_set16(dev, REG_CONFIG, modes[idx]);
> +        i2c_set16(dev, REG_CALIBRATION, 0x0000);
> +
> +        g_assert_cmphex(i2c_get16(dev, REG_CURRENT), ==, 0x0000);
> +        g_assert_cmphex(i2c_get16(dev, REG_POWER), ==, 0x0000);
> +    }
> +}
> +
>  /* Clamping at full scale and the OVF (math overflow) flag */
>  static void test_edges_overflow(void *obj, void *data, QGuestAllocator 
> *alloc)
>  {
> @@ -560,6 +584,7 @@ static void ina230_register_nodes(void)
>                   NULL);
>      qos_add_test("power", "ina230", test_power, NULL);
>      qos_add_test("zero-cal", "ina230", test_zero_cal, NULL);
> +    qos_add_test("zero-cal-channels", "ina230", test_zero_cal_channels, 
> NULL);
>      qos_add_test("edges-overflow", "ina230", test_edges_overflow, NULL);
>      qos_add_test("alert-shunt-over", "ina230", test_alert_shunt_over, NULL);
>      qos_add_test("alert-latch", "ina230", test_alert_latch, NULL);
> 


Reply via email to