From: Peter Krempa <[email protected]>

Trying to pass STDIO fds to a virCommand is very bad and test cases must
not do that.

Same way with invalid FDs.

Add code which makes qemuxmlconftest fail if any test case would attempt
that.

Signed-off-by: Peter Krempa <[email protected]>
---
 tests/qemuxml2argvmock.c |  3 +++
 tests/qemuxmlconftest.c  | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 0440bb15e2..4f47b2598e 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -193,6 +193,7 @@ virCommandPassFD(virCommand *cmd,
     if (fd == STDIN_FILENO ||
         fd == STDOUT_FILENO ||
         fd == STDERR_FILENO) {
+        virTestDummyFDContextMarkError(g_strdup("test case tried to pass stdio 
FDs to virCommandPassFD"));
         return;
     }

@@ -200,6 +201,8 @@ virCommandPassFD(virCommand *cmd,
      * operations on those since they cause errors in e.g. valgrind.
      */
     if (fcntl(fd, F_GETFD) == -1) {
+        virTestDummyFDContextMarkError(g_strdup_printf("test case tried to 
pass invalid FD '%d' to virCommandPassFD",
+                                                       fd));
         return;
     }

diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 3d30bf6ccc..acc98cbad2 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -916,6 +916,16 @@ testCompareXMLToArgv(const void *data)
         goto cleanup;
     }

+    if (info->fdsubsts->errors) {
+        GSList *n;
+
+        for (n = info->fdsubsts->errors; n; n = n->next) {
+            VIR_TEST_VERBOSE("%s", (char *) n->data);
+        }
+
+        goto cleanup;
+    }
+
     if (testCompareXMLToArgvValidateSchema(cmd, info) < 0)
         goto cleanup;

-- 
2.54.0

Reply via email to