summaryrefslogtreecommitdiff
path: root/tests/nwfilterxml2xmltest.c
Commit message (Collapse)AuthorAgeFilesLines
* src/tests: use g_autoptr for virNWFilterDef and virNWFilterRuleDefJiang Jiacheng2023-01-201-14/+8
| | | | | | | | Use g_autoptr() for virNWFilterDef and virNWFilterRuleDef and remove unnecessary label. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* conf: nwfilter: Provide only virNWFilterDefParsePeter Krempa2022-10-061-1/+1
| | | | | | | Replace virNWFilterDefParseString/File with the common function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* tests: Remove unused includesPeng Liang2022-06-161-5/+0
| | | | | Signed-off-by: Peng Liang <tcx4c70@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
* tests: nwfilter: use g_autofreeJán Tomko2021-09-091-7/+3
| | | | | Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
* lib: Drop internal virXXXPtr typedefsMichal Privoznik2021-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | Historically, we declared pointer type to our types: typedef struct _virXXX virXXX; typedef virXXX *virXXXPtr; But usefulness of such declaration is questionable, at best. Unfortunately, we can't drop every such declaration - we have to carry some over, because they are part of public API (e.g. virDomainPtr). But for internal types - we can do drop them and use what every other C project uses 'virXXX *'. This change was generated by a very ugly shell script that generated sed script which was then called over each file in the repository. For the shell script refer to the cover letter: https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
* nwfilterxml2xmltest: Rename cases with XMLs not conforming to schemaPeter Krempa2020-10-201-22/+22
| | | | | | | | | There's quite a few negative tests. In anticipation of schema testing of the 'nwfilterxml2xmlin' directory rename all negative/non-conformant XMLs with the -invalid suffix. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
* tests: Use g_strdup_printf() instead of virAsprintf()Michal Privoznik2019-11-121-7/+2
| | | | | Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
* src: More cleanup of some system headers already contained in internal.hErik Skultety2018-09-201-2/+0
| | | | | | | | | | | All of the ones being removed are pulled in by internal.h. The only exception is sanlock which expects the application to include <stdint.h> before sanlock's headers, because sanlock prototypes use fixed width int, but they don't include stdint.h themselves, so we have to leave that one in place. Signed-off-by: Erik Skultety <eskultet@redhat.com> Acked-by: Michal Privoznik <mprivozn@redhat.com>
* internal: Move <stdio.h> include to internal.hErik Skultety2018-09-201-1/+0
| | | | | | | | It doesn't really make sense for us to have stdlib.h and string.h but not stdio.h in the internal.h header. Signed-off-by: Erik Skultety <eskultet@redhat.com> Acked-by: Michal Privoznik <mprivozn@redhat.com>
* Remove backslash alignment attemptsAndrea Bolognani2017-11-031-9/+9
| | | | | | | | | | | | | | | | | | Right-aligning backslashes when defining macros or using complex commands in Makefiles looks cute, but as soon as any changes is required to the code you end up with either distractingly broken alignment or unnecessarily big diffs where most of the changes are just pushing all backslashes a few characters to one side. Generated using $ git grep -El '[[:blank:]][[:blank:]]\\$' | \ grep -E '*\.([chx]|am|mk)$$' | \ while read f; do \ sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \ done Signed-off-by: Andrea Bolognani <abologna@redhat.com>
* tests: Rename VIRT_TEST_* macros to VIR_TEST_*Andrea Bolognani2017-04-041-1/+1
| | | | | | We use the "vir" prefix pretty consistently in our APIs, both external and internal, which made these macros stood out.
* tests: Rename virtTestCompareToFile to virTestCompareToFile.Tomáš Ryšavý2016-06-081-1/+1
| | | | This function doesn't follow our convention of naming functions.
* tests: Rename virtTestRun to virTestRun.Tomáš Ryšavý2016-06-081-2/+2
| | | | This function doesn't follow our convention of naming functions.
* tests: Add virtTestCompareToFileCole Robinson2015-04-231-8/+1
| | | | Replaces a common pattern used in many test files
* tests: Use *DefParseFile moreCole Robinson2015-04-231-5/+1
|
* Indent top-level labels by one space in tests/Ján Tomko2014-03-251-1/+1
|
* Require spaces around equality comparisonsMartin Kletzander2014-03-181-1/+1
| | | | | | | | | Commit a1cbe4b5 added a check for spaces around assignments and this patch extends it to checks for spaces around '=='. One exception is virAssertCmpInt where comma after '==' is acceptable (since it is a macro and '==' is its argument). Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
* Remove test case average timingDaniel P. Berrange2013-10-081-1/+1
| | | | | | | The test case average timing code has not been used by any test case ever. Delete it to remove complexity. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Remove virConnectPtr arg from virNWFilterDefParse*Daniel P. Berrange2013-10-071-1/+1
| | | | | | | None of the virNWFilterDefParse* methods require a virConnectPtr arg, so just drop it Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Don't ignore errors parsing nwfilter rulesDaniel P. Berrange2013-09-251-8/+6
| | | | | | | | | For inexplicable reasons, the nwfilter XML parser is intentionally ignoring errors that arise during parsing. As well as meaning that users don't get any feedback on their XML mistakes, this will lead it to silently drop data in OOM conditions. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Introduce OOM reporting to virAsprintfMichal Privoznik2013-07-101-0/+2
| | | | | | | Actually, I'm turning this function into a macro as filename, function name and line number needs to be passed. The new function virAsprintfInternal is introduced with the extended set of arguments.
* virutil: Move string related functions to virstring.cMichal Privoznik2013-05-021-0/+1
| | | | | | | | The source code base needs to be adapted as well. Some files include virutil.h just for the string related functions (here, the include is substituted to match the new file), some include virutil.h without any need (here, the include is removed), and some require both.
* Rename xml.{c,h} to virxml.{c,h}Daniel P. Berrange2012-12-211-1/+1
|
* Rename threads.{c,h} to virthread.{c,h}Daniel P. Berrange2012-12-211-1/+1
|
* nwfilter: Add support for ipsetStefan Berger2012-05-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the recent ipset iptables extension to libvirt's nwfilter subsystem. Ipset allows to maintain 'sets' of IP addresses, ports and other packet parameters and allows for faster lookup (in the order of O(1) vs. O(n)) and rule evaluation to achieve higher throughput than what can be achieved with individual iptables rules. On the command line iptables supports ipset using iptables ... -m set --match-set <ipset name> <flags> -j ... where 'ipset name' is the name of a previously created ipset and flags is a comma-separated list of up to 6 flags. Flags use 'src' and 'dst' for selecting IP addresses, ports etc. from the source or destination part of a packet. So a concrete example may look like this: iptables -A INPUT -m set --match-set test src,src -j ACCEPT Since ipset management is quite complex, the idea was to leave ipset management outside of libvirt but still allow users to reference an ipset. The user would have to make sure the ipset is available once the VM is started so that the iptables rule(s) referencing the ipset can be created. Using XML to describe an ipset in an nwfilter rule would then look as follows: <rule action='accept' direction='in'> <all ipset='test' ipsetflags='src,src'/> </rule> The two parameters on the command line are also the two distinct XML attributes 'ipset' and 'ipsetflags'. FYI: Here is the man page for ipset: https://ipset.netfilter.org/ipset.man.html Regards, Stefan
* Cleanup for a return statement in source filesMartin Kletzander2012-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | Return statements with parameter enclosed in parentheses were modified and parentheses were removed. The whole change was scripted, here is how: List of files was obtained using this command: git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' | \ grep -e '\.[ch]$' -e '\.py$' Found files were modified with this command: sed -i -e \ 's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \ -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_' Then checked for nonsense. The whole command looks like this: git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' | \ grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e \ 's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \ -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
* build: expand rule to cover testsuiteEric Blake2012-02-031-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was done with: sed -i 's/\(\bfree *(/VIR_FREE(/g' tests/*.c followed by fixing the few compile errors that resulted. * cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation): Remove tests from exemption. * tests/testutils.h: Add common header. * tests/commandhelper.c: Fix offenders. * tests/cputest.c: Likewise. * tests/domainsnapshotxml2xmltest.c: Likewise. * tests/interfacexml2xmltest.c: Likewise. * tests/networkxml2argvtest.c: Likewise. * tests/networkxml2xmltest.c: Likewise. * tests/nodedevxml2xmltest.c: Likewise. * tests/nodeinfotest.c: Likewise. * tests/nwfilterxml2xmltest.c: Likewise. * tests/qemuargv2xmltest.c: Likewise. * tests/qemuxml2argvtest.c: Likewise. * tests/qemuxml2xmltest.c: Likewise. * tests/qemuxmlnstest.c: Likewise. * tests/qparamtest.c: Likewise. * tests/sexpr2xmltest.c: Likewise. * tests/storagepoolxml2xmltest.c: Likewise. * tests/storagevolxml2xmltest.c: Likewise. * tests/testutils.c: Likewise. * tests/virshtest.c: Likewise. * tests/xencapstest.c: Likewise. * tests/xmconfigtest.c: Likewise. * tests/xml2sexprtest.c: Likewise.
* Add test cases for new ways to access variables in filtersStefan Berger2012-01-111-0/+3
| | | | | | This patch adds a couple of XML parser / schema validator test cases for the new 'ways' to access variables via index or iterator.
* Add test cases for STP traffic filteringStefan Berger2011-11-221-0/+1
| | | | | | | This patch adds a few test cases for the XML parsing of STP filtering nodes. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
* Add test cases for VLAN traffic filteringStefan Berger2011-11-191-0/+1
| | | | | | | This patch adds a few test cases for the XML parsing of VLAN filtering nodes. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
* Add test cases for parsing of list valuesStefan Berger2011-11-181-0/+2
| | | | | | | | This patch adds test cases for parsing of parameters with multiple occurrances of the same name. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
* Add test casesStefan Berger2011-11-181-0/+2
| | | | | | | | Add test case for the chain names with known prefixes and the chain priority. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
* tests: Lower stack usage below 4096 bytesMatthias Bolte2011-04-301-21/+31
| | | | | | | | | Make virtTestLoadFile allocate the buffer to read the file into. Fix logic error in virtTestLoadFile, stop reading on the first empty line. Use virFileReadLimFD in virtTestCaptureProgramOutput to avoid manual buffer handling.
* tests: simplify common setupEric Blake2011-04-291-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few of the tests were missing basic sanity checks, while most of them were doing copy-and-paste initialization (in fact, some of them pasted the argc > 1 check more than once!). It's much nicer to do things in one common place, and minimizes the size of the next patch that fixes getcwd usage. * tests/testutils.h (EXIT_AM_HARDFAIL): New define. (progname, abs_srcdir): Define for all tests. (VIRT_TEST_MAIN): Change callback signature. * tests/testutils.c (virtTestMain): Do more common init. * tests/commandtest.c (mymain): Simplify. * tests/cputest.c (mymain): Likewise. * tests/esxutilstest.c (mymain): Likewise. * tests/eventtest.c (mymain): Likewise. * tests/hashtest.c (mymain): Likewise. * tests/networkxml2xmltest.c (mymain): Likewise. * tests/nodedevxml2xmltest.c (myname): Likewise. * tests/nodeinfotest.c (mymain): Likewise. * tests/nwfilterxml2xmltest.c (mymain): Likewise. * tests/qemuargv2xmltest.c (mymain): Likewise. * tests/qemuhelptest.c (mymain): Likewise. * tests/qemuxml2argvtest.c (mymain): Likewise. * tests/qemuxml2xmltest.c (mymain): Likewise. * tests/qparamtest.c (mymain): Likewise. * tests/sexpr2xmltest.c (mymain): Likewise. * tests/sockettest.c (mymain): Likewise. * tests/statstest.c (mymain): Likewise. * tests/storagepoolxml2xmltest.c (mymain): Likewise. * tests/storagevolxml2xmltest.c (mymain): Likewise. * tests/virbuftest.c (mymain): Likewise. * tests/virshtest.c (mymain): Likewise. * tests/vmx2xmltest.c (mymain): Likewise. * tests/xencapstest.c (mymain): Likewise. * tests/xmconfigtest.c (mymain): Likewise. * tests/xml2sexprtest.c (mymain): Likewise. * tests/xml2vmxtest.c (mymain): Likewise.
* Put <stdbool.h> into internal.h so it is available everywhereDaniel P. Berrange2011-02-241-1/+0
| | | | | | | Remove the <stdbool.h> header from all source files / headers and just put it into internal.h * src/internal.h: Add <stdbool.h>
* tests: Fix detection of expected errorsJiri Denemark2010-11-291-10/+5
|
* test: silence nwfilter testStefan Berger2010-10-131-49/+79
| | | | This patch silences the nwfilter test case.
* nwfilter: Add test case for testing the state attributeStefan Berger2010-10-071-0/+3
| | | | | | This patch adds a test case for testing the XML parser's and instantiator's support of the state attribute. The other test case tests existing capabilities. Both test cases will be used in TCK again.
* nwfilter: Add a test case for testing the comment attributeStefan Berger2010-09-301-0/+2
| | | | | This patch adds a test case for testing the XML parser's and instantiator's support of the comment attribute.
* nwfilter: add support for RAPR protocolStefan Berger2010-04-271-0/+1
| | | | | | | | | | | | | | | | | | | This patch adds support for the RARP protocol. This may be needed due to qemu sending out a RARP packet (at least that's what it seems to want to do even though the protocol id is wrong) when migration finishes and we'd need a rule to let the packets pass. Unfortunately my installation of ebtables does not understand -p RARP and also seems to otherwise depend on strings in /etc/ethertype translated to protocol identifiers. Therefore I need to pass -p 0x8035 for RARP. To generally get rid of the dependency of that file I switch all so far supported protocols to use their protocol identifier in the -p parameter rather than the string. I am also extending the schema and added a test case. changes from v1 to v2: - added test case into patch
* nwfilter: enable hex number inputs in filter XMLStefan Berger2010-04-261-0/+2
| | | | | | | | | | | | | | With this patch I want to enable hex number inputs in the filter XML. A number that was entered as hex is also printed as hex unless a string representing the meaning can be found. I am also extending the schema and adding a test case. A problem with the DSCP value is fixed on the way as well. Changes from V1 to V2: - using asHex boolean in all printf type of functions to select the output format in hex or decimal format
* nwfilter: extend schema + add testcase w/ connlimit-aboveStefan Berger2010-04-231-0/+2
| | | | | I am extending the schema with the recently added connlimit-above attribute and adding a test case for it to the test suite.
* nwfilter: More XML parser test casesStefan Berger2010-04-091-0/+4
| | | | This patch adds a couple more nwfilter test cases for the XML parser tests.
* This patch removes the virConnectPtr parameter from all functions where it's ↵Stefan Berger2010-04-051-1/+1
| | | | not necessary starting out with removing it as a parameter to the error reporting function.
* This patch adds a couple of test cases for the XML parsing test suite ↵Stefan Berger2010-04-021-0/+121
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>