Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: streamline extension standalone testing #546

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/ten_manager/bin/tman",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_manager/install/template_mode_with_same_name_extension/mock_app",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_manager/install/mock_extension/mock_extension",
"args": [
"--config-file=${workspaceFolder}/out/linux/x64/tests/local_registry/config.json",
"install",
"extension",
"default_extension_cpp"
"--standalone",
],
"preRunCommands": [
"script import pathlib;import subprocess;import lldb;rustc_sysroot = subprocess.getoutput(\"rustc --print sysroot\");rustlib_etc = pathlib.Path(rustc_sysroot) / \"lib\" / \"rustlib\" / \"etc\";lldb.debugger.HandleCommand(f'command script import \"{rustlib_etc / \"lldb_lookup.py\"}\"');lldb.debugger.HandleCommand(f'command source -s 0 \"{rustlib_etc / \"lldb_commands\"}\"')"
Expand Down Expand Up @@ -533,6 +533,17 @@
}
}
},
{
"name": "extension standalone test (C/C++) (lldb, launch)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/standalone_test_cpp/default_extension_cpp/out/linux/x64/tests/default_extension_cpp_test",
"args": [],
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/cpp/standalone_test_cpp/default_extension_cpp/out/linux/x64/tests/",
"env": {
"ASAN_OPTIONS": "use_sigaltstack=0",
},
},
{
"name": "app (Python Main) (debugpy, launch)",
"type": "debugpy",
Expand Down
8 changes: 0 additions & 8 deletions core/include_internal/ten_runtime/addon/addon_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ TEN_RUNTIME_PRIVATE_API void ten_addon_host_on_destroy_instance_ctx_destroy(
TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_host_create(
TEN_ADDON_TYPE type);

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_host_find(
TEN_ADDON_TYPE addon_type, const char *addon_name);

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *
ten_addon_host_find_or_create_one_if_not_found(TEN_ADDON_TYPE addon_type,
const char *addon_name,
bool *newly_created);

TEN_RUNTIME_PRIVATE_API void ten_addon_host_load_metadata(
ten_addon_host_t *self, ten_env_t *ten_env,
ten_addon_on_init_func_t on_init);
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ typedef struct ten_addon_store_t ten_addon_store_t;
TEN_RUNTIME_PRIVATE_API ten_addon_store_t *ten_addon_loader_get_global_store(
void);

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_addon_loader_find(
const char *addon_loader);

TEN_RUNTIME_API ten_addon_host_t *ten_addon_register_addon_loader(
const char *name, const char *base_dir, ten_addon_t *addon,
void *register_ctx);
Expand Down
26 changes: 26 additions & 0 deletions core/include_internal/ten_runtime/addon/common/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright © 2025 Agora
// This file is part of TEN Framework, an open source project.
// Licensed under the Apache License, Version 2.0, with certain conditions.
// Refer to the "LICENSE" file in the root directory for more information.
//
#pragma once

#include "ten_runtime/ten_config.h"

#include "ten_runtime/addon/addon.h"

typedef struct ten_addon_host_t ten_addon_host_t;

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_store_find_by_type(
TEN_ADDON_TYPE addon_type, const char *addon_name);

TEN_RUNTIME_PRIVATE_API int ten_addon_store_lock_by_type(
TEN_ADDON_TYPE addon_type);

TEN_RUNTIME_PRIVATE_API int ten_addon_store_unlock_by_type(
TEN_ADDON_TYPE addon_type);

TEN_RUNTIME_PRIVATE_API int ten_addon_store_lock_all_type(void);

TEN_RUNTIME_PRIVATE_API int ten_addon_store_unlock_all_type(void);
13 changes: 7 additions & 6 deletions core/include_internal/ten_runtime/addon/common/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ typedef struct ten_addon_store_t {

TEN_RUNTIME_PRIVATE_API void ten_addon_store_init(ten_addon_store_t *store);

TEN_RUNTIME_PRIVATE_API void ten_addon_store_add(ten_addon_store_t *store,
ten_addon_host_t *addon);

TEN_RUNTIME_PRIVATE_API ten_addon_t *ten_addon_store_del(
ten_addon_store_t *store, const char *name);

TEN_RUNTIME_PRIVATE_API void ten_addon_store_del_all(ten_addon_store_t *store);

TEN_RUNTIME_PRIVATE_API int ten_addon_store_lock(ten_addon_store_t *store);

TEN_RUNTIME_PRIVATE_API int ten_addon_store_unlock(ten_addon_store_t *store);

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *ten_addon_store_find(
ten_addon_store_t *store, const char *name);

TEN_RUNTIME_PRIVATE_API ten_addon_host_t *
ten_addon_store_find_or_create_one_if_not_found(ten_addon_store_t *store,
TEN_ADDON_TYPE addon_type,
const char *addon_name,
bool *newly_created);
14 changes: 11 additions & 3 deletions core/include_internal/ten_runtime/addon_loader/addon_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@

#include "include_internal/ten_runtime/binding/common.h"
#include "ten_runtime/addon/addon.h"
#include "ten_utils/lib/mutex.h"
#include "ten_utils/lib/signature.h"

#define TEN_ADDON_LOADER_SIGNATURE 0xAE4FCDE7983727E4U

typedef struct ten_addon_loader_t ten_addon_loader_t;
typedef struct ten_addon_host_t ten_addon_host_t;

typedef struct ten_addon_loader_singleton_store_t {
ten_atomic_t valid;
ten_mutex_t *lock;
ten_list_t store; // ten_addon_loader_t
} ten_addon_loader_singleton_store_t;

typedef void (*ten_addon_loader_on_init_func_t)(
ten_addon_loader_t *addon_loader);

Expand All @@ -38,10 +45,11 @@ typedef struct ten_addon_loader_t {
ten_addon_loader_on_load_addon_func_t on_load_addon;
} ten_addon_loader_t;

TEN_RUNTIME_PRIVATE_API ten_list_t *ten_addon_loader_get_all(void);
TEN_RUNTIME_PRIVATE_API int ten_addon_loader_singleton_store_lock(void);

TEN_RUNTIME_PRIVATE_API int ten_addon_loader_singleton_store_unlock(void);

TEN_RUNTIME_PRIVATE_API bool ten_addon_loader_check_integrity(
ten_addon_loader_t *self);
TEN_RUNTIME_PRIVATE_API ten_list_t *ten_addon_loader_singleton_get_all(void);

TEN_RUNTIME_API ten_addon_loader_t *ten_addon_loader_create(
ten_addon_loader_on_init_func_t on_init,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ TEN_RUNTIME_PRIVATE_API void ten_builtin_extension_group_addon_destroy_instance(
void *context);

TEN_RUNTIME_PRIVATE_API void ten_builtin_extension_group_addon_register(void);

TEN_RUNTIME_PRIVATE_API void ten_builtin_extension_group_addon_unregister(void);
2 changes: 0 additions & 2 deletions core/include_internal/ten_runtime/test/test_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ typedef struct ten_env_t ten_env_t;

TEN_RUNTIME_PRIVATE_API void ten_builtin_test_extension_addon_register(void);

TEN_RUNTIME_PRIVATE_API void ten_builtin_test_extension_addon_unregister(void);

TEN_RUNTIME_PRIVATE_API void
ten_builtin_test_extension_ten_env_notify_on_start_done(ten_env_t *ten_env,
void *user_data);
Expand Down
Loading
Loading