In testCompareDomJobInfoByName, we should get different jobinfo for fc4
and fc5, as we set different jobinfo value for fc5 in
testDomainSetDummyData. And when use "--completed --keep-completed"
flags, the completed job info should be preserved, with only
"--completed" flag, the completed job info should be deleted, so should
get none next time.
In testCompareDomJobAbortByName, domjobabort should set type to
cancelled and preserve the operation.
Signed-off-by: Luke Yue <lukedyue(a)gmail.com>
---
tests/virshtest.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 751e8ffc49..4e2efcb69a 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -291,6 +291,87 @@ static int testCompareDomControlInfoByName(const void *data
G_GNUC_UNUSED)
return testCompareOutputLit(exp, NULL, argv);
}
+static int testCompareDomJobInfoByName(const void *data G_GNUC_UNUSED)
+{
+ const char *const argv[] = { VIRSH_CUSTOM, "domjobinfo fc4;\
+ domjobinfo fc5;\
+ domjobinfo fc5 --completed --keep-completed;\
+ domjobinfo fc5 --completed;\
+ domjobinfo fc5 --completed", NULL };
+ const char *exp = "\
+Job type: None \n\
+\n\
+Job type: Bounded \n\
+Operation: Backup \n\
+Time elapsed: 4000 ms\n\
+Time remaining: 6000 ms\n\
+Data processed: 10.000 KiB\n\
+Data remaining: 20.000 KiB\n\
+Data total: 30.000 KiB\n\
+Memory processed: 1.000 MiB\n\
+Memory remaining: 2.000 MiB\n\
+Memory total: 3.000 MiB\n\
+File processed: 512.000 KiB\n\
+File remaining: 1.500 MiB\n\
+File total: 2.000 MiB\n\
+\n\
+Job type: Completed \n\
+Operation: Start \n\
+Time elapsed: 10000 ms\n\
+Data processed: 30.000 KiB\n\
+Data remaining: 0.000 B\n\
+Data total: 30.000 KiB\n\
+Memory processed: 3.000 MiB\n\
+Memory remaining: 0.000 B\n\
+Memory total: 3.000 MiB\n\
+File processed: 2.000 MiB\n\
+File remaining: 0.000 B\n\
+File total: 2.000 MiB\n\
+\n\
+Job type: Completed \n\
+Operation: Start \n\
+Time elapsed: 10000 ms\n\
+Data processed: 30.000 KiB\n\
+Data remaining: 0.000 B\n\
+Data total: 30.000 KiB\n\
+Memory processed: 3.000 MiB\n\
+Memory remaining: 0.000 B\n\
+Memory total: 3.000 MiB\n\
+File processed: 2.000 MiB\n\
+File remaining: 0.000 B\n\
+File total: 2.000 MiB\n\
+\n\
+Job type: None \n\
+\n";
+ return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testCompareDomJobAbortByName(const void *data G_GNUC_UNUSED)
+{
+ const char *const argv[] = { VIRSH_CUSTOM, "domjobinfo fc5;\
+ domjobabort fc5; domjobinfo fc5", NULL };
+ const char *exp = "\
+Job type: Bounded \n\
+Operation: Backup \n\
+Time elapsed: 4000 ms\n\
+Time remaining: 6000 ms\n\
+Data processed: 10.000 KiB\n\
+Data remaining: 20.000 KiB\n\
+Data total: 30.000 KiB\n\
+Memory processed: 1.000 MiB\n\
+Memory remaining: 2.000 MiB\n\
+Memory total: 3.000 MiB\n\
+File processed: 512.000 KiB\n\
+File remaining: 1.500 MiB\n\
+File total: 2.000 MiB\n\
+\n\
+\n\
+Job type: Cancelled \n\
+Operation: Backup \n\
+\n";
+ return testCompareOutputLit(exp, NULL, argv);
+}
+
struct testInfo {
const char *const *argv;
const char *result;
@@ -383,6 +464,14 @@ mymain(void)
testCompareDomControlInfoByName, NULL) != 0)
ret = -1;
+ if (virTestRun("virsh domjobinfo (by name)",
+ testCompareDomJobInfoByName, NULL) != 0)
+ ret = -1;
+
+ if (virTestRun("virsh domjobabort (by name)",
+ testCompareDomJobAbortByName, 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