tests/lib/conds: run pre-cond test by name
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 30 Apr 2024 17:31:39 +0000 (17:31 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2024 02:56:57 +0000 (22:56 -0400)
commit2bddca6f62d10c07ca6078d52a3f65f95f944c2f
tree4020bc56555ac07255301e08be5f2a1dd5c2722d
parent7376c71d813475dad8cfd0c4cfd67e0dd69fa38a
tests/lib/conds: run pre-cond test by name

Change `conds-trigger` to run triggers by name, instead of by index.
This makes it easier to run an arbitrary trigger by hand, when
developing.

Example:

    $ tests/lib/conds/conds-triggers list | python3 -m json.tool
    ...
    {
        "cond-id": "pre:field-class-integer-set-field-value-range:valid-n",
        "name": "field-class-integer-set-field-value-range:valid-n-gt-64"
    },
    ...
    $ tests/lib/conds/conds-triggers run field-class-integer-set-field-value-range:valid-n-gt-64
    <abort message>

Update the `test.py` driver to match.  Update it also to output the
trigger name in a TAP comment before each test, to make it easier for a
developer to run a failing test by hand.

Example:

    $ tests/lib/conds/test-conds.sh
    # Running trigger `field-class-integer-set-field-value-range:not-null:field-class`
    # TAP results for LibPrePostCondsTestCase
    ok 1 - test_field_class_integer_set_field_value_range_not_null_field_class (test.LibPrePostCondsTestCase.test_field_class_integer_set_field_value_range_not_null_field_class)
    # Running trigger `field-class-integer-set-field-value-range:valid-n-0`
    ok 2 - test_field_class_integer_set_field_value_range_valid_n_0 (test.LibPrePostCondsTestCase.test_field_class_integer_set_field_value_range_valid_n_0)
    # Running trigger `field-class-integer-set-field-value-range:valid-n-gt-64`
    ok 3 - test_field_class_integer_set_field_value_range_valid_n_gt_64 (test.LibPrePostCondsTestCase.test_field_class_integer_set_field_value_range_valid_n_gt_64)

Note the little quirk that the `Running trigger` comment is displayed
before the `TAP results for ...` comment.  The latter is displayed when
the first result is recorded, so I'm not sure how to fix this, but I
don't think it's really a problem as it is.

Since the test name is now a used as a key, modify `condMain()` to check
that the test names passed in the `condTriggers` vectors are unique.  If
there is a duplicate name, we get:

    $ tests/lib/conds/conds-triggers list
    Duplicate test name `field-class-integer-set-field-value-range:valid-n-0`

Ensuring unique names would have probably been useful anyway, since we
generate Python methods based on that name, so we don't want any
clashes.

Change-Id: Ie05ad4070d9ea859e0678ee1cf5ed1c4010f9829
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12503
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
tests/lib/conds/test.py
tests/lib/conds/utils.cpp
This page took 0.024615 seconds and 4 git commands to generate.