Add a slow-mode subtest that boots aarch64/virt and ppc64/pseries at their maximum -smp count and asserts that qtest_init() returns within 15 seconds. This guards against quadratic-time init regressions when many child objects are created under a single parent, such as the "[*]" auto-index property scan that made pseries take ~10 s to launch before qemu_extend_irqs() switched to explicit indices.
AI-used-for: code (refactoring) Signed-off-by: Alexander Graf <[email protected]> --- tests/qtest/qom-test.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index cf4c6b5add..0bfb3233ac 100644 --- a/tests/qtest/qom-test.c +++ b/tests/qtest/qom-test.c @@ -238,8 +238,32 @@ static void test_qom_qtests(void) qtest_quit(qts); } +/* + * Guard against O(n^2) init-time regressions when many child objects are + * created under one parent (e.g. board-created CPUs). Launch the machine + * at its maximum SMP count and assert an upper bound on time-to-monitor. + * The bound is generous (15 s) so this only fires when init cost blows up + * quadratically, not on ordinary CI jitter. + */ +static void test_smp_max(gconstpointer data) +{ + const char *args = data; + gint64 t0, dt; + QTestState *qts; + + t0 = g_get_monotonic_time(); + qts = qtest_initf("%s", args); + dt = g_get_monotonic_time() - t0; + + g_test_message("smp-max init time: %" G_GINT64_FORMAT " ms", dt / 1000); + g_assert_cmpint(dt, <, 15 * G_USEC_PER_SEC); + + qtest_quit(qts); +} + int main(int argc, char **argv) { + const char *arch = qtest_get_arch(); char *v_env = getenv("V"); if (v_env) { @@ -251,5 +275,16 @@ int main(int argc, char **argv) qtest_cb_for_every_machine(add_machine_test_case, g_test_quick()); qtest_add_func("qom/qom-qtests", test_qom_qtests); + if (g_test_slow()) { + if (g_str_equal(arch, "aarch64")) { + qtest_add_data_func("qom/smp-max/virt", + "-M virt,gic-version=max -smp 512", + test_smp_max); + } else if (g_str_equal(arch, "ppc64")) { + qtest_add_data_func("qom/smp-max/pseries", + "-M pseries -smp 512", test_smp_max); + } + } + return g_test_run(); } -- 2.47.1
