[libvirt] [PATCH 2/9] tests: add macro for dealing with exclusive flags

Ján Tomko posted 9 patches 6 years, 10 months ago
Only 8 patches received!
There is a newer version of this series
[libvirt] [PATCH 2/9] tests: add macro for dealing with exclusive flags
Posted by Ján Tomko 6 years, 10 months ago
We can reject some non-sensical combinations with an error
message, once we add flags for them.

Introduce a macro to make this easier.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 tests/qemuxml2argvtest.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 04b6c00eba..b04cf7c923 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -467,6 +467,21 @@ testCompareXMLToStartupXML(const void *data)
 }
 
 
+# define TEST_EXCLUSIVE_FLAGS(FLAG1, FLAG2) \
+    if ((testFlags & FLAG1) && (testFlags & FLAG2)) { \
+        VIR_TEST_DEBUG("Flags %s and %s are mutually exclusive\n", \
+                       #FLAG1, #FLAG2); \
+        return -1; \
+    }
+
+
+static int
+testCheckExclusiveFlags(int testFlags ATTRIBUTE_UNUSED)
+{
+    return 0;
+}
+
+
 static int
 testCompareXMLToArgv(const void *data)
 {
@@ -509,6 +524,9 @@ testCompareXMLToArgv(const void *data)
     if (virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_ENABLE_FIPS))
         flags |= FLAG_FIPS;
 
+    if (testCheckExclusiveFlags(info->flags) < 0)
+        goto cleanup;
+
     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
         goto cleanup;
 
-- 
2.16.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/9] tests: add macro for dealing with exclusive flags
Posted by Michal Privoznik 6 years, 10 months ago
On 09/09/2018 04:10 AM, Ján Tomko wrote:
> We can reject some non-sensical combinations with an error
> message, once we add flags for them.
> 
> Introduce a macro to make this easier.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  tests/qemuxml2argvtest.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 04b6c00eba..b04cf7c923 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -467,6 +467,21 @@ testCompareXMLToStartupXML(const void *data)
>  }
>  
>  
> +# define TEST_EXCLUSIVE_FLAGS(FLAG1, FLAG2) \
> +    if ((testFlags & FLAG1) && (testFlags & FLAG2)) { \
> +        VIR_TEST_DEBUG("Flags %s and %s are mutually exclusive\n", \
> +                       #FLAG1, #FLAG2); \
> +        return -1; \
> +    }
> +
> +

What's wrong with VIR_EXCLUSIVE_FLAGS_RET()?

Michal

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