]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedevmdevctltest: Use internal linewrapping and variable command path stripping
authorPeter Krempa <pkrempa@redhat.com>
Fri, 9 Apr 2021 07:21:28 +0000 (09:21 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:10 +0000 (15:55 +0200)
Remove `nodedevCompareToFile` which was stripping the path to mdevctl
since it's no longer needed if we use the new features of
virCommandSetDryRun.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-define.argv
tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-start.argv
tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-define.argv
tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-start.argv
tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-define.argv
tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-start.argv
tests/nodedevmdevctldata/mdevctl-create.argv
tests/nodedevmdevctldata/mdevctl-list-defined.argv
tests/nodedevmdevctldata/mdevctl-stop.argv
tests/nodedevmdevctldata/mdevctl-undefine.argv
tests/nodedevmdevctltest.c

index 118ec7a8da603786f7f09015db1f3ec2972cc1b9..b8bb276f9f77444aecda1ae4015dedfaebac9d86 100644 (file)
@@ -1,2 +1,5 @@
-$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin \
+mdevctl \
+define \
+-p 0000:00:02.0 \
+--jsonfile /dev/stdin \
 --uuid=d069d019-36ea-4111-8f0a-8c9a70e21366
index 129f438e4ad2423dabc5097e5d47f9346a148346..73a8046d8401b2c62f55266a444f0be1ee5f5ede 100644 (file)
@@ -1,2 +1,5 @@
-$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin \
+mdevctl \
+start \
+-p 0000:00:02.0 \
+--jsonfile /dev/stdin \
 --uuid=d069d019-36ea-4111-8f0a-8c9a70e21366
index 773e98b96353b420028019b0b84e298de56ca51f..bf8637ed577069992833e0ed052845f480c4ea83 100644 (file)
@@ -1 +1,4 @@
-$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin
+mdevctl \
+define \
+-p 0000:00:02.0 \
+--jsonfile /dev/stdin
index eb7262035e48328fe36b1dd7641164fa99db6b5e..eae63f7a7fa51f9169c725e5c0ec8be1649b2a5b 100644 (file)
@@ -1 +1,4 @@
-$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin
+mdevctl \
+start \
+-p 0000:00:02.0 \
+--jsonfile /dev/stdin
index 773e98b96353b420028019b0b84e298de56ca51f..bf8637ed577069992833e0ed052845f480c4ea83 100644 (file)
@@ -1 +1,4 @@
-$MDEVCTL_BINARY$ define -p 0000:00:02.0 --jsonfile /dev/stdin
+mdevctl \
+define \
+-p 0000:00:02.0 \
+--jsonfile /dev/stdin
index eb7262035e48328fe36b1dd7641164fa99db6b5e..eae63f7a7fa51f9169c725e5c0ec8be1649b2a5b 100644 (file)
@@ -1 +1,4 @@
-$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin
+mdevctl \
+start \
+-p 0000:00:02.0 \
+--jsonfile /dev/stdin
index 802109340cbd4ac0e21d07395666e000a391cc04..f19c9780dc373e15bc11a2a52e3784b3ee7bb031 100644 (file)
@@ -1 +1,3 @@
-$MDEVCTL_BINARY$ start -u 8a05ad83-3472-497d-8631-8142f31460e8
+mdevctl \
+start \
+-u 8a05ad83-3472-497d-8631-8142f31460e8
index 72b5906e9ea9b5b70a4a3192a93d5de66616d88f..f6199681fac2d6e33b6c0c654b269c3a0554e2d9 100644 (file)
@@ -1 +1,4 @@
-$MDEVCTL_BINARY$ list --dumpjson --defined
+mdevctl \
+list \
+--dumpjson \
+--defined
index 3dbaab671b3330fd0b7d4a161ac0cc13b502b978..cc621191d6eb8c34acf936953bc9c8bedc993de9 100644 (file)
@@ -1 +1,3 @@
-$MDEVCTL_BINARY$ stop -u e2451f73-c95b-4124-b900-e008af37c576
+mdevctl \
+stop \
+-u e2451f73-c95b-4124-b900-e008af37c576
index 54717455f73b9ef11e1dbcb69050ff7116591164..f1a59c524239a39c28639d42d1f375530e6510a5 100644 (file)
@@ -1 +1,3 @@
-$MDEVCTL_BINARY$ undefine -u d76a6b78-45ed-4149-a325-005f9abc5281
+mdevctl \
+undefine \
+-u d76a6b78-45ed-4149-a325-005f9abc5281
index 48d4f9e81866aafeda7043e9a34cb3cb5151b7ee..27bdc67928bb5357aed38e2afc746a44f5bd66ab 100644 (file)
@@ -40,21 +40,6 @@ testCommandDryRunCallback(const char *const*args G_GNUC_UNUSED,
     *stdinbuf = g_strdup(input);
 }
 
-/* We don't want the result of the test to depend on the path to the mdevctl
- * binary on the developer's machine, so replace the path to mdevctl with a
- * placeholder string before comparing to the expected output */
-static int
-nodedevCompareToFile(const char *actual,
-                     const char *filename)
-{
-    g_autofree char *replacedCmdline = NULL;
-
-    replacedCmdline = virStringReplace(actual, MDEVCTL, "$MDEVCTL_BINARY$");
-
-    return virTestCompareToFile(replacedCmdline, filename);
-}
-
-
 typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef *, char **, char **);
 
 
@@ -87,14 +72,14 @@ testMdevctlStartOrDefine(const char *virt_type,
     if (!cmd)
         goto cleanup;
 
-    virCommandSetDryRun(dryRunToken, &buf, false, false, testCommandDryRunCallback, &stdinbuf);
+    virCommandSetDryRun(dryRunToken, &buf, true, true, testCommandDryRunCallback, &stdinbuf);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
     if (!(actualCmdline = virBufferCurrentContent(&buf)))
         goto cleanup;
 
-    if (nodedevCompareToFile(actualCmdline, cmdfile) < 0)
+    if (virTestCompareToFileFull(actualCmdline, cmdfile, false) < 0)
         goto cleanup;
 
     if (virTestCompareToFile(stdinbuf, jsonfile) < 0)
@@ -159,14 +144,14 @@ testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, const char
     if (!cmd)
         goto cleanup;
 
-    virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL);
+    virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
     if (!(actualCmdline = virBufferCurrentContent(&buf)))
         goto cleanup;
 
-    if (nodedevCompareToFile(actualCmdline, outfile) < 0)
+    if (virTestCompareToFileFull(actualCmdline, outfile, false) < 0)
         goto cleanup;
 
     ret = 0;
@@ -221,14 +206,14 @@ testMdevctlListDefined(const void *data G_GNUC_UNUSED)
     if (!cmd)
         goto cleanup;
 
-    virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL);
+    virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
     if (!(actualCmdline = virBufferCurrentContent(&buf)))
         goto cleanup;
 
-    if (nodedevCompareToFile(actualCmdline, cmdlinefile) < 0)
+    if (virTestCompareToFileFull(actualCmdline, cmdlinefile, false) < 0)
         goto cleanup;
 
     ret = 0;
@@ -270,7 +255,7 @@ testMdevctlParse(const void *data)
         virBufferAddStr(&xmloutbuf, devxml);
     }
 
-    if (nodedevCompareToFile(virBufferCurrentContent(&xmloutbuf), xmloutfile) < 0)
+    if (virTestCompareToFileFull(virBufferCurrentContent(&xmloutbuf), xmloutfile, false) < 0)
         goto cleanup;
 
     ret = 0;