From 269daba5e7b1d0eff82a86305afd4b8dd6c23956 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 24 Oct 2019 14:43:44 -0400 Subject: [PATCH] Fix: tests: add cli/params/test_params to Makefile and fix it The test bt_plugin_params.py has been broken for a while, because guess what? It's not ran by the testsuite! So first, add it to the Makefile. Then, update the value types expected by the component class. I made it so it raises an exception if it gets an object of a type it doesn't expect. That should make the test a bit more robust. Change-Id: I1749287e7d0e61d8b46d905b2a7ded13ec07283a Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2254 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- tests/Makefile.am | 8 ++++++-- tests/data/cli/params/bt_plugin_params.py | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index f8d0f788..ac7eb887 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -41,6 +41,7 @@ dist_check_SCRIPTS = \ cli/convert/test_auto_source_discovery_params \ cli/convert/test_auto_source_discovery_log_level \ cli/convert/test_convert_args \ + cli/params/test_params \ cli/test_help \ cli/test_intersection \ cli/test_output_ctf_metadata \ @@ -119,9 +120,12 @@ endif if ENABLE_PYTHON_PLUGINS if ENABLE_PYTHON_BINDINGS -TESTS_CLI += cli/convert/test_auto_source_discovery_grouping \ +TESTS_CLI += \ + cli/convert/test_auto_source_discovery_grouping \ cli/convert/test_auto_source_discovery_log_level \ - cli/convert/test_auto_source_discovery_params + cli/convert/test_auto_source_discovery_params \ + cli/params/test_params + TESTS_PLUGINS += plugins/flt.utils.trimmer/test_trimming \ plugins/flt.utils.muxer/succeed/test_succeed endif diff --git a/tests/data/cli/params/bt_plugin_params.py b/tests/data/cli/params/bt_plugin_params.py index 6b608896..63c655b0 100644 --- a/tests/data/cli/params/bt_plugin_params.py +++ b/tests/data/cli/params/bt_plugin_params.py @@ -24,17 +24,29 @@ def to_string(p): # additional information (u suffix to differentiate unsigned integers from # signed integers). - if type(p) is bt2.ArrayValue: + if type(p) is bt2._ArrayValueConst: s = '[{}]'.format(', '.join([to_string(x) for x in p])) - elif type(p) is bt2.MapValue: + elif type(p) is bt2._MapValueConst: s = '{{{}}}'.format( ', '.join([k + '=' + to_string(p[k]) for k in sorted(p.keys())]) ) - elif type(p) is bt2.UnsignedIntegerValue: + elif type(p) is bt2._UnsignedIntegerValueConst: s = str(p) + 'u' - else: + elif ( + type(p) + in ( + bt2._StringValueConst, + bt2._SignedIntegerValueConst, + bt2._RealValueConst, + bt2._BoolValueConst, + ) + or p is None + ): s = str(p) + else: + raise TypeError('Unexpected type', type(p)) + return s -- 2.34.1