From 2ed4beaa60a9124458503c92298381f96f94ba52 Mon Sep 17 00:00:00 2001 From: Hu Yueh-Wei Date: Fri, 4 Oct 2024 12:34:08 +0800 Subject: [PATCH] feat: add more standalone testing logic --- .../ten_runtime/binding/cpp/internal/test/extension_tester.h | 4 ++-- core/include/ten_runtime/test/extension_tester.h | 5 ++++- core/src/ten_runtime/test/extension_tester.c | 4 ++-- .../cpp/standalone_test/default_extension_cpp/test/basic.cc | 2 +- tests/ten_runtime/smoke/standalone_test/basic.cc | 2 +- tests/ten_runtime/smoke/standalone_test/basic_c.cc | 2 +- tests/ten_runtime/smoke/standalone_test/on_cmd.cc | 2 +- tests/ten_runtime/smoke/standalone_test/on_cmd_c.cc | 2 +- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/include/ten_runtime/binding/cpp/internal/test/extension_tester.h b/core/include/ten_runtime/binding/cpp/internal/test/extension_tester.h index 57b2eea8a..c2e4c1b47 100644 --- a/core/include/ten_runtime/binding/cpp/internal/test/extension_tester.h +++ b/core/include/ten_runtime/binding/cpp/internal/test/extension_tester.h @@ -33,9 +33,9 @@ class extension_tester_t { extension_tester_t &operator=(const extension_tester_t &&) = delete; // @} - void add_addon_name(const char *addon_name) { + void set_test_mode_single(const char *addon_name) { TEN_ASSERT(addon_name, "Invalid argument."); - ten_extension_tester_add_addon_name(c_extension_tester, addon_name); + ten_extension_tester_set_test_mode_single(c_extension_tester, addon_name); } void add_addon_base_dir(const char *addon_path) { diff --git a/core/include/ten_runtime/test/extension_tester.h b/core/include/ten_runtime/test/extension_tester.h index c83f65daf..74a366d40 100644 --- a/core/include/ten_runtime/test/extension_tester.h +++ b/core/include/ten_runtime/test/extension_tester.h @@ -24,7 +24,10 @@ TEN_RUNTIME_API ten_extension_tester_t *ten_extension_tester_create( TEN_RUNTIME_API void ten_extension_tester_destroy(ten_extension_tester_t *self); -TEN_RUNTIME_API void ten_extension_tester_add_addon_name( +// Testing a single extension, all messages input by the tester will be directed +// to this extension, and all outputs from the extension will be sent back to +// the tester. +TEN_RUNTIME_API void ten_extension_tester_set_test_mode_single( ten_extension_tester_t *self, const char *addon_name); TEN_RUNTIME_API void ten_extension_tester_add_addon_base_dir( diff --git a/core/src/ten_runtime/test/extension_tester.c b/core/src/ten_runtime/test/extension_tester.c index 503fd3032..d328ff400 100644 --- a/core/src/ten_runtime/test/extension_tester.c +++ b/core/src/ten_runtime/test/extension_tester.c @@ -92,8 +92,8 @@ ten_extension_tester_t *ten_extension_tester_create( return self; } -void ten_extension_tester_add_addon_name(ten_extension_tester_t *self, - const char *addon_name) { +void ten_extension_tester_set_test_mode_single(ten_extension_tester_t *self, + const char *addon_name) { TEN_ASSERT(self && ten_extension_tester_check_integrity(self, true), "Invalid argument."); TEN_ASSERT(addon_name, "Invalid argument."); diff --git a/tests/ten_runtime/integration/cpp/standalone_test/default_extension_cpp/test/basic.cc b/tests/ten_runtime/integration/cpp/standalone_test/default_extension_cpp/test/basic.cc index fac581ef4..8d389f32f 100644 --- a/tests/ten_runtime/integration/cpp/standalone_test/default_extension_cpp/test/basic.cc +++ b/tests/ten_runtime/integration/cpp/standalone_test/default_extension_cpp/test/basic.cc @@ -39,7 +39,7 @@ TEST(Test, Basic) { // NOLINT ten_string_destroy(path); - tester->add_addon_name("default_extension_cpp"); + tester->set_test_mode_single("default_extension_cpp"); tester->run(); diff --git a/tests/ten_runtime/smoke/standalone_test/basic.cc b/tests/ten_runtime/smoke/standalone_test/basic.cc index b1d36b676..1026e662a 100644 --- a/tests/ten_runtime/smoke/standalone_test/basic.cc +++ b/tests/ten_runtime/smoke/standalone_test/basic.cc @@ -60,7 +60,7 @@ class extension_tester_1 : public ten::extension_tester_t { TEST(StandaloneTest, Basic) { // NOLINT auto *tester = new extension_tester_1(); - tester->add_addon_name("standalone_test_basic__test_extension_1"); + tester->set_test_mode_single("standalone_test_basic__test_extension_1"); bool rc = tester->run(); TEN_ASSERT(rc, "Should not happen."); diff --git a/tests/ten_runtime/smoke/standalone_test/basic_c.cc b/tests/ten_runtime/smoke/standalone_test/basic_c.cc index 7ddafe809..41a6f92fd 100644 --- a/tests/ten_runtime/smoke/standalone_test/basic_c.cc +++ b/tests/ten_runtime/smoke/standalone_test/basic_c.cc @@ -69,7 +69,7 @@ void ten_extension_tester_on_start(TEN_UNUSED ten_extension_tester_t *tester, TEST(StandaloneTest, BasicC) { // NOLINT ten_extension_tester_t *tester = ten_extension_tester_create(ten_extension_tester_on_start, nullptr); - ten_extension_tester_add_addon_name( + ten_extension_tester_set_test_mode_single( tester, "standalone_test_basic_c__test_extension_1"); bool rc = ten_extension_tester_run(tester); diff --git a/tests/ten_runtime/smoke/standalone_test/on_cmd.cc b/tests/ten_runtime/smoke/standalone_test/on_cmd.cc index 69bc4b3e9..d42ac49c6 100644 --- a/tests/ten_runtime/smoke/standalone_test/on_cmd.cc +++ b/tests/ten_runtime/smoke/standalone_test/on_cmd.cc @@ -80,7 +80,7 @@ class extension_tester_1 : public ten::extension_tester_t { TEST(StandaloneTest, OnCmd) { // NOLINT auto *tester = new extension_tester_1(); - tester->add_addon_name("standalone_test_on_cmd__test_extension_1"); + tester->set_test_mode_single("standalone_test_on_cmd__test_extension_1"); bool rc = tester->run(); TEN_ASSERT(rc, "Should not happen."); diff --git a/tests/ten_runtime/smoke/standalone_test/on_cmd_c.cc b/tests/ten_runtime/smoke/standalone_test/on_cmd_c.cc index 5507265ad..02c999593 100644 --- a/tests/ten_runtime/smoke/standalone_test/on_cmd_c.cc +++ b/tests/ten_runtime/smoke/standalone_test/on_cmd_c.cc @@ -102,7 +102,7 @@ void ten_extension_tester_on_cmd(TEN_UNUSED ten_extension_tester_t *tester, TEST(StandaloneTest, OnCmdC) { // NOLINT ten_extension_tester_t *tester = ten_extension_tester_create( ten_extension_tester_on_start, ten_extension_tester_on_cmd); - ten_extension_tester_add_addon_name( + ten_extension_tester_set_test_mode_single( tester, "standalone_test_on_cmd_c__test_extension_1"); bool rc = ten_extension_tester_run(tester);