diff --git a/rcl/test/rcl/test_arguments.cpp b/rcl/test/rcl/test_arguments.cpp index e86d215ed..cbff38e3d 100644 --- a/rcl/test/rcl/test_arguments.cpp +++ b/rcl/test/rcl/test_arguments.cpp @@ -210,7 +210,7 @@ TEST_F(CLASSNAME(TestArgumentsFixture, RMW_IMPLEMENTATION), check_known_vs_unkno EXPECT_TRUE( are_known_ros_args( {"--ros-args", "--thread-attrs-value", - "[{priority: 10, scheduling_policy: FIFO, name: thread-1, core_affinity: [1,2,3]}]"})); + "[{priority: 10, scheduling_policy: FIFO, tag: attr-1, core_affinity: [1,2,3]}]"})); } bool @@ -238,7 +238,7 @@ TEST_F(CLASSNAME(TestArgumentsFixture, RMW_IMPLEMENTATION), check_valid_vs_inval "--params-file", parameters_filepath.c_str(), "--log-level", "INFO", "--log-config-file", "file.config", "--thread-attrs-value", - "[{priority: 10, scheduling_policy: IDLE, name: thread-1, core_affinity: [1]}]" + "[{priority: 10, scheduling_policy: IDLE, tag: attr-1, core_affinity: [1]}]" })); // ROS args unknown to rcl are not (necessarily) invalid diff --git a/rcl/test/resources/test_arguments/test_thread_attrs.yaml b/rcl/test/resources/test_arguments/test_thread_attrs.yaml index af9e89cb8..b1096dcc2 100644 --- a/rcl/test/resources/test_arguments/test_thread_attrs.yaml +++ b/rcl/test/resources/test_arguments/test_thread_attrs.yaml @@ -1,8 +1,8 @@ -- name: thread-1 +- tag: attr-1 priority: 10 scheduling_policy: FIFO core_affinity: [1] -- name: thread-2 +- tag: attr-2 priority: 20 scheduling_policy: RR core_affinity: [2] diff --git a/rcl_yaml_param_parser/src/impl/types.h b/rcl_yaml_param_parser/src/impl/types.h index f7f0c27ee..aae3e384b 100644 --- a/rcl_yaml_param_parser/src/impl/types.h +++ b/rcl_yaml_param_parser/src/impl/types.h @@ -68,7 +68,7 @@ typedef enum thread_attr_key_type_e THREAD_ATTR_KEY_CORE_AFFINITY = 1, THREAD_ATTR_KEY_SCHEDULING_POLICY = 2, THREAD_ATTR_KEY_PRIORITY = 4, - THREAD_ATTR_KEY_NAME = 8 + THREAD_ATTR_KEY_TAG = 8 } thread_attr_key_type_t; typedef enum thread_attr_key_bits_e @@ -78,7 +78,7 @@ typedef enum thread_attr_key_bits_e THREAD_ATTR_KEY_CORE_AFFINITY | THREAD_ATTR_KEY_SCHEDULING_POLICY | THREAD_ATTR_KEY_PRIORITY | - THREAD_ATTR_KEY_NAME + THREAD_ATTR_KEY_TAG } thread_attr_key_bits_t; #ifdef __cplusplus diff --git a/rcl_yaml_param_parser/src/parse_thread_attr.c b/rcl_yaml_param_parser/src/parse_thread_attr.c index a659d2f4e..88eca2bb6 100644 --- a/rcl_yaml_param_parser/src/parse_thread_attr.c +++ b/rcl_yaml_param_parser/src/parse_thread_attr.c @@ -64,10 +64,10 @@ parse_thread_attr_key( *key_type = THREAD_ATTR_KEY_PRIORITY; } else if (strcmp(str, "scheduling_policy") == 0) { *key_type = THREAD_ATTR_KEY_SCHEDULING_POLICY; - } else if (strcmp(str, "name") == 0) { - *key_type = THREAD_ATTR_KEY_NAME; + } else if (strcmp(str, "tag") == 0) { + *key_type = THREAD_ATTR_KEY_TAG; } else if (*str == '\0') { - RCUTILS_SET_ERROR_MSG("empty name for a thread attribute"); + RCUTILS_SET_ERROR_MSG("empty tag for a thread attribute"); ret = RCUTILS_RET_ERROR; goto error; } else { @@ -122,7 +122,7 @@ rcutils_ret_t parse_thread_attr( rcutils_thread_core_affinity_t core_affinity = rcutils_get_zero_initialized_thread_core_affinity(); int priority; - char const * name = NULL; + char const * tag = NULL; rcutils_allocator_t allocator = attrs->allocator; void * ret_val = NULL; @@ -154,7 +154,7 @@ rcutils_ret_t parse_thread_attr( const char * value = (char *)event.data.scalar.value; yaml_scalar_style_t style = event.data.scalar.style; - const yaml_char_t * tag = event.data.scalar.tag; + const yaml_char_t * yaml_tag = event.data.scalar.tag; data_types_t val_type; switch (key_type) { @@ -174,8 +174,8 @@ rcutils_ret_t parse_thread_attr( } value = (char *)event.data.scalar.value; style = event.data.scalar.style; - tag = event.data.scalar.tag; - ret_val = get_value(value, style, tag, &val_type, allocator); + yaml_tag = event.data.scalar.tag; + ret_val = get_value(value, style, yaml_tag, &val_type, allocator); if (DATA_TYPE_INT64 != val_type) { RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING( "Unrecognized value for thread core affinity: %s", value); @@ -195,7 +195,7 @@ rcutils_ret_t parse_thread_attr( if (event.type != YAML_SCALAR_EVENT) { goto error; } - ret_val = get_value(value, style, tag, &val_type, allocator); + ret_val = get_value(value, style, yaml_tag, &val_type, allocator); if (DATA_TYPE_INT64 != val_type) { RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING( "Unrecognized value for thread priority: %s", value); @@ -210,17 +210,17 @@ rcutils_ret_t parse_thread_attr( } sched_policy = parse_thread_attr_scheduling_policy(value); break; - case THREAD_ATTR_KEY_NAME: + case THREAD_ATTR_KEY_TAG: if (event.type != YAML_SCALAR_EVENT) { goto error; } if (*value == '\0') { - RCUTILS_SET_ERROR_MSG("Empty thread name"); + RCUTILS_SET_ERROR_MSG("Empty thread attribute tag"); ret = RCUTILS_RET_ERROR; goto error; } - name = rcutils_strdup(value, allocator); - if (NULL == name) { + tag = rcutils_strdup(value, allocator); + if (NULL == tag) { ret = RCUTILS_RET_BAD_ALLOC; goto error; } @@ -241,18 +241,18 @@ rcutils_ret_t parse_thread_attr( goto error; } - ret = rcutils_thread_attrs_add_attr(attrs, sched_policy, &core_affinity, priority, name); + ret = rcutils_thread_attrs_add_attr(attrs, sched_policy, &core_affinity, priority, tag); if (RCUTILS_RET_OK != ret) { goto error; } - allocator.deallocate((char *)name, allocator.state); + allocator.deallocate((char *)tag, allocator.state); return RCUTILS_RET_OK; error: - if (NULL != name) { - allocator.deallocate((char *)name, allocator.state); + if (NULL != tag) { + allocator.deallocate((char *)tag, allocator.state); } if (NULL != ret_val) { allocator.deallocate(ret_val, allocator.state); diff --git a/rcl_yaml_param_parser/test/test_parse_thread_attr.cpp b/rcl_yaml_param_parser/test/test_parse_thread_attr.cpp index 1251066c4..058c09ffa 100644 --- a/rcl_yaml_param_parser/test/test_parse_thread_attr.cpp +++ b/rcl_yaml_param_parser/test/test_parse_thread_attr.cpp @@ -78,14 +78,14 @@ TEST_F(TestParseThreadAttr, success) { yaml_event_t event; prepare_yaml_parser( - "{ priority: 10, name: thread-1, core_affinity: [1], scheduling_policy: FIFO }"); + "{ priority: 10, tag: attr-1, core_affinity: [1], scheduling_policy: FIFO }"); ret = parse_thread_attr(&parser, &attrs); EXPECT_EQ(RCUTILS_RET_OK, ret); EXPECT_EQ(1, attrs.num_attributes); EXPECT_EQ(10, attrs.attributes[0].priority); - EXPECT_STREQ("thread-1", attrs.attributes[0].name); + EXPECT_STREQ("attr-1", attrs.attributes[0].tag); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[0].core_affinity, 1)); EXPECT_EQ(RCUTILS_THREAD_SCHEDULING_POLICY_FIFO, attrs.attributes[0].scheduling_policy); @@ -102,7 +102,7 @@ TEST_F(TestParseThreadAttr, unknown_key) { rcutils_ret_t ret; prepare_yaml_parser( - "{ priority: 10, name: thread-1, core_affinity: [1], unknown_key: FIFO }"); + "{ priority: 10, tag: attr-1, core_affinity: [1], unknown_key: FIFO }"); ret = parse_thread_attr(&parser, &attrs); EXPECT_EQ(RCUTILS_RET_ERROR, ret); @@ -112,7 +112,7 @@ TEST_F(TestParseThreadAttr, all_valid_keys_with_unknown_key) { rcutils_ret_t ret; prepare_yaml_parser( - "{ priority: 10, name: thread-1, core_affinity: [1], " + "{ priority: 10, tag: attr-1, core_affinity: [1], " "scheduling_policy: FIFO, unknown_key: RR }"); ret = parse_thread_attr(&parser, &attrs); @@ -122,7 +122,7 @@ TEST_F(TestParseThreadAttr, all_valid_keys_with_unknown_key) { TEST_F(TestParseThreadAttr, missing_key_value) { rcutils_ret_t ret; prepare_yaml_parser( - "{ priority: 10, name: thread-1 }"); + "{ priority: 10, tag: attr-1 }"); ret = parse_thread_attr(&parser, &attrs); EXPECT_EQ(RCUTILS_RET_ERROR, ret); @@ -135,7 +135,7 @@ TEST_F(TestParseThreadAttrs, success) { ss << "["; for (std::size_t i = 0; i < 100; ++i) { ss << "{ priority: " << i * 10; - ss << ", name: thread-" << i; + ss << ", tag: attr-" << i; ss << ", core_affinity: [" << i << "]"; ss << ", scheduling_policy: FIFO },"; } @@ -151,9 +151,9 @@ TEST_F(TestParseThreadAttrs, success) { for (std::size_t i = 0; i < 100; ++i) { EXPECT_EQ(i * 10, attrs.attributes[i].priority); ss.str(""); - ss << "thread-" << i; + ss << "attr-" << i; buf = ss.str(); - EXPECT_STREQ(buf.c_str(), attrs.attributes[i].name); + EXPECT_STREQ(buf.c_str(), attrs.attributes[i].tag); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i)); EXPECT_EQ(RCUTILS_THREAD_SCHEDULING_POLICY_FIFO, attrs.attributes[i].scheduling_policy); } @@ -162,7 +162,7 @@ TEST_F(TestParseThreadAttrs, success) { TEST_F(TestParseThreadAttr, affinity_multiple_core) { rcutils_ret_t ret; prepare_yaml_parser( - "{ priority: 10, name: thread-1, core_affinity: [1,2,3], scheduling_policy: FIFO }"); + "{ priority: 10, tag: attr-1, core_affinity: [1,2,3], scheduling_policy: FIFO }"); ret = parse_thread_attr(&parser, &attrs); EXPECT_EQ(RCUTILS_RET_OK, ret); diff --git a/rcl_yaml_param_parser/test/test_parser_thread_attr.cpp b/rcl_yaml_param_parser/test/test_parser_thread_attr.cpp index c50ad9d1b..6d8668a0a 100644 --- a/rcl_yaml_param_parser/test/test_parser_thread_attr.cpp +++ b/rcl_yaml_param_parser/test/test_parser_thread_attr.cpp @@ -89,8 +89,8 @@ TEST_F(TestParserThreadAttr, success_file) { for (size_t i = 0; i < 10; ++i) { EXPECT_EQ(attrs.attributes[i].priority, i * 10); char buf[32]; - snprintf(buf, sizeof(buf), "thread-%lu", i); - EXPECT_STREQ(buf, attrs.attributes[i].name); + snprintf(buf, sizeof(buf), "attr-%lu", i); + EXPECT_STREQ(buf, attrs.attributes[i].tag); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i)); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i + 10)); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i * i)); @@ -114,8 +114,8 @@ TEST_F(TestParserThreadAttr, success_value) { for (size_t i = 0; i < 10; ++i) { EXPECT_EQ(attrs.attributes[i].priority, i * 10); char buf[32]; - snprintf(buf, sizeof(buf), "thread-%lu", i); - EXPECT_STREQ(buf, attrs.attributes[i].name); + snprintf(buf, sizeof(buf), "attr-%lu", i); + EXPECT_STREQ(buf, attrs.attributes[i].tag); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i)); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i + 10)); EXPECT_TRUE(rcutils_thread_core_affinity_is_set(&attrs.attributes[i].core_affinity, i * i)); diff --git a/rcl_yaml_param_parser/test/thread_attr_success.yaml b/rcl_yaml_param_parser/test/thread_attr_success.yaml index 5e9bdafa2..062c98a97 100644 --- a/rcl_yaml_param_parser/test/thread_attr_success.yaml +++ b/rcl_yaml_param_parser/test/thread_attr_success.yaml @@ -1,40 +1,40 @@ - priority: 0 - name: thread-0 + tag: attr-0 core_affinity: [0,10,0] scheduling_policy: BADSCHEDPOLICY1 - priority: 10 - name: thread-1 + tag: attr-1 core_affinity: [1,11,1] scheduling_policy: FIFO - priority: 20 - name: thread-2 + tag: attr-2 core_affinity: [2,12,4] scheduling_policy: RR - priority: 30 - name: thread-3 + tag: attr-3 core_affinity: [3,13,9] scheduling_policy: SPORADIC - priority: 40 - name: thread-4 + tag: attr-4 core_affinity: [4,14,16] scheduling_policy: OTHER - priority: 50 - name: thread-5 + tag: attr-5 core_affinity: [5,15,25] scheduling_policy: IDLE - priority: 60 - name: thread-6 + tag: attr-6 core_affinity: [6,16,36] scheduling_policy: BATCH - priority: 70 - name: thread-7 + tag: attr-7 core_affinity: [7,17,49] scheduling_policy: DEADLINE - priority: 80 - name: thread-8 + tag: attr-8 core_affinity: [8,18,64] scheduling_policy: BADSCHEDPOLICY2 - priority: 90 - name: thread-9 + tag: attr-9 core_affinity: [9,19,81] scheduling_policy: FIFO