On Thu, Jun 04, 2026 at 17:17:01 -0400, Laine Stump wrote: > From: Laine Stump <[email protected]> > > Does this do what's needed for testing? (I haven't added any cases to > qemumonitorjsontest before, so it was a bit of an adventure to (I > hope) figure it out).
Well, you did much more than I actually wanted and it's on me for not being specific :). It would be completely enough to just do the auto-generated tests (GEN_TEST_FUNC, DO_TEST_GEN). Those, if you pass arguments which excercise all parameters, are usually sufficient as they still do schema validation. Specifically 'qemuMonitorTestAddItemVerbatim' that you used is a bit harder to maintain if you want to add new stuff later. > > If this is correct, I'll squash it into Patch 1. Anyways, it is correct; go ahead, > > Signed-off-by: Laine Stump <[email protected]> > --- > tests/qemumonitorjsontest.c | 79 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > > diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c > index e34dbad7cd..f59b97c1c3 100644 > --- a/tests/qemumonitorjsontest.c > +++ b/tests/qemumonitorjsontest.c > @@ -2776,6 +2776,84 @@ testQemuMonitorJSONGetSEVInfo(const void *opaque) > } > > > +static int > +testQemuMonitorJSONAnnounceInterface(const void *opaque) > +{ > + const testGenericData *data = opaque; > + g_autoptr(qemuMonitorTest) test = NULL; > + > + if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema))) > + return -1; > + > + /* Test 1 - all parameters are default */ > + if (qemuMonitorTestAddItemVerbatim(test, > + "{" > + " \"execute\": \"announce-self\"," > + " \"arguments\": {" > + " \"initial\": 50," > + " \"max\": 550," > + " \"rounds\": 5," > + " \"step\": 50" > + " }," > + " \"id\":\"libvirt-1\"" > + "}", > + NULL, > + "{\"return\":{}}") < 0) { > + return -1; > + } > + > + > + if (qemuMonitorJSONAnnounceSelf(qemuMonitorTestGetMonitor(test), NULL, > 0, 0, 0, 0) < 0) > + return -1; > + > + /* Test 2 - interface device set, everything else default */ > + if (qemuMonitorTestAddItemVerbatim(test, > + "{" > + " \"execute\": \"announce-self\"," > + " \"arguments\": {" > + " \"interfaces\":[\"net0\"]," > + " \"initial\": 50," > + " \"max\": 550," > + " \"rounds\": 5," > + " \"step\": 50" > + " }," > + " \"id\":\"libvirt-2\"" > + "}", > + NULL, > + "{\"return\":{}}") < 0) { > + return -1; > + } > + > + > + if (qemuMonitorJSONAnnounceSelf(qemuMonitorTestGetMonitor(test), "net0", > 0, 0, 0, 0) < 0) > + return -1; > + > + /* Test 3 - all parameters explicitly set */ > + if (qemuMonitorTestAddItemVerbatim(test, > + "{" > + " \"execute\": \"announce-self\"," > + " \"arguments\": {" > + " \"interfaces\":[\"skid00\"]," > + " \"initial\": 23," > + " \"max\": 54," > + " \"rounds\": 867," > + " \"step\": 5309" > + " }," > + " \"id\":\"libvirt-3\"" > + "}", > + NULL, > + "{\"return\":{}}") < 0) { > + return -1; > + } > + > + > + if (qemuMonitorJSONAnnounceSelf(qemuMonitorTestGetMonitor(test), > "skid00", 23, 54, 867, 5309) < 0) > + return -1; > + > + return 0; > +} > + > + > struct testQemuMonitorJSONGetGuestCPUData { > const char *name; > bool qomListGet; > @@ -2940,6 +3018,7 @@ mymain(void) > DO_TEST(Transaction); > DO_TEST(BlockExportAdd); > DO_TEST(BlockdevReopen); > + DO_TEST(AnnounceInterface); > DO_TEST_SIMPLE("qmp_capabilities", qemuMonitorJSONSetCapabilities); > DO_TEST_SIMPLE("system_powerdown", qemuMonitorJSONSystemPowerdown); > DO_TEST_SIMPLE("system_reset", qemuMonitorJSONSystemReset); > -- > 2.54.0 > Reviewed-by: Peter Krempa <[email protected]>
