summaryrefslogtreecommitdiffstats
path: root/tests/json_echo/run-test.py
Commit message (Collapse)AuthorAgeFilesLines
* tests: json_echo: Print errors to stderrPhil Sutter2021-08-241-7/+7
| | | | | | | | | | | | | | Apart from the obvious, this fixes exit_dump() which tried to dump the wrong variable ('out' instead of 'obj') and missed that json.dumps() doesn't print but just returns a string. Make it call exit_err() to share some code, which changes the prefix from 'FAIL' to 'Error' as a side-effect. While being at it, fix for a syntax warning with newer Python in unrelated code. Fixes: bb32d8db9a125 ("JSON: Add support for echo option") Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: json_echo: Support testing host binariesPhil Sutter2020-02-071-4/+19
| | | | | | | Support -H/--host option to use host's libnftables.so.1. Alternatively users may specify a custom library path via -l/--library option. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: json_echo: Fix for Python3Phil Sutter2020-02-071-1/+1
| | | | | | | | The keys() method returns an object which does not support indexing, so convert it to a list prior to doing so. Fixes: a35e3a0cdc63a ("tests: json_echo: convert to py3") Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests/json_echo: Drop needless workaroundPhil Sutter2019-06-071-4/+2
| | | | | | | | With cache issues now resolved, there is no need for the multi add test workaround anymore. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* tests: json_echo: convert to py3Shekhar Sharma2019-05-291-22/+23
| | | | | | | | This patch converts the run-test.py file to run on both python3 and python2. Signed-off-by: Shekhar Sharma <shekhar250198@gmail.com> Acked-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* parser_json: Rewrite echo supportPhil Sutter2019-04-031-61/+145
| | | | | | | | | | | | | | | | | Instead of guessing which object to update with retrieved handle, introduce a list containing struct cmd <-> json_t associations. Upon batch commit, allocated cmd objects are assigned a unique netlink sequence number. Monitor events contain that number as well, so they may be associated to the cmd object which triggered them. Using json_cmd_assoc list the event may in turn be associated to the input's JSON object which should receive the handle value. This also fixes incorrect behaviour if JSON input contained "insert" commands. Fixes: bb32d8db9a125 ("JSON: Add support for echo option") Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* doc: Spelling and grammar fixesVille Skyttä2018-11-131-1/+1
| | | | | Signed-off-by: Ville Skyttä <ville.skytta@iki.fi> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* JSON: Add support for echo optionPhil Sutter2018-10-291-0/+211
The basic principle is to not return a JSON object freshly created from netlink responses, but just update the existing user-provided one to make sure callers get back exactly what they expect. To achieve that, keep the parsed JSON object around in a global variable ('cur_root') and provide a custom callback to insert handles into it from received netlink messages. The tricky bit here is updating rules since unique identification is problematic. Therefore drop possibly present handles from input and later assume updates are received in order so the first rule not having a handle set is the right one. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>