On Mon, Aug 16, 2021 at 07:19:49PM +0800, Luke Yue wrote:
Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx> --- tests/virshtest.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/virshtest.c b/tests/virshtest.c index 53db2aa19a..273596d636 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -291,6 +291,22 @@ static int testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED) return testCompareOutputLit(exp, NULL, argv); } +static int testCompareDetachDevice(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] = { VIRSH_CUSTOM, "detach-device", "fc5", + "../examples/xml/test/testdevif.xml", NULL }; + const char *exp = "Device detached successfully\n\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testCompareDetachDeviceAlias(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] = { VIRSH_CUSTOM, "detach-device-alias", "fc5", + "ua-testCD", NULL }; + const char *exp = "Device detach request sent successfully\n\n"; + return testCompareOutputLit(exp, NULL, argv); +} +
Not many XMLs from the previous patch are used here. There could also be some negative tests (failing on a device that does not exist for example). But if you de-duplicate the code then you can also go the other route and test the generic functions without running 'virsh -c test:///...' for every piece of functionality.
struct testInfo { const char *const *argv; const char *result; @@ -383,6 +399,14 @@ mymain(void) testCompareDomControlInfoByName, NULL) != 0) ret = -1; + if (virTestRun("virsh detach-device", + testCompareDetachDevice, NULL) != 0) + ret = -1; + + if (virTestRun("virsh detach-device-alias", + testCompareDetachDeviceAlias, NULL) != 0) + ret = -1; + /* It's a bit awkward listing result before argument, but that's a * limitation of C99 vararg macros. */ # define DO_TEST(i, result, ...) \ -- 2.32.0
Attachment:
signature.asc
Description: PGP signature