From 0188c9683f40cbf4895d6f8a858f8801949581b3 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 11 Nov 2024 13:15:11 +0800 Subject: [PATCH] fix: invalid graph (#249) Co-authored-by: Hu Yueh-Wei --- .../ten_runtime/binding/cpp/internal/addon.h | 118 ++++----- .../ten_runtime/app/endpoint.h | 3 + .../extension/extension_info/extension_info.h | 8 +- core/src/ten_runtime/app/app.c | 7 +- core/src/ten_runtime/app/close.c | 9 +- core/src/ten_runtime/app/endpoint.c | 11 + core/src/ten_runtime/app/predefined_graph.c | 54 ++-- .../extension/extension_info/extension_info.c | 230 ++++++++++++------ .../extension/extension_info/json.c | 6 +- .../extension/extension_info/value.c | 65 +++-- .../extension/msg_dest_info/msg_dest_info.c | 11 +- .../extension/msg_dest_info/value.c | 2 +- .../cmd/start_graph/field/extension_info.c | 22 +- .../default_extension_cpp/src/main.cc | 59 +++++ .../cmd_conversion/cmd_conversion_data.cc | 3 +- .../cmd_conversion/cmd_conversion_graph.cc | 9 +- .../cmd_conversion/cmd_conversion_path.cc | 2 + .../cmd_conversion_path_array_1.cc | 2 + .../cmd_conversion_path_array_2.cc | 2 + .../cmd_conversion_path_array_3.cc | 2 + .../cmd_conversion_path_array_4.cc | 2 + .../cmd_conversion_path_array_5.cc | 2 + .../cmd_conversion_path_array_6.cc | 2 + .../cmd_conversion_path_array_7.cc | 2 + .../cmd_conversion_path_keep_original.cc | 2 + .../cmd_conversion_path_nested_1.cc | 2 + .../cmd_conversion_path_nested_2.cc | 2 + .../cmd_conversion_path_nested_3.cc | 2 + .../cmd_conversion_path_nested_4.cc | 2 + .../cmd_conversion_path_nested_5.cc | 2 + .../predefined_graph_multi_extension_1.cc | 3 +- .../predefined_graph_multi_extension_4.cc | 13 +- 32 files changed, 449 insertions(+), 212 deletions(-) diff --git a/core/include/ten_runtime/binding/cpp/internal/addon.h b/core/include/ten_runtime/binding/cpp/internal/addon.h index 222513482..54d033594 100644 --- a/core/include/ten_runtime/binding/cpp/internal/addon.h +++ b/core/include/ten_runtime/binding/cpp/internal/addon.h @@ -219,63 +219,67 @@ class extension_addon_t : public addon_t { } // namespace ten -#define TEN_CPP_REGISTER_ADDON_AS_EXTENSION_GROUP(NAME, CLASS) \ - class NAME##_default_extension_group_addon_t \ - : public ten::extension_group_addon_t { \ - public: \ - void on_create_instance(ten::ten_env_t &ten_env, const char *name, \ - void *context) override { \ - auto *instance = new CLASS(name); \ - ten_env.on_create_instance_done(instance, context); \ - } \ - void on_destroy_instance(ten::ten_env_t &ten_env, void *instance, \ - void *context) override { \ - delete static_cast(instance); \ - ten_env.on_destroy_instance_done(context); \ - } \ - }; \ - static ten::addon_t *g_##NAME##_default_extension_group_addon = nullptr; \ - TEN_CONSTRUCTOR(____ctor_ten_declare_##NAME##_extension_group_addon____) { \ - g_##NAME##_default_extension_group_addon = \ - new NAME##_default_extension_group_addon_t(); \ - ten_string_t *base_dir = ten_path_get_module_path( \ - (void *)____ctor_ten_declare_##NAME##_extension_group_addon____); \ - ten_addon_register_extension_group( \ - #NAME, ten_string_get_raw_str(base_dir), \ - g_##NAME##_default_extension_group_addon->get_c_addon()); \ - ten_string_destroy(base_dir); \ - } \ - TEN_DESTRUCTOR(____dtor_ten_declare_##NAME##_##TYPE##_addon____) { \ - ten_addon_unregister_extension_group(#NAME); \ - delete g_##NAME##_default_extension_group_addon; \ +#define TEN_CPP_REGISTER_ADDON_AS_EXTENSION_GROUP(NAME, CLASS) \ + class NAME##_default_extension_group_addon_t \ + : public ten::extension_group_addon_t { \ + public: \ + void on_create_instance(ten::ten_env_t &ten_env, const char *name, \ + void *context) override { \ + auto *instance = new CLASS(name); \ + ten_env.on_create_instance_done(instance, context); \ + } \ + void on_destroy_instance(ten::ten_env_t &ten_env, void *instance, \ + void *context) override { \ + delete static_cast(instance); \ + ten_env.on_destroy_instance_done(context); \ + } \ + }; \ + static ten::addon_t *g_##NAME##_default_extension_group_addon = nullptr; \ + TEN_CONSTRUCTOR(____ctor_ten_declare_##NAME##_extension_group_addon____) { \ + g_##NAME##_default_extension_group_addon = \ + new NAME##_default_extension_group_addon_t(); \ + ten_string_t *base_dir = \ + ten_path_get_module_path(/* NOLINTNEXTLINE */ \ + (void *) \ + ____ctor_ten_declare_##NAME##_extension_group_addon____); \ + ten_addon_register_extension_group( \ + #NAME, ten_string_get_raw_str(base_dir), \ + g_##NAME##_default_extension_group_addon->get_c_addon()); \ + ten_string_destroy(base_dir); \ + } \ + TEN_DESTRUCTOR(____dtor_ten_declare_##NAME##_##TYPE##_addon____) { \ + ten_addon_unregister_extension_group(#NAME); \ + delete g_##NAME##_default_extension_group_addon; \ } -#define TEN_CPP_REGISTER_ADDON_AS_EXTENSION(NAME, CLASS) \ - class NAME##_default_extension_addon_t : public ten::extension_addon_t { \ - public: \ - void on_create_instance(ten::ten_env_t &ten_env, const char *name, \ - void *context) override { \ - auto *instance = new CLASS(name); \ - ten_env.on_create_instance_done(instance, context); \ - } \ - void on_destroy_instance(ten::ten_env_t &ten_env, void *instance, \ - void *context) override { \ - delete static_cast(instance); \ - ten_env.on_destroy_instance_done(context); \ - } \ - }; \ - static ten::addon_t *g_##NAME##_default_extension_addon = nullptr; \ - TEN_CONSTRUCTOR(____ctor_ten_declare_##NAME##_extension_addon____) { \ - g_##NAME##_default_extension_addon = \ - new NAME##_default_extension_addon_t(); \ - ten_string_t *base_dir = ten_path_get_module_path( \ - (void *)____ctor_ten_declare_##NAME##_extension_addon____); \ - ten_addon_register_extension( \ - #NAME, ten_string_get_raw_str(base_dir), \ - g_##NAME##_default_extension_addon->get_c_addon()); \ - ten_string_destroy(base_dir); \ - } \ - TEN_DESTRUCTOR(____dtor_ten_declare_##NAME##_##TYPE##_addon____) { \ - ten_addon_unregister_extension(#NAME); \ - delete g_##NAME##_default_extension_addon; \ +#define TEN_CPP_REGISTER_ADDON_AS_EXTENSION(NAME, CLASS) \ + class NAME##_default_extension_addon_t : public ten::extension_addon_t { \ + public: \ + void on_create_instance(ten::ten_env_t &ten_env, const char *name, \ + void *context) override { \ + auto *instance = new CLASS(name); \ + ten_env.on_create_instance_done(instance, context); \ + } \ + void on_destroy_instance(ten::ten_env_t &ten_env, void *instance, \ + void *context) override { \ + delete static_cast(instance); \ + ten_env.on_destroy_instance_done(context); \ + } \ + }; \ + static ten::addon_t *g_##NAME##_default_extension_addon = nullptr; \ + TEN_CONSTRUCTOR(____ctor_ten_declare_##NAME##_extension_addon____) { \ + g_##NAME##_default_extension_addon = \ + new NAME##_default_extension_addon_t(); \ + ten_string_t *base_dir = \ + ten_path_get_module_path(/* NOLINTNEXTLINE */ \ + (void *) \ + ____ctor_ten_declare_##NAME##_extension_addon____); \ + ten_addon_register_extension( \ + #NAME, ten_string_get_raw_str(base_dir), \ + g_##NAME##_default_extension_addon->get_c_addon()); \ + ten_string_destroy(base_dir); \ + } \ + TEN_DESTRUCTOR(____dtor_ten_declare_##NAME##_##TYPE##_addon____) { \ + ten_addon_unregister_extension(#NAME); \ + delete g_##NAME##_default_extension_addon; \ } diff --git a/core/include_internal/ten_runtime/app/endpoint.h b/core/include_internal/ten_runtime/app/endpoint.h index c84908b02..82d15fedd 100644 --- a/core/include_internal/ten_runtime/app/endpoint.h +++ b/core/include_internal/ten_runtime/app/endpoint.h @@ -19,3 +19,6 @@ TEN_RUNTIME_PRIVATE_API bool ten_app_is_endpoint_closed(ten_app_t *self); TEN_RUNTIME_PRIVATE_API void ten_app_create_protocol_context_store( ten_app_t *self); + +TEN_RUNTIME_PRIVATE_API bool ten_app_is_protocol_context_store_closed( + ten_app_t *self); diff --git a/core/include_internal/ten_runtime/extension/extension_info/extension_info.h b/core/include_internal/ten_runtime/extension/extension_info/extension_info.h index 7c5f5e255..f22aa0304 100644 --- a/core/include_internal/ten_runtime/extension/extension_info/extension_info.h +++ b/core/include_internal/ten_runtime/extension/extension_info/extension_info.h @@ -42,8 +42,9 @@ typedef struct ten_extension_info_t { TEN_RUNTIME_PRIVATE_API ten_extension_info_t *ten_extension_info_create(void); -TEN_RUNTIME_PRIVATE_API ten_shared_ptr_t *ten_extension_info_clone( - ten_extension_info_t *self, ten_list_t *extensions_info, ten_error_t *err); +TEN_RUNTIME_PRIVATE_API bool ten_extensions_info_clone(ten_list_t *from, + ten_list_t *to, + ten_error_t *err); TEN_RUNTIME_PRIVATE_API bool ten_extension_info_check_integrity( ten_extension_info_t *self, bool check_thread); @@ -58,8 +59,7 @@ TEN_RUNTIME_PRIVATE_API bool ten_extension_info_is_desired_extension_group( TEN_RUNTIME_PRIVATE_API ten_shared_ptr_t *get_extension_info_in_extensions_info( ten_list_t *extensions_info, const char *app_uri, const char *graph_id, const char *extension_group_name, const char *extension_addon_name, - const char *extension_instance_name, bool *new_one_created, - ten_error_t *err); + const char *extension_instance_name, bool should_exist, ten_error_t *err); TEN_RUNTIME_PRIVATE_API ten_extension_info_t *ten_extension_info_from_smart_ptr( ten_smart_ptr_t *smart_ptr); diff --git a/core/src/ten_runtime/app/app.c b/core/src/ten_runtime/app/app.c index d9482830f..a7b273d46 100644 --- a/core/src/ten_runtime/app/app.c +++ b/core/src/ten_runtime/app/app.c @@ -111,6 +111,7 @@ ten_app_t *ten_app_create(ten_app_on_configure_func_t on_configure, self->state = TEN_APP_STATE_INIT; self->endpoint_protocol = NULL; + self->protocol_context_store = NULL; ten_list_init(&self->engines); ten_list_init(&self->orphan_connections); @@ -157,8 +158,10 @@ void ten_app_destroy(ten_app_t *self) { ten_ref_dec_ref(&self->endpoint_protocol->ref); } - ten_protocol_context_store_destroy(self->protocol_context_store); - self->protocol_context_store = NULL; + if (self->protocol_context_store) { + ten_protocol_context_store_destroy(self->protocol_context_store); + self->protocol_context_store = NULL; + } ten_value_deinit(&self->manifest); ten_value_deinit(&self->property); diff --git a/core/src/ten_runtime/app/close.c b/core/src/ten_runtime/app/close.c index 1fc4e8ca6..c2921f04b 100644 --- a/core/src/ten_runtime/app/close.c +++ b/core/src/ten_runtime/app/close.c @@ -41,7 +41,7 @@ static bool ten_app_could_be_close(ten_app_t *self) { TEN_ASSERT(self && ten_app_check_integrity(self, true), "Should not happen."); if (ten_app_has_no_work(self) && ten_app_is_endpoint_closed(self) && - ten_protocol_context_store_is_closed(self->protocol_context_store)) { + ten_app_is_protocol_context_store_closed(self)) { return true; } @@ -86,6 +86,13 @@ static void ten_app_close_task(void *app_, TEN_UNUSED void *arg) { ten_app_t *app = (ten_app_t *)app_; TEN_ASSERT(app_ && ten_app_check_integrity(app_, true), "Should not happen."); + // The app might be closed due to the problems during creation, ex: some + // property is invalid. And all resources have not been created yet. + if (ten_app_could_be_close(app)) { + ten_app_proceed_to_close(app); + return; + } + ten_app_close_sync(app); } diff --git a/core/src/ten_runtime/app/endpoint.c b/core/src/ten_runtime/app/endpoint.c index 42a513fd0..d484cf44e 100644 --- a/core/src/ten_runtime/app/endpoint.c +++ b/core/src/ten_runtime/app/endpoint.c @@ -76,3 +76,14 @@ void ten_app_create_protocol_context_store(ten_app_t *self) { self->protocol_context_store, ten_app_on_protocol_context_store_closed, self); } + +bool ten_app_is_protocol_context_store_closed(ten_app_t *self) { + TEN_ASSERT(self && ten_app_check_integrity(self, true), + "Access across threads."); + + if (!self->protocol_context_store) { + return true; + } + + return ten_protocol_context_store_is_closed(self->protocol_context_store); +} diff --git a/core/src/ten_runtime/app/predefined_graph.c b/core/src/ten_runtime/app/predefined_graph.c index 801e0c4b6..eb3fe7a4c 100644 --- a/core/src/ten_runtime/app/predefined_graph.c +++ b/core/src/ten_runtime/app/predefined_graph.c @@ -261,12 +261,9 @@ bool ten_app_get_predefined_graph_extensions_and_groups_info_by_name( return false; } - ten_list_foreach (&predefined_graph_info->extensions_info, iter) { - ten_extension_info_t *extension_info = - ten_shared_ptr_get_data(ten_smart_ptr_listnode_get(iter.node)); - if (!ten_extension_info_clone(extension_info, extensions_info, err)) { - return false; - } + if (!ten_extensions_info_clone( + extensions_info, &predefined_graph_info->extensions_info, err)) { + return false; } ten_list_foreach (&predefined_graph_info->extension_groups_info, iter) { @@ -316,8 +313,11 @@ bool ten_app_get_predefined_graphs_from_property(ten_app_t *self) { goto done; } + int graph_idx = -1; ten_list_foreach (ten_value_peek_array(predefined_graphs), predefined_graphs_iter) { + graph_idx++; + ten_value_t *predefined_graph_info_value = ten_ptr_listnode_get(predefined_graphs_iter.node); TEN_ASSERT(predefined_graph_info_value && @@ -361,6 +361,7 @@ bool ten_app_get_predefined_graphs_from_property(ten_app_t *self) { ten_value_get_bool(predefined_graph_info_singleton_value, &err); } + // Parse 'nodes'. ten_value_t *predefined_graph_info_nodes_value = ten_value_object_peek(predefined_graph_info_value, TEN_STR_NODES); if (predefined_graph_info_nodes_value && @@ -390,18 +391,26 @@ bool ten_app_get_predefined_graphs_from_property(ten_app_t *self) { } const char *type = ten_value_peek_raw_str(type_value); - if (!strcmp(type, TEN_STR_EXTENSION)) { - ten_extension_info_node_from_value( + + // Only the extension node is preferred. + result = ten_c_string_is_equal(type, TEN_STR_EXTENSION); + if (result) { + ten_shared_ptr_t *extension_info = ten_extension_info_node_from_value( predefined_graph_info_node_item_value, - &predefined_graph_info->extensions_info, NULL); - } else { + &predefined_graph_info->extensions_info, &err); + if (!extension_info) { + result = false; + } + } + + if (!result) { ten_predefined_graph_info_destroy(predefined_graph_info); - result = false; goto done; } } } + // Parse 'connections'. ten_value_t *predefined_graph_info_connections_value = ten_value_object_peek(predefined_graph_info_value, TEN_STR_CONNECTIONS); if (predefined_graph_info_connections_value && @@ -415,16 +424,23 @@ bool ten_app_get_predefined_graphs_from_property(ten_app_t *self) { predefined_graph_info_connection_item_value), "Invalid argument."); - if (!predefined_graph_info_connection_item_value || - !ten_value_is_object(predefined_graph_info_connection_item_value)) { + result = + predefined_graph_info_connection_item_value && + ten_value_is_object(predefined_graph_info_connection_item_value); + if (result) { + ten_shared_ptr_t *src_extension_in_connection = + ten_extension_info_parse_connection_src_part_from_value( + predefined_graph_info_connection_item_value, + &predefined_graph_info->extensions_info, &err); + if (!src_extension_in_connection) { + result = false; + } + } + + if (!result) { ten_predefined_graph_info_destroy(predefined_graph_info); - result = false; goto done; } - - ten_extension_info_parse_connection_src_part_from_value( - predefined_graph_info_connection_item_value, - &predefined_graph_info->extensions_info, NULL); } } @@ -449,6 +465,8 @@ bool ten_app_get_predefined_graphs_from_property(ten_app_t *self) { done: if (result == false) { ten_list_clear(&self->predefined_graph_infos); + TEN_LOGE("[%s] Failed to parse predefined_graphs[%d], %s", + ten_app_get_uri(self), graph_idx, ten_error_errmsg(&err)); } ten_error_deinit(&err); diff --git a/core/src/ten_runtime/extension/extension_info/extension_info.c b/core/src/ten_runtime/extension/extension_info/extension_info.c index 99a7ddbf5..6747c97c3 100644 --- a/core/src/ten_runtime/extension/extension_info/extension_info.c +++ b/core/src/ten_runtime/extension/extension_info/extension_info.c @@ -122,24 +122,35 @@ static void ten_extension_info_destroy(ten_extension_info_t *self) { TEN_FREE(self); } -// 1. All extension_info will be stored in the `extensions_info`, including -// those defined in the `nodes` section, and those defined in each `dest` -// section in `connections`. +// 1. All extension_info will be stored in the `extensions_info`, only including +// those defined in the `nodes` section. Any extension_info used in +// `connections` must be declared in the `nodes`. // // 2. All extension_info in the `extensions_info` are unique, which is -// identified by the `loc` field. +// identified by the `loc` field. // // 3. Each extension_info in the `extensions_info` is a shared_ptr, and if one -// is used in the `dest` section, a weak_ptr will be created to reference it to -// avoid there is a cycle in the graph. +// is used in the `dest` section, a weak_ptr will be created to reference it +// to avoid there is a cycle in the graph. +// +// Parameters: +// +// - should_exist: the extension_info should be found in `extensions_info` if +// true. If we are parsing the `nodes` section, it should be false. And if we +// are parsing the `connections` section, it should be true. ten_shared_ptr_t *get_extension_info_in_extensions_info( ten_list_t *extensions_info, const char *app_uri, const char *graph_id, const char *extension_group_name, const char *extension_addon_name, - const char *extension_instance_name, bool *new_one_created, - ten_error_t *err) { + const char *extension_instance_name, bool should_exist, ten_error_t *err) { TEN_ASSERT(extensions_info && extension_group_name && extension_instance_name, "Should not happen."); + if (!should_exist) { + TEN_ASSERT( + extension_addon_name, + "Expect to be a create request, the extension_addon_name is required."); + } + ten_extension_info_t *extension_info = NULL; // Find the corresponding extension_info according to the instance name of @@ -147,6 +158,7 @@ ten_shared_ptr_t *get_extension_info_in_extensions_info( ten_listnode_t *extension_info_node = ten_list_find_shared_ptr_custom_4( extensions_info, app_uri, graph_id, extension_group_name, extension_instance_name, ten_extension_info_is_specified_extension); + if (extension_info_node) { extension_info = ten_shared_ptr_get_data( ten_smart_ptr_listnode_get(extension_info_node)); @@ -154,13 +166,8 @@ ten_shared_ptr_t *get_extension_info_in_extensions_info( ten_extension_info_check_integrity(extension_info, true), "Should not happen."); - if (new_one_created) { - *new_one_created = false; - } - // The extension addon name should be equal if both specified. - if (extension_addon_name && strlen(extension_addon_name) && - !ten_string_is_empty(&extension_info->extension_addon_name) && + if (extension_addon_name && !ten_c_string_is_empty(extension_addon_name) && !ten_string_is_equal_c_str(&extension_info->extension_addon_name, extension_addon_name)) { if (err) { @@ -172,37 +179,57 @@ ten_shared_ptr_t *get_extension_info_in_extensions_info( ten_string_get_raw_str(&extension_info->extension_addon_name)); } else { TEN_ASSERT( - 0, "extension '%s' is associated with different addon '%s', '%s'", + 0, + "extension '%s' is associated with different addon '%s', " + "'%s'", extension_instance_name, extension_addon_name, ten_string_get_raw_str(&extension_info->extension_addon_name)); } - return NULL; } - // If we know the extension addon name now, add this data to the - // extension_info. - if (extension_addon_name && strlen(extension_addon_name) && - ten_string_is_empty(&extension_info->extension_addon_name)) { - ten_string_set_formatted(&extension_info->extension_addon_name, "%s", - extension_addon_name); + if (!should_exist) { + if (extension_info_node) { + if (err) { + ten_error_set(err, TEN_ERRNO_INVALID_GRAPH, + "The extension_info is duplicated, extension_group: " + "%s, extension : %s.", + extension_group_name, extension_instance_name); + } else { + TEN_ASSERT(0, + "The extension_info is duplicated, extension_group: %s, " + "extension: %s.", + extension_group_name, extension_instance_name); + } + + return NULL; + } } return ten_smart_ptr_listnode_get(extension_info_node); - } + } else { + if (should_exist) { + if (err) { + ten_error_set(err, TEN_ERRNO_INVALID_GRAPH, + "The extension_info is not found, extension_group: %s, " + "extension: %s.", + extension_group_name, extension_instance_name); + } else { + TEN_ASSERT(0, + "The extension_info is not found, extension_group: %s, " + "extension: %s.", + extension_group_name, extension_instance_name); + } - TEN_ASSERT(!extension_info, "Should not happen."); + return NULL; + } + } ten_extension_info_t *self = ten_extension_info_create(); - ten_loc_set(&self->loc, app_uri, graph_id, extension_group_name, extension_instance_name); - - // Add the extension addon name if we know it now. - if (extension_addon_name && strlen(extension_addon_name)) { - ten_string_set_formatted(&self->extension_addon_name, "%s", - extension_addon_name); - } + ten_string_set_formatted(&self->extension_addon_name, "%s", + extension_addon_name); ten_shared_ptr_t *shared_self = ten_shared_ptr_create(self, ten_extension_info_destroy); @@ -210,9 +237,6 @@ ten_shared_ptr_t *get_extension_info_in_extensions_info( ten_list_push_smart_ptr_back(extensions_info, shared_self); ten_shared_ptr_destroy(shared_self); - if (new_one_created) { - *new_one_created = true; - } return shared_self_; } @@ -239,9 +263,8 @@ static bool copy_msg_dest(ten_list_t *to_static_info, return true; } -ten_shared_ptr_t *ten_extension_info_clone(ten_extension_info_t *self, - ten_list_t *extensions_info, - ten_error_t *err) { +static ten_shared_ptr_t *ten_extension_info_clone_except_dest( + ten_extension_info_t *self, ten_list_t *extensions_info, ten_error_t *err) { TEN_ASSERT(extensions_info, "Should not happen."); TEN_ASSERT(self, "Invalid argument."); @@ -252,66 +275,119 @@ ten_shared_ptr_t *ten_extension_info_clone(ten_extension_info_t *self, TEN_ASSERT(ten_extension_info_check_integrity(self, false), "Invalid use of extension_info %p.", self); - bool new_extension_info_created = false; ten_shared_ptr_t *new_dest = get_extension_info_in_extensions_info( extensions_info, ten_string_get_raw_str(&self->loc.app_uri), ten_string_get_raw_str(&self->loc.graph_id), ten_string_get_raw_str(&self->loc.extension_group_name), ten_string_get_raw_str(&self->extension_addon_name), ten_string_get_raw_str(&self->loc.extension_name), - &new_extension_info_created, err); + /* should_exist = */ false, err); + TEN_ASSERT(new_dest, "Should not happen."); + + ten_extension_info_t *new_extension_info = ten_shared_ptr_get_data(new_dest); + TEN_ASSERT(new_extension_info && + ten_extension_info_check_integrity(new_extension_info, true), + "Should not happen."); + + ten_value_object_merge_with_clone(new_extension_info->property, + self->property); - if (new_extension_info_created) { - ten_extension_info_t *new_extension_info = - ten_shared_ptr_get_data(new_dest); - TEN_ASSERT(new_extension_info && - ten_extension_info_check_integrity(new_extension_info, true), + ten_list_foreach (&self->msg_conversion_contexts, iter) { + ten_msg_conversion_context_t *msg_conversion = + ten_ptr_listnode_get(iter.node); + TEN_ASSERT(msg_conversion && + ten_msg_conversion_context_check_integrity(msg_conversion), "Should not happen."); - ten_value_object_merge_with_clone(new_extension_info->property, - self->property); + bool rc = ten_msg_conversion_context_merge( + &new_extension_info->msg_conversion_contexts, msg_conversion, err); + TEN_ASSERT(rc, "Should not happen."); + } - ten_list_foreach (&self->msg_conversion_contexts, iter) { - ten_msg_conversion_context_t *msg_conversion = - ten_ptr_listnode_get(iter.node); - TEN_ASSERT(msg_conversion && - ten_msg_conversion_context_check_integrity(msg_conversion), - "Should not happen."); + return new_dest; +} - bool rc = ten_msg_conversion_context_merge( - &new_extension_info->msg_conversion_contexts, msg_conversion, err); - TEN_ASSERT(rc, "Should not happen."); - } +static ten_shared_ptr_t *ten_extension_info_clone_dest( + ten_extension_info_t *self, ten_list_t *extensions_info, ten_error_t *err) { + TEN_ASSERT(extensions_info, "Should not happen."); - if (!copy_msg_dest(&new_extension_info->msg_dest_info.cmd, - &self->msg_dest_info.cmd, extensions_info, err)) { - return NULL; - } + TEN_ASSERT(self, "Invalid argument."); + // TEN_NOLINTNEXTLINE(thread-check) + // thread-check: The graph-related information of the extension remains + // unchanged during the lifecycle of engine/graph, allowing safe + // cross-thread access. + TEN_ASSERT(ten_extension_info_check_integrity(self, false), + "Invalid use of extension_info %p.", self); - if (!copy_msg_dest(&new_extension_info->msg_dest_info.data, - &self->msg_dest_info.data, extensions_info, err)) { - return NULL; - } + ten_shared_ptr_t *exist_dest = get_extension_info_in_extensions_info( + extensions_info, ten_string_get_raw_str(&self->loc.app_uri), + ten_string_get_raw_str(&self->loc.graph_id), + ten_string_get_raw_str(&self->loc.extension_group_name), + ten_string_get_raw_str(&self->extension_addon_name), + ten_string_get_raw_str(&self->loc.extension_name), + /* should_exist = */ true, err); + TEN_ASSERT(exist_dest, "Should not happen."); - if (!copy_msg_dest(&new_extension_info->msg_dest_info.audio_frame, - &self->msg_dest_info.audio_frame, extensions_info, - err)) { - return NULL; - } + ten_extension_info_t *exist_extension_info = + ten_shared_ptr_get_data(exist_dest); + TEN_ASSERT(exist_extension_info && + ten_extension_info_check_integrity(exist_extension_info, true), + "Should not happen."); - if (!copy_msg_dest(&new_extension_info->msg_dest_info.video_frame, - &self->msg_dest_info.video_frame, extensions_info, - err)) { - return NULL; + if (!copy_msg_dest(&exist_extension_info->msg_dest_info.cmd, + &self->msg_dest_info.cmd, extensions_info, err)) { + return NULL; + } + + if (!copy_msg_dest(&exist_extension_info->msg_dest_info.data, + &self->msg_dest_info.data, extensions_info, err)) { + return NULL; + } + + if (!copy_msg_dest(&exist_extension_info->msg_dest_info.audio_frame, + &self->msg_dest_info.audio_frame, extensions_info, err)) { + return NULL; + } + + if (!copy_msg_dest(&exist_extension_info->msg_dest_info.video_frame, + &self->msg_dest_info.video_frame, extensions_info, err)) { + return NULL; + } + + if (!copy_msg_dest(&exist_extension_info->msg_dest_info.interface, + &self->msg_dest_info.interface, extensions_info, err)) { + return NULL; + } + + return exist_dest; +} + +bool ten_extensions_info_clone(ten_list_t *from, ten_list_t *to, + ten_error_t *err) { + TEN_ASSERT(from && to, "Should not happen."); + + // `ten_extension_info_clone_except_dest()` will call + // `get_extension_info_in_extensions_info()`. In + // `get_extension_info_in_extensions_info()`, we need to determine if + // `extension_info` exists in `extensions_info`. Therefore, we should first + // clone the `nodes` and then proceed to clone the `connections`. + ten_list_foreach (from, iter) { + ten_extension_info_t *extension_info = + ten_shared_ptr_get_data(ten_smart_ptr_listnode_get(iter.node)); + if (!ten_extension_info_clone_except_dest(extension_info, to, err)) { + return false; } + } - if (!copy_msg_dest(&new_extension_info->msg_dest_info.interface, - &self->msg_dest_info.interface, extensions_info, err)) { - return NULL; + ten_list_foreach (from, iter) { + ten_extension_info_t *extension_info = + ten_shared_ptr_get_data(ten_smart_ptr_listnode_get(iter.node)); + if (!ten_extension_info_clone_dest(extension_info, to, err)) { + return false; } } - return new_dest; + return true; } bool ten_extension_info_check_integrity(ten_extension_info_t *self, diff --git a/core/src/ten_runtime/extension/extension_info/json.c b/core/src/ten_runtime/extension/extension_info/json.c index 98652eb2d..815fb4cc0 100644 --- a/core/src/ten_runtime/extension/extension_info/json.c +++ b/core/src/ten_runtime/extension/extension_info/json.c @@ -262,7 +262,7 @@ ten_shared_ptr_t *ten_extension_info_nodes_from_json( ten_shared_ptr_t *self = get_extension_info_in_extensions_info( extensions_info, app_uri, graph_id, extension_group_name, addon_name, - instance_name, NULL, err); + instance_name, false, err); if (!self) { return NULL; } @@ -313,7 +313,7 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_json( ten_shared_ptr_t *self = get_extension_info_in_extensions_info( extensions_info, app_uri, graph_id, extension_group_name, NULL, - extension_name, NULL, err); + extension_name, true, err); if (!self) { return NULL; } @@ -404,7 +404,7 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_dest_part_from_json( ten_shared_ptr_t *self = get_extension_info_in_extensions_info( extensions_info, app_uri, graph_id, extension_group_name, NULL, - extension_name, NULL, err); + extension_name, true, err); if (!self) { return NULL; } diff --git a/core/src/ten_runtime/extension/extension_info/value.c b/core/src/ten_runtime/extension/extension_info/value.c index e2ef4becd..6a5436378 100644 --- a/core/src/ten_runtime/extension/extension_info/value.c +++ b/core/src/ten_runtime/extension/extension_info/value.c @@ -12,6 +12,8 @@ #include "include_internal/ten_runtime/extension/msg_dest_info/msg_dest_info.h" #include "include_internal/ten_runtime/extension/msg_dest_info/value.h" #include "include_internal/ten_runtime/msg_conversion/msg_conversion_context.h" +#include "ten_runtime/common/errno.h" +#include "ten_utils/lib/error.h" #include "ten_utils/macro/check.h" #include "ten_utils/value/value.h" #include "ten_utils/value/value_merge.h" @@ -80,7 +82,7 @@ static bool parse_msg_conversions_value( ten_shared_ptr_t *ten_extension_info_node_from_value( ten_value_t *value, ten_list_t *extensions_info, ten_error_t *err) { - TEN_ASSERT(value && extensions_info, "Should not happen."); + TEN_ASSERT(value && extensions_info, "Invalid argument."); const char *app_uri = ten_value_object_peek_string(value, TEN_STR_APP); const char *graph_id = ten_value_object_peek_string(value, TEN_STR_GRAPH); @@ -91,7 +93,7 @@ ten_shared_ptr_t *ten_extension_info_node_from_value( ten_shared_ptr_t *self = get_extension_info_in_extensions_info( extensions_info, app_uri, graph_id, extension_group_name, addon_name, - instance_name, NULL, err); + instance_name, false, err); if (!self) { return NULL; } @@ -104,10 +106,13 @@ ten_shared_ptr_t *ten_extension_info_node_from_value( ten_value_t *props_value = ten_value_object_peek(value, TEN_STR_PROPERTY); if (props_value) { if (!ten_value_is_object(props_value)) { - // Indicates an error. - TEN_ASSERT(0, - "Failed to parse 'prop' in 'start_graph' command, it's not an " - "object."); + if (err) { + ten_error_set(err, TEN_ERRNO_GENERIC, + "The `property` in graph node should be an object."); + } else { + TEN_ASSERT(0, "The `property` in graph node should be an object."); + } + return NULL; } @@ -119,28 +124,40 @@ ten_shared_ptr_t *ten_extension_info_node_from_value( ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_value( ten_value_t *value, ten_list_t *extensions_info, ten_error_t *err) { - TEN_ASSERT(value && extensions_info, "Should not happen."); + TEN_ASSERT(value && extensions_info, "Invalid argument."); const char *app_uri = ten_value_object_peek_string(value, TEN_STR_APP); const char *graph_id = ten_value_object_peek_string(value, TEN_STR_GRAPH); const char *extension_group_name = ten_value_object_peek_string(value, TEN_STR_EXTENSION_GROUP); - if (!extension_group_name) { - TEN_ASSERT(0, "Should not happen."); + if (!extension_group_name || ten_c_string_is_empty(extension_group_name)) { + if (err) { + ten_error_set(err, TEN_ERRNO_INVALID_GRAPH, + "The extension_group in connection is required."); + } else { + TEN_ASSERT(0, "The extension_group in connection is required."); + } + return NULL; } const char *extension_name = ten_value_object_peek_string(value, TEN_STR_EXTENSION); - if (!extension_name) { - TEN_ASSERT(0, "Should not happen."); + if (!extension_name || ten_c_string_is_empty(extension_name)) { + if (err) { + ten_error_set(err, TEN_ERRNO_INVALID_GRAPH, + "The extension in connection is required."); + } else { + TEN_ASSERT(0, "The extension in connection is required."); + } + return NULL; } ten_shared_ptr_t *self = get_extension_info_in_extensions_info( extensions_info, app_uri, graph_id, extension_group_name, NULL, - extension_name, NULL, err); + extension_name, true, err); if (!self) { return NULL; } @@ -165,7 +182,6 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_value( if (!parse_msg_dest_value(data_value, extensions_info, &extension_info->msg_dest_info.data, extension_info, err)) { - TEN_ASSERT(0, "Should not happen."); return NULL; } } @@ -177,7 +193,6 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_value( if (!parse_msg_dest_value(video_frame_value, extensions_info, &extension_info->msg_dest_info.video_frame, extension_info, err)) { - TEN_ASSERT(0, "Should not happen."); return NULL; } } @@ -189,7 +204,6 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_value( if (!parse_msg_dest_value(audio_frame_value, extensions_info, &extension_info->msg_dest_info.audio_frame, extension_info, err)) { - TEN_ASSERT(0, "Should not happen."); return NULL; } } @@ -201,7 +215,6 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_src_part_from_value( if (!parse_msg_dest_value(interface_value, extensions_info, &extension_info->msg_dest_info.interface, extension_info, err)) { - TEN_ASSERT(0, "Should not happen."); return NULL; } } @@ -220,21 +233,31 @@ ten_shared_ptr_t *ten_extension_info_parse_connection_dest_part_from_value( const char *extension_group_name = ten_value_object_peek_string(value, TEN_STR_EXTENSION_GROUP); - if (!extension_group_name) { - TEN_ASSERT(0, "Should not happen."); + if (!extension_group_name || ten_c_string_is_empty(extension_group_name)) { + if (err) { + ten_error_set(err, TEN_ERRNO_INVALID_GRAPH, + "The extension_group in connection is required."); + } else { + TEN_ASSERT(0, "The extension_group in connection is required."); + } return NULL; } const char *extension_name = ten_value_object_peek_string(value, TEN_STR_EXTENSION); - if (!extension_name) { - TEN_ASSERT(0, "Should not happen."); + if (!extension_name || ten_c_string_is_empty(extension_name)) { + if (err) { + ten_error_set(err, TEN_ERRNO_INVALID_GRAPH, + "The extension in connection is required."); + } else { + TEN_ASSERT(0, "The extension in connection is required."); + } return NULL; } ten_shared_ptr_t *self = get_extension_info_in_extensions_info( extensions_info, app_uri, graph_id, extension_group_name, NULL, - extension_name, NULL, err); + extension_name, true, err); if (!self) { return NULL; } diff --git a/core/src/ten_runtime/extension/msg_dest_info/msg_dest_info.c b/core/src/ten_runtime/extension/msg_dest_info/msg_dest_info.c index 44044a246..ce2efdba8 100644 --- a/core/src/ten_runtime/extension/msg_dest_info/msg_dest_info.c +++ b/core/src/ten_runtime/extension/msg_dest_info/msg_dest_info.c @@ -75,8 +75,15 @@ ten_shared_ptr_t *ten_msg_dest_info_clone(ten_shared_ptr_t *self, ten_extension_info_t *dest_extension_info = ten_extension_info_from_smart_ptr(dest); - ten_shared_ptr_t *new_dest = - ten_extension_info_clone(dest_extension_info, extensions_info, err); + ten_shared_ptr_t *new_dest = get_extension_info_in_extensions_info( + extensions_info, + ten_string_get_raw_str(&dest_extension_info->loc.app_uri), + ten_string_get_raw_str(&dest_extension_info->loc.graph_id), + ten_string_get_raw_str(&dest_extension_info->loc.extension_group_name), + NULL, ten_string_get_raw_str(&dest_extension_info->loc.extension_name), + true, err); + TEN_ASSERT(new_dest, "Should not happen."); + if (!new_dest) { return NULL; } diff --git a/core/src/ten_runtime/extension/msg_dest_info/value.c b/core/src/ten_runtime/extension/msg_dest_info/value.c index fe23ab6d6..beddebf59 100644 --- a/core/src/ten_runtime/extension/msg_dest_info/value.c +++ b/core/src/ten_runtime/extension/msg_dest_info/value.c @@ -212,7 +212,7 @@ ten_shared_ptr_t *ten_msg_dest_info_from_value( goto done; error: - if (!self) { + if (self) { ten_msg_dest_info_destroy(self); self = NULL; } diff --git a/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/field/extension_info.c b/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/field/extension_info.c index 564efa3cc..c3cf01193 100644 --- a/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/field/extension_info.c +++ b/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/field/extension_info.c @@ -24,7 +24,6 @@ #include "ten_utils/container/list.h" #include "ten_utils/container/list_str.h" #include "ten_utils/lib/error.h" -#include "ten_utils/lib/json.h" #include "ten_utils/lib/smart_ptr.h" #include "ten_utils/lib/string.h" #include "ten_utils/log/log.h" @@ -153,17 +152,9 @@ bool ten_cmd_start_graph_copy_extensions_info( TEN_ASSERT(rc, "Should not happen."); } - ten_list_foreach (&src_cmd->extensions_info, iter) { - ten_shared_ptr_t *extension_info_ = ten_smart_ptr_listnode_get(iter.node); - ten_extension_info_t *extension_info = - ten_extension_info_from_smart_ptr(extension_info_); - - bool rc = ten_extension_info_clone(extension_info, - &self_cmd->extensions_info, err); - TEN_ASSERT(rc, "Should not happen."); - if (!rc) { - return false; - } + if (!ten_extensions_info_clone(&src_cmd->extensions_info, + &self_cmd->extensions_info, err)) { + return false; } return true; @@ -228,8 +219,11 @@ bool ten_cmd_start_graph_process_extensions_info( goto error; } - ten_extension_info_parse_connection_src_part_from_value( - item_value, ten_raw_cmd_start_graph_get_extensions_info(cmd), err); + if (ten_extension_info_parse_connection_src_part_from_value( + item_value, ten_raw_cmd_start_graph_get_extensions_info(cmd), + err) == NULL) { + goto error; + } } } diff --git a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc index 9eb834d48..e3068c02a 100644 --- a/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc +++ b/tests/ten_runtime/integration/cpp/check_start_graph/check_start_graph_source/ten_packages/extension/default_extension_cpp/src/main.cc @@ -20,12 +20,71 @@ class test_extension : public ten::extension_t { void on_init(ten::ten_env_t &ten_env) override { ten_env.on_init_done(); } + // NOLINTNEXTLINE + void send_invalid_graph(ten::ten_env_t &ten_env) { + ten::error_t err; + + bool result = ten_env.send_json( + R"({ + "_ten": { + "type": "start_graph", + "dest": [{ + "app": "localhost" + }], + "nodes": [ + { + "type": "extension", + "name": "default_extension_cpp", + "addon": "default_extension_cpp", + "extension_group": "default_extension_group" + }, + { + "type": "extension", + "name": "default_extension_cpp_2", + "addon": "default_extension_cpp", + "extension_group": "default_extension_group" + } + ], + "connections": [ + { + "extension": "default_extension_cpp", + "extension_group": "default_extension_group", + "cmd": [ + { + "name": "test", + "dest": [ + { + "extension": "default_extension_cpp_2", + "extension_group": "default_extension_group_2" + } + ] + } + ] + } + ] + } + })", + &err); + + assert(!result && "The graph should be invalid."); + + // The extension_info is not found, extension_group: + // default_extension_group_2, extension: default_extension_cpp_2. + std::string err_msg = err.errmsg(); + + // NOLINTNEXTLINE + assert(err_msg.find("default_extension_group_2") != std::string::npos && + "Incorrect msg."); + } + void on_start(ten::ten_env_t &ten_env) override { ten_env.on_start_done(); if (!started) { started = true; + send_invalid_graph(ten_env); + ten_env.send_json( R"({ "_ten": { diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_data.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_data.cc index 360bbe5a2..5f9b3ae98 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_data.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_data.cc @@ -6,7 +6,6 @@ // #include #include -#include #include "gtest/gtest.h" #include "include_internal/ten_runtime/binding/cpp/ten.h" @@ -102,11 +101,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_data_extension_1", "extension_group": "cmd_mapping_data_extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_data_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_graph.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_graph.cc index 76054e941..75f58a12f 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_graph.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_graph.cc @@ -6,7 +6,6 @@ // #include #include -#include #include "gtest/gtest.h" #include "include_internal/ten_runtime/binding/cpp/ten.h" @@ -72,11 +71,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_conversion_graph__extension_1", "extension_group": "default_extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_conversion_graph__extension_2", @@ -122,8 +123,10 @@ void *test_app_thread_main(TEN_UNUSED void *args) { return nullptr; } -TEN_CPP_REGISTER_ADDON_AS_EXTENSION(cmd_conversion_graph__extension_1, test_extension_1); -TEN_CPP_REGISTER_ADDON_AS_EXTENSION(cmd_conversion_graph__extension_2, test_extension_2); +TEN_CPP_REGISTER_ADDON_AS_EXTENSION(cmd_conversion_graph__extension_1, + test_extension_1); +TEN_CPP_REGISTER_ADDON_AS_EXTENSION(cmd_conversion_graph__extension_2, + test_extension_2); } // namespace diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path.cc index 182fa09e0..cbf470c11 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path.cc @@ -71,11 +71,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path__test_extension_1", "extension_group": "cmd_mapping_path__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_1.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_1.cc index 268fc4402..4c0f7653d 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_1.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_1.cc @@ -71,11 +71,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_1__test_extension_1", "extension_group": "cmd_mapping_path_array_1__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_1__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_2.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_2.cc index e857860c0..c4586167f 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_2.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_2.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_2__test_extension_1", "extension_group": "cmd_mapping_path_array_2__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_2__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_3.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_3.cc index d893d638a..41c4655e6 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_3.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_3.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_3__test_extension_1", "extension_group": "cmd_mapping_path_array_3__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_3__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_4.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_4.cc index a211f3b76..ee23fe866 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_4.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_4.cc @@ -74,11 +74,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_4__test_extension_1", "extension_group": "cmd_mapping_path_array_4__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_4__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_5.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_5.cc index 7ba846fc5..7994e1bd3 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_5.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_5.cc @@ -74,11 +74,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_5__test_extension_1", "extension_group": "cmd_mapping_path_array_5__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_5__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_6.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_6.cc index c942c4e00..151b8b15b 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_6.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_6.cc @@ -74,11 +74,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_6__test_extension_1", "extension_group": "cmd_mapping_path_array_6__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_6__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_7.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_7.cc index 466a116cb..54f022dc4 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_7.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_array_7.cc @@ -74,11 +74,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_array_7__test_extension_1", "extension_group": "cmd_mapping_path_array_7__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_array_7__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_keep_original.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_keep_original.cc index 8a5b26e99..0e47af6d3 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_keep_original.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_keep_original.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_keep_original__test_extension_1", "extension_group": "cmd_mapping_path_keep_original__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_keep_original__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_1.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_1.cc index cce21b818..8bf03999f 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_1.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_1.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_nested_1__test_extension_1", "extension_group": "cmd_mapping_path_nested_1__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_nested_1__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_2.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_2.cc index cc1f4b4d7..b76cfbb40 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_2.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_2.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_nested_2__test_extension_1", "extension_group": "cmd_mapping_path_nested_2__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_nested_2__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_3.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_3.cc index e2ce37b88..becadcece 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_3.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_3.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_nested_3__test_extension_1", "extension_group": "cmd_mapping_path_nested_3__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_nested_3__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_4.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_4.cc index 58419f7fe..7393e5824 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_4.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_4.cc @@ -73,11 +73,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_nested_4__test_extension_1", "extension_group": "cmd_mapping_path_nested_4__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_nested_4__test_extension_2", diff --git a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_5.cc b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_5.cc index 31270c07f..5e3d65107 100644 --- a/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_5.cc +++ b/tests/ten_runtime/smoke/cmd_conversion/cmd_conversion_path_nested_5.cc @@ -75,11 +75,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "cmd_mapping_path_nested_5__test_extension_1", "extension_group": "cmd_mapping_path_nested_5__extension_group" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "cmd_mapping_path_nested_5__test_extension_2", diff --git a/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_1.cc b/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_1.cc index 708b074e7..25a2e1864 100644 --- a/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_1.cc +++ b/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_1.cc @@ -6,7 +6,6 @@ // #include #include -#include #include "gtest/gtest.h" #include "include_internal/ten_runtime/binding/cpp/ten.h" @@ -72,11 +71,13 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "predefined_graph_multi_extension_1__extension_1", "extension_group": "predefined_graph_multi_extension_1" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "predefined_graph_multi_extension_1__extension_2", diff --git a/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_4.cc b/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_4.cc index a5a2b7891..cbc73e36e 100644 --- a/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_4.cc +++ b/tests/ten_runtime/smoke/extension_test/predefined_graph/predefined_graph_multi_extension_4.cc @@ -6,7 +6,6 @@ // #include #include -#include #include "gtest/gtest.h" #include "include_internal/ten_runtime/binding/cpp/ten.h" @@ -90,16 +89,19 @@ class test_app : public ten::app_t { "auto_start": false, "singleton": true, "nodes": [{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_1", "addon": "predefined_graph_multi_extension_4__extension_1", "extension_group": "predefined_graph_multi_extension_4" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_2", "addon": "predefined_graph_multi_extension_4__extension_2", "extension_group": "predefined_graph_multi_extension_4" },{ + "app": "msgpack://127.0.0.1:8001/", "type": "extension", "name": "test_extension_3", "addon": "predefined_graph_multi_extension_4__extension_3", @@ -150,14 +152,11 @@ void *test_app_thread_main(TEN_UNUSED void *args) { } TEN_CPP_REGISTER_ADDON_AS_EXTENSION( - predefined_graph_multi_extension_4__extension_1, - test_extension_1); + predefined_graph_multi_extension_4__extension_1, test_extension_1); TEN_CPP_REGISTER_ADDON_AS_EXTENSION( - predefined_graph_multi_extension_4__extension_2, - test_extension_2); + predefined_graph_multi_extension_4__extension_2, test_extension_2); TEN_CPP_REGISTER_ADDON_AS_EXTENSION( - predefined_graph_multi_extension_4__extension_3, - test_extension_3); + predefined_graph_multi_extension_4__extension_3, test_extension_3); } // namespace