Fix: tests: add cli/params/test_params to Makefile and fix it
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 24 Oct 2019 18:43:44 +0000 (14:43 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Sat, 26 Oct 2019 20:36:38 +0000 (16:36 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2254
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
tests/Makefile.am
tests/data/cli/params/bt_plugin_params.py

index f8d0f788b42de34bd585847156329b8f86d90fa6..ac7eb887004897b987b82d374da8dc5ce09a7f71 100644 (file)
@@ -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
index 6b60889645a624b150c8067dbc134d08b97deffb..63c655b0e74be0fd1ca1edbcdb22c7fbed1138a6 100644 (file)
@@ -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
 
 
This page took 0.042629 seconds and 4 git commands to generate.