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 <stefanb@us.ibm.com>
This commit is contained in:
Stefan Berger 2010-04-02 13:28:28 -04:00
parent b3e8f9f415
commit 8459218cbc
48 changed files with 908 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,19 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<ah-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
srcipaddr='f:e:d::c:b:a' srcipmask='127'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<ah-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<ah-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<ah srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<ah srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<ah srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,19 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<all-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
srcipaddr='f:e:d::c:b:a' srcipmask='127'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<all-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<all-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<all srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<all srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<all srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,33 @@
<filter name='testcase'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<arp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
protocolid='arp'
dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'
hwtype='12'
protocoltype='34'
opcode='Request'
arpsrcmacaddr='1:2:3:4:5:6'
arpdstmacaddr='a:b:c:d:e:f'/>
</rule>
<rule action='accept' direction='out'>
<arp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
opcode='1' hwtype='255' protocoltype='255'/>
</rule>
<rule action='accept' direction='out'>
<arp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
opcode='11' hwtype='256' protocoltype='256'/>
</rule>
<rule action='accept' direction='out'>
<arp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
opcode='65535' hwtype='65535' protocoltype='65535' />
</rule>
<rule action='accept' direction='out'>
<arp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
opcode='65536' hwtype='65536' protocoltype='65536' />
</rule>
</filter>

View File

@ -0,0 +1,19 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<esp-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
srcipaddr='f:e:d::c:b:a' srcipmask='127'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<esp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<esp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<esp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<esp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<esp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<icmp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2' type='12' code='11'/>
</rule>
<rule action='accept' direction='in'>
<icmp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33' type='255' code='255'/>
</rule>
<rule action='accept' direction='in'>
<icmp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33' type='256' code='256'/>
</rule>
</filter>

View File

@ -0,0 +1,19 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<icmpv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
srcipaddr='f:e:d::c:b:a' srcipmask='127'
dscp='2' type='12' code='11'/>
</rule>
<rule action='accept' direction='in'>
<icmpv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33' type='255' code='255'/>
</rule>
<rule action='accept' direction='in'>
<icmpv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='33' type='256' code='256'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<igmp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<igmp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<igmp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,34 @@
<filter name='testcase'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<ip srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'
srcipaddr='10.1.2.3' srcipmask='255.255.255.255'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
protocol='udp'
srcportstart='20' srcportend='22'
dstportstart='100' dstportend='101'
/>
</rule>
<rule action='accept' direction='out'>
<ip srcipaddr='10.1.2.3' srcipmask='255.255.128.0'
dstipaddr='10.1.2.3' dstipmask='255.255.255.0'
protocol='17' dscp='63'
/>
</rule>
<rule action='accept' direction='in'>
<ip srcipaddr='10.1.2.3' srcipmask='255.255.255.254'
dstipaddr='10.1.2.3' dstipmask='255.255.255.128'
protocol='255' dscp='64'
/>
</rule>
<rule action='accept' direction='inout'>
<ip srcipaddr='10.1.2.3' srcipmask='255.255.255.127'
dstipaddr='10.1.2.3' dstipmask='255.255.255.254'
protocol='256' dscp='64'
/>
</rule>
</filter>

View File

@ -0,0 +1,43 @@
<filter name='testcase'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<ipv6 srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:fe'
dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80'
srcipaddr='::10.1.2.3' srcipmask='22'
dstipaddr='::10.1.2.3'
dstipmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000'
protocol='udp'
srcportstart='20' srcportend='22'
dstportstart='100' dstportend='101'
/>
</rule>
<rule action='accept' direction='inout'>
<ipv6 srcipaddr='1::2' srcipmask='128'
dstipaddr='a:b:c::'
dstipmask='ffff:ffff:ffff:ffff:8000::'
protocol='6'
srcportstart='20' srcportend='22'
dstportstart='100' dstportend='101'
/>
</rule>
<rule action='accept' direction='inout'>
<ipv6 srcipaddr='1::2' srcipmask='128'
dstipaddr='a:b:c::'
dstipmask='ffff:ffff:ffff:ffff:8000::'
protocol='6'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'
/>
</rule>
<rule action='accept' direction='inout'>
<ipv6 srcipaddr='1::2' srcipmask='128'
dstipaddr='a:b:c::'
dstipmask='ffff:ffff:ffff:ffff:8000::'
protocol='18'
/>
</rule>
</filter>

