diff options
author | Terry Wilson <twilson@redhat.com> | 2018-10-09 11:31:32 -0500 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-10-11 15:00:46 -0700 |
commit | a7be68a4d77791bbe02c37f7ad8ae60b02e5679e (patch) | |
tree | 07aa0cbcbcffa7f7a80905d20c627481b768d244 /tests/test-ovsdb.py | |
parent | 39cc92aa651e209e246d6e1547662ba0cafb9f1d (diff) | |
download | openvswitch-a7be68a4d77791bbe02c37f7ad8ae60b02e5679e.tar.gz |
Test the Python C JSON extension
The C JSON parser was added quite a while ago, but unless you
configure with --enable-shared and have the Python 2/3 development
libraries installed, and the resulting python-ovs module installed,
'make check' won't actually test it.
This patch changes Python-based tests to run from the
$builddir/python directory and makes the tests configurable to use
both JSON backends. There are some unicode failures in the C JSON
extension that I left unfixed in this patch to make it easy to
show run the new tests on broken code. The next patch in this set
works around the issue.
Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
Diffstat (limited to 'tests/test-ovsdb.py')
-rw-r--r-- | tests/test-ovsdb.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py index 14491a2e9..b99109dc2 100644 --- a/tests/test-ovsdb.py +++ b/tests/test-ovsdb.py @@ -23,6 +23,7 @@ import uuid import ovs.db.idl import ovs.db.schema import ovs.db.types +import ovs.json import ovs.ovsuuid import ovs.poller import ovs.stream @@ -815,14 +816,20 @@ The following options are also available: def main(argv): try: - options, args = getopt.gnu_getopt(argv[1:], 't:h', + options, args = getopt.gnu_getopt(argv[1:], 't:h:j:', ['timeout', - 'help']) + 'help', 'json-parser']) except getopt.GetoptError as geo: sys.stderr.write("%s: %s\n" % (ovs.util.PROGRAM_NAME, geo.msg)) sys.exit(1) timeout = None + # Save the old version to detect whether we support the C Parser + # but then override to the Python parser because it is always available + # and is the historical default + ORIG_PARSER = ovs.json.PARSER + ovs.json.PARSER = ovs.json.PARSER_PY + for key, value in options: if key in ['-h', '--help']: usage() @@ -834,6 +841,17 @@ def main(argv): except TypeError: raise error.Error("value %s on -t or --timeout is not at " "least 1" % value) + elif key in ['-j', '--json-parser']: + if value == "python": + ovs.json.PARSER = ovs.json.PARSER_PY + elif value in ('C', 'c'): + if ORIG_PARSER != ovs.json.PARSER_C: + raise error.Error("C parser selected, but not compiled") + else: + ovs.json.PARSER = ovs.json.PARSER_C + else: + raise error.Error( + "invalid option: %s, json-parser must be 'C' or json") else: sys.exit(0) |