[libvirt PATCH 9/9] tests: Add tests for unknown elements and attributes in cpu defintion

Jonathon Jongsma jjongsma at redhat.com
Mon Sep 28 16:20:19 UTC 2020


On Mon, 2020-09-21 at 15:07 +0200, Tim Wiederhake wrote:
> Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
> ---
>  tests/cputest.c                              | 4 ++++
>  tests/cputestdata/x86_64-bogus-attribute.xml | 2 ++
>  tests/cputestdata/x86_64-bogus-element.xml   | 3 +++
>  3 files changed, 9 insertions(+)
>  create mode 100644 tests/cputestdata/x86_64-bogus-attribute.xml
>  create mode 100644 tests/cputestdata/x86_64-bogus-element.xml
> 
> diff --git a/tests/cputest.c b/tests/cputest.c
> index 30a125c3da..2d00040497 100644
> --- a/tests/cputest.c
> +++ b/tests/cputest.c
> @@ -1106,6 +1106,10 @@ mymain(void)
>          } \
>      } while (0)
>  
> +    /* invalid xml */
> +    DO_TEST_COMPARE_FLAGS(VIR_ARCH_X86_64, "host", "bogus-element",
> VIR_CPU_COMPARE_ERROR, VIR_CONNECT_COMPARE_CPU_VALIDATE_XML);
> +    DO_TEST_COMPARE_FLAGS(VIR_ARCH_X86_64, "host", "bogus-
> attribute", VIR_CPU_COMPARE_ERROR,
> VIR_CONNECT_COMPARE_CPU_VALIDATE_XML);
> +
>      /* host to host comparison */
>      DO_TEST_COMPARE(VIR_ARCH_X86_64, "host", "host",
> VIR_CPU_COMPARE_IDENTICAL);
>      DO_TEST_COMPARE(VIR_ARCH_X86_64, "host", "host-better",
> VIR_CPU_COMPARE_INCOMPATIBLE);
> diff --git a/tests/cputestdata/x86_64-bogus-attribute.xml
> b/tests/cputestdata/x86_64-bogus-attribute.xml
> new file mode 100644
> index 0000000000..073ee793e6
> --- /dev/null
> +++ b/tests/cputestdata/x86_64-bogus-attribute.xml
> @@ -0,0 +1,2 @@
> +<cpu nonExistantAttribute="">

nickpick: the proper spelling is "existent"

> +</cpu>
> diff --git a/tests/cputestdata/x86_64-bogus-element.xml
> b/tests/cputestdata/x86_64-bogus-element.xml
> new file mode 100644
> index 0000000000..79f98bad18
> --- /dev/null
> +++ b/tests/cputestdata/x86_64-bogus-element.xml
> @@ -0,0 +1,3 @@
> +<cpu>
> +  <nonExistantElement/>

again.

> +</cpu>




More information about the libvir-list mailing list