I spotted some messages in the CLI code that could print the component
class type as a string rather than an integer.
bt_component_class_type_string is not accessible to the CLI code,
because it's in a lib header. Move it to common/common.h, and rename it
accordingly.
Adjust all existing callers, and use it in cli/babeltrace2.c.
Before:
$ ./src/cli/babeltrace2 query src.ctf.fs foo
...
Failed to query component class: unknown query object: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=1 object="foo"
After:
$ ./src/cli/babeltrace2 query src.ctf.fs foo
...
Failed to query component class: unknown query object: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=SOURCE object="foo"
Change-Id: I88f01ac7cae9723ce11dbf2ec0843a06d761abb6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6273
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
+ "comp-cls-name=\"%s\", comp-cls-type=%s",
cfg->cmd_data.query.cfg_component->plugin_name->str,
cfg->cmd_data.query.cfg_component->comp_cls_name->str,
cfg->cmd_data.query.cfg_component->plugin_name->str,
cfg->cmd_data.query.cfg_component->comp_cls_name->str,
- cfg->cmd_data.query.cfg_component->type);
+ bt_common_component_class_type_string(
+ cfg->cmd_data.query.cfg_component->type));
if (ret) {
BT_CLI_LOGE_APPEND_CAUSE(
"Failed to query component class: %s: plugin-name=\"%s\", "
if (ret) {
BT_CLI_LOGE_APPEND_CAUSE(
"Failed to query component class: %s: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d "
+ "comp-cls-name=\"%s\", comp-cls-type=%s "
"object=\"%s\"", fail_reason,
cfg->cmd_data.query.cfg_component->plugin_name->str,
cfg->cmd_data.query.cfg_component->comp_cls_name->str,
"object=\"%s\"", fail_reason,
cfg->cmd_data.query.cfg_component->plugin_name->str,
cfg->cmd_data.query.cfg_component->comp_cls_name->str,
- cfg->cmd_data.query.cfg_component->type,
+ bt_common_component_class_type_string(
+ cfg->cmd_data.query.cfg_component->type),
cfg->cmd_data.query.object->str);
goto error;
}
cfg->cmd_data.query.object->str);
goto error;
}
if (!needed_comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
if (!needed_comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
+ "comp-cls-name=\"%s\", comp-cls-type=%s",
cfg->cmd_data.help.cfg_component->plugin_name->str,
cfg->cmd_data.help.cfg_component->comp_cls_name->str,
cfg->cmd_data.help.cfg_component->plugin_name->str,
cfg->cmd_data.help.cfg_component->comp_cls_name->str,
- cfg->cmd_data.help.cfg_component->type);
+ bt_common_component_class_type_string(
+ cfg->cmd_data.help.cfg_component->type));
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
+ "comp-cls-name=\"%s\", comp-cls-type=%s",
plugin_name, comp_cls_name,
plugin_name, comp_cls_name,
- BT_COMPONENT_CLASS_TYPE_SOURCE);
+ bt_common_component_class_type_string(
+ BT_COMPONENT_CLASS_TYPE_SOURCE));
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
+ "comp-cls-name=\"%s\", comp-cls-type=%s",
plugin_name, comp_cls_name,
plugin_name, comp_cls_name,
- BT_COMPONENT_CLASS_TYPE_SOURCE);
+ bt_common_component_class_type_string(
+ BT_COMPONENT_CLASS_TYPE_SOURCE));
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
- plugin_name, comp_cls_name, comp_cls_type);
+ "comp-cls-name=\"%s\", comp-cls-type=%s",
+ plugin_name, comp_cls_name,
+ bt_common_component_class_type_string(comp_cls_type));
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
if (!comp_cls) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot find component class: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d",
+ "comp-cls-name=\"%s\", comp-cls-type=%s",
cfg_comp->plugin_name->str,
cfg_comp->comp_cls_name->str,
cfg_comp->plugin_name->str,
cfg_comp->comp_cls_name->str,
+ bt_common_component_class_type_string(cfg_comp->type));
if (ret) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot create component: plugin-name=\"%s\", "
if (ret) {
BT_CLI_LOGE_APPEND_CAUSE(
"Cannot create component: plugin-name=\"%s\", "
- "comp-cls-name=\"%s\", comp-cls-type=%d, "
+ "comp-cls-name=\"%s\", comp-cls-type=%s, "
"comp-name=\"%s\"",
cfg_comp->plugin_name->str,
cfg_comp->comp_cls_name->str,
"comp-name=\"%s\"",
cfg_comp->plugin_name->str,
cfg_comp->comp_cls_name->str,
- cfg_comp->type, cfg_comp->instance_name->str);
+ bt_common_component_class_type_string(cfg_comp->type),
+ cfg_comp->instance_name->str);
str->str[len + 1] = '\0';
}
str->str[len + 1] = '\0';
}
+static inline
+const char *bt_common_component_class_type_string(
+ enum bt_component_class_type type)
+{
+ switch (type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ return "SOURCE";
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ return "SINK";
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ return "FILTER";
+ default:
+ return "(unknown)";
+ }
+}
+
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
}
#endif
"addr=%p, name=\"%s\", type=%s",
comp_cls,
bt_component_class_get_name(comp_cls),
"addr=%p, name=\"%s\", type=%s",
comp_cls,
bt_component_class_get_name(comp_cls),
- bt_component_class_type_string(comp_cls->type));
+ bt_common_component_class_type_string(comp_cls->type));
return BT_FUNC_STATUS_OK;
}
return BT_FUNC_STATUS_OK;
}
# define bt_component_class_freeze(_cc)
#endif
# define bt_component_class_freeze(_cc)
#endif
-static inline
-const char *bt_component_class_type_string(enum bt_component_class_type type)
-{
- switch (type) {
- case BT_COMPONENT_CLASS_TYPE_SOURCE:
- return "SOURCE";
- case BT_COMPONENT_CLASS_TYPE_SINK:
- return "SINK";
- case BT_COMPONENT_CLASS_TYPE_FILTER:
- return "FILTER";
- default:
- return "(unknown)";
- }
-}
-
static inline
bool bt_component_class_has_message_iterator_class(
struct bt_component_class *component_class)
static inline
bool bt_component_class_has_message_iterator_class(
struct bt_component_class *component_class)
char tmp_prefix[TMP_PREFIX_LEN];
BUF_APPEND(", %stype=%s, %sname=\"%s\"",
char tmp_prefix[TMP_PREFIX_LEN];
BUF_APPEND(", %stype=%s, %sname=\"%s\"",
- PRFIELD(bt_component_class_type_string(comp_class->type)),
+ PRFIELD(bt_common_component_class_type_string(comp_class->type)),
PRFIELD_GSTRING(comp_class->name));
if (comp_class->description) {
PRFIELD_GSTRING(comp_class->name));
if (comp_class->description) {
if (comp_class_id) {
BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", "
"%splugin-name=\"%s\"",
if (comp_class_id) {
BUF_APPEND(", %scomp-cls-type=%s, %scomp-cls-name=\"%s\", "
"%splugin-name=\"%s\"",
- PRFIELD(bt_component_class_type_string(
+ PRFIELD(bt_common_component_class_type_string(
comp_class_id->type)),
PRFIELD_GSTRING(comp_class_id->name),
PRFIELD_GSTRING(comp_class_id->plugin_name));
comp_class_id->type)),
PRFIELD_GSTRING(comp_class_id->name),
PRFIELD_GSTRING(comp_class_id->plugin_name));
NULL,
descriptor->name,
cur_cc_descr_attr->comp_class_descriptor->name,
NULL,
descriptor->name,
cur_cc_descr_attr->comp_class_descriptor->name,
- bt_component_class_type_string(
+ bt_common_component_class_type_string(
cur_cc_descr_attr->comp_class_descriptor->type),
cur_cc_descr_attr->type_name,
cur_cc_descr_attr->type);
cur_cc_descr_attr->comp_class_descriptor->type),
cur_cc_descr_attr->type_name,
cur_cc_descr_attr->type);
NULL,
descriptor->name,
cur_cc_descr_attr->comp_class_descriptor->name,
NULL,
descriptor->name,
cur_cc_descr_attr->comp_class_descriptor->name,
- bt_component_class_type_string(
+ bt_common_component_class_type_string(
cur_cc_descr_attr->comp_class_descriptor->type),
cur_cc_descr_attr->type_name,
cur_cc_descr_attr->type);
cur_cc_descr_attr->comp_class_descriptor->type),
cur_cc_descr_attr->type_name,
cur_cc_descr_attr->type);
NULL,
descriptor->name,
cc_full_descr->descriptor->name,
NULL,
descriptor->name,
cc_full_descr->descriptor->name,
- bt_component_class_type_string(
+ bt_common_component_class_type_string(
cc_full_descr->descriptor->type));
if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
cc_full_descr->descriptor->type));
if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
bt_plugin_get_name(*plugin_out),
comp_class,
bt_component_class_get_name(comp_class),
bt_plugin_get_name(*plugin_out),
comp_class,
bt_component_class_get_name(comp_class),
- bt_component_class_type_string(
+ bt_common_component_class_type_string(
bt_component_class_get_type(comp_class)));
goto error;
}
bt_component_class_get_type(comp_class)));
goto error;
}
'src.query.SourceWithQueryThatPrintsParams' 'please-fail' '-p' 'a=2'
# Non-existent component class.
'src.query.SourceWithQueryThatPrintsParams' 'please-fail' '-p' 'a=2'
# Non-existent component class.
-expect_failure 'Cannot find component class: plugin-name="query", comp-cls-name="NonExistentSource", comp-cls-type=1' \
+expect_failure 'Cannot find component class: plugin-name="query", comp-cls-name="NonExistentSource", comp-cls-type=SOURCE' \
'src.query.NonExistentSource' 'the-object' '-p' 'a=2'
# Wrong parameter syntax.
'src.query.NonExistentSource' 'the-object' '-p' 'a=2'
# Wrong parameter syntax.
bt_cli "${stdout}" "${stderr}" help src.ctf.bob
isnt $? 0 "help with unknown component class name"
bt_cli "${stdout}" "${stderr}" help src.ctf.bob
isnt $? 0 "help with unknown component class name"
-grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=1' "${stderr}"
+grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=SOURCE' "${stderr}"
ok $? "help with unknown component class name produces expected error"
grep --silent 'Description: CTF input and output' "${stdout}"
ok $? "help with unknown component class name produces expected error"
grep --silent 'Description: CTF input and output' "${stdout}"