i Joel and Alistair, On Wed, Jul 01, 2026 at 01:05:55PM +0930, Joel Stanley wrote: > On Mon, 29 Jun 2026 at 11:21, Alistair Francis <[email protected]> wrote: > > > > On Wed, Jun 17, 2026 at 5:04 AM Kuan-Wei Chiu <[email protected]> wrote: > > > > > > Add minimal qtest coverage for the Milk-V Duo machine to validate basic > > > MMIO mapping and register access. > > > > > > Currently tested: > > > - Verify DW8250 UART component version and type signatures. > > > - Test read/write access to CV1800B clock bypass register. > > > > > > Tested with: > > > $ meson test -C build -v qemu:qtest-riscv64/milkv-duo-test > > > [...] > > > Ok: 1 > > > Fail: 0 > > > > > > Signed-off-by: Kuan-Wei Chiu <[email protected]> > > > --- > > > MAINTAINERS | 1 + > > > tests/qtest/meson.build | 3 +- > > > tests/qtest/milkv-duo-test.c | 70 ++++++++++++++++++++++++++++++++++++ > > > 3 files changed, 73 insertions(+), 1 deletion(-) > > > create mode 100644 tests/qtest/milkv-duo-test.c > > > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > > index e197dcb5b2..472513537f 100644 > > > --- a/MAINTAINERS > > > +++ b/MAINTAINERS > > > @@ -1807,6 +1807,7 @@ F: hw/riscv/milkv_duo.c > > > F: include/hw/char/dw8250.h > > > F: include/hw/misc/cv1800b_clk.h > > > F: include/hw/riscv/cv1800b.h > > > +F: tests/qtest/milkv-duo-test.c > > > > > > RX Machines > > > ----------- > > > diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build > > > index 4897325d84..38acbdc0c8 100644 > > > --- a/tests/qtest/meson.build > > > +++ b/tests/qtest/meson.build > > > @@ -293,7 +293,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \ > > > (config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') and > > > config_all_devices.has_key('CONFIG_RISCV_IOMMU') ? > > > ['iommu-riscv-test'] : []) + \ > > > - (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) > > > + (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) + > > > \ > > > + ['milkv-duo-test'] > > > > > > qos_test_ss = ss.source_set() > > > qos_test_ss.add( > > > diff --git a/tests/qtest/milkv-duo-test.c b/tests/qtest/milkv-duo-test.c > > > new file mode 100644 > > > index 0000000000..06064b8733 > > > --- /dev/null > > > +++ b/tests/qtest/milkv-duo-test.c > > > @@ -0,0 +1,70 @@ > > > +/* > > > + * QTest for Milk-V Duo Board > > > + * > > > + * Copyright (c) 2026 Kuan-Wei Chiu <[email protected]> > > > + * > > > + * SPDX-License-Identifier: GPL-2.0-or-later > > > + */ > > > + > > > +#include "qemu/osdep.h" > > > +#include "libqtest.h" > > > + > > > +#define CV1800B_CLK_BASE 0x03002000 > > > +#define CV1800B_CLK_BYPASS 0x030 > > > +#define CV1800B_CLK_BYPASS_RESET 0xFFFFFFFF > > > +#define TEST_PATTERN_5A 0x5A5A5A5A > > > +#define TEST_PATTERN_A5 0xA5A5A5A5 > > > + > > > +#define CV1800B_UART0_BASE 0x04140000 > > > +#define DW_UART_UCV 0xF8 > > > +#define DW_UART_CTR 0xFC > > > +#define DW_UART_VERSION_3_23A 0x3332332A > > > +#define DW_UART_TYPE_SIGNATURE 0x44570110 > > > + > > > +static void test_milkv_duo_uart(void) > > > +{ > > > + QTestState *qts; > > > + uint32_t component_version; > > > + uint32_t component_type; > > > + > > > + qts = qtest_init("-M milkv-duo"); > > > + > > > + component_version = qtest_readl(qts, CV1800B_UART0_BASE + > > > DW_UART_UCV); > > > + g_assert_cmphex(component_version, ==, DW_UART_VERSION_3_23A); > > > + > > > + component_type = qtest_readl(qts, CV1800B_UART0_BASE + DW_UART_CTR); > > > + g_assert_cmphex(component_type, ==, DW_UART_TYPE_SIGNATURE); > > > + > > > + qtest_quit(qts); > > > +} > > > + > > > +static void test_milkv_duo_clk(void) > > > +{ > > > + QTestState *qts; > > > + uint32_t clk_bypass_val; > > > + > > > + qts = qtest_init("-M milkv-duo"); > > > + > > > + clk_bypass_val = qtest_readl(qts, CV1800B_CLK_BASE + > > > CV1800B_CLK_BYPASS); > > > + g_assert_cmphex(clk_bypass_val, ==, CV1800B_CLK_BYPASS_RESET); > > > + > > > + qtest_writel(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS, > > > TEST_PATTERN_5A); > > > + clk_bypass_val = qtest_readl(qts, CV1800B_CLK_BASE + > > > CV1800B_CLK_BYPASS); > > > + g_assert_cmphex(clk_bypass_val, ==, TEST_PATTERN_5A); > > > + > > > + qtest_writel(qts, CV1800B_CLK_BASE + CV1800B_CLK_BYPASS, > > > TEST_PATTERN_A5); > > > + clk_bypass_val = qtest_readl(qts, CV1800B_CLK_BASE + > > > CV1800B_CLK_BYPASS); > > > + g_assert_cmphex(clk_bypass_val, ==, TEST_PATTERN_A5); > > > + > > > + qtest_quit(qts); > > > +} > > > + > > > +int main(int argc, char **argv) > > > +{ > > > + g_test_init(&argc, &argv, NULL); > > > + > > > + qtest_add_func("/riscv/milkv-duo/uart", test_milkv_duo_uart); > > > + qtest_add_func("/riscv/milkv-duo/clk", test_milkv_duo_clk); > > > > Thanks for the tests. These are just checking some static values > > though. Can you also add a boot test? > > +1 > > A functional test that exercises -bios -kernel -dtb, as well as the > sd device would be great.
I'll try to add the boot test. I assume this means the test will need a way to fetch the kernel image and dtb from somewhere. Would it be acceptable to host these files on my personal github, or is there a more appropriate place I should upload them to? Regards, Kuan-Wei
