From 8459218cbcc680a76889e101550cda41432a72a7 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Fri, 2 Apr 2010 13:28:28 -0400 Subject: [PATCH] This patch adds a couple of test cases for the XML parsing test suite covering various filterable protocols. For each test case an input XML and an output XML is provided checking the input XML after parsing and converting back into XML against the exepcted output XML. Signed-off-by: Stefan Berger --- tests/Makefile.am | 10 ++ tests/nwfilterxml2xmlin/ah-ipv6-test.xml | 19 +++ tests/nwfilterxml2xmlin/ah-test.xml | 18 +++ tests/nwfilterxml2xmlin/all-ipv6-test.xml | 19 +++ tests/nwfilterxml2xmlin/all-test.xml | 18 +++ tests/nwfilterxml2xmlin/arp-test.xml | 33 +++++ tests/nwfilterxml2xmlin/esp-ipv6-test.xml | 19 +++ tests/nwfilterxml2xmlin/esp-test.xml | 18 +++ tests/nwfilterxml2xmlin/icmp-test.xml | 18 +++ tests/nwfilterxml2xmlin/icmpv6-test.xml | 19 +++ tests/nwfilterxml2xmlin/igmp-test.xml | 18 +++ tests/nwfilterxml2xmlin/ip-test.xml | 34 +++++ tests/nwfilterxml2xmlin/ipv6-test.xml | 43 +++++++ tests/nwfilterxml2xmlin/mac-test.xml | 23 ++++ tests/nwfilterxml2xmlin/ref-rule-test.xml | 18 +++ tests/nwfilterxml2xmlin/ref-test.xml | 4 + tests/nwfilterxml2xmlin/sctp-ipv6-test.xml | 22 ++++ tests/nwfilterxml2xmlin/sctp-test.xml | 22 ++++ tests/nwfilterxml2xmlin/tcp-ipv6-test.xml | 22 ++++ tests/nwfilterxml2xmlin/tcp-test.xml | 22 ++++ tests/nwfilterxml2xmlin/udp-ipv6-test.xml | 22 ++++ tests/nwfilterxml2xmlin/udp-test.xml | 22 ++++ tests/nwfilterxml2xmlin/udplite-ipv6-test.xml | 19 +++ tests/nwfilterxml2xmlin/udplite-test.xml | 18 +++ tests/nwfilterxml2xmlout/ah-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/ah-test.xml | 12 ++ tests/nwfilterxml2xmlout/all-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/all-test.xml | 12 ++ tests/nwfilterxml2xmlout/arp-test.xml | 18 +++ tests/nwfilterxml2xmlout/esp-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/esp-test.xml | 12 ++ tests/nwfilterxml2xmlout/icmp-test.xml | 12 ++ tests/nwfilterxml2xmlout/icmpv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/igmp-test.xml | 12 ++ tests/nwfilterxml2xmlout/ip-test.xml | 15 +++ tests/nwfilterxml2xmlout/ipv6-test.xml | 15 +++ tests/nwfilterxml2xmlout/mac-test.xml | 18 +++ tests/nwfilterxml2xmlout/ref-rule-test.xml | 13 ++ tests/nwfilterxml2xmlout/ref-test.xml | 4 + tests/nwfilterxml2xmlout/sctp-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/sctp-test.xml | 12 ++ tests/nwfilterxml2xmlout/tcp-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/tcp-test.xml | 12 ++ tests/nwfilterxml2xmlout/udp-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/udp-test.xml | 12 ++ .../nwfilterxml2xmlout/udplite-ipv6-test.xml | 12 ++ tests/nwfilterxml2xmlout/udplite-test.xml | 12 ++ tests/nwfilterxml2xmltest.c | 121 ++++++++++++++++++ 48 files changed, 908 insertions(+) create mode 100644 tests/nwfilterxml2xmlin/ah-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/ah-test.xml create mode 100644 tests/nwfilterxml2xmlin/all-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/all-test.xml create mode 100644 tests/nwfilterxml2xmlin/arp-test.xml create mode 100644 tests/nwfilterxml2xmlin/esp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/esp-test.xml create mode 100644 tests/nwfilterxml2xmlin/icmp-test.xml create mode 100644 tests/nwfilterxml2xmlin/icmpv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/igmp-test.xml create mode 100644 tests/nwfilterxml2xmlin/ip-test.xml create mode 100644 tests/nwfilterxml2xmlin/ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/mac-test.xml create mode 100644 tests/nwfilterxml2xmlin/ref-rule-test.xml create mode 100644 tests/nwfilterxml2xmlin/ref-test.xml create mode 100644 tests/nwfilterxml2xmlin/sctp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/sctp-test.xml create mode 100644 tests/nwfilterxml2xmlin/tcp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/tcp-test.xml create mode 100644 tests/nwfilterxml2xmlin/udp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/udp-test.xml create mode 100644 tests/nwfilterxml2xmlin/udplite-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlin/udplite-test.xml create mode 100644 tests/nwfilterxml2xmlout/ah-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/ah-test.xml create mode 100644 tests/nwfilterxml2xmlout/all-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/all-test.xml create mode 100644 tests/nwfilterxml2xmlout/arp-test.xml create mode 100644 tests/nwfilterxml2xmlout/esp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/esp-test.xml create mode 100644 tests/nwfilterxml2xmlout/icmp-test.xml create mode 100644 tests/nwfilterxml2xmlout/icmpv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/igmp-test.xml create mode 100644 tests/nwfilterxml2xmlout/ip-test.xml create mode 100644 tests/nwfilterxml2xmlout/ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/mac-test.xml create mode 100644 tests/nwfilterxml2xmlout/ref-rule-test.xml create mode 100644 tests/nwfilterxml2xmlout/ref-test.xml create mode 100644 tests/nwfilterxml2xmlout/sctp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/sctp-test.xml create mode 100644 tests/nwfilterxml2xmlout/tcp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/tcp-test.xml create mode 100644 tests/nwfilterxml2xmlout/udp-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/udp-test.xml create mode 100644 tests/nwfilterxml2xmlout/udplite-ipv6-test.xml create mode 100644 tests/nwfilterxml2xmlout/udplite-test.xml create mode 100644 tests/nwfilterxml2xmltest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 090b320edc..883d1ace9b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -72,6 +72,8 @@ EXTRA_DIST = \ nodedevschemadata \ vmx2xmldata \ xml2vmxdata \ + nwfilterxml2xmlout \ + nwfilterxml2xmlin \ $(patsubst %,qemuhelpdata/%,$(qemuhelpdata)) noinst_PROGRAMS = virshtest conftest \ @@ -103,6 +105,8 @@ endif noinst_PROGRAMS += networkxml2xmltest +noinst_PROGRAMS += nwfilterxml2xmltest + noinst_PROGRAMS += storagevolxml2xmltest storagepoolxml2xmltest noinst_PROGRAMS += nodedevxml2xmltest @@ -162,6 +166,7 @@ endif if WITH_QEMU TESTS += qemuxml2argvtest qemuxml2xmltest qemuargv2xmltest qemuhelptest +TESTS += nwfilterxml2xmltest endif if WITH_ESX @@ -286,6 +291,11 @@ networkxml2xmltest_SOURCES = \ testutils.c testutils.h networkxml2xmltest_LDADD = $(LDADDS) +nwfilterxml2xmltest_SOURCES = \ + nwfilterxml2xmltest.c \ + testutils.c testutils.h +nwfilterxml2xmltest_LDADD = $(LDADDS) + storagevolxml2xmltest_SOURCES = \ storagevolxml2xmltest.c \ testutils.c testutils.h diff --git a/tests/nwfilterxml2xmlin/ah-ipv6-test.xml b/tests/nwfilterxml2xmlin/ah-ipv6-test.xml new file mode 100644 index 0000000000..f0200985df --- /dev/null +++ b/tests/nwfilterxml2xmlin/ah-ipv6-test.xml @@ -0,0 +1,19 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/ah-test.xml b/tests/nwfilterxml2xmlin/ah-test.xml new file mode 100644 index 0000000000..e72c935142 --- /dev/null +++ b/tests/nwfilterxml2xmlin/ah-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/all-ipv6-test.xml b/tests/nwfilterxml2xmlin/all-ipv6-test.xml new file mode 100644 index 0000000000..32772370a8 --- /dev/null +++ b/tests/nwfilterxml2xmlin/all-ipv6-test.xml @@ -0,0 +1,19 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/all-test.xml b/tests/nwfilterxml2xmlin/all-test.xml new file mode 100644 index 0000000000..73ba6b16f2 --- /dev/null +++ b/tests/nwfilterxml2xmlin/all-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/arp-test.xml b/tests/nwfilterxml2xmlin/arp-test.xml new file mode 100644 index 0000000000..d4484dcb2d --- /dev/null +++ b/tests/nwfilterxml2xmlin/arp-test.xml @@ -0,0 +1,33 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/esp-ipv6-test.xml b/tests/nwfilterxml2xmlin/esp-ipv6-test.xml new file mode 100644 index 0000000000..ac381dd000 --- /dev/null +++ b/tests/nwfilterxml2xmlin/esp-ipv6-test.xml @@ -0,0 +1,19 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/esp-test.xml b/tests/nwfilterxml2xmlin/esp-test.xml new file mode 100644 index 0000000000..56e28d6db1 --- /dev/null +++ b/tests/nwfilterxml2xmlin/esp-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/icmp-test.xml b/tests/nwfilterxml2xmlin/icmp-test.xml new file mode 100644 index 0000000000..dcb2825814 --- /dev/null +++ b/tests/nwfilterxml2xmlin/icmp-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/icmpv6-test.xml b/tests/nwfilterxml2xmlin/icmpv6-test.xml new file mode 100644 index 0000000000..a9494bafd8 --- /dev/null +++ b/tests/nwfilterxml2xmlin/icmpv6-test.xml @@ -0,0 +1,19 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/igmp-test.xml b/tests/nwfilterxml2xmlin/igmp-test.xml new file mode 100644 index 0000000000..407cf1cf5a --- /dev/null +++ b/tests/nwfilterxml2xmlin/igmp-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/ip-test.xml b/tests/nwfilterxml2xmlin/ip-test.xml new file mode 100644 index 0000000000..35ac11fcb6 --- /dev/null +++ b/tests/nwfilterxml2xmlin/ip-test.xml @@ -0,0 +1,34 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/ipv6-test.xml b/tests/nwfilterxml2xmlin/ipv6-test.xml new file mode 100644 index 0000000000..556796fa01 --- /dev/null +++ b/tests/nwfilterxml2xmlin/ipv6-test.xml @@ -0,0 +1,43 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/mac-test.xml b/tests/nwfilterxml2xmlin/mac-test.xml new file mode 100644 index 0000000000..5e52675294 --- /dev/null +++ b/tests/nwfilterxml2xmlin/mac-test.xml @@ -0,0 +1,23 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/ref-rule-test.xml b/tests/nwfilterxml2xmlin/ref-rule-test.xml new file mode 100644 index 0000000000..1464016b72 --- /dev/null +++ b/tests/nwfilterxml2xmlin/ref-rule-test.xml @@ -0,0 +1,18 @@ + + 83011800-f663-96d6-8841-fd836b4318c6 + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/ref-test.xml b/tests/nwfilterxml2xmlin/ref-test.xml new file mode 100644 index 0000000000..760272c174 --- /dev/null +++ b/tests/nwfilterxml2xmlin/ref-test.xml @@ -0,0 +1,4 @@ + + 83011800-f663-96d6-8841-fd836b4318c6 + + diff --git a/tests/nwfilterxml2xmlin/sctp-ipv6-test.xml b/tests/nwfilterxml2xmlin/sctp-ipv6-test.xml new file mode 100644 index 0000000000..10c883658e --- /dev/null +++ b/tests/nwfilterxml2xmlin/sctp-ipv6-test.xml @@ -0,0 +1,22 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/sctp-test.xml b/tests/nwfilterxml2xmlin/sctp-test.xml new file mode 100644 index 0000000000..2fa0553922 --- /dev/null +++ b/tests/nwfilterxml2xmlin/sctp-test.xml @@ -0,0 +1,22 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/tcp-ipv6-test.xml b/tests/nwfilterxml2xmlin/tcp-ipv6-test.xml new file mode 100644 index 0000000000..f4340f9ee8 --- /dev/null +++ b/tests/nwfilterxml2xmlin/tcp-ipv6-test.xml @@ -0,0 +1,22 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/tcp-test.xml b/tests/nwfilterxml2xmlin/tcp-test.xml new file mode 100644 index 0000000000..e3111e89e4 --- /dev/null +++ b/tests/nwfilterxml2xmlin/tcp-test.xml @@ -0,0 +1,22 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/udp-ipv6-test.xml b/tests/nwfilterxml2xmlin/udp-ipv6-test.xml new file mode 100644 index 0000000000..f2a73896f2 --- /dev/null +++ b/tests/nwfilterxml2xmlin/udp-ipv6-test.xml @@ -0,0 +1,22 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/udp-test.xml b/tests/nwfilterxml2xmlin/udp-test.xml new file mode 100644 index 0000000000..e20171e3d5 --- /dev/null +++ b/tests/nwfilterxml2xmlin/udp-test.xml @@ -0,0 +1,22 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/udplite-ipv6-test.xml b/tests/nwfilterxml2xmlin/udplite-ipv6-test.xml new file mode 100644 index 0000000000..2f2b8d4941 --- /dev/null +++ b/tests/nwfilterxml2xmlin/udplite-ipv6-test.xml @@ -0,0 +1,19 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlin/udplite-test.xml b/tests/nwfilterxml2xmlin/udplite-test.xml new file mode 100644 index 0000000000..207b0000fa --- /dev/null +++ b/tests/nwfilterxml2xmlin/udplite-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/ah-ipv6-test.xml b/tests/nwfilterxml2xmlout/ah-ipv6-test.xml new file mode 100644 index 0000000000..6d65b3de57 --- /dev/null +++ b/tests/nwfilterxml2xmlout/ah-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/ah-test.xml b/tests/nwfilterxml2xmlout/ah-test.xml new file mode 100644 index 0000000000..e51b9e5cac --- /dev/null +++ b/tests/nwfilterxml2xmlout/ah-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/all-ipv6-test.xml b/tests/nwfilterxml2xmlout/all-ipv6-test.xml new file mode 100644 index 0000000000..263a679966 --- /dev/null +++ b/tests/nwfilterxml2xmlout/all-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/all-test.xml b/tests/nwfilterxml2xmlout/all-test.xml new file mode 100644 index 0000000000..97b6426d87 --- /dev/null +++ b/tests/nwfilterxml2xmlout/all-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/arp-test.xml b/tests/nwfilterxml2xmlout/arp-test.xml new file mode 100644 index 0000000000..2ce46aed3b --- /dev/null +++ b/tests/nwfilterxml2xmlout/arp-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/esp-ipv6-test.xml b/tests/nwfilterxml2xmlout/esp-ipv6-test.xml new file mode 100644 index 0000000000..3852aaca47 --- /dev/null +++ b/tests/nwfilterxml2xmlout/esp-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/esp-test.xml b/tests/nwfilterxml2xmlout/esp-test.xml new file mode 100644 index 0000000000..1acb6a0193 --- /dev/null +++ b/tests/nwfilterxml2xmlout/esp-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/icmp-test.xml b/tests/nwfilterxml2xmlout/icmp-test.xml new file mode 100644 index 0000000000..98d3cacd8e --- /dev/null +++ b/tests/nwfilterxml2xmlout/icmp-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/icmpv6-test.xml b/tests/nwfilterxml2xmlout/icmpv6-test.xml new file mode 100644 index 0000000000..3334038a84 --- /dev/null +++ b/tests/nwfilterxml2xmlout/icmpv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/igmp-test.xml b/tests/nwfilterxml2xmlout/igmp-test.xml new file mode 100644 index 0000000000..735a8534e3 --- /dev/null +++ b/tests/nwfilterxml2xmlout/igmp-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/ip-test.xml b/tests/nwfilterxml2xmlout/ip-test.xml new file mode 100644 index 0000000000..678f750213 --- /dev/null +++ b/tests/nwfilterxml2xmlout/ip-test.xml @@ -0,0 +1,15 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/ipv6-test.xml b/tests/nwfilterxml2xmlout/ipv6-test.xml new file mode 100644 index 0000000000..fcc5c0da26 --- /dev/null +++ b/tests/nwfilterxml2xmlout/ipv6-test.xml @@ -0,0 +1,15 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/mac-test.xml b/tests/nwfilterxml2xmlout/mac-test.xml new file mode 100644 index 0000000000..5c769d2510 --- /dev/null +++ b/tests/nwfilterxml2xmlout/mac-test.xml @@ -0,0 +1,18 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/ref-rule-test.xml b/tests/nwfilterxml2xmlout/ref-rule-test.xml new file mode 100644 index 0000000000..2979a3e00a --- /dev/null +++ b/tests/nwfilterxml2xmlout/ref-rule-test.xml @@ -0,0 +1,13 @@ + + 83011800-f663-96d6-8841-fd836b4318c6 + + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/ref-test.xml b/tests/nwfilterxml2xmlout/ref-test.xml new file mode 100644 index 0000000000..f2f8564c75 --- /dev/null +++ b/tests/nwfilterxml2xmlout/ref-test.xml @@ -0,0 +1,4 @@ + + 83011800-f663-96d6-8841-fd836b4318c6 + + diff --git a/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml b/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml new file mode 100644 index 0000000000..3ef8589a00 --- /dev/null +++ b/tests/nwfilterxml2xmlout/sctp-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/sctp-test.xml b/tests/nwfilterxml2xmlout/sctp-test.xml new file mode 100644 index 0000000000..1780f97c4e --- /dev/null +++ b/tests/nwfilterxml2xmlout/sctp-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml b/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml new file mode 100644 index 0000000000..fcbe7a4a0f --- /dev/null +++ b/tests/nwfilterxml2xmlout/tcp-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/tcp-test.xml b/tests/nwfilterxml2xmlout/tcp-test.xml new file mode 100644 index 0000000000..a13afe1490 --- /dev/null +++ b/tests/nwfilterxml2xmlout/tcp-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/udp-ipv6-test.xml b/tests/nwfilterxml2xmlout/udp-ipv6-test.xml new file mode 100644 index 0000000000..abcf698169 --- /dev/null +++ b/tests/nwfilterxml2xmlout/udp-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/udp-test.xml b/tests/nwfilterxml2xmlout/udp-test.xml new file mode 100644 index 0000000000..03b0bede14 --- /dev/null +++ b/tests/nwfilterxml2xmlout/udp-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml b/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml new file mode 100644 index 0000000000..9f41181535 --- /dev/null +++ b/tests/nwfilterxml2xmlout/udplite-ipv6-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmlout/udplite-test.xml b/tests/nwfilterxml2xmlout/udplite-test.xml new file mode 100644 index 0000000000..f629dc4001 --- /dev/null +++ b/tests/nwfilterxml2xmlout/udplite-test.xml @@ -0,0 +1,12 @@ + + 5c6d49af-b071-6127-b4ec-6f8ed4b55335 + + + + + + + + + + diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c new file mode 100644 index 0000000000..a7e6126de1 --- /dev/null +++ b/tests/nwfilterxml2xmltest.c @@ -0,0 +1,121 @@ +#include + +#include +#include +#include +#include + +#include +#include + +#include "internal.h" +#include "testutils.h" +#include "xml.h" +#include "threads.h" +#include "nwfilter_params.h" +#include "nwfilter_conf.h" +#include "testutilsqemu.h" + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) { + char inXmlData[MAX_FILE]; + char *inXmlPtr = &(inXmlData[0]); + char outXmlData[MAX_FILE]; + char *outXmlPtr = &(outXmlData[0]); + char *actual = NULL; + int ret = -1; + virNWFilterDefPtr dev = NULL; + + if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0) + goto fail; + + if (!(dev = virNWFilterDefParseString(NULL, inXmlData))) + goto fail; + + if (!(actual = virNWFilterDefFormat(NULL, dev))) + goto fail; + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); + goto fail; + } + + ret = 0; + + fail: + free(actual); + virNWFilterDefFree(dev); + return ret; +} + +static int testCompareXMLToXMLHelper(const void *data) { + char inxml[PATH_MAX]; + char outxml[PATH_MAX]; + snprintf(inxml, PATH_MAX, "%s/nwfilterxml2xmlin/%s.xml", + abs_srcdir, (const char*)data); + snprintf(outxml, PATH_MAX, "%s/nwfilterxml2xmlout/%s.xml", + abs_srcdir, (const char*)data); + return testCompareXMLToXMLFiles(inxml, outxml); +} + + +static int +mymain(int argc, char **argv) +{ + int ret = 0; + char cwd[PATH_MAX]; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + return (EXIT_FAILURE); + } + + abs_srcdir = getenv("abs_srcdir"); + if (!abs_srcdir) + abs_srcdir = getcwd(cwd, sizeof(cwd)); + +#define DO_TEST(name) \ + if (virtTestRun("NWFilter XML-2-XML " name, \ + 1, testCompareXMLToXMLHelper, (name)) < 0) \ + ret = -1 + + DO_TEST("mac-test"); + DO_TEST("arp-test"); + DO_TEST("ip-test"); + DO_TEST("ipv6-test"); + + DO_TEST("tcp-test"); + DO_TEST("udp-test"); + DO_TEST("icmp-test"); + DO_TEST("igmp-test"); + DO_TEST("sctp-test"); + DO_TEST("udplite-test"); + DO_TEST("esp-test"); + DO_TEST("ah-test"); + DO_TEST("all-test"); + + DO_TEST("tcp-ipv6-test"); + DO_TEST("udp-ipv6-test"); + DO_TEST("icmpv6-test"); + DO_TEST("sctp-ipv6-test"); + DO_TEST("udplite-ipv6-test"); + DO_TEST("esp-ipv6-test"); + DO_TEST("ah-ipv6-test"); + DO_TEST("all-ipv6-test"); + + DO_TEST("ref-test"); + DO_TEST("ref-rule-test"); + + return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +VIRT_TEST_MAIN(mymain) -- GitLab