tests/lib: pass C++ wrapper types to `RunIn` callbacks
[babeltrace.git] / tests / lib / conds / conds-triggers.cpp
CommitLineData
5d7e8359
PP
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
5 */
6
7#include <babeltrace2/babeltrace.h>
8
9#include "common/assert.h"
c802cacb 10
053db960 11#include "utils.hpp"
5d7e8359 12
486428e8 13static void trigger_graph_mip_version(void)
cc09350f 14{
486428e8 15 bt_graph_create(292);
cc09350f
SM
16}
17
486428e8 18static bt_field_class *get_uint_fc(bt_self_component *self_comp)
5d7e8359 19{
486428e8
SM
20 bt_trace_class *tc = bt_trace_class_create(self_comp);
21 bt_field_class *fc;
5d7e8359 22
486428e8
SM
23 BT_ASSERT(tc);
24 fc = bt_field_class_integer_unsigned_create(tc);
25 BT_ASSERT(fc);
26 return fc;
5d7e8359
PP
27}
28
5d15e4ca 29static void trigger_fc_int_set_field_value_range_n_0(const bt2::SelfComponent self)
5d7e8359 30{
5d15e4ca 31 bt_field_class_integer_set_field_value_range(get_uint_fc(self.libObjPtr()), 0);
5d7e8359
PP
32}
33
5d15e4ca 34static void trigger_fc_int_set_field_value_range_n_gt_64(const bt2::SelfComponent self)
5d7e8359 35{
5d15e4ca 36 bt_field_class_integer_set_field_value_range(get_uint_fc(self.libObjPtr()), 65);
5d7e8359
PP
37}
38
5d15e4ca 39static void trigger_fc_int_set_field_value_range_null(bt2::SelfComponent)
5d7e8359 40{
486428e8 41 bt_field_class_integer_set_field_value_range(NULL, 23);
5d7e8359
PP
42}
43
486428e8
SM
44static const struct cond_trigger triggers[] = {
45 COND_TRIGGER_PRE_BASIC("pre:graph-create:valid-mip-version", NULL, trigger_graph_mip_version),
46 COND_TRIGGER_PRE_RUN_IN_COMP_CLS_INIT("pre:field-class-integer-set-field-value-range:valid-n",
47 "0", trigger_fc_int_set_field_value_range_n_0),
48 COND_TRIGGER_PRE_RUN_IN_COMP_CLS_INIT("pre:field-class-integer-set-field-value-range:valid-n",
49 "gt-64", trigger_fc_int_set_field_value_range_n_gt_64),
50 COND_TRIGGER_PRE_RUN_IN_COMP_CLS_INIT(
51 "pre:field-class-integer-set-field-value-range:not-null:field-class", NULL,
52 trigger_fc_int_set_field_value_range_null),
5d7e8359
PP
53};
54
55int main(int argc, const char *argv[])
56{
486428e8
SM
57 cond_main(argc, argv, triggers, sizeof(triggers) / sizeof(*triggers));
58 return 0;
5d7e8359 59}
This page took 0.044824 seconds and 4 git commands to generate.