View File

@ -0,0 +1,23 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<mac srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
protocolid='arp'/>
</rule>
<rule action='accept' direction='in'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'
protocolid='ipv4'/>
</rule>
<rule action='accept' direction='in'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'
protocolid='1536'/>
</rule>
<rule action='accept' direction='in'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'
protocolid='15'/>
</rule>
<rule action='accept' direction='in'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'
protocolid='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase'>
<uuid>83011800-f663-96d6-8841-fd836b4318c6</uuid>
<filterref filter='clean-traffic'/>
<rule action='accept' direction='out'>
<mac srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff'
protocolid='arp'/>
</rule>
<rule action='accept' direction='out'>
<tcp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='out'>
<udp-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
dscp='2'/>
</rule>
</filter>

View File

@ -0,0 +1,4 @@
<filter name='testcase'>
<uuid>83011800-f663-96d6-8841-fd836b4318c6</uuid>
<filterref filter='clean-traffic'/>
</filter>

View File

@ -0,0 +1,22 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<sctp-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<sctp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in'>
<sctp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
</rule>
</filter>

View File

@ -0,0 +1,22 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<sctp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<sctp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in'>
<sctp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
</rule>
</filter>

View File

@ -0,0 +1,22 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<tcp-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<tcp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in'>
<tcp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
</rule>
</filter>

View File

@ -0,0 +1,22 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<tcp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<tcp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in'>
<tcp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
</rule>
</filter>

View File

@ -0,0 +1,22 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<udp-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<udp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c' srcipmask='128'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in'>
<udp-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
</rule>
</filter>

View File

@ -0,0 +1,22 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<udp srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<udp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='33'
srcportstart='20' srcportend='21'
dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in'>
<udp srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='32'
dscp='63'
srcportstart='255' srcportend='256'
dstportstart='65535' dstportend='65536'/>
</rule>
</filter>

View File

@ -0,0 +1,19 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<udplite-ipv6 srcmacaddr='1:2:3:4:5:6'
dstipaddr='a:b:c::d:e:f' dstipmask='128'
srcipaddr='f:e:d::c:b:a' srcipmask='127'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<udplite-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='a:b:c::' srcipmask='128'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<udplite-ipv6 srcmacaddr='1:2:3:4:5:6'
srcipaddr='::10.1.2.3' srcipmask='129'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out'>
<udplite srcmacaddr='1:2:3:4:5:6'
dstipaddr='10.1.2.3' dstipmask='255.255.255.255'
dscp='2'/>
</rule>
<rule action='accept' direction='in'>
<udplite srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
<rule action='accept' direction='in'>
<udplite srcmacaddr='1:2:3:4:5:6'
srcipaddr='10.1.2.3' srcipmask='22'
dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<ah-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='f:e:d::c:b:a' srcipmask='127' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<ah-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<ah-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<ah srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<ah srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<ah srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<all-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='f:e:d::c:b:a' srcipmask='127' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<all-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<all-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<all srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<all srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<all srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' hwtype='12' protocoltype='34' opcode='Request' arpsrcmacaddr='01:02:03:04:05:06' arpdstmacaddr='0a:0b:0c:0d:0e:0f'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' hwtype='255' protocoltype='255' opcode='Request'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' hwtype='256' protocoltype='256' opcode='11'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' hwtype='65535' protocoltype='65535' opcode='65535'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<arp srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<esp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='f:e:d::c:b:a' srcipmask='127' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<esp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<esp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<esp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<esp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<esp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<icmp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2' type='12' code='11'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<icmp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33' type='255' code='255'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<icmp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<icmpv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='f:e:d::c:b:a' srcipmask='127' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2' type='12' code='11'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<icmpv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33' type='255' code='255'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<icmpv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<igmp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<igmp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<igmp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,15 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<ip srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' srcipaddr='10.1.2.3' srcipmask='32' dstipaddr='10.1.2.3' dstipmask='32' protocol='udp' srcportstart='20' srcportend='22' dstportstart='100' dstportend='101'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<ip srcipaddr='10.1.2.3' srcipmask='17' dstipaddr='10.1.2.3' dstipmask='24' protocol='udp' dscp='63'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<ip srcipaddr='10.1.2.3' srcipmask='31' dstipaddr='10.1.2.3' dstipmask='25' protocol='255'/>
</rule>
<rule action='accept' direction='inout' priority='500'>
<ip srcipaddr='10.1.2.3' dstipaddr='10.1.2.3' dstipmask='31'/>
</rule>
</filter>

View File

@ -0,0 +1,15 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<ipv6 srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:fe' dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:80' srcipaddr='::10.1.2.3' srcipmask='22' dstipaddr='::10.1.2.3' dstipmask='113' protocol='udp' srcportstart='20' srcportend='22' dstportstart='100' dstportend='101'/>
</rule>
<rule action='accept' direction='inout' priority='500'>
<ipv6 srcipaddr='1::2' srcipmask='128' dstipaddr='a:b:c::' dstipmask='65' protocol='tcp' srcportstart='20' srcportend='22' dstportstart='100' dstportend='101'/>
</rule>
<rule action='accept' direction='inout' priority='500'>
<ipv6 srcipaddr='1::2' srcipmask='128' dstipaddr='a:b:c::' dstipmask='65' protocol='tcp' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
<rule action='accept' direction='inout' priority='500'>
<ipv6 srcipaddr='1::2' srcipmask='128' dstipaddr='a:b:c::' dstipmask='65' protocol='18'/>
</rule>
</filter>

View File

@ -0,0 +1,18 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<mac srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' protocolid='arp'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' protocolid='ipv4'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' protocolid='1536'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<mac dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' protocolid='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,13 @@
<filter name='testcase' chain='root'>
<uuid>83011800-f663-96d6-8841-fd836b4318c6</uuid>
<filterref filter='clean-traffic'/>
<rule action='accept' direction='out' priority='500'>
<mac srcmacaddr='01:02:03:04:05:06' srcmacmask='ff:ff:ff:ff:ff:ff' protocolid='arp'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<tcp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='out' priority='500'>
<udp-ipv6 srcmacaddr='01:02:03:04:05:06' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
</filter>

View File

@ -0,0 +1,4 @@
<filter name='testcase' chain='root'>
<uuid>83011800-f663-96d6-8841-fd836b4318c6</uuid>
<filterref filter='clean-traffic'/>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<sctp-ipv6 srcmacaddr='01:02:03:04:05:06' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<sctp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<sctp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<sctp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<sctp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<sctp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<tcp-ipv6 srcmacaddr='01:02:03:04:05:06' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<tcp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<tcp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<tcp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<tcp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<tcp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<udp-ipv6 srcmacaddr='01:02:03:04:05:06' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipmask='128' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udp-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<udp srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32' dscp='33' srcportstart='20' srcportend='21' dstportstart='100' dstportend='1111'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udp srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='32' dscp='63' srcportstart='255' srcportend='256' dstportstart='65535'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<udplite-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='f:e:d::c:b:a' srcipmask='127' dstipaddr='a:b:c::d:e:f' dstipmask='128' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udplite-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='a:b:c::' srcipmask='128' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udplite-ipv6 srcmacaddr='01:02:03:04:05:06' srcipaddr='::10.1.2.3' dscp='33'/>
</rule>
</filter>

View File

@ -0,0 +1,12 @@
<filter name='testcase' chain='root'>
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
<rule action='accept' direction='out' priority='500'>
<udplite srcmacaddr='01:02:03:04:05:06' dstipaddr='10.1.2.3' dstipmask='32' dscp='2'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udplite srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
<rule action='accept' direction='in' priority='500'>
<udplite srcmacaddr='01:02:03:04:05:06' srcipaddr='10.1.2.3' srcipmask='22' dscp='33'/>
</rule>
</filter>

121
tests/nwfilterxml2xmltest.c Normal file
View File

@ -0,0 +1,121 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#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)