[PATCH 10/10] tests: virerror: Make sure that error messages stay in correct order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since we don't look up the error message according to the error code but
they have to be in the correct order in virErrorMsgStrings, we need
to make sure that they stay in the correct order.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/virerrortest.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/virerrortest.c b/tests/virerrortest.c
index 0d0377bfa8..6d333f02d0 100644
--- a/tests/virerrortest.c
+++ b/tests/virerrortest.c
@@ -87,6 +87,24 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED)
 }


+static int
+virErrorTestMsgOrder(const void *opaque ATTRIBUTE_UNUSED)
+{
+    size_t i;
+    int ret = 0;
+
+    for (i = 0; i < VIR_ERR_NUMBER_LAST; i++) {
+        if (i != virErrorMsgStrings[i].error) {
+            VIR_TEST_VERBOSE("\nvirErrorMsgStrings[%zu] error code is '%d'\n",
+                             i, virErrorMsgStrings[i].error);
+            ret = -1;
+        }
+    }
+
+    return ret;
+}
+
+
 static int
 mymain(void)
 {
@@ -94,6 +112,8 @@ mymain(void)

     if (virTestRun("error message strings ", virErrorTestMsgs, NULL) < 0)
         ret = -1;
+    if (virTestRun("error messages are in correct order ", virErrorTestMsgOrder, NULL) < 0)
+        ret = -1;

     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.19.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux