From 903ea8d3a1dc5d42620f139e458a1ca59735e22b Mon Sep 17 00:00:00 2001 From: yp9522 Date: Fri, 21 Jun 2024 15:02:49 +0800 Subject: [PATCH 01/33] support compiler ark_toolchain_unittest Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IA716C Change-Id: I3f7acb9b3bcb157a97fea7cd3ab9264ef0e4866f Signed-off-by: yp9522 --- tooling/test/BUILD.gn | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tooling/test/BUILD.gn b/tooling/test/BUILD.gn index 7d941caf..34bfcbac 100644 --- a/tooling/test/BUILD.gn +++ b/tooling/test/BUILD.gn @@ -144,7 +144,10 @@ ohos_shared_library("jsdebugtest") { external_deps += [ "hilog:libhilog" ] } - external_deps += [ "cJSON:cjson_static" ] + external_deps += [ + "cJSON:cjson_static", + "ets_runtime:libark_jsruntime", + ] install_enable = false output_extension = "so" subsystem_name = "test" @@ -298,6 +301,7 @@ host_unittest_action("DebuggerClientTest") { # hiviewdfx libraries external_deps = hiviewdfx_ext_deps external_deps += [ + "bounds_checking_function:libsec_shared", "cJSON:cjson_static", "icu:shared_icui18n", "icu:shared_icuuc", @@ -343,6 +347,7 @@ host_unittest_action("DebuggerCIntClientTest") { # hiviewdfx libraries external_deps = hiviewdfx_ext_deps external_deps += [ + "bounds_checking_function:libsec_shared", "cJSON:cjson_static", "icu:shared_icui18n", "icu:shared_icuuc", -- Gitee From 6ae33250174496548a0ab93e0d90c81cd8ff1158 Mon Sep 17 00:00:00 2001 From: ZitongLi Date: Fri, 2 Aug 2024 16:40:17 +0800 Subject: [PATCH 02/33] Refactoring getthreadortaskid Issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAHGXO Signed-off-by: zitongli --- inspector/inspector.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/inspector/inspector.cpp b/inspector/inspector.cpp index 3292a9d6..2b2fe896 100644 --- a/inspector/inspector.cpp +++ b/inspector/inspector.cpp @@ -303,14 +303,16 @@ void Inspector::OnMessage(std::string&& msg) #if defined(OHOS_PLATFORM) uint64_t Inspector::GetThreadOrTaskId() { - uint64_t threadOrTaskId = static_cast(getproctid()); #if defined(ENABLE_FFRT_INTERFACES) - threadOrTaskId = ffrt_this_task_get_id(); - if (threadOrTaskId == 0) { - threadOrTaskId = static_cast(getproctid()); + uint64_t threadOrTaskId = ffrt_this_task_get_id(); + if (threadOrTaskId != 0) { + return threadOrTaskId; + } else { + return static_cast(getproctid()); } +#else + return static_cast(getproctid()); #endif // defined(ENABLE_FFRT_INTERFACES) - return threadOrTaskId; } #endif // defined(OHOS_PLATFORM) -- Gitee From 2de90f8bab15ea6fe17995a0f3e3ac3bac2c1afa Mon Sep 17 00:00:00 2001 From: fangting Date: Sun, 4 Aug 2024 15:04:36 +0800 Subject: [PATCH 03/33] update tag update tag Issue:#IAFYVD Signed-off-by: fangting --- build/third_party_gn/googletest/BUILD.gn | 175 +++-- build/third_party_gn/icu/icu4c/BUILD.gn | 16 +- build/third_party_gn/libuv/BUILD.gn | 35 +- build/third_party_gn/libuv/src/log_ohos.c | 20 + build/third_party_gn/libuv/src/trace_ohos.c | 19 + build/third_party_gn/musl/BUILD.gn | 69 +- build/third_party_gn/musl/musl_src.gni | 720 +++++++++++++------- build/third_party_gn/musl/musl_template.gni | 105 +-- build/third_party_gn/openssl/BUILD.gn | 4 + 9 files changed, 732 insertions(+), 431 deletions(-) create mode 100644 build/third_party_gn/libuv/src/log_ohos.c create mode 100644 build/third_party_gn/libuv/src/trace_ohos.c diff --git a/build/third_party_gn/googletest/BUILD.gn b/build/third_party_gn/googletest/BUILD.gn index 05146504..04449d71 100644 --- a/build/third_party_gn/googletest/BUILD.gn +++ b/build/third_party_gn/googletest/BUILD.gn @@ -19,8 +19,22 @@ config("gtest_private_config") { include_dirs = [ "$googletest_dir" ] } +config("gtest_private_config_rtti") { + visibility = [ ":*" ] + include_dirs = [ "googletest" ] + cflags = [ "-frtti" ] + cflags_objcc = [ "-frtti" ] + cflags_cc = [ "-frtti" ] +} + config("gtest_config") { include_dirs = [ "$googletest_dir/include" ] + cflags_cc = [ + "-std=c++17", + "-Wno-float-equal", + "-Wno-sign-compare", + "-Wno-reorder-init-list", + ] if (is_mingw) { cflags_cc = [ "-Wno-unused-const-variable", @@ -29,57 +43,74 @@ config("gtest_config") { } } +sources_files = [ + "$googletest_dir/include/gtest/gtest-death-test.h", + "$googletest_dir/include/gtest/gtest-matchers.h", + "$googletest_dir/include/gtest/gtest-message.h", + "$googletest_dir/include/gtest/gtest-param-test.h", + "$googletest_dir/include/gtest/gtest-printers.h", + "$googletest_dir/include/gtest/gtest-test-part.h", + "$googletest_dir/include/gtest/gtest-typed-test.h", + "$googletest_dir/include/gtest/gtest_pred_impl.h", + "$googletest_dir/include/gtest/gtest_prod.h", + "$googletest_dir/include/gtest/hwext/gtest-ext.h", + "$googletest_dir/include/gtest/hwext/gtest-filter.h", + "$googletest_dir/include/gtest/hwext/gtest-multithread.h", + "$googletest_dir/include/gtest/hwext/gtest-tag.h", + "$googletest_dir/include/gtest/hwext/utils.h", + "$googletest_dir/include/gtest/internal/custom/gtest-port.h", + "$googletest_dir/include/gtest/internal/custom/gtest-printers.h", + "$googletest_dir/include/gtest/internal/custom/gtest.h", + "$googletest_dir/include/gtest/internal/gtest-death-test-internal.h", + "$googletest_dir/include/gtest/internal/gtest-filepath.h", + "$googletest_dir/include/gtest/internal/gtest-internal.h", + "$googletest_dir/include/gtest/internal/gtest-param-util.h", + "$googletest_dir/include/gtest/internal/gtest-port-arch.h", + "$googletest_dir/include/gtest/internal/gtest-port.h", + "$googletest_dir/include/gtest/internal/gtest-string.h", + "$googletest_dir/include/gtest/internal/gtest-type-util.h", + "$googletest_dir/src/gtest-all.cc", + "$googletest_dir/src/gtest-assertion-result.cc", + "$googletest_dir/src/gtest-death-test.cc", + "$googletest_dir/src/gtest-filepath.cc", + "$googletest_dir/src/gtest-internal-inl.h", + "$googletest_dir/src/gtest-matchers.cc", + "$googletest_dir/src/gtest-port.cc", + "$googletest_dir/src/gtest-printers.cc", + "$googletest_dir/src/gtest-test-part.cc", + "$googletest_dir/src/gtest-typed-test.cc", + "$googletest_dir/src/gtest.cc", + "$googletest_dir/src/hwext/gtest-ext.cc", + "$googletest_dir/src/hwext/gtest-filter.cc", + "$googletest_dir/src/hwext/gtest-multithread.cpp", + "$googletest_dir/src/hwext/gtest-tag.cc", + "$googletest_dir/src/hwext/gtest-utils.cc", +] + static_library("gtest") { testonly = true public = [ "$googletest_dir/include/gtest/gtest-spi.h", "$googletest_dir/include/gtest/gtest.h", ] - sources = [ - "$googletest_dir/include/gtest/gtest-death-test.h", - "$googletest_dir/include/gtest/gtest-matchers.h", - "$googletest_dir/include/gtest/gtest-message.h", - "$googletest_dir/include/gtest/gtest-param-test.h", - "$googletest_dir/include/gtest/gtest-printers.h", - "$googletest_dir/include/gtest/gtest-test-part.h", - "$googletest_dir/include/gtest/gtest-typed-test.h", - "$googletest_dir/include/gtest/gtest_pred_impl.h", - "$googletest_dir/include/gtest/gtest_prod.h", - "$googletest_dir/include/gtest/hwext/gtest-ext.h", - "$googletest_dir/include/gtest/hwext/gtest-filter.h", - "$googletest_dir/include/gtest/hwext/gtest-tag.h", - "$googletest_dir/include/gtest/hwext/utils.h", - "$googletest_dir/include/gtest/internal/custom/gtest-port.h", - "$googletest_dir/include/gtest/internal/custom/gtest-printers.h", - "$googletest_dir/include/gtest/internal/custom/gtest.h", - "$googletest_dir/include/gtest/internal/gtest-death-test-internal.h", - "$googletest_dir/include/gtest/internal/gtest-filepath.h", - "$googletest_dir/include/gtest/internal/gtest-internal.h", - "$googletest_dir/include/gtest/internal/gtest-param-util.h", - "$googletest_dir/include/gtest/internal/gtest-port-arch.h", - "$googletest_dir/include/gtest/internal/gtest-port.h", - "$googletest_dir/include/gtest/internal/gtest-string.h", - "$googletest_dir/include/gtest/internal/gtest-type-util.h", - "$googletest_dir/src/gtest-all.cc", - "$googletest_dir/src/gtest-death-test.cc", - "$googletest_dir/src/gtest-filepath.cc", - "$googletest_dir/src/gtest-internal-inl.h", - "$googletest_dir/src/gtest-matchers.cc", - "$googletest_dir/src/gtest-port.cc", - "$googletest_dir/src/gtest-printers.cc", - "$googletest_dir/src/gtest-test-part.cc", - "$googletest_dir/src/gtest-typed-test.cc", - "$googletest_dir/src/gtest.cc", - "$googletest_dir/src/hwext/gtest-ext.cc", - "$googletest_dir/src/hwext/gtest-filter.cc", - "$googletest_dir/src/hwext/gtest-tag.cc", - "$googletest_dir/src/hwext/gtest-utils.cc", - ] + sources = sources_files sources -= [ "$googletest_dir/src/gtest-all.cc" ] public_configs = [ ":gtest_config" ] configs += [ ":gtest_private_config" ] } +static_library("gtest_rtti") { + testonly = true + public = [ + "$googletest_dir/include/gtest/gtest-spi.h", + "$googletest_dir/include/gtest/gtest.h", + ] + sources = sources_files + sources -= [ "$googletest_dir/src/gtest-all.cc" ] + public_configs = [ ":gtest_config" ] + configs += [ ":gtest_private_config_rtti" ] +} + static_library("gtest_main") { testonly = true sources = [ "$googletest_dir/src/gtest_main.cc" ] @@ -91,6 +122,14 @@ config("gmock_private_config") { include_dirs = [ "$googlemock_dir" ] } +config("gmock_private_config_rtti") { + visibility = [ ":*" ] + include_dirs = [ "googlemock_dir/include" ] + cflags = [ "-frtti" ] + cflags_objcc = [ "-frtti" ] + cflags_cc = [ "-frtti" ] +} + config("gmock_config") { include_dirs = [ "$googlemock_dir/include" ] @@ -104,37 +143,49 @@ config("gmock_config") { ] } +gmock_sources_files = [ + "$googlemock_dir/include/gmock/gmock-actions.h", + "$googlemock_dir/include/gmock/gmock-cardinalities.h", + "$googlemock_dir/include/gmock/gmock-function-mocker.h", + "$googlemock_dir/include/gmock/gmock-matchers.h", + "$googlemock_dir/include/gmock/gmock-more-actions.h", + "$googlemock_dir/include/gmock/gmock-more-matchers.h", + "$googlemock_dir/include/gmock/gmock-nice-strict.h", + "$googlemock_dir/include/gmock/gmock-spec-builders.h", + "$googlemock_dir/include/gmock/internal/custom/gmock-generated-actions.h", + "$googlemock_dir/include/gmock/internal/custom/gmock-matchers.h", + "$googlemock_dir/include/gmock/internal/custom/gmock-port.h", + "$googlemock_dir/include/gmock/internal/gmock-internal-utils.h", + "$googlemock_dir/include/gmock/internal/gmock-port.h", + "$googlemock_dir/include/gmock/internal/gmock-pp.h", + "$googlemock_dir/src/gmock-all.cc", + "$googlemock_dir/src/gmock-cardinalities.cc", + "$googlemock_dir/src/gmock-internal-utils.cc", + "$googlemock_dir/src/gmock-matchers.cc", + "$googlemock_dir/src/gmock-spec-builders.cc", + "$googlemock_dir/src/gmock.cc", +] + static_library("gmock") { testonly = true public = [ "$googlemock_dir/include/gmock/gmock.h" ] - sources = [ - "$googlemock_dir/include/gmock/gmock-actions.h", - "$googlemock_dir/include/gmock/gmock-cardinalities.h", - "$googlemock_dir/include/gmock/gmock-function-mocker.h", - "$googlemock_dir/include/gmock/gmock-matchers.h", - "$googlemock_dir/include/gmock/gmock-more-actions.h", - "$googlemock_dir/include/gmock/gmock-more-matchers.h", - "$googlemock_dir/include/gmock/gmock-nice-strict.h", - "$googlemock_dir/include/gmock/gmock-spec-builders.h", - "$googlemock_dir/include/gmock/internal/custom/gmock-generated-actions.h", - "$googlemock_dir/include/gmock/internal/custom/gmock-matchers.h", - "$googlemock_dir/include/gmock/internal/custom/gmock-port.h", - "$googlemock_dir/include/gmock/internal/gmock-internal-utils.h", - "$googlemock_dir/include/gmock/internal/gmock-port.h", - "$googlemock_dir/include/gmock/internal/gmock-pp.h", - "$googlemock_dir/src/gmock-all.cc", - "$googlemock_dir/src/gmock-cardinalities.cc", - "$googlemock_dir/src/gmock-internal-utils.cc", - "$googlemock_dir/src/gmock-matchers.cc", - "$googlemock_dir/src/gmock-spec-builders.cc", - "$googlemock_dir/src/gmock.cc", - ] + sources = gmock_sources_files sources -= [ "$googlemock_dir/src/gmock-all.cc" ] public_configs = [ ":gmock_config" ] configs += [ ":gmock_private_config" ] deps = [ ":gtest" ] } +static_library("gmock_rtti") { + testonly = true + public = [ "$googlemock_dir/include/gmock/gmock.h" ] + sources = gmock_sources_files + sources -= [ "$googlemock_dir/src/gmock-all.cc" ] + public_configs = [ ":gmock_config" ] + configs += [ ":gmock_private_config_rtti" ] + deps = [ ":gtest_rtti" ] +} + static_library("gmock_main") { testonly = true sources = [ "$googlemock_dir/src/gmock_main.cc" ] diff --git a/build/third_party_gn/icu/icu4c/BUILD.gn b/build/third_party_gn/icu/icu4c/BUILD.gn index 082ce8bc..cafe6465 100644 --- a/build/third_party_gn/icu/icu4c/BUILD.gn +++ b/build/third_party_gn/icu/icu4c/BUILD.gn @@ -499,13 +499,7 @@ ohos_shared_library("shared_icuuc") { "-shared", "-lm", ] - if (current_os == "ios") { - ldflags += [ - "-Wl", - "-install_name", - "@rpath/libhmicuuc.framework/libhmicuuc", - ] - } + configs = [ ":icu_config", "$build_root/config/compiler:rtti", @@ -552,14 +546,6 @@ ohos_shared_library("shared_icuuc") { install_enable = true } -if (current_os == "ios") { - ohos_combine_darwin_framework("libhmicuuc") { - deps = [ ":shared_icuuc" ] - subsystem_name = "thirdparty" - part_name = "icu" - } -} - ohos_shared_library("shared_icui18n") { ldflags = [ "-shared", diff --git a/build/third_party_gn/libuv/BUILD.gn b/build/third_party_gn/libuv/BUILD.gn index b7276c26..5bb82bb0 100644 --- a/build/third_party_gn/libuv/BUILD.gn +++ b/build/third_party_gn/libuv/BUILD.gn @@ -20,6 +20,7 @@ common_source = [ "//third_party/libuv/src/random.c", "//third_party/libuv/src/strscpy.c", "//third_party/libuv/src/threadpool.c", + "//third_party/libuv/src/thread-common.c", "//third_party/libuv/src/timer.c", "//third_party/libuv/src/uv-common.c", "//third_party/libuv/src/uv-data-getter-setters.c", @@ -28,7 +29,6 @@ common_source = [ ] if (!is_mingw && !is_win) { nonwin_srcs = [ - "//third_party/libuv/src/unix/epoll.c", "//third_party/libuv/src/unix/async.c", "//third_party/libuv/src/unix/core.c", "//third_party/libuv/src/unix/dl.c", @@ -57,6 +57,7 @@ config("libuv_config") { "//third_party/libuv/src", "//third_party/libuv/src/unix", ] + defines = [] cflags = [ "-Wno-unused-parameter" ] if (is_linux || is_ohos) { cflags += [ @@ -68,7 +69,7 @@ config("libuv_config") { # Adding NDEBUG macro manually to avoid compilation # error in debug version, FIX ME # https://gitee.com/openharmony/build/pulls/1206/files - defines = [ "NDEBUG" ] + defines += [ "NDEBUG" ] } else if (is_mingw || is_win) { cflags += [ "-Wno-missing-braces", @@ -79,7 +80,7 @@ config("libuv_config") { "-Wno-error=unknown-pragmas", "-Wno-unused-variable", ] - defines = [ + defines += [ "WIN32_LEAN_AND_MEAN", "_WIN32_WINNT=0x0600", ] @@ -98,7 +99,7 @@ config("libuv_config") { "ws2_32", ] } else if (is_android) { - defines = [ "_GNU_SOURCE" ] + defines += [ "_GNU_SOURCE" ] } } @@ -122,7 +123,7 @@ ohos_source_set("libuv_source") { stack_protector_ret = false configs = [ ":libuv_config" ] sources = common_source - + external_deps = [] if (is_mac || (defined(is_ios) && is_ios)) { sources += nonwin_srcs + [ "//third_party/libuv/src/unix/bsd-ifaddrs.c", @@ -132,8 +133,9 @@ ohos_source_set("libuv_source") { "//third_party/libuv/src/unix/darwin.c", "//third_party/libuv/src/unix/fsevents.c", "//third_party/libuv/src/unix/os390-proctitle.c", + "//third_party/libuv/src/unix/log_unix.c", + "//third_party/libuv/src/unix/trace_unix.c", ] - sources -= [ "//third_party/libuv/src/unix/epoll.c" ] } else if (is_mingw || is_win) { sources += [ "//third_party/libuv/src/win/async.c", @@ -146,6 +148,7 @@ ohos_source_set("libuv_source") { "//third_party/libuv/src/win/getaddrinfo.c", "//third_party/libuv/src/win/getnameinfo.c", "//third_party/libuv/src/win/handle.c", + "//third_party/libuv/src/win/log_win.c", "//third_party/libuv/src/win/loop-watcher.c", "//third_party/libuv/src/win/pipe.c", "//third_party/libuv/src/win/poll.c", @@ -156,6 +159,7 @@ ohos_source_set("libuv_source") { "//third_party/libuv/src/win/stream.c", "//third_party/libuv/src/win/tcp.c", "//third_party/libuv/src/win/thread.c", + "//third_party/libuv/src/win/trace_win.c", "//third_party/libuv/src/win/tty.c", "//third_party/libuv/src/win/udp.c", "//third_party/libuv/src/win/util.c", @@ -164,31 +168,30 @@ ohos_source_set("libuv_source") { ] } else if (is_ohos || (defined(is_android) && is_android)) { sources += nonwin_srcs + [ - "//third_party/libuv/src/unix/linux-core.c", - "//third_party/libuv/src/unix/linux-inotify.c", - "//third_party/libuv/src/unix/linux-syscalls.c", + "//third_party/libuv/src/unix/linux.c", "//third_party/libuv/src/unix/procfs-exepath.c", - "//third_party/libuv/src/unix/pthread-fixes.c", "//third_party/libuv/src/unix/random-getentropy.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", ] + sources += [ + "src/log_ohos.c", + "src/trace_ohos.c", + ] } else if (is_linux) { sources += nonwin_srcs + [ - "//third_party/libuv/src/unix/linux-core.c", - "//third_party/libuv/src/unix/linux-inotify.c", - "//third_party/libuv/src/unix/linux-syscalls.c", + "//third_party/libuv/src/unix/linux.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", + "//third_party/libuv/src/unix/log_unix.c", + "//third_party/libuv/src/unix/trace_unix.c", ] } else { sources += nonwin_srcs + [ - "//third_party/libuv/src/unix/linux-core.c", - "//third_party/libuv/src/unix/linux-inotify.c", - "//third_party/libuv/src/unix/linux-syscalls.c", + "//third_party/libuv/src/unix/linux.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", diff --git a/build/third_party_gn/libuv/src/log_ohos.c b/build/third_party_gn/libuv/src/log_ohos.c new file mode 100644 index 00000000..adca6ab0 --- /dev/null +++ b/build/third_party_gn/libuv/src/log_ohos.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "uv_log.h" + +int uv__log_impl(enum uv__log_level level, const char* fmt, ...) +{ + return 0; +} \ No newline at end of file diff --git a/build/third_party_gn/libuv/src/trace_ohos.c b/build/third_party_gn/libuv/src/trace_ohos.c new file mode 100644 index 00000000..d288639d --- /dev/null +++ b/build/third_party_gn/libuv/src/trace_ohos.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#define UV_TRACE_TAG (1ULL << 30) + +void uv_start_trace(uint64_t tag, const char* name) {} +void uv_end_trace(uint64_t tag) {} \ No newline at end of file diff --git a/build/third_party_gn/musl/BUILD.gn b/build/third_party_gn/musl/BUILD.gn index 2b827ba2..8cbfe3ec 100644 --- a/build/third_party_gn/musl/BUILD.gn +++ b/build/third_party_gn/musl/BUILD.gn @@ -39,41 +39,46 @@ action("create_porting_src") { outdir = [ "${target_out_dir}/${musl_ported_dir}" ] src_files = musl_src_arch_file - src_files += musl_inc_root_files - src_files += musl_inc_fortify_files - src_files += musl_inc_sys_files - src_files += musl_inc_scsi_files - src_files += musl_inc_netpacket_files - src_files += musl_inc_netinet_files - src_files += musl_inc_net_files - src_files += musl_inc_arpa_files - src_files += musl_inc_bits_files - src_files += musl_src_ldso src_files += musl_src_file + src_files += musl_src_ldso + src_files += musl_inc_bits_files + src_files += musl_inc_arpa_files + src_files += musl_inc_net_files + src_files += musl_inc_netinet_files + src_files += musl_inc_netpacket_files + src_files += musl_inc_scsi_files + src_files += musl_inc_sys_files + src_files += musl_inc_fortify_files + src_files += musl_inc_root_files + src_files += musl_inc_info_files + src_files += musl_inc_trace_files src_files += [ - "scripts/create_syscall.sh", - "scripts/create_vesion.sh", - "scripts/create_alltypes.sh", - "scripts/install.py", - "tools/install.sh", - "tools/version.sh", - "VERSION", - "include/alltypes.h.in", - "arch/${musl_arch}/bits/syscall.h.in", - "arch/${musl_arch}/bits/alltypes.h.in", - "tools/mkalltypes.sed", - "crt/rcrt1.c", - "crt/crt1.c", "crt/Scrt1.c", - "crt/${musl_arch}/crtn.s", + "crt/crt1.c", + "crt/rcrt1.c", + "tools/mkalltypes.sed", + "arch/${musl_arch}/bits/alltypes.h.in", + "arch/${musl_arch}/bits/syscall.h.in", + "include/alltypes.h.in", + "VERSION", + "tools/version.sh", + "tools/install.sh", + "scripts/install.py", + "scripts/create_alltypes.sh", + "scripts/create_vesion.sh", + "scripts/create_syscall.sh", + ] + src_files += [ "crt/${musl_arch}/crti.s", + "crt/${musl_arch}/crtn.s", ] + args = [ "-i" ] + rebase_path(sources_dir) args += [ "-o" ] + rebase_path(outdir) args += [ "-p" ] + [ "${musl_target_os}" ] foreach(i, src_files) { - foreach(s, musl_src_porting_file) { + foreach(s, musl_src_files_ext) { if (i == s) { src_files -= [ "${s}" ] } @@ -85,16 +90,24 @@ action("create_porting_src") { outputs += [ "${target_out_dir}/${musl_ported_dir}/${s}" ] } - foreach(s, musl_src_porting_file) { + foreach(s, musl_src_files_ext) { outputs += [ "${target_out_dir}/${musl_ported_dir}/${s}" ] } + inputs = [] + foreach(i, src_files) { + foreach(s, musl_src_linux_files) { + if (i == s) { + src_files -= [ "${s}" ] + } + } + } foreach(s, src_files) { inputs += [ "${musl_dir}/${s}" ] } - foreach(s, musl_src_porting_file) { - inputs += [ "${musl_porting_dir}/${s}" ] + foreach(s, musl_src_files_ext) { + inputs += [ "${musl_dir}/${s}" ] } } diff --git a/build/third_party_gn/musl/musl_src.gni b/build/third_party_gn/musl/musl_src.gni index eeb0267d..aa32f5cc 100644 --- a/build/third_party_gn/musl/musl_src.gni +++ b/build/third_party_gn/musl/musl_src.gni @@ -14,6 +14,7 @@ import("//third_party/FreeBSD/FreeBSD.gni") import("$build_root/third_party_gn/musl/musl_config.gni") +OPTRTDIR = "//third_party/optimized-routines/" if (musl_arch == "arm") { musl_src_arch_file = [ "src/exit/arm/__aeabi_atexit.c", @@ -21,7 +22,6 @@ if (musl_arch == "arm") { "src/fenv/arm/fenv.c", "src/ldso/arm/dlsym.s", "src/ldso/arm/dlsym_time64.S", - "src/ldso/arm/dlvsym.s", "src/ldso/arm/find_exidx.c", "src/ldso/arm/tlsdesc.S", "src/math/arm/fabs.c", @@ -44,6 +44,7 @@ if (musl_arch == "arm") { "src/thread/arm/atomics.s", "src/thread/arm/clone.s", "src/thread/arm/syscall_cp.s", + "src/linux/arm/flock.s", "compat/time32/adjtime32.c", "compat/time32/adjtimex_time32.c", "compat/time32/aio_suspend_time32.c", @@ -113,7 +114,6 @@ if (musl_arch == "arm") { musl_src_arch_file = [ "src/fenv/aarch64/fenv.s", "src/ldso/aarch64/dlsym.s", - "src/ldso/aarch64/dlvsym.s", "src/ldso/aarch64/tlsdesc.s", "src/math/aarch64/ceil.c", "src/math/aarch64/ceilf.c", @@ -152,15 +152,58 @@ if (musl_arch == "arm") { "src/thread/aarch64/__set_thread_area.s", "src/thread/aarch64/__unmapself.s", "src/thread/aarch64/clone.s", - "src/misc/aarch64/fstat.s", "src/thread/aarch64/syscall_cp.s", - "src/misc/aarch64/syscall.s", + "src/linux/aarch64/flock.s", + ] +} else if (musl_arch == "mips") { + musl_src_arch_file = [ + "src/fenv/mips/fenv-sf.c", + "src/fenv/mips/fenv.S", + "src/ldso/mips/dlsym_time64.S", + "src/ldso/mips/dlsym.s", + "src/math/mips/fabs.c", + "src/math/mips/fabsf.c", + "src/math/mips/sqrt.c", + "src/math/mips/sqrtf.c", + "src/setjmp/mips/longjmp.S", + "src/setjmp/mips/setjmp.S", + "src/signal/mips/sigsetjmp.s", + "src/thread/mips/__unmapself.s", + "src/thread/mips/clone.s", + "src/thread/mips/syscall_cp.s", + "src/unistd/mips/pipe.s", + ] +} else if (musl_arch == "riscv64") { + musl_src_arch_file = [ + "src/fenv/riscv64/fenv-sf.c", + "src/fenv/riscv64/fenv.S", + "src/ldso/riscv64/dlsym.s", + "src/ldso/riscv64/tlsdesc.s", + "src/math/riscv64/copysign.c", + "src/math/riscv64/copysignf.c", + "src/math/riscv64/fabs.c", + "src/math/riscv64/fabsf.c", + "src/math/riscv64/fma.c", + "src/math/riscv64/fmaf.c", + "src/math/riscv64/fmax.c", + "src/math/riscv64/fmaxf.c", + "src/math/riscv64/fmin.c", + "src/math/riscv64/fminf.c", + "src/math/riscv64/sqrt.c", + "src/math/riscv64/sqrtf.c", + "src/setjmp/riscv64/longjmp.S", + "src/setjmp/riscv64/setjmp.S", + "src/signal/riscv64/restore.s", + "src/signal/riscv64/sigsetjmp.s", + "src/thread/riscv64/__set_thread_area.s", + "src/thread/riscv64/__unmapself.s", + "src/thread/riscv64/clone.s", + "src/thread/riscv64/syscall_cp.s", ] } else if (musl_arch == "x86_64") { musl_src_arch_file = [ "src/fenv/x86_64/fenv.s", "src/ldso/x86_64/dlsym.s", - "src/ldso/x86_64/dlvsym.s", "src/ldso/x86_64/tlsdesc.s", "src/math/x86_64/__invtrigl.s", "src/math/x86_64/acosl.s", @@ -205,38 +248,32 @@ if (musl_arch == "arm") { "src/thread/x86_64/__unmapself.s", "src/thread/x86_64/clone.s", "src/thread/x86_64/syscall_cp.s", + "src/linux/x86_64/flock.s", ] -} else if (musl_arch == "mips") { +} else if (musl_arch == "loongarch64") { musl_src_arch_file = [ - "src/fenv/mips/fenv.S", - "src/fenv/mips/fenv-sf.c", - "src/ldso/mips/dlsym.s", - "src/ldso/mips/dlsym_time64.S", - "src/math/mips/fabs.c", - "src/math/mips/fabsf.c", - "src/math/mips/sqrt.c", - "src/math/mips/sqrtf.c", - "src/setjmp/mips/longjmp.S", - "src/setjmp/mips/setjmp.S", - "src/signal/mips/restore.s", - "src/signal/mips/sigsetjmp.s", - "src/thread/mips/__unmapself.s", - "src/thread/mips/clone.s", - "src/thread/mips/syscall_cp.s", + "src/fenv/loongarch64/fenv.S", + "src/ldso/loongarch64/dlsym.s", + "src/ldso/loongarch64/tlsdesc.s", + "src/setjmp/loongarch64/longjmp.S", + "src/setjmp/loongarch64/setjmp.S", + "src/signal/loongarch64/restore.s", + "src/signal/loongarch64/sigsetjmp.s", + "src/thread/loongarch64/__set_thread_area.s", + "src/thread/loongarch64/__unmapself.s", + "src/thread/loongarch64/clone.s", + "src/thread/loongarch64/syscall_cp.s", ] } musl_src_file = [ - "src/thread/pthread_cond_clockwait.c", - "src/thread/pthread_cond_timedwait_monotonic_np.c", - "src/thread/pthread_cond_timeout_np.c", "src/internal/pthread_impl.h", "src/internal/locale_impl.h", - "src/thread/pthread_rwlock_clockrdlock.c", + "src/internal/locale_impl.c", + "src/internal/stdio_impl.h", + "src/internal/unsupported_api.h", + "src/internal/syscall_hooks.h", "src/thread/pthread_rwlock_timedrdlock.c", - "src/thread/pthread_rwlock_timedrdlock_monotonic_np.c", - "src/thread/pthread_rwlock_clockwrlock.c", - "src/thread/pthread_rwlock_timedwrlock_monotonic_np.c", "src/thread/pthread_rwlock_timedwrlock.c", "src/aio/aio.c", "src/aio/aio_suspend.c", @@ -391,6 +428,7 @@ musl_src_file = [ "src/exit/at_quick_exit.c", "src/exit/atexit.c", "src/exit/exit.c", + "src/exit/cxa_thread_atexit_impl.c", "src/exit/quick_exit.c", "src/fcntl/creat.c", "src/fcntl/fcntl.c", @@ -398,6 +436,7 @@ musl_src_file = [ "src/fcntl/openat.c", "src/fcntl/posix_fadvise.c", "src/fcntl/posix_fallocate.c", + "src/fdsan/fdsan.c", "src/fenv/__flt_rounds.c", "src/fenv/fegetexceptflag.c", "src/fenv/feholdexcept.c", @@ -406,6 +445,8 @@ musl_src_file = [ "src/fenv/fesetround.c", "src/fenv/feupdateenv.c", "src/fortify/fortify.c", + "src/gwp_asan/gwp_asan.c", + "src/gwp_asan/gwp_asan.h", "src/internal/defsysinfo.c", "src/internal/floatscan.c", "src/internal/intscan.c", @@ -413,9 +454,7 @@ musl_src_file = [ "src/internal/procfdname.c", "src/internal/shgetc.c", "src/internal/syscall_ret.c", - "src/internal/vdso.c", "src/internal/version.c", - "src/internal/network_conf_function.c", "src/hilog/hilog_adapter.c", "src/hilog/vsnprintf_s_p.c", "src/ipc/ftok.c", @@ -488,15 +527,14 @@ musl_src_file = [ "src/linux/open_by_handle_at.c", "src/linux/personality.c", "src/linux/pivot_root.c", - "src/linux/ppoll.c", "src/linux/prctl.c", + "src/linux/preadv2.c", "src/linux/prlimit.c", "src/linux/process_vm.c", "src/linux/ptrace.c", "src/linux/quotactl.c", "src/linux/readahead.c", "src/linux/reboot.c", - "src/linux/tgkill.c", "src/linux/remap_file_pages.c", "src/linux/sbrk.c", "src/linux/sendfile.c", @@ -508,6 +546,7 @@ musl_src_file = [ "src/linux/settimeofday.c", "src/linux/signalfd.c", "src/linux/splice.c", + "src/linux/statx.c", "src/linux/stime.c", "src/linux/swap.c", "src/linux/sync_file_range.c", @@ -521,6 +560,7 @@ musl_src_file = [ "src/linux/vmsplice.c", "src/linux/wait3.c", "src/linux/wait4.c", + "src/linux/pwritev2.c", "src/linux/xattr.c", "src/locale/__lctrans.c", "src/locale/__mo_lookup.c", @@ -542,6 +582,7 @@ musl_src_file = [ "src/locale/setlocale.c", "src/locale/strcoll.c", "src/locale/strtod_l.c", + "src/locale/wcstod_l.c", "src/locale/strfmon.c", "src/locale/strxfrm.c", "src/locale/textdomain.c", @@ -556,8 +597,6 @@ musl_src_file = [ "src/malloc/mallocng/malloc.c", "src/malloc/mallocng/meta.h", "src/malloc/mallocng/realloc.c", - "src/malloc/stats.c", - "src/malloc/calloc.c", "src/malloc/free.c", "src/malloc/libc_calloc.c", "src/malloc/lite_malloc.c", @@ -1029,6 +1068,7 @@ musl_src_file = [ "src/regex/regerror.c", "src/regex/regexec.c", "src/regex/tre-mem.c", + "src/syscall_hooks/syscall_hooks.c", "src/sched/sched_cpualloc.c", "src/sched/affinity.c", "src/sched/sched_cpucount.c", @@ -1049,6 +1089,7 @@ musl_src_file = [ "src/search/tsearch.c", "src/search/twalk.c", "src/select/poll.c", + "src/select/ppoll.c", "src/select/pselect.c", "src/select/select.c", "src/setjmp/longjmp.c", @@ -1091,7 +1132,6 @@ musl_src_file = [ "src/signal/sigtimedwait.c", "src/signal/sigwait.c", "src/signal/sigwaitinfo.c", - "src/sigchain/sigchain.c", "src/stat/__xstat.c", "src/stat/chmod.c", "src/stat/fchmod.c", @@ -1250,6 +1290,7 @@ musl_src_file = [ "src/stdlib/strtol.c", "src/stdlib/wcstod.c", "src/stdlib/wcstol.c", + "src/string/strcspn.c", "src/string/bcmp.c", "src/string/bcopy.c", "src/string/bzero.c", @@ -1268,13 +1309,11 @@ musl_src_file = [ "src/string/stpcpy.c", "src/string/stpncpy.c", "src/string/strcasecmp.c", - "src/string/strcasestr.c", "src/string/strcat.c", "src/string/strchr.c", "src/string/strchrnul.c", "src/string/strcmp.c", "src/string/strcpy.c", - "src/string/strcspn.c", "src/string/strdup.c", "src/string/strerror_r.c", "src/string/strlcat.c", @@ -1415,9 +1454,6 @@ musl_src_file = [ "src/thread/pthread_mutex_lock.c", "src/thread/pthread_mutex_setprioceiling.c", "src/thread/pthread_mutex_timedlock.c", - "src/thread/pthread_mutex_clocklock.c", - "src/thread/pthread_mutex_timedlock_monotonic_np.c", - "src/thread/pthread_mutex_lock_timeout_np.c", "src/thread/pthread_mutex_trylock.c", "src/thread/pthread_mutex_unlock.c", "src/thread/pthread_mutexattr_destroy.c", @@ -1596,6 +1632,39 @@ musl_src_file = [ "src/info/application_target_sdk_version.c", "src/info/device_api_version.c", "src/info/fatal_message.c", + "arch/generic/crtbrand.s", + "crt/crtplus.c", + "ldso/namespace.h", + "ldso/ns_config.h", + "ldso/strops.h", + "ldso/cfi.h", + "ldso/ld_log.h", + "ldso/dynlink_rand.h", + "src/internal/vdso.c", + "src/internal/emulate_wait4.c", + "src/internal/malloc_config.h", + "src/internal/malloc_random.h", + "src/internal/hilog_adapter.h", + "src/internal/musl_log.h", + "src/internal/musl_log.c", + "src/internal/network_conf_function.c", + "src/internal/network_conf_function.h", + "src/internal/services.h", + "src/internal/proc_xid_impl.h", + "src/linux/tgkill.c", + "src/malloc/calloc.c", + "src/malloc/stats.c", + "src/sigchain/sigchain.c", + "src/thread/pthread_cond_clockwait.c", + "src/thread/pthread_cond_timedwait_monotonic_np.c", + "src/thread/pthread_cond_timeout_np.c", + "src/thread/pthread_mutex_clocklock.c", + "src/thread/pthread_mutex_timedlock_monotonic_np.c", + "src/thread/pthread_mutex_lock_timeout_np.c", + "src/thread/pthread_rwlock_clockrdlock.c", + "src/thread/pthread_rwlock_timedrdlock_monotonic_np.c", + "src/thread/pthread_rwlock_clockwrlock.c", + "src/thread/pthread_rwlock_timedwrlock_monotonic_np.c", ] if (musl_arch == "arm") { @@ -1718,13 +1787,54 @@ if (musl_arch == "arm") { musl_src_filterout = [ "src/fenv/fenv.c", "src/ldso/dlsym.c", + "src/ldso/tlsdesc.c", + "src/math/fabs.c", + "src/math/fabsf.c", + "src/math/sqrt.c", + "src/math/sqrtf.c", + "src/setjmp/longjmp.c", + "src/setjmp/setjmp.c", + "src/signal/restore.c", + "src/signal/sigsetjmp.c", + "src/thread/__unmapself.c", + "src/thread/clone.c", + "src/thread/syscall_cp.c", + "src/unistd/pipe.c", + ] +} else if (musl_arch == "riscv64") { + musl_src_filterout = [ + "src/fenv/fenv.c", + "src/ldso/dlsym.c", + "src/ldso/tlsdesc.c", "src/math/fabs.c", "src/math/fabsf.c", + "src/math/fma.c", "src/math/fmaf.c", + "src/math/fmax.c", + "src/math/fmaxf.c", + "src/math/fmin.c", + "src/math/fminf.c", "src/math/sqrt.c", "src/math/sqrtf.c", + "src/setjmp/longjmp.c", "src/setjmp/setjmp.c", "src/signal/restore.c", + "src/signal/sigsetjmp.c", + "src/thread/__set_thread_area.c", + "src/thread/__unmapself.c", + "src/thread/clone.c", + "src/thread/syscall_cp.c", + ] +} else if (musl_arch == "loongarch64") { + musl_src_filterout = [ + "src/fenv/fenv.c", + "src/ldso/dlsym.c", + "src/ldso/tlsdesc.c", + "src/setjmp/longjmp.c", + "src/setjmp/setjmp.c", + "src/signal/restore.c", + "src/signal/sigsetjmp.c", + "src/thread/__set_thread_area.c", "src/thread/__unmapself.c", "src/thread/clone.c", "src/thread/syscall_cp.c", @@ -1828,7 +1938,6 @@ if (musl_arch == "arm") { "arch/x86_64/bits/stat.h", "arch/x86_64/bits/stdint.h", "arch/x86_64/bits/user.h", - "arch/generic/bits/dirent.h", "arch/generic/bits/errno.h", "arch/generic/bits/hwcap.h", @@ -1855,40 +1964,115 @@ if (musl_arch == "arm") { ] } else if (musl_arch == "mips") { musl_inc_bits_files = [ - "arch/mips/bits/errno.h", - "arch/mips/bits/fcntl.h", + "arch/generic/bits/fcntl.h", "arch/mips/bits/fenv.h", "arch/mips/bits/float.h", - "arch/mips/bits/hwcap.h", - "arch/mips/bits/ioctl.h", - "arch/mips/bits/ipcstat.h", - "arch/mips/bits/mman.h", - "arch/mips/bits/msg.h", - "arch/mips/bits/poll.h", "arch/mips/bits/posix.h", - "arch/mips/bits/ptrace.h", "arch/mips/bits/reg.h", - "arch/mips/bits/resource.h", - "arch/mips/bits/sem.h", "arch/mips/bits/setjmp.h", - "arch/mips/bits/shm.h", "arch/mips/bits/signal.h", - "arch/mips/bits/socket.h", "arch/mips/bits/stat.h", - "arch/mips/bits/statfs.h", "arch/mips/bits/stdint.h", - "arch/mips/bits/termios.h", "arch/mips/bits/user.h", + "arch/generic/bits/dirent.h", + "arch/generic/bits/errno.h", + "arch/generic/bits/hwcap.h", "arch/generic/bits/ioctl_fix.h", + "arch/generic/bits/ioctl.h", "arch/generic/bits/io.h", "arch/generic/bits/ipc.h", + "arch/generic/bits/ipcstat.h", "arch/generic/bits/kd.h", "arch/generic/bits/limits.h", "arch/generic/bits/link.h", + "arch/generic/bits/mman.h", + "arch/generic/bits/msg.h", + "arch/generic/bits/poll.h", + "arch/generic/bits/ptrace.h", + "arch/generic/bits/resource.h", + "arch/generic/bits/sem.h", + "arch/generic/bits/shm.h", + "arch/generic/bits/socket.h", "arch/generic/bits/soundcard.h", + "arch/generic/bits/statfs.h", + "arch/generic/bits/termios.h", "arch/generic/bits/vt.h", ] +} else if (musl_arch == "riscv64") { + musl_inc_bits_files = [ + "arch/generic/bits/fcntl.h", + "arch/riscv64/bits/fenv.h", + "arch/riscv64/bits/float.h", + "arch/riscv64/bits/posix.h", + "arch/riscv64/bits/reg.h", + "arch/riscv64/bits/setjmp.h", + "arch/riscv64/bits/signal.h", + "arch/riscv64/bits/stat.h", + "arch/riscv64/bits/stdint.h", + "arch/riscv64/bits/user.h", + + "arch/generic/bits/dirent.h", + "arch/generic/bits/errno.h", + "arch/generic/bits/hwcap.h", + "arch/generic/bits/ioctl_fix.h", + "arch/generic/bits/ioctl.h", + "arch/generic/bits/io.h", + "arch/generic/bits/ipc.h", + "arch/generic/bits/ipcstat.h", + "arch/generic/bits/kd.h", + "arch/generic/bits/limits.h", + "arch/generic/bits/link.h", + "arch/generic/bits/mman.h", + "arch/generic/bits/msg.h", + "arch/generic/bits/poll.h", + "arch/generic/bits/ptrace.h", + "arch/generic/bits/resource.h", + "arch/generic/bits/sem.h", + "arch/generic/bits/shm.h", + "arch/generic/bits/socket.h", + "arch/generic/bits/soundcard.h", + "arch/generic/bits/statfs.h", + "arch/generic/bits/termios.h", + "arch/generic/bits/vt.h", + ] +} else if (musl_arch == "loongarch64") { + musl_inc_bits_files = [ + "arch/loongarch64/bits/fenv.h", + "arch/loongarch64/bits/float.h", + "arch/loongarch64/bits/posix.h", + "arch/loongarch64/bits/reg.h", + "arch/loongarch64/bits/setjmp.h", + "arch/loongarch64/bits/signal.h", + "arch/loongarch64/bits/stat.h", + "arch/loongarch64/bits/stdint.h", + "arch/loongarch64/bits/user.h", + + "arch/generic/bits/dirent.h", + "arch/generic/bits/errno.h", + "arch/generic/bits/hwcap.h", + "arch/generic/bits/ioctl_fix.h", + "arch/generic/bits/ioctl.h", + "arch/generic/bits/io.h", + "arch/generic/bits/ipc.h", + "arch/generic/bits/ipcstat.h", + "arch/generic/bits/kd.h", + "arch/generic/bits/link.h", + "arch/generic/bits/mman.h", + "arch/generic/bits/msg.h", + "arch/generic/bits/poll.h", + "arch/generic/bits/sem.h", + "arch/generic/bits/shm.h", + "arch/generic/bits/socket.h", + "arch/generic/bits/soundcard.h", + "arch/generic/bits/termios.h", + "arch/generic/bits/vt.h", + "arch/generic/bits/statfs.h", + "arch/generic/bits/ptrace.h", + "arch/generic/bits/resource.h", + "arch/generic/bits/fcntl.h", + "arch/generic/bits/limits.h", + ] } musl_inc_arpa_files = [ @@ -2117,239 +2301,245 @@ musl_inc_root_files = [ "include/wchar.h", "include/wctype.h", "include/wordexp.h", + "include/syscall_hooks.h", + "include/pthread_ffrt.h", ] -musl_src_porting_file = [ - "arch/aarch64/syscall_arch.h", - "arch/arm/bits/fenv.h", - "arch/generic/bits/shm.h", - "arch/generic/crtbrand.s", - "arch/x86_64/bits/float.h", - "include/ctype.h", - "include/info/application_target_sdk_version.h", - "include/info/device_api_version.h", - "include/info/fatal_message.h", - "include/malloc.h", - "include/pthread.h", - "include/fcntl.h", - "include/poll.h", - "include/stdio.h", - "include/stdlib.h", - "include/string.h", - "include/sys/stat.h", - "include/sys/sspret.h", - "include/sys/cdefs.h", - "include/fortify/fcntl.h", - "include/fortify/fortify.h", - "include/fortify/poll.h", - "include/fortify/socket.h", - "include/fortify/stat.h", - "include/fortify/stdlib.h", - "include/fortify/string.h", - "include/fortify/unistd.h", - "include/fortify/stdio.h", +musl_src_files_ext = [ + "src/internal/linux/musl_log.c", + "src/internal/linux/vdso.c", + "src/hook/linux/malloc_common.c", + "src/hook/linux/musl_preinit.c", + "src/hook/linux/musl_socket_preinit.c", + "src/hook/linux/socket_common.c", + "src/hook/linux/memory_trace.c", + "src/hook/linux/musl_fdtrack.c", + "src/hook/linux/musl_fdtrack_load.c", + "src/hook/linux/musl_preinit_common.c", + "src/hook/linux/musl_socket_preinit_common.c", + "crt/linux/crtplus.c", + "src/linux/arm/linux/flock.s", + "src/linux/aarch64/linux/flock.s", + "src/linux/x86_64/linux/flock.s", + "src/exit/linux/assert.c", + "src/exit/linux/atexit.c", + "src/fdsan/linux/fdsan.c", + "src/fortify/linux/fortify.c", + "src/gwp_asan/linux/gwp_asan.c", + "src/gwp_asan/linux/gwp_asan.h", + "src/hilog/linux/hilog_adapter.c", + "src/hilog/linux/hilog_common.h", + "src/hilog/linux/output_p.inl", + "src/hilog/linux/vsnprintf_s_p.c", + "src/hilog/linux/vsnprintf_s_p.h", + "src/linux/linux/clone.c", + "src/linux/linux/getprocpid.c", + "src/network/linux/getaddrinfo.c", + "src/syscall_hooks/linux/syscall_hooks.c", + "src/signal/linux/sigaction.c", + "src/thread/linux/pthread_create.c", + "src/trace/linux/trace_marker.c", + "include/trace/linux/trace_marker.h", + "src/info/linux/application_target_sdk_version.c", + "src/info/linux/device_api_version.c", + "src/info/linux/fatal_message.c", + "ldso/linux/cfi.c", + "ldso/linux/dynlink.c", + "ldso/linux/dynlink_rand.h", + "ldso/linux/ld_log.h", + "ldso/linux/namespace.h", + "ldso/linux/ns_config.h", + "ldso/linux/strops.c", + "ldso/linux/zip_archive.h", + "ldso/linux/cfi.h", + "ldso/linux/dynlink_rand.c", + "ldso/linux/ld_log.c", + "ldso/linux/namespace.c", + "ldso/linux/ns_config.c", + "ldso/linux/strops.h", + "include/sys/linux/capability.h", + "include/sys/linux/cdefs.h", + "include/sys/linux/sspret.h", + "include/info/linux/application_target_sdk_version.h", + "include/info/linux/device_api_version.h", + "include/info/linux/fatal_message.h", + "include/fortify/linux/fcntl.h", + "include/fortify/linux/poll.h", + "include/fortify/linux/stat.h", + "include/fortify/linux/stdlib.h", + "include/fortify/linux/unistd.h", + "include/fortify/linux/fortify.h", + "include/fortify/linux/socket.h", + "include/fortify/linux/stdio.h", + "include/fortify/linux/string.h", + "include/linux/dlfcn_ext.h", + "include/linux/sigchain.h", + "include/linux/syscall_hooks.h", + "src/ldso/arm/linux/dlvsym.s", + "src/ldso/aarch64/linux/dlvsym.s", + "src/ldso/x86_64/linux/dlvsym.s", + "src/misc/aarch64/linux/fstat.s", + "src/misc/aarch64/linux/syscall.s", + "src/malloc/linux/calloc.c", + "src/malloc/linux/stats.c", + "src/sigchain/linux/sigchain.c", + "src/internal/linux/malloc_config.h", + "src/internal/linux/proc_xid_impl.h", + "src/internal/linux/malloc_random.h", + "src/internal/linux/musl_log.h", + "src/internal/linux/syscall_hooks.h", + "src/hook/linux/common_def.h", + "src/hook/linux/musl_fdtrack.h", + "src/hook/linux/musl_fdtrack_hook.h", + "src/hook/linux/musl_malloc_dispatch.h", + "src/hook/linux/musl_malloc_dispatch_table.h", + "src/hook/linux/musl_preinit_common.h", + "src/hook/linux/musl_malloc.h", + "src/hook/linux/musl_socket_dispatch.h", + "src/hook/linux/musl_socket_preinit_common.h", + "src/hook/linux/memory_trace.h", + "src/hook/linux/musl_socket.h", +] + +musl_src_linux_files = [ + "src/internal/malloc_config.h", + "src/internal/proc_xid_impl.h", + "src/internal/malloc_random.h", + "src/internal/musl_log.h", + "src/internal/syscall_hooks.h", + "src/hook/common_def.h", + "src/hook/musl_fdtrack.h", + "src/hook/musl_fdtrack_hook.h", + "src/hook/musl_malloc_dispatch.h", + "src/hook/musl_malloc_dispatch_table.h", + "src/hook/musl_preinit_common.h", + "src/hook/musl_malloc.h", + "src/hook/musl_socket_dispatch.h", + "src/hook/musl_socket_preinit_common.h", + "src/hook/memory_trace.h", + "src/hook/musl_socket.h", + "src/internal/musl_log.c", + "src/internal/vdso.c", + "src/hook/malloc_common.c", + "src/hook/musl_preinit.c", + "src/hook/musl_socket_preinit.c", + "src/hook/socket_common.c", + "src/hook/memory_trace.c", + "src/hook/musl_fdtrack.c", + "src/hook/musl_fdtrack_load.c", + "src/hook/musl_preinit_common.c", + "src/hook/musl_socket_preinit_common.c", + "crt/crtplus.c", + "src/linux/arm/flock.s", + "src/linux/aarch64/flock.s", + "src/linux/x86_64/flock.s", + "src/exit/assert.c", + "src/exit/atexit.c", + "src/fdsan/fdsan.c", "src/fortify/fortify.c", - "include/sys/capability.h", - "include/sys/reboot.h", - "include/sys/socket.h", - "include/sys/sysinfo.h", - "include/signal.h", - "include/sigchain.h", - "include/sched.h", - "src/internal/dynlink.h", - "include/sys/tgkill.h", - "include/trace/trace_marker.h", - "include/unistd.h", - "include/dlfcn.h", - "include/dlfcn_ext.h", - "src/fcntl/open.c", + "src/gwp_asan/gwp_asan.c", + "src/gwp_asan/gwp_asan.h", + "src/hilog/hilog_adapter.c", "src/hilog/hilog_common.h", + "src/hilog/output_p.inl", + "src/hilog/vsnprintf_s_p.c", "src/hilog/vsnprintf_s_p.h", - "src/internal/hilog_adapter.h", - "src/internal/musl_log.h", - "src/info/application_target_sdk_version.c", - "src/info/device_api_version.c", - "src/info/fatal_message.c", - "src/env/__init_tls.c", - "src/env/__libc_start_main.c", - "src/internal/pthread_impl.h", - "src/internal/locale_impl.h", - "src/internal/syscall.h", - "src/internal/services.h", - "src/internal/network_conf_function.h", - "src/internal/network_conf_function.c", - "src/internal/proc_xid_impl.h", - "ldso/namespace.h", - "ldso/ns_config.h", - "ldso/strops.h", - "src/legacy/ulimit.c", "src/linux/clone.c", "src/linux/getprocpid.c", - "src/linux/reboot.c", - "src/linux/tgkill.c", - "src/malloc/mallocng/malloc_usable_size.c", - "src/malloc/mallocng/malloc.c", - "src/malloc/mallocng/meta.h", - "src/malloc/mallocng/donate.c", - "src/malloc/mallocng/aligned_alloc.c", - "src/malloc/lite_malloc.c", - "src/malloc/stats.c", - "src/malloc/calloc.c", - "src/malloc/free.c", - "src/network/getnameinfo.c", - "src/malloc/libc_calloc.c", - "src/malloc/realloc.c", - "src/network/inet_legacy.c", - "src/network/lookup_name.c", - "src/network/lookup_serv.c", - "src/network/resolvconf.c", - "src/network/socket.c", - "src/passwd/getspnam_r.c", - "src/sched/sched_setparam.c", - "src/sched/sched_getparam.c", - "src/sched/sched_setscheduler.c", - "src/sched/sched_getscheduler.c", - "src/thread/arm/clone.s", - "src/thread/arm/syscall_cp.s", - "src/thread/pthread_mutex_clocklock.c", - "src/thread/pthread_mutex_timedlock.c", - "src/thread/pthread_mutex_lock.c", - "src/thread/pthread_mutex_timedlock_monotonic_np.c", - "src/thread/pthread_mutex_lock_timeout_np.c", - "src/thread/pthread_mutex_init.c", - "src/thread/pthread_rwlock_clockrdlock.c", - "src/thread/pthread_rwlock_timedrdlock.c", - "src/thread/pthread_rwlock_timedrdlock_monotonic_np.c", - "src/thread/pthread_rwlock_init.c", - "src/thread/pthread_cond_timedwait.c", - "src/thread/pthread_cond_timedwait_monotonic_np.c", - "src/thread/pthread_cond_timeout_np.c", - "src/thread/pthread_cond_clockwait.c", - "src/thread/pthread_cond_init.c", + "src/network/getaddrinfo.c", + "src/syscall_hooks/syscall_hooks.c", + "src/signal/sigaction.c", "src/thread/pthread_create.c", - "src/thread/pthread_rwlock_clockwrlock.c", - "src/thread/pthread_rwlock_timedwrlock_monotonic_np.c", - "src/thread/pthread_rwlock_timedwrlock.c", - "src/thread/pthread_sigmask.c", "src/trace/trace_marker.c", - "src/ldso/dlclose.c", - "src/ldso/dlerror.c", + "include/trace/trace_marker.h", + "src/info/application_target_sdk_version.c", + "src/info/device_api_version.c", + "src/info/fatal_message.c", + "ldso/cfi.c", "ldso/dynlink.c", - "src/exit/atexit.c", - "crt/arm/crti.s", - "crt/aarch64/crti.s", - "crt/crtplus.c", - "ldso/cfi.h", + "ldso/dynlink_rand.h", "ldso/ld_log.h", + "ldso/namespace.h", + "ldso/ns_config.h", + "ldso/strops.c", + "ldso/zip_archive.h", + "ldso/cfi.h", + "ldso/dynlink_rand.c", "ldso/ld_log.c", "ldso/namespace.c", "ldso/ns_config.c", - "ldso/strops.c", - "ldso/cfi.c", - "ldso/dynlink_rand.c", - "ldso/dynlink_rand.h", - "src/sched/sched_cpualloc.c", - "src/signal/signal.c", - "src/signal/sigaction.c", - "src/signal/siginterrupt.c", - "include/langinfo.h", - "include/locale.h", - "src/hilog/hilog_adapter.c", - "src/hilog/vsnprintf_s_p.c", - "src/internal/libc.h", - "src/locale/dcngettext.c", - "src/locale/locale_map.c", - "src/locale/langinfo.c", - "src/locale/newlocale.c", - "src/time/__tz.c", - "src/time/gmtime_r.c", - "src/time/strftime.c", - "src/time/strptime.c", - "src/time/time_impl.h", - "src/ldso/aarch64/dlvsym.s", + "ldso/strops.h", + "include/sys/capability.h", + "include/sys/cdefs.h", + "include/sys/sspret.h", + "include/info/application_target_sdk_version.h", + "include/info/device_api_version.h", + "include/info/fatal_message.h", + "include/fortify/fcntl.h", + "include/fortify/poll.h", + "include/fortify/stat.h", + "include/fortify/stdlib.h", + "include/fortify/unistd.h", + "include/fortify/fortify.h", + "include/fortify/socket.h", + "include/fortify/stdio.h", + "include/fortify/string.h", + "include/dlfcn_ext.h", + "include/sigchain.h", + "include/syscall_hooks.h", "src/ldso/arm/dlvsym.s", - "src/ldso/riscv64/dlvsym.s", + "src/ldso/aarch64/dlvsym.s", "src/ldso/x86_64/dlvsym.s", - "src/stdio/__fdopen.c", - "src/stdio/vfprintf.c", - "src/stdio/__stdio_read.c", - "src/stdio/__stdio_write.c", - "src/stdio/__stdout_write.c", - "src/stdio/fread.c", - "src/stdio/fmemopen.c", - "src/stdio/freopen.c", - "src/stdio/stdin.c", - "src/stdio/__fmodeflags.c", - "src/stdio/fopen.c", - "src/stdio/ofl.c", - "src/stdio/fclose.c", - "src/stdio/__toread.c", - "src/stdio/__towrite.c", - "src/stdio/stderr.c", - "src/stdio/fgets.c", - "src/stdio/vsnprintf.c", - "src/stdio/vsscanf.c", - "src/internal/stdio_impl.h", - "src/internal/vdso.c", - "src/time/clock_gettime.c", - "src/time/clock_getres.c", - "src/time/gettimeofday.c", - "src/time/time.c", - "src/unistd/getpid.c", - "src/process/_Fork.c", - "src/process/vfork.c", - "src/process/arm/__vfork.s", - "src/process/x86_64/__vfork.s", - "src/linux/cache.c", - "src/sched/sched_getcpu.c", - "src/sigchain/sigchain.c", - "src/conf/legacy.c", - "src/conf/sysconf.c", - "src/env/getenv.c", - "src/string/strcasecmp.c", - "src/string/strncasecmp.c", - "src/string/strncat.c", - "src/string/stpncpy.c", - "src/string/strncpy.c", - "src/stat/fstat.c", - "src/string/strcspn.c", - "src/thread/pthread_once.c", - "src/thread/pthread_cancel.c", - "src/mq/mq_notify.c", - "src/aio/aio.c", "src/misc/aarch64/fstat.s", "src/misc/aarch64/syscall.s", - "src/stdlib/strtol.c", - "src/stdlib/strtod.c", - "src/thread/sem_timedwait.c", - "src/stdio/vfscanf.c", - "src/stdio/fileno.c", + "src/malloc/calloc.c", + "src/malloc/stats.c", + "src/sigchain/sigchain.c", ] +if (musl_arch == "arm") { + musl_src_file += [ + "src/process/arm/__vfork.s", + "src/ldso/arm/dlvsym.s", + ] +} else if (musl_arch == "aarch64") { + musl_src_file += [ + "arch/aarch64/syscall_arch.h", + "src/misc/aarch64/fstat.s", + "src/misc/aarch64/syscall.s", + "src/ldso/aarch64/dlvsym.s", + ] +} else if (musl_arch == "loongarch64") { + musl_src_file += [ "arch/loongarch64/syscall_arch.h" ] +} else if (musl_arch == "x86_64") { + musl_src_file += [ + "src/process/x86_64/__vfork.s", + "src/ldso/x86_64/dlvsym.s", + ] +} + musl_inc_hook_files = [ - "//third_party/musl/porting/linux/user/src/internal/hilog_adapter.h", - "//third_party/musl/porting/linux/user/src/internal/musl_log.h", - "//third_party/musl/porting/linux/user/src/hook/memory_trace.h", - "//third_party/musl/porting/linux/user/src/hook/musl_malloc_dispatch_table.h", - "//third_party/musl/porting/linux/user/src/hook/musl_malloc_dispatch.h", - "//third_party/musl/porting/linux/user/src/hook/musl_preinit_common.h", + "//third_party/musl/src/internal/hilog_adapter.h", + "//third_party/musl/src/internal/linux/musl_log.h", + "//third_party/musl/src/hook/linux/memory_trace.h", + "//third_party/musl/src/hook/linux/musl_fdtrack.h", + "//third_party/musl/src/hook/linux/musl_fdtrack_hook.h", + "//third_party/musl/src/hook/linux/musl_malloc_dispatch_table.h", + "//third_party/musl/src/hook/linux/musl_malloc_dispatch.h", + "//third_party/musl/src/hook/linux/musl_preinit_common.h", + "//third_party/musl/src/hook/linux/musl_socket_dispatch.h", ] added_freebsd_files = [ - "$FREEBSD_DIR/contrib/gdtoa/strtod.c", - "$FREEBSD_DIR/contrib/gdtoa/gethex.c", - "$FREEBSD_DIR/contrib/gdtoa/smisc.c", - "$FREEBSD_DIR/contrib/gdtoa/misc.c", - "$FREEBSD_DIR/contrib/gdtoa/strtord.c", - "$FREEBSD_DIR/contrib/gdtoa/hexnan.c", - "$FREEBSD_DIR/contrib/gdtoa/gmisc.c", - "$FREEBSD_DIR/contrib/gdtoa/hd_init.c", - "$FREEBSD_DIR/contrib/gdtoa/strtodg.c", - "$FREEBSD_DIR/contrib/gdtoa/ulp.c", - "$FREEBSD_DIR/contrib/gdtoa/strtof.c", - "$FREEBSD_DIR/contrib/gdtoa/sum.c", - "$FREEBSD_DIR/lib/libc/gdtoa/glue.c", - "$FREEBSD_DIR/lib/libc/stdio/parsefloat.c", + "$FREEBSD_DIR/contrib/tcp_wrappers/strcasecmp.c", + "$FREEBSD_DIR/lib/libc/gen/arc4random.c", + "$FREEBSD_DIR/lib/libc/gen/arc4random_uniform.c", + "$FREEBSD_DIR/lib/libc/stdlib/qsort.c", + "$FREEBSD_DIR/lib/libc/stdlib/strtoimax.c", + "$FREEBSD_DIR/lib/libc/stdlib/strtoul.c", + "$FREEBSD_DIR/lib/libc/stdlib/strtoumax.c", ] +freebsd_headers = [ "$FREEBSD_DIR/contrib/libexecinfo/execinfo.h" ] + freebsd_sys_headers = [ "$FREEBSD_DIR/sys/sys/queue.h" ] diff --git a/build/third_party_gn/musl/musl_template.gni b/build/third_party_gn/musl/musl_template.gni index 21f5dd2c..1d217bf3 100644 --- a/build/third_party_gn/musl/musl_template.gni +++ b/build/third_party_gn/musl/musl_template.gni @@ -302,6 +302,7 @@ template("musl_libs") { "//third_party/jemalloc/include/", "//third_party/jemalloc/include/jemalloc/internal", "//third_party/jemalloc/include/jemalloc", + "//third_party/FreeBSD/contrib/libexecinfo", ] } @@ -333,25 +334,43 @@ template("musl_libs") { source_set("soft_musl_src") { sources_orig = [] sources = [] - + include_dirs = [] sources_orig = musl_src_arch_file + musl_src_file + sources_orig -= musl_src_filterout sources_orig -= [ - "src/env/__stack_chk_fail.c", - "src/env/__libc_start_main.c", - "src/env/__init_tls.c", - "src/string/memset.c", "src/string/mempcpy.c", + "src/string/memset.c", + "src/env/__init_tls.c", + "src/env/__libc_start_main.c", + "src/env/__stack_chk_fail.c", "src/stdlib/qsort.c", "src/stdlib/qsort_nr.c", - ] - if (musl_arch == "mips") { - sources_orig += [ "src/string/memset.c" ] - } - sources_orig -= musl_src_filterout - - sources += [ - "$FREEBSD_DIR/contrib/tcp_wrappers/strcasecmp.c", - "$FREEBSD_DIR/lib/libc/stdlib/qsort.c", + "src/string/strncpy.c", + ] + + freebsd_files = [ + "//third_party/FreeBSD/contrib/gdtoa/strtod.c", + "//third_party/FreeBSD/contrib/gdtoa/gethex.c", + "//third_party/FreeBSD/contrib/gdtoa/smisc.c", + "//third_party/FreeBSD/contrib/gdtoa/misc.c", + "//third_party/FreeBSD/contrib/gdtoa/strtord.c", + "//third_party/FreeBSD/contrib/gdtoa/hexnan.c", + "//third_party/FreeBSD/contrib/gdtoa/gmisc.c", + "//third_party/FreeBSD/contrib/gdtoa/hd_init.c", + "//third_party/FreeBSD/contrib/gdtoa/strtodg.c", + "//third_party/FreeBSD/contrib/gdtoa/ulp.c", + "//third_party/FreeBSD/contrib/gdtoa/strtof.c", + "//third_party/FreeBSD/contrib/gdtoa/sum.c", + "//third_party/FreeBSD/lib/libc/gdtoa/glue.c", + "//third_party/FreeBSD/lib/libc/stdio/parsefloat.c", + "//third_party/FreeBSD/contrib/tcp_wrappers/strcasecmp.c", + "//third_party/FreeBSD/lib/libc/gen/arc4random.c", + "//third_party/FreeBSD/lib/libc/gen/arc4random_uniform.c", + "//third_party/FreeBSD/lib/libc/stdlib/qsort.c", + "//third_party/FreeBSD/lib/libc/stdlib/strtoimax.c", + "//third_party/FreeBSD/lib/libc/stdlib/strtoul.c", + "//third_party/FreeBSD/lib/libc/stdlib/strtoumax.c", + "//third_party/musl/third_party/openbsd/lib/libc/string/strncpy.c", ] if (musl_arch == "arm") { @@ -382,6 +401,7 @@ template("musl_libs") { "src/math/powl.c", "src/math/sinf.c", "src/math/cosf.c", + "src/linux/flock.c", ] } else if (musl_arch == "aarch64") { sources_orig -= [ @@ -416,12 +436,23 @@ template("musl_libs") { "src/math/sincos.c", "src/math/pow.c", "src/math/powf.c", + "src/linux/flock.c", ] } else if (musl_arch == "x86_64") { - sources_orig -= [ "src/thread/${musl_arch}/__set_thread_area.s" ] + sources_orig -= [ + "src/thread/${musl_arch}/__set_thread_area.s", + "src/linux/flock.c", + ] } defines = [] + defines += [ "FEATURE_ICU_LOCALE" ] + + # There are two ways to implement cxa_thread_atexit_impl: + # - CXA_THREAD_USE_TSD(default): use pthread_key_xxx to implement cxa_thread_atexit_impl. + # - CXA_THREAD_USE_TLS: put dtors in pthread to implement cxa_thread_atexit_impl. + defines += [ "CXA_THREAD_USE_TSD" ] + if (musl_arch == "arm") { defines += [ "MUSL_ARM_ARCH" ] } @@ -477,8 +508,7 @@ template("musl_libs") { "$OPTRTDIR/string/arm/strcmp.S", "$OPTRTDIR/string/arm/strlen-armv6t2.S", ] - - sources += added_freebsd_files + sources += freebsd_files asmflags = [ "-D__memcpy_arm = memcpy", "-D__memchr_arm = memchr", @@ -487,6 +517,7 @@ template("musl_libs") { "-D__strlen_armv6t2 = strlen", ] } else if (musl_arch == "aarch64") { + sources += freebsd_files if (defined(ARM_FEATURE_SVE)) { sources += [ "$OPTRTDIR/string/aarch64/memchr-sve.S", @@ -565,7 +596,6 @@ template("musl_libs") { "$OPTRTDIR/string/aarch64/strnlen.S", "$OPTRTDIR/string/aarch64/strrchr.S", ] - sources += added_freebsd_files asmflags = [ "-D__memmove_aarch64 = memmove", "-D__memcpy_aarch64 = memcpy", @@ -588,37 +618,19 @@ template("musl_libs") { cflags = [ "-O3", "-fPIC", - "-ffreestanding", "-fstack-protector-strong", - "-flto", ] - if (use_jemalloc) { - defines += [ "USE_JEMALLOC" ] - if (use_jemalloc_dfx_intf) { - defines += [ "USE_JEMALLOC_DFX_INTF" ] - } - include_dirs = [ "//third_party/jemalloc/include/jemalloc" ] - } - - if (!defined(include_dirs)) { - if (musl_arch == "aarch64") { - include_dirs = [ "//third_party/FreeBSD/lib/libc/aarch64" ] - } - if (musl_arch == "arm") { - include_dirs = [ "//third_party/FreeBSD/lib/libc/arm" ] - } - } else { - if (musl_arch == "aarch64") { - include_dirs += [ "//third_party/FreeBSD/lib/libc/aarch64" ] - } - if (musl_arch == "arm") { - include_dirs += [ "//third_party/FreeBSD/lib/libc/arm" ] - } - } - configs -= musl_inherited_configs configs += [ ":soft_musl_config" ] + if (musl_arch == "aarch64") { + include_dirs += [ "//third_party/FreeBSD/lib/libc/aarch64" ] + } else if (musl_arch == "arm") { + include_dirs += [ "//third_party/FreeBSD/lib/libc/arm" ] + } + include_dirs += [ "//third_party/FreeBSD/lib/libc/include" ] + include_dirs += [ "//third_party/FreeBSD/contrib/libexecinfo" ] + include_dirs += [ "//third_party/FreeBSD/crypto/openssh/openbsd-compat" ] if (!defined(defines)) { defines = [] @@ -633,7 +645,8 @@ template("musl_libs") { defines += [ "TARGET_GUARD_SIZE=${_product_config.device_guard_size}" ] } } - + external_deps = [] + external_deps += [ "FreeBSD:libc_static" ] deps = porting_deps } @@ -827,6 +840,8 @@ template("musl_libs") { ":soft_musl_src_nossp", ":soft_musl_src_optimize", ] + external_deps = [] + external_deps = [ "FreeBSD:libc_static" ] output_name = "libc" complete_static_lib = true } diff --git a/build/third_party_gn/openssl/BUILD.gn b/build/third_party_gn/openssl/BUILD.gn index 0b311628..cae0e8ea 100644 --- a/build/third_party_gn/openssl/BUILD.gn +++ b/build/third_party_gn/openssl/BUILD.gn @@ -636,6 +636,10 @@ libdefault_common_sources = [ "//third_party/openssl/providers/implementations/ciphers/cipher_cts.c", "//third_party/openssl/providers/implementations/ciphers/cipher_null.c", "//third_party/openssl/providers/implementations/ciphers/cipher_sm4.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_ccm.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_ccm_hw.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_gcm.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_gcm_hw.c", "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_hw.c", "//third_party/openssl/providers/implementations/ciphers/cipher_tdes.c", "//third_party/openssl/providers/implementations/ciphers/cipher_tdes_common.c", -- Gitee From ff9e36d6421dfdf238e00cac6ad7ac8c4400b41c Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Mon, 5 Aug 2024 22:45:42 +0800 Subject: [PATCH 04/33] Revert pr 682 Issue: #IAI0Q4 This reverts commit 6bb8d597704f9194bf9791d5f1ce465696662ab1. Signed-off-by: yang-19970325 --- tooling/agent/debugger_impl.cpp | 7 ++----- tooling/agent/debugger_impl.h | 11 ----------- tooling/backend/js_pt_hooks.cpp | 20 ++++++++------------ tooling/backend/js_pt_hooks.h | 1 + 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index c2ee0ba6..fcd48504 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -124,10 +124,6 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file // Store parsed script in map scripts_[script->GetScriptId()] = std::move(script); - - // Store parsed file url, used by hook to determine - // whether a Break_on_start pause is needed - parsedFileNames_.emplace(url); return true; } @@ -404,7 +400,8 @@ void DebuggerImpl::InitializeExtendedProtocolsList() "setNativeRange", "resetSingleStepper", "callFunctionOn", - "smartStepInto" + "smartStepInto", + "callFunctionOn" }; debuggerExtendedProtocols_ = std::move(debuggerProtocolList); } diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 9c842173..153f5d8f 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -273,16 +273,6 @@ private: return recordName; } - void RemoveUrlFromParsedSet(std::string &url) - { - parsedFileNames_.erase(url); - } - - bool IsUrlFoundInParsedSet(std::string &url) - { - return parsedFileNames_.find(url) != parsedFileNames_.end(); - } - class Frontend { public: explicit Frontend(ProtocolChannel *channel) : channel_(channel) {} @@ -334,7 +324,6 @@ private: JsDebuggerManager::SingleStepperFunc stepperFunc_ {nullptr}; JsDebuggerManager::ReturnNativeFunc returnNative_ {nullptr}; std::vector debuggerExtendedProtocols_ {}; - CUnorderedSet parsedFileNames_ {}; friend class JSPtHooks; friend class test::TestHooks; diff --git a/tooling/backend/js_pt_hooks.cpp b/tooling/backend/js_pt_hooks.cpp index c46f608b..bcb05660 100644 --- a/tooling/backend/js_pt_hooks.cpp +++ b/tooling/backend/js_pt_hooks.cpp @@ -16,7 +16,6 @@ #include "backend/js_pt_hooks.h" #include "agent/debugger_impl.h" -#include "ecmascript/jspandafile/js_pandafile_manager.h" namespace panda::ecmascript::tooling { void JSPtHooks::DebuggerStmt([[maybe_unused]] const JSPtLocation &location) @@ -48,16 +47,13 @@ bool JSPtHooks::SingleStep(const JSPtLocation &location) LOG_DEBUGGER(VERBOSE) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset(); [[maybe_unused]] LocalScope scope(debugger_->vm_); - if (!debugger_->parsedFileNames_.empty()) { - auto jsPandaFile = location.GetJsPandaFile(); - DebugInfoExtractor *extractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(jsPandaFile); - std::string url = extractor->GetSourceFile(location.GetMethodId()); - if (debugger_->IsUrlFoundInParsedSet(url)) { - debugger_->RemoveUrlFromParsedSet(url); - debugger_->NotifyPaused({}, BREAK_ON_START); - return false; - } + if (UNLIKELY(firstTime_)) { + firstTime_ = false; + + debugger_->NotifyPaused({}, BREAK_ON_START); + return false; } + // pause or step complete if (debugger_->NotifySingleStep(location)) { debugger_->NotifyPaused({}, OTHER); @@ -88,8 +84,8 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr [[maybe_unused]] LocalScope scope(debugger_->vm_); static uint32_t scriptId = 0; - if (!debugger_->NotifyScriptParsed(scriptId++, pandaFileName.data(), entryPoint)) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: LoadModule: " << pandaFileName << " NotifyParsed fail"; + if (debugger_->NotifyScriptParsed(scriptId++, pandaFileName.data(), entryPoint)) { + firstTime_ = true; } } diff --git a/tooling/backend/js_pt_hooks.h b/tooling/backend/js_pt_hooks.h index 085c6fdf..cb5f7726 100644 --- a/tooling/backend/js_pt_hooks.h +++ b/tooling/backend/js_pt_hooks.h @@ -46,6 +46,7 @@ private: NO_MOVE_SEMANTIC(JSPtHooks); DebuggerImpl *debugger_ {nullptr}; + bool firstTime_ {true}; }; } // namespace panda::ecmascript::tooling #endif // ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H \ No newline at end of file -- Gitee From 728479cdcc9ab8891a20e1eef9f0b20ca8317eca Mon Sep 17 00:00:00 2001 From: Viktoria Shirunova Date: Thu, 11 Jul 2024 14:19:56 +0300 Subject: [PATCH 05/33] Regress tests: support aot/pgo modes Issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/IACS7R Testing: All required pre-merge tests passed. Results are available in the ggwatcher. Signed-off-by: Viktoria Shirunova Change-Id: Icea1593831a1c81a2641ac99d60508caa978e99a --- build/compile_script/ark.py | 579 +++++++++++++++++++++--------------- 1 file changed, 345 insertions(+), 234 deletions(-) diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index 53faada5..4da2ce07 100755 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -24,7 +24,7 @@ import os import platform import subprocess import sys -from typing import List, Tuple, Union, Optional +from typing import List, Any, Tuple, Union, Optional CURRENT_FILENAME = os.path.basename(__file__) @@ -96,7 +96,7 @@ class ArkPy: REGRESS_TEST_LOG_FILE_NAME = "regresstest.log" PREBUILTS_DOWNLOAD_CONFIG_FILE_PATH = \ "./arkcompiler/toolchain/build/prebuilts_download/prebuilts_download_config.json" - INDENTATION_STRING_PER_LEVEL = " " # for help message + INDENTATION_STRING_PER_LEVEL = " " # for help message # In ARG_DICT, "flags" and "description" are must-keys for the leaf-dicts in it. # (Future designer need know.) ARG_DICT = { @@ -221,14 +221,14 @@ class ArkPy: "gn_targets_depend_on": ["default"], }, "gn_target": { - "flags": [""], # any other flags + "flags": [""], # any other flags "description": "Build for arkcompiler target assigned by user. Targets include group(ets_runtime), " "ohos_executable(ark_js_vm), ohos_shared_library(libark_jsruntime), " "ohos_static_library(static_icuuc), ohos_source_set(libark_jsruntime_set), " "ohos_unittest(EcmaVm_001_Test), action(EcmaVm_001_TestAction) and other target of user-defined " "template type in \"*.gn*\" file.", - "gn_targets_depend_on": [], # not need, depend on deps of itself in "*.gn*" file + "gn_targets_depend_on": [], # not need, depend on deps of itself in "*.gn*" file }, }, "option": { @@ -264,7 +264,7 @@ class ArkPy: "keep-going": { "flags": ["--keep-going=*", "-keep-going=*"], "description": "Keep running unittest etc. until errors occured less than N times" - " (use 0 to ignore all errors).", + " (use 0 to ignore all errors).", }, }, "help": { @@ -289,7 +289,7 @@ class ArkPy: arg_list = list(dict.fromkeys(arg_list)) # match [help] flag if len(arg_list) == 0 or ( - True in [self.is_dict_flags_match_arg(self.ARG_DICT["help"], arg) for arg in arg_list]): + True in [self.is_dict_flags_match_arg(self.ARG_DICT.get("help"), arg) for arg in arg_list]): print(self.get_help_msg_of_all()) return # match [[os_cpu].[mode]] flag @@ -307,135 +307,192 @@ class ArkPy: if fnmatch(arg_to_match, flag): return True return False - + @staticmethod - def get_test262_cmd(gn_args, out_path, x64_out_path, run_pgo, enable_litecg, args_to_test262_cmd, - timeout): - - print("running test262 in AsmMode\n") - if any('target_cpu="arm64"' in arg for arg in gn_args): - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu:" \ - "../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --ark-arch aarch64" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path) + def libs_dir(is_arm, is_aot, is_pgo, out_dir, x64_out_dir) -> str: + if is_arm and is_aot and is_pgo: + return (f"--libs-dir ../../{out_dir}/arkcompiler/ets_runtime:" + f"../../{out_dir}/thirdparty/icu:" + f"../../{out_dir}/third_party/icu:" + f"../../thirdparty/zlib:" + f"../../prebuilts/clang/ohos/linux-x86_64/llvm/lib") + if is_arm and is_aot and not is_pgo: + return ("--libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" + f":../../{x64_out_dir}/thirdparty/icu/") + if not is_arm and is_aot: + return (f"--libs-dir ../../{out_dir}/arkcompiler/ets_runtime" + f":../../{out_dir}/thirdparty/icu:" + f"../../{out_dir}/third_party/icu:" + f"../../thirdparty/zlib:" + f"../../prebuilts/clang/ohos/linux-x86_64/llvm/lib") + # not is_arm and not is_aot + return " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" + + @staticmethod + def get_cmd(test_suite, test_script_name, test_script_path, gn_args, out_path, x64_out_path, aot_mode, run_pgo, + enable_litecg, args_to_cmd, timeout, ignore_list: Optional[str] = None): + cmd = [ + f"cd {test_script_path}", + f"&& python3 {test_script_name} {args_to_cmd}", + f"--timeout {timeout}", + f"--ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm", + "--ark-frontend=es2panda" + ] + is_arm = any('target_cpu="arm64"' in arg for arg in gn_args) + if is_arm: + cmd.append("--ark-arch aarch64") + cmd.append(f"--ark-arch-root=../../{out_path}/common/common/libc/") + cmd.append(f"--ark-frontend-binary=../../{x64_out_path}/arkcompiler/ets_frontend/es2abc") + cmd.append(f"--merge-abc-binary=../../{x64_out_path}/arkcompiler/ets_frontend/merge_abc") + if aot_mode: + cmd.append(f"--ark-aot-tool=../../{x64_out_path}/arkcompiler/ets_runtime/ark_aot_compiler") + if test_suite == "regresstest": + cmd.append(f"--stub-path=../../{x64_out_path}/gen/arkcompiler/ets_runtime/stub.an") else: - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {2}" \ - " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, timeout) - return test262_cmd + cmd.append(f"--ark-frontend-binary=../../{out_path}/arkcompiler/ets_frontend/es2abc") + cmd.append(f"--merge-abc-binary=../../{out_path}/arkcompiler/ets_frontend/merge_abc") + if aot_mode: + cmd.append(f"--ark-aot-tool=../../{out_path}/arkcompiler/ets_runtime/ark_aot_compiler") + if test_suite == "regresstest": + cmd.append(f"--stub-path=../../{out_path}/gen/arkcompiler/ets_runtime/stub.an") + + cmd.append(ArkPy.libs_dir( + is_arm=is_arm, + is_aot=aot_mode, + is_pgo=run_pgo, + out_dir=out_path, + x64_out_dir=x64_out_path + )) + + if aot_mode: + cmd.append("--ark-aot") + mode = ["AOT"] + if run_pgo: + cmd.append("--run-pgo") + mode.append("PGO") + if enable_litecg: + cmd.append("--enable-litecg") + mode.append("LiteCG") + mode_str = " ".join(mode) + print(f"Running {test_suite} in {mode_str} Mode\n") + + if test_suite == "regresstest" and ignore_list: + cmd.append(f"--ignore-list {ignore_list}") + + if test_suite == "regresstest": + cmd.append(f"--out-dir ../../{out_path}") + + return " ".join(cmd) @staticmethod def get_test262_aot_cmd(gn_args, out_path, x64_out_path, run_pgo, enable_litecg, args_to_test262_cmd, - timeout): + timeout): print("running test262 in AotMode\n") if any('target_cpu="arm64"' in arg for arg in gn_args): if run_pgo: test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {4}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu:" \ - "../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --ark-arch aarch64" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-aot" \ - " --ark-frontend=es2panda"\ - "{3}".format(args_to_test262_cmd, out_path, x64_out_path, " --run-pgo", timeout) + " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu:" \ + "../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + " --ark-arch aarch64" \ + " --ark-arch-root=../../{1}/common/common/libc/" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-aot" \ + " --ark-frontend=es2panda" \ + "{3}".format(args_to_test262_cmd, out_path, x64_out_path, " --run-pgo", timeout) else: test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{2}/thirdparty/icu/" \ - " --ark-arch aarch64" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-aot" \ - " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout) + " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{2}/thirdparty/icu/" \ + " --ark-arch aarch64" \ + " --ark-arch-root=../../{1}/common/common/libc/" \ + " --ark-aot" \ + " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout) else: test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu" \ - ":../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-aot" \ - " --ark-frontend=es2panda"\ - "{2}".format(args_to_test262_cmd, out_path, " --run-pgo" if run_pgo else "", timeout) + " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu" \ + ":../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-aot" \ + " --ark-frontend=es2panda" \ + "{2}".format(args_to_test262_cmd, out_path, " --run-pgo" if run_pgo else "", timeout) if enable_litecg: test262_cmd = test262_cmd + " --enable-litecg" return test262_cmd @staticmethod - def get_test262_jit_cmd(gn_args, out_path, x64_out_path, args_to_test262_cmd, timeout): - print("running test262 in JIT mode\n") + def get_jit_cmd(test_suite, test_script_name, test_script_path, gn_args, out_path, x64_out_path, args_to_cmd, + timeout): + print(f"running {test_suite} in JIT mode\n") if any('target_cpu="arm64"' in arg for arg in gn_args): - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{1}/thirdparty/icu/" \ - ":../../{1}/thirdparty/bounds_checking_function" \ - ":../../{1}/arkcompiler/ets_runtime:" \ - " --ark-arch aarch64" \ - " --run-jit" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout) + cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ + " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{1}/thirdparty/icu/" \ + ":../../{1}/thirdparty/bounds_checking_function" \ + ":../../{1}/arkcompiler/ets_runtime:" \ + " --ark-arch aarch64" \ + " --run-jit" \ + " --ark-arch-root=../../{1}/common/common/libc/" \ + " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda".format(args_to_cmd, out_path, x64_out_path, timeout, + test_script_name, test_script_path) else: - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu" \ - ":../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --run-jit" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda"\ - "{2}".format(args_to_test262_cmd, out_path, x64_out_path, timeout) - return test262_cmd - + cmd = "cd arkcompiler/ets_frontend && python3 {4} {0} --timeout {3}" \ + " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu" \ + ":../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + " --run-jit" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda" \ + "{2}".format(args_to_cmd, out_path, x64_out_path, timeout, test_script_name) + return cmd + @staticmethod - def get_test262_baseline_jit_cmd(gn_args, out_path, x64_out_path, args_to_test262_cmd, timeout): - print("running test262 in baseline JIT mode\n") + def get_baseline_jit_cmd(test_suite, test_script_name, test_script_path, gn_args, out_path, x64_out_path, + args_to_test262_cmd, timeout): + print(f"running {test_suite} in baseline JIT mode\n") if any('target_cpu="arm64"' in arg for arg in gn_args): - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - ":../../{1}/thirdparty/icu" \ - ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos" \ - ":../../{1}/thirdparty/bounds_checking_function" \ - ":../../{1}/arkcompiler/ets_runtime" \ - ":../../{1}/common/common/libc/lib" \ - " --ark-arch aarch64" \ - " --run-baseline-jit" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout) + cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ + " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + ":../../{1}/thirdparty/icu" \ + ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos" \ + ":../../{1}/thirdparty/bounds_checking_function" \ + ":../../{1}/arkcompiler/ets_runtime" \ + ":../../{1}/common/common/libc/lib" \ + " --ark-arch aarch64" \ + " --run-baseline-jit" \ + " --ark-arch-root=../../{1}/common/common/libc/" \ + " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout, + test_script_name, test_script_path) else: - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../{1}/lib.unstripped/arkcompiler/ets_runtime" \ - ":../../{1}/lib.unstripped/thirdparty/icu" \ - ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - ":../../{1}/lib.unstripped/thirdparty/bounds_checking_function/" \ - " --run-baseline-jit" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda"\ - "{2}".format(args_to_test262_cmd, out_path, x64_out_path, timeout) - return test262_cmd + cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ + " --libs-dir ../../{1}/lib.unstripped/arkcompiler/ets_runtime" \ + ":../../{1}/lib.unstripped/thirdparty/icu" \ + ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + ":../../{1}/lib.unstripped/thirdparty/bounds_checking_function/" \ + " --run-baseline-jit" \ + " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ + " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ + " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda" \ + "{2}".format(args_to_test262_cmd, out_path, x64_out_path, timeout, + test_script_name, test_script_path) + return cmd @staticmethod def build_args_to_test262_cmd(arg_list): @@ -556,6 +613,16 @@ class ArkPy: sys.exit(1) return None, arg_list + @staticmethod + def __get_x64_out_path(out_path) -> str: + if 'release' in out_path: + return 'out/x64.release' + if 'debug' in out_path: + return 'out/x64.debug' + if 'fastverify' in out_path: + return 'out/x64.fastverify' + return "" + def get_binaries(self): host_os = sys.platform host_cpu = platform.machine() @@ -572,18 +639,18 @@ class ArkPy: print("\nLogic of getting gn binary or ninja binary does not match logic of prebuilts_download." \ "\nCheck func \033[92m{0} of class {1} in file {2}\033[0m against file {3} if the name of this " \ "file had not changed!\n".format( - sys._getframe().f_code.co_name, self.__class__.__name__, CURRENT_FILENAME, - self.PREBUILTS_DOWNLOAD_CONFIG_FILE_PATH)) + sys._getframe().f_code.co_name, self.__class__.__name__, CURRENT_FILENAME, + self.PREBUILTS_DOWNLOAD_CONFIG_FILE_PATH)) raise error if self.gn_binary_path == "" or self.ninja_binary_path == "": print("\nLogic of prebuilts_download may be wrong." \ "\nCheck \033[92mdata in file {0}\033[0m against func {1} of class {2} in file {3}!\n".format( - self.PREBUILTS_DOWNLOAD_CONFIG_FILE_PATH, sys._getframe().f_code.co_name, self.__class__.__name__, - CURRENT_FILENAME)) + self.PREBUILTS_DOWNLOAD_CONFIG_FILE_PATH, sys._getframe().f_code.co_name, self.__class__.__name__, + CURRENT_FILENAME)) sys.exit(0) if not os.path.isfile(self.gn_binary_path) or not os.path.isfile(self.ninja_binary_path): print("\nStep for prebuilts_download may be ommited. (\033[92m./prebuilts_download.sh\033[0m)" \ - "\nCheck \033[92mwhether gn binary and ninja binary are under directory prebuilts\033[0m!\n".format()) + "\nCheck \033[92mwhether gn binary and ninja binary are under directory prebuilts\033[0m!\n".format()) sys.exit(0) return @@ -603,13 +670,13 @@ class ArkPy: if len(arg_to_list) == 1: os_cpu_part = arg_to_list[0] mode_part = "release" - key_to_dict_in_os_cpu_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT["os_cpu"], os_cpu_part) - key_to_dict_in_mode_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT["mode"], mode_part) + key_to_dict_in_os_cpu_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT.get("os_cpu"), os_cpu_part) + key_to_dict_in_mode_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT.get("mode"), mode_part) elif len(arg_to_list) == 2: os_cpu_part = arg_to_list[0] mode_part = arg_to_list[1] - key_to_dict_in_os_cpu_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT["os_cpu"], os_cpu_part) - key_to_dict_in_mode_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT["mode"], mode_part) + key_to_dict_in_os_cpu_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT.get("os_cpu"), os_cpu_part) + key_to_dict_in_mode_matched_arg = self.which_dict_flags_match_arg(self.ARG_DICT.get("mode"), mode_part) else: print("\"\033[92m{0}\033[0m\" combined with more than 2 flags is not supported.".format(arg)) if (key_to_dict_in_os_cpu_matched_arg == "") | (key_to_dict_in_mode_matched_arg == ""): @@ -635,7 +702,7 @@ class ArkPy: help_msg += "\033[32mCommand template:\033[0m\n{}\n\n".format( " python3 ark.py \033[92m[os_cpu].[mode] [gn_target] [option]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --aot] " \ - "[none or --pgo] [none or --litecg] [none, file or dir] [none or --threads=X] [option]\033[0m\n" + "[none or --pgo] [none or --litecg] [none, file or dir] [none or --threads=X] [option]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --jit] [none or --threads=X]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --baseline-jit] [none or --threads=X]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [unittest] [option]\033[0m\n" @@ -686,8 +753,13 @@ class ArkPy: # prepare log file build_log_path = os.path.join(out_path, log_file_name) backup(build_log_path, "w") + if arg_list is not None: + build_target = " ".join([str(arg).strip() for arg in arg_list + if arg is not None or len(str(arg).strip()) > 0]) + else: + build_target = "" str_to_build_log = "================================\nbuild_time: {0}\nbuild_target: {1}\n\n".format( - str_of_time_now(), " ".join(arg_list)) + str_of_time_now(), build_target) _write(build_log_path, str_to_build_log, "a") # gn command print("=== gn gen start ===") @@ -704,13 +776,13 @@ class ArkPy: # Always add " -d keeprsp" to ninja command to keep response file("*.rsp"), thus we could get shared libraries # of an excutable from its response file. ninja_cmd = \ - self.ninja_binary_path + \ - (" -v" if self.enable_verbose else "") + \ - (" -d keepdepfile" if self.enable_keepdepfile else "") + \ - " -d keeprsp" + \ - " -C {}".format(out_path) + \ - " {}".format(" ".join(arg_list)) + \ - " -k {}".format(self.ignore_errors) + self.ninja_binary_path + \ + (" -v" if self.enable_verbose else "") + \ + (" -d keepdepfile" if self.enable_keepdepfile else "") + \ + " -d keeprsp" + \ + " -C {}".format(out_path) + \ + " {}".format(" ".join(arg_list if arg_list else [])) + \ + " -k {}".format(self.ignore_errors) print(ninja_cmd) code = call_with_output(ninja_cmd, build_log_path) if code != 0: @@ -720,77 +792,141 @@ class ArkPy: print("=== ninja success! ===\n") return - def build_for_test262(self, out_path, timeout, gn_args: list, arg_list: list, log_file_name: str, - aot_mode: bool, run_pgo=False, enable_litecg=False, run_jit=False, - run_baseline_jit=False): - args_to_test262_cmd = self.build_args_to_test262_cmd(arg_list) - x64_out_path = "" + def call_build_gn_target(self, gn_args, out_path, x64_out_path, test_suite, log_file_name): if any('target_cpu="arm64"' in arg for arg in gn_args): - if 'release' in out_path: - x64_out_path = 'out/x64.release' - if 'debug' in out_path: - x64_out_path = 'out/x64.debug' gn_args.append("so_dir_for_qemu=\"../../{0}/common/common/libc/\"".format(out_path)) gn_args.append("run_with_qemu=true".format(out_path)) if not os.path.exists(x64_out_path): os.makedirs(x64_out_path) self.build_for_gn_target( - x64_out_path, ['target_os="linux"', 'target_cpu="x64"', 'is_debug=false'], - self.ARG_DICT["target"]["test262"]["gn_targets_depend_on"], log_file_name) + x64_out_path, + ['target_os="linux"', 'target_cpu="x64"', 'is_debug=false'], + self.ARG_DICT.get("target").get(test_suite).get("gn_targets_depend_on"), + log_file_name) self.build_for_gn_target( - out_path, gn_args, self.ARG_DICT["target"]["test262"]["arm64_gn_targets_depend_on"], log_file_name) + out_path, + gn_args, + self.ARG_DICT.get("target").get(test_suite).get("arm64_gn_targets_depend_on"), + log_file_name) else: self.build_for_gn_target( - out_path, gn_args, self.ARG_DICT["target"]["test262"]["gn_targets_depend_on"], log_file_name) + out_path, + gn_args, + self.ARG_DICT.get("target").get(test_suite).get("gn_targets_depend_on"), + log_file_name) + + def get_build_cmd(self, *, test_suite, test_script_name, test_script_path, + out_path, x64_out_path, gn_args: list, args_to_cmd: str, timeout, + run_jit: bool = False, run_baseline_jit: bool = False, aot_mode: bool = False, + run_pgo: bool = False, enable_litecg: bool = False, ignore_list: Optional[str] = None) -> str: if run_jit: - test262_cmd = self.get_test262_jit_cmd(gn_args, out_path, x64_out_path, args_to_test262_cmd, timeout) + cmd = self.get_jit_cmd(test_suite, test_script_name, test_script_path, + gn_args, out_path, x64_out_path, args_to_cmd, timeout) elif run_baseline_jit: - test262_cmd = self.get_test262_baseline_jit_cmd(gn_args, out_path, x64_out_path, - args_to_test262_cmd, timeout) - elif aot_mode: - test262_cmd = self.get_test262_aot_cmd(gn_args, out_path, x64_out_path, run_pgo, enable_litecg, args_to_test262_cmd, - timeout) + cmd = self.get_baseline_jit_cmd(test_suite, test_script_name, test_script_path, + gn_args, out_path, x64_out_path, args_to_cmd, timeout) + elif aot_mode and test_suite == "test262": + cmd = self.get_test262_aot_cmd(gn_args, out_path, x64_out_path, run_pgo, + enable_litecg, args_to_cmd, timeout) else: - test262_cmd = self.get_test262_cmd(gn_args, out_path, x64_out_path, run_pgo, - enable_litecg, args_to_test262_cmd, timeout) - test262_log_path = os.path.join(out_path, log_file_name) - str_to_test262_log = "================================\ntest262_time: {0}\ntest262_target: {1}\n\n".format( - str_of_time_now(), args_to_test262_cmd) - _write(test262_log_path, str_to_test262_log, "a") - print("=== test262 start ===") - code = call_with_output(test262_cmd, test262_log_path) + cmd = self.get_cmd(test_suite, test_script_name, test_script_path, + gn_args, out_path, x64_out_path, aot_mode, run_pgo, + enable_litecg, args_to_cmd, timeout, ignore_list) + return cmd + + def build_for_suite(self, *, test_suite, test_script_name, test_script_path, + out_path, gn_args: list, log_file_name, args_to_cmd: str, timeout, + run_jit: bool = False, run_baseline_jit: bool = False, aot_mode: bool = False, + run_pgo: bool = False, enable_litecg: bool = False, ignore_list: Optional[str] = None): + x64_out_path = self.__get_x64_out_path(out_path) + self.call_build_gn_target(gn_args, out_path, x64_out_path, test_suite, log_file_name) + cmd = self.get_build_cmd( + test_suite=test_suite, + test_script_name=test_script_name, + test_script_path=test_script_path, + out_path=out_path, + x64_out_path=x64_out_path, + gn_args=gn_args, + args_to_cmd=args_to_cmd, + timeout=timeout, + run_jit=run_jit, + run_baseline_jit=run_baseline_jit, + aot_mode=aot_mode, run_pgo=run_pgo, enable_litecg=enable_litecg, ignore_list=ignore_list) + log_path = str(os.path.join(out_path, log_file_name)) + str_to_log = "================================\n{2}_time: {0}\n{2}_target: {1}\n\n".format( + str_of_time_now(), args_to_cmd, test_suite) + _write(log_path, str_to_log, "a") + print(f"=== {test_suite} start ===") + code = call_with_output(cmd, log_path) if code != 0: - print("=== test262 fail! ===\n") + print(f"=== {test_suite} fail! ===\n") sys.exit(code) - print("=== test262 success! ===\n") + print(f"=== {test_suite} success! ===\n") + + def build_for_test262(self, out_path, gn_args: list, arg_list: list): + timeout, arg_list = self.parse_timeout(arg_list) + arg_list = arg_list[1:] + + is_aot_mode, arg_list = self.__purge_arg_list("--aot", arg_list) + is_pgo, arg_list = self.__purge_arg_list("--pgo", arg_list) + is_litecg, arg_list = self.__purge_arg_list("--litecg", arg_list) + is_jit, arg_list = self.__purge_arg_list("--jit", arg_list) + is_baseline_jit, arg_list = self.__purge_arg_list("--baseline-jit", arg_list) + print(f"Test262: arg_list = {arg_list}") + + args_to_test262_cmd = self.build_args_to_test262_cmd(arg_list) + self.build_for_suite( + test_suite="test262", + test_script_name="test262/run_test262.py", + test_script_path="arkcompiler/ets_frontend", + out_path=out_path, + gn_args=gn_args, + log_file_name=self.TEST262_LOG_FILE_NAME, + args_to_cmd=args_to_test262_cmd, + timeout=timeout, + run_jit=is_jit, + run_pgo=is_pgo, + run_baseline_jit=is_baseline_jit, + aot_mode=is_aot_mode, + enable_litecg=is_litecg + ) - def build_for_unittest(self, out_path: str, gn_args: list, log_file_name:str): + def build_for_unittest(self, out_path: str, gn_args: list, log_file_name: str): self.build_for_gn_target( - out_path, gn_args, self.ARG_DICT["target"]["unittest"]["gn_targets_depend_on"], + out_path, gn_args, self.ARG_DICT.get("target").get("unittest").get("gn_targets_depend_on"), log_file_name) return - def build_for_regress_test(self, out_path, gn_args: list, arg_list: list, log_file_name: str, timeout): + def build_for_regress_test(self, out_path, gn_args: list, arg_list: list): + timeout, arg_list = self.parse_option(arg_list, option_name="--timeout", default_value=200) + ignore_list, arg_list = self.parse_option(arg_list, option_name="--ignore-list", default_value=None) + + arg_list = arg_list[1:] + + is_aot, arg_list = self.__purge_arg_list("--aot", arg_list) + is_pgo, arg_list = self.__purge_arg_list("--pgo", arg_list) + is_litecg, arg_list = self.__purge_arg_list("--litecg", arg_list) + is_jit, arg_list = self.__purge_arg_list("--jit", arg_list) + is_baseline_jit, arg_list = self.__purge_arg_list("--baseline-jit", arg_list) + print(f"Regress: arg_list = {arg_list}") + args_to_regress_test_cmd = self.build_args_to_regress_cmd(arg_list) - self.build_for_gn_target( - out_path, gn_args, self.ARG_DICT["target"]["regresstest"]["gn_targets_depend_on"], log_file_name) - regress_test_cmd = "python3 arkcompiler/ets_runtime/test/regresstest/run_regress_test.py --timeout {2}" \ - " --ark-tool ./{0}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary ./{0}/arkcompiler/ets_frontend/es2abc" \ - " --LD_LIBRARY_PATH ./{0}/arkcompiler/ets_runtime:./{0}/thirdparty/icu:" \ - "./prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --out-dir ./{0}/ {1}".format(out_path, args_to_regress_test_cmd, timeout) - regress_test_log_path = os.path.join(out_path, log_file_name) - str_to_test_log = "============\n regresstest_time: {0}\nregresstest_target: {1}\n\n".format( - str_of_time_now(), regress_test_cmd) - _write(regress_test_log_path, str_to_test_log, "a") - print("=== regresstest start ===") - code = call_with_output(regress_test_cmd, regress_test_log_path) - if code != 0: - print("=== regresstest fail! ===\n") - sys.exit(code) - print("=== regresstest success! ===\n") - return + self.build_for_suite( + test_suite="regresstest", + test_script_name="test/regresstest/run_regress_test.py", + test_script_path="arkcompiler/ets_runtime", + out_path=out_path, + gn_args=gn_args, + log_file_name=self.REGRESS_TEST_LOG_FILE_NAME, + args_to_cmd=args_to_regress_test_cmd, + timeout=timeout, + run_jit=is_jit, + run_pgo=is_pgo, + run_baseline_jit=is_baseline_jit, + aot_mode=is_aot, + enable_litecg=is_litecg, + ignore_list=ignore_list + ) def build(self, out_path: str, gn_args: list, arg_list: list): if not os.path.exists(out_path): @@ -798,47 +934,17 @@ class ArkPy: os.makedirs(out_path) if len(arg_list) == 0: self.build_for_gn_target(out_path, gn_args, ["default"], self.GN_TARGET_LOG_FILE_NAME) - elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["workload"], arg_list[0]): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("workload"), arg_list[0]): self.build_for_workload(arg_list, out_path, gn_args, 'workload.log') - elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["test262"], arg_list[0]): - timeout, arg_list = self.parse_timeout(arg_list) - run_aot_mode = len(arg_list) >= 2 and arg_list[1] == "--aot" - run_aot_pgo_litecg = len(arg_list) >= 4 and ((arg_list[2] == "--pgo" and arg_list[3] == "--litecg") or - (arg_list[3] == "--pgo" and arg_list[2] == "--litecg")) - run_aot_pgo = len(arg_list) >= 3 and arg_list[2] == "--pgo" - run_aot_litecg = len(arg_list) >= 3 and arg_list[2] == "--litecg" - run_jit = len(arg_list) >= 2 and arg_list[1] == "--jit" - run_baseline_jit = len(arg_list) >= 2 and arg_list[1] == "--baseline-jit" - if run_aot_mode: - if run_aot_pgo_litecg: - self.build_for_test262(out_path, timeout, gn_args, arg_list[4:], self.TEST262_LOG_FILE_NAME, True, - True, True) - elif run_aot_litecg: - self.build_for_test262(out_path, timeout, gn_args, arg_list[3:], self.TEST262_LOG_FILE_NAME, True, - False, True) - elif run_aot_pgo: - self.build_for_test262(out_path, timeout, gn_args, arg_list[3:], - self.TEST262_LOG_FILE_NAME, True, True) - else: - self.build_for_test262(out_path, timeout, gn_args, arg_list[2:], self.TEST262_LOG_FILE_NAME, True) - elif run_jit: - self.build_for_test262(out_path, timeout, gn_args, arg_list[2:], - self.TEST262_LOG_FILE_NAME, False, False, - False, True) - elif run_baseline_jit: - self.build_for_test262(out_path, timeout, gn_args, arg_list[2:], - self.TEST262_LOG_FILE_NAME, False, False, - False, False, True) - else: - self.build_for_test262(out_path, timeout, gn_args, arg_list[1:], self.TEST262_LOG_FILE_NAME, False) - elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["unittest"], arg_list[0]): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("test262"), arg_list[0]): + self.build_for_test262(out_path, gn_args, arg_list) + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("unittest"), arg_list[0]): if len(arg_list) > 1: print("\033[92m\"unittest\" not support additional arguments.\033[0m\n".format()) sys.exit(0) self.build_for_unittest(out_path, gn_args, self.UNITTEST_LOG_FILE_NAME) - elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["regresstest"], arg_list[0]): - timeout, arg_list = self.parse_option(arg_list, option_name="--timeout", default_value=200) - self.build_for_regress_test(out_path, gn_args, arg_list[1:], self.REGRESS_TEST_LOG_FILE_NAME, timeout) + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("target").get("regresstest"), arg_list[0]): + self.build_for_regress_test(out_path, gn_args, arg_list) else: self.build_for_gn_target(out_path, gn_args, arg_list, self.GN_TARGET_LOG_FILE_NAME) return @@ -851,27 +957,27 @@ class ArkPy: gn_args_ret = [] for arg in arg_list: # match [option][clean] flag - if self.is_dict_flags_match_arg(self.ARG_DICT["option"]["clean"], arg): + if self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("clean"), arg): self.clean(out_path) sys.exit(0) # match [option][clean-continue] flag - elif self.is_dict_flags_match_arg(self.ARG_DICT["option"]["clean-continue"], arg): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("clean-continue"), arg): if not self.has_cleaned: self.clean(out_path) self.has_cleaned = True # match [option][gn-args] flag - elif self.is_dict_flags_match_arg(self.ARG_DICT["option"]["gn-args"], arg): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("gn-args"), arg): gn_args_ret.append(arg[(arg.find("=") + 1):]) # match [option][keepdepfile] flag - elif self.is_dict_flags_match_arg(self.ARG_DICT["option"]["keepdepfile"], arg): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("keepdepfile"), arg): if not self.enable_keepdepfile: self.enable_keepdepfile = True # match [option][verbose] flag - elif self.is_dict_flags_match_arg(self.ARG_DICT["option"]["verbose"], arg): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("verbose"), arg): if not self.enable_verbose: self.enable_verbose = True # match [option][keep-going] flag - elif self.is_dict_flags_match_arg(self.ARG_DICT["option"]["keep-going"], arg): + elif self.is_dict_flags_match_arg(self.ARG_DICT.get("option").get("keep-going"), arg): if self.ignore_errors == 1: input_value = arg[(arg.find("=") + 1):] try: @@ -908,13 +1014,13 @@ class ArkPy: run_interpreter = True self.build_for_gn_target(out_path, gn_args, ["default"], self.GN_TARGET_LOG_FILE_NAME) workload_cmd = "cd arkcompiler/ets_runtime/test/workloadtest/ && python3 work_load.py" \ - " --code-path {0}" \ - " --report {1}" \ - " --tools-type {2}" \ - " --boundary-value {3}" \ - " --run-count {4}" \ - " --code-v {5}" \ - .format(root_dir, report, tools, boundary_value, run_count, code_v) + " --code-path {0}" \ + " --report {1}" \ + " --tools-type {2}" \ + " --boundary-value {3}" \ + " --run-count {4}" \ + " --code-v {5}" \ + .format(root_dir, report, tools, boundary_value, run_count, code_v) if run_interpreter: workload_cmd += " --run-interpreter true" workload_log_path = os.path.join(out_path, log_file_name) @@ -934,19 +1040,24 @@ class ArkPy: self.get_binaries() # get out_path name_of_out_dir_of_second_level = \ - self.ARG_DICT["os_cpu"][os_cpu_key]["prefix_of_name_of_out_dir_of_second_level"] + \ + self.ARG_DICT.get("os_cpu").get(os_cpu_key).get("prefix_of_name_of_out_dir_of_second_level") + \ self.DELIMITER_FOR_SECOND_OUT_DIR_NAME + \ - self.ARG_DICT["mode"][mode_key]["suffix_of_name_of_out_dir_of_second_level"] + self.ARG_DICT.get("mode").get(mode_key).get("suffix_of_name_of_out_dir_of_second_level") out_path = os.path.join(self.NAME_OF_OUT_DIR_OF_FIRST_LEVEL, name_of_out_dir_of_second_level) # match [option] flag [arg_list, gn_args] = self.match_options(arg_list, out_path) # get expression which would be written to args.gn file - gn_args.extend(self.ARG_DICT["os_cpu"][os_cpu_key]["gn_args"]) - gn_args.extend(self.ARG_DICT["mode"][mode_key]["gn_args"]) + gn_args.extend(self.ARG_DICT.get("os_cpu").get(os_cpu_key).get("gn_args")) + gn_args.extend(self.ARG_DICT.get("mode").get(mode_key).get("gn_args")) # start to build self.build(out_path, gn_args, arg_list) return + def __purge_arg_list(self, option_name: str, arg_list: List[Any]) -> Tuple[bool, List[Any]]: + if option_name in arg_list: + arg_list.remove(option_name) + return True, arg_list + return False, arg_list if __name__ == "__main__": -- Gitee From 9c44ad64b31b1b30b6962b29aff5baa9ed00aa67 Mon Sep 17 00:00:00 2001 From: bigtea Date: Mon, 5 Aug 2024 09:29:53 +0800 Subject: [PATCH 06/33] Fix failed and enable UT Issue: IAGKTX Signed-off-by: bigtea --- tooling/test/client_utils/test_list.cpp | 13 -- tooling/test/debugger_cint_client_test.cpp | 2 +- tooling/test/debugger_client_test.cpp | 2 +- .../test/testcases/js_cpuprofile_async_test.h | 109 --------------- .../test/testcases/js_cpuprofile_loop_test.h | 26 +--- .../testcases/js_cpuprofile_recursion_test.h | 120 ----------------- .../test/testcases/js_cpuprofile_step_test.h | 127 ------------------ tooling/test/testcases/js_cpuprofile_test.h | 18 +-- websocket/test/websocket_test.cpp | 8 +- 9 files changed, 12 insertions(+), 413 deletions(-) delete mode 100755 tooling/test/testcases/js_cpuprofile_async_test.h delete mode 100644 tooling/test/testcases/js_cpuprofile_recursion_test.h delete mode 100755 tooling/test/testcases/js_cpuprofile_step_test.h diff --git a/tooling/test/client_utils/test_list.cpp b/tooling/test/client_utils/test_list.cpp index f3acefb5..cdd96ac0 100644 --- a/tooling/test/client_utils/test_list.cpp +++ b/tooling/test/client_utils/test_list.cpp @@ -24,8 +24,6 @@ #include "tooling/test/testcases/js_closure_scope_test.h" #include "tooling/test/testcases/js_container_test.h" #include "tooling/test/testcases/js_exception_test.h" -#include "tooling/test/testcases/js_heapsampling_loop_test.h" -#include "tooling/test/testcases/js_heapsampling_test.h" #include "tooling/test/testcases/js_local_variable_scope_test.h" #include "tooling/test/testcases/js_module_variable_test.h" #include "tooling/test/testcases/js_source_test.h" @@ -51,9 +49,6 @@ #include "tooling/test/testcases/js_stepinto_async_test.h" #include "tooling/test/testcases/js_stepout_arrow_test.h" #include "tooling/test/testcases/js_stepout_async_test.h" -#include "tooling/test/testcases/js_cpuprofile_test.h" -#include "tooling/test/testcases/js_cpuprofile_async_test.h" -#include "tooling/test/testcases/js_cpuprofile_step_test.h" #include "tooling/test/testcases/js_heapusage_test.h" #include "tooling/test/testcases/js_heapusage_async_test.h" #include "tooling/test/testcases/js_heapusage_step_test.h" @@ -72,8 +67,6 @@ #include "tooling/test/testcases/js_breakpoint_loop_test.h" #include "tooling/test/testcases/js_breakpoint_recursion_test.h" #include "tooling/test/testcases/js_breakpoint_switch_test.h" -#include "tooling/test/testcases/js_cpuprofile_loop_test.h" -#include "tooling/test/testcases/js_cpuprofile_recursion_test.h" #include "tooling/test/testcases/js_heapusage_loop_test.h" #include "tooling/test/testcases/js_heapusage_recursion_test.h" #include "tooling/test/testcases/js_smart_stepInto_test.h" @@ -94,7 +87,6 @@ static void RegisterTests() TestUtil::RegisterTest("JsModuleVariableTest", GetJsModuleVariableTest()); TestUtil::RegisterTest("JsSourceTest", GetJsSourceTest()); TestUtil::RegisterTest("JsTracingTest", GetJsTracingTest()); - TestUtil::RegisterTest("JsHeapsamplingTest", GetJsHeapsamplingTest()); TestUtil::RegisterTest("JsWatchTest", GetJsWatchTest()); TestUtil::RegisterTest("JsHeapdumpTest", GetJsHeapdumpTest()); TestUtil::RegisterTest("JsAllocationtrackTest", GetJsAllocationtrackTest()); @@ -113,16 +105,12 @@ static void RegisterTests() TestUtil::RegisterTest("JsStepintoAsyncTest", GetJsStepintoAsyncTest()); TestUtil::RegisterTest("JsStepoutArrowTest", GetJsStepoutArrowTest()); TestUtil::RegisterTest("JsStepoutAsyncTest", GetJsStepoutAsyncTest()); - TestUtil::RegisterTest("JsCpuprofileTest", GetJsCpuprofileTest()); - TestUtil::RegisterTest("JsCpuprofileAsyncTest", GetJsCpuprofileAsyncTest()); - TestUtil::RegisterTest("JsCpuprofileStepTest", GetJsCpuprofileStepTest()); TestUtil::RegisterTest("JsHeapusageTest", GetJsHeapusageTest()); TestUtil::RegisterTest("JsHeapusageAsyncTest", GetJsHeapusageAsyncTest()); TestUtil::RegisterTest("JsHeapusageStepTest", GetJsHeapusageStepTest()); TestUtil::RegisterTest("JsHeapdumpLoopTest", GetJsHeapdumpLoopTest()); TestUtil::RegisterTest("JsAllocationTrackLoopTest", GetJsAllocationTrackLoopTest()); TestUtil::RegisterTest("JsAllocationTrackRecursionTest", GetJsAllocationTrackRecursionTest()); - TestUtil::RegisterTest("JsHeapSamplingLoopTest", GetJsHeapSamplingLoopTest()); TestUtil::RegisterTest("JsJsWatchBasicTypeTest", GetJsWatchBasicTypeTest()); TestUtil::RegisterTest("JsJsWatchSetTypeTest", GetJsWatchSetTypeTest()); TestUtil::RegisterTest("JsJsWatchOtherTypeTest", GetJsWatchOtherTypeTest()); @@ -138,7 +126,6 @@ static void RegisterTests() TestUtil::RegisterTest("JsBreakpointLoopTest", GetJsBreakpointLoopTest()); TestUtil::RegisterTest("JsBreakpointRecursionTest", GetJsBreakpointRecursionTest()); TestUtil::RegisterTest("JsBreakpointSwitchTest", GetJsBreakpointSwitchTest()); - TestUtil::RegisterTest("JsCpuprofileLoopTest", GetJsCpuprofileLoopTest()); TestUtil::RegisterTest("JsHeapusageLoopTest", GetJsHeapusageLoopTest()); TestUtil::RegisterTest("JsHeapusageRecursionTest", GetJsHeapusageRecursionTest()); TestUtil::RegisterTest("JsSmartStepoutTest", GetJsSmartStepoutTest()); diff --git a/tooling/test/debugger_cint_client_test.cpp b/tooling/test/debugger_cint_client_test.cpp index 09809e99..b03f609b 100644 --- a/tooling/test/debugger_cint_client_test.cpp +++ b/tooling/test/debugger_cint_client_test.cpp @@ -65,7 +65,7 @@ public: JSThread *thread {nullptr}; }; -HWTEST_P_L0(DebuggerCIntClientTest, DISABLED_DebuggerSuite) +HWTEST_P_L0(DebuggerCIntClientTest, DebuggerSuite) { std::string testName = GetCurrentTestName(); std::cout << "Running " << testName << std::endl; diff --git a/tooling/test/debugger_client_test.cpp b/tooling/test/debugger_client_test.cpp index 2f54ce54..8f9db150 100644 --- a/tooling/test/debugger_client_test.cpp +++ b/tooling/test/debugger_client_test.cpp @@ -66,7 +66,7 @@ public: }; //NOTE: enable (issue 18042) -HWTEST_P_L0(DebuggerClientTest, DISABLED_DebuggerSuite) +HWTEST_P_L0(DebuggerClientTest, DebuggerSuite) { std::string testName = GetCurrentTestName(); std::cout << "Running " << testName << std::endl; diff --git a/tooling/test/testcases/js_cpuprofile_async_test.h b/tooling/test/testcases/js_cpuprofile_async_test.h deleted file mode 100755 index c1fb48a9..00000000 --- a/tooling/test/testcases/js_cpuprofile_async_test.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_ASYNC_TEST_H -#define ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_ASYNC_TEST_H - -#include "tooling/test/client_utils/test_util.h" - -namespace panda::ecmascript::tooling::test { -class JsCpuprofileAsyncTest : public TestActions { -public: - JsCpuprofileAsyncTest() - { - testAction = { - {SocketAction::SEND, "enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "runtime-enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "run"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - // load async_func.js - {SocketAction::RECV, "Debugger.scriptParsed", ActionRule::STRING_CONTAIN}, - // break on start - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - {SocketAction::SEND, "cpuprofile-enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "cpuprofile"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "async_func.js 18"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "cpuprofile-stop"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, - [](auto recv, auto, auto) -> bool { - std::unique_ptr json = PtJson::Parse(recv); - Result ret; - int id = 0; - ret = json->GetInt("id", &id); - if (ret != Result::SUCCESS) { - return false; - } - - std::unique_ptr result = nullptr; - ret = json->GetObject("result", &result); - if (ret != Result::SUCCESS) { - return false; - } - - std::unique_ptr profile = nullptr; - ret = result->GetObject("profile", &profile); - if (ret != Result::SUCCESS) { - return false; - } - - return true; - }}, - {SocketAction::SEND, "cpuprofile-disable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - // reply success and run - {SocketAction::SEND, "success"}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - }; - } - - std::pair GetEntryPoint() override - { - return {pandaFile_, entryPoint_}; - } - ~JsCpuprofileAsyncTest() = default; - -private: - std::string pandaFile_ = DEBUGGER_ABC_DIR "async_func.abc"; - std::string sourceFile_ = DEBUGGER_JS_DIR "async_func.js"; - std::string entryPoint_ = "_GLOBAL::func_main_0"; -}; - -std::unique_ptr GetJsCpuprofileAsyncTest() -{ - return std::make_unique(); -} -} // namespace panda::ecmascript::tooling::test - -#endif // ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_ASYNC_TEST_H diff --git a/tooling/test/testcases/js_cpuprofile_loop_test.h b/tooling/test/testcases/js_cpuprofile_loop_test.h index f837cd65..a33541ec 100644 --- a/tooling/test/testcases/js_cpuprofile_loop_test.h +++ b/tooling/test/testcases/js_cpuprofile_loop_test.h @@ -39,43 +39,23 @@ public: {SocketAction::SEND, "cpuprofile"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "common_func.js 64"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "common_func.js 65"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - + // resume and stop cpuprofile {SocketAction::SEND, "resume"}, {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, {SocketAction::SEND, "cpuprofile-stop"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, [this](auto recv, auto, auto) -> bool { return RecvCpuprofileInfo(recv); }}, - + // cpuprofile second time and disable {SocketAction::SEND, "cpuprofile"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, {SocketAction::SEND, "cpuprofile-stop"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, [this](auto recv, auto, auto) -> bool { return RecvCpuprofileInfo(recv); }}, - {SocketAction::SEND, "cpuprofile-disable"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - // reply success and run + // reply success {SocketAction::SEND, "success"}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, }; } diff --git a/tooling/test/testcases/js_cpuprofile_recursion_test.h b/tooling/test/testcases/js_cpuprofile_recursion_test.h deleted file mode 100644 index a09a13db..00000000 --- a/tooling/test/testcases/js_cpuprofile_recursion_test.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_RECURSION_TEST_H -#define ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_RECURSION_TEST_H - -#include "tooling/test/client_utils/test_util.h" - -namespace panda::ecmascript::tooling::test { -class JsCpuprofileRecursionTest : public TestActions { -public: - JsCpuprofileRecursionTest() - { - testAction = { - {SocketAction::SEND, "enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "runtime-enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "run"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - // load common_func.js - {SocketAction::RECV, "Debugger.scriptParsed", ActionRule::STRING_CONTAIN}, - // break on start - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - {SocketAction::SEND, "cpuprofile-enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "cpuprofile"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "common_func.js 67"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - {SocketAction::SEND, "cpuprofile-stop"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, - [this](auto recv, auto, auto) -> bool { return RecvCpuprofileInfo(recv); }}, - - {SocketAction::SEND, "cpuprofile"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - {SocketAction::SEND, "cpuprofile-stop"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, - [this](auto recv, auto, auto) -> bool { return RecvCpuprofileInfo(recv); }}, - - {SocketAction::SEND, "cpuprofile-disable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - // reply success and run - {SocketAction::SEND, "success"}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - }; - } - - bool RecvCpuprofileInfo(std::string recv) - { - std::unique_ptr json = PtJson::Parse(recv); - Result ret; - int id = 0; - ret = json->GetInt("id", &id); - if (ret != Result::SUCCESS) { - return false; - } - - std::unique_ptr result = nullptr; - ret = json->GetObject("result", &result); - if (ret != Result::SUCCESS) { - return false; - } - - std::unique_ptr profile = nullptr; - ret = result->GetObject("profile", &profile); - if (ret != Result::SUCCESS) { - return false; - } - return true; - } - - std::pair GetEntryPoint() override - { - return {pandaFile_, entryPoint_}; - } - ~JsCpuprofileRecursionTest() = default; - -private: - std::string pandaFile_ = DEBUGGER_ABC_DIR "common_func.abc"; - std::string sourceFile_ = DEBUGGER_JS_DIR "common_func.js"; - std::string entryPoint_ = "_GLOBAL::func_main_0"; -}; - -std::unique_ptr GetJsCpuprofileRecursionTest() -{ - return std::make_unique(); -} -} // namespace panda::ecmascript::tooling::test - -#endif // ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_LOOP_TEST_H diff --git a/tooling/test/testcases/js_cpuprofile_step_test.h b/tooling/test/testcases/js_cpuprofile_step_test.h deleted file mode 100755 index 199d3f1e..00000000 --- a/tooling/test/testcases/js_cpuprofile_step_test.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_STEP_TEST_H -#define ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_STEP_TEST_H - -#include "tooling/test/client_utils/test_util.h" - -namespace panda::ecmascript::tooling::test { -class JsCpuprofileStepTest : public TestActions { -public: - JsCpuprofileStepTest() - { - testAction = { - {SocketAction::SEND, "enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "runtime-enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "run"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - // load sample.js - {SocketAction::RECV, "Debugger.scriptParsed", ActionRule::STRING_CONTAIN}, - // break on start - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - {SocketAction::SEND, "cpuprofile-enable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "cpuprofile"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "sample.js 23"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "so"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "si"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "sov"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "so"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "sov"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - {SocketAction::SEND, "cpuprofile-stop"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, - [](auto recv, auto, auto) -> bool { - std::unique_ptr json = PtJson::Parse(recv); - Result ret; - int id = 0; - ret = json->GetInt("id", &id); - if (ret != Result::SUCCESS) { - return false; - } - - std::unique_ptr result = nullptr; - ret = json->GetObject("result", &result); - if (ret != Result::SUCCESS) { - return false; - } - - std::unique_ptr profile = nullptr; - ret = result->GetObject("profile", &profile); - if (ret != Result::SUCCESS) { - return false; - } - return true; - }}, - {SocketAction::SEND, "cpuprofile-disable"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - // reply success and run - {SocketAction::SEND, "success"}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - }; - } - - std::pair GetEntryPoint() override - { - return {pandaFile_, entryPoint_}; - } - ~JsCpuprofileStepTest() = default; - -private: - std::string pandaFile_ = DEBUGGER_ABC_DIR "sample.abc"; - std::string sourceFile_ = DEBUGGER_JS_DIR "sample.js"; - std::string entryPoint_ = "_GLOBAL::func_main_0"; -}; - -std::unique_ptr GetJsCpuprofileStepTest() -{ - return std::make_unique(); -} -} // namespace panda::ecmascript::tooling::test - -#endif // ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_CPUPROFILE_STEP_TEST_H diff --git a/tooling/test/testcases/js_cpuprofile_test.h b/tooling/test/testcases/js_cpuprofile_test.h index 9f99b793..8c2e4dd4 100755 --- a/tooling/test/testcases/js_cpuprofile_test.h +++ b/tooling/test/testcases/js_cpuprofile_test.h @@ -38,15 +38,11 @@ public: {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, {SocketAction::SEND, "cpuprofile"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "sample.js 23"}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - + // resume {SocketAction::SEND, "resume"}, {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - + // stop and disable {SocketAction::SEND, "cpuprofile-stop"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, [](auto recv, auto, auto) -> bool { @@ -73,16 +69,8 @@ public: }}, {SocketAction::SEND, "cpuprofile-disable"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, - {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, - - // reply success and run + // reply success {SocketAction::SEND, "success"}, - {SocketAction::SEND, "resume"}, - {SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN}, - {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, }; } diff --git a/websocket/test/websocket_test.cpp b/websocket/test/websocket_test.cpp index 1c942286..0523f2a6 100644 --- a/websocket/test/websocket_test.cpp +++ b/websocket/test/websocket_test.cpp @@ -65,7 +65,7 @@ public: const std::string WebSocketTest::LONG_MSG = std::string(1000, 'f'); const std::string WebSocketTest::LONG_LONG_MSG = std::string(0xfffff, 'f'); -HWTEST_F(WebSocketTest, DISABLED_ConnectWebSocketTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ConnectWebSocketTest, testing::ext::TestSize.Level0) { WebSocketServer serverSocket; bool ret = false; @@ -162,7 +162,7 @@ HWTEST_F(WebSocketTest, DISABLED_ConnectWebSocketTest, testing::ext::TestSize.Le } } -HWTEST_F(WebSocketTest, DISABLED_ReConnectWebSocketTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ReConnectWebSocketTest, testing::ext::TestSize.Level0) { WebSocketServer serverSocket; bool ret = false; @@ -222,7 +222,7 @@ HWTEST_F(WebSocketTest, DISABLED_ReConnectWebSocketTest, testing::ext::TestSize. sleep(3); } -HWTEST_F(WebSocketTest, DISABLED_ClientAbnormalTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ClientAbnormalTest, testing::ext::TestSize.Level0) { WebSocketClient clientSocket; ASSERT_STREQ(clientSocket.GetSocketStateString().c_str(), "closed"); @@ -231,7 +231,7 @@ HWTEST_F(WebSocketTest, DISABLED_ClientAbnormalTest, testing::ext::TestSize.Leve ASSERT_FALSE(clientSocket.SendReply(HELLO_SERVER)); } -HWTEST_F(WebSocketTest, DISABLED_ServerAbnormalTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ServerAbnormalTest, testing::ext::TestSize.Level0) { WebSocketServer serverSocket; // No connection established, the function returns directly. -- Gitee From 6401c3212896d1e9643288ebcfb90958db04bcee Mon Sep 17 00:00:00 2001 From: yanzhiqi1 Date: Fri, 9 Aug 2024 14:39:36 +0800 Subject: [PATCH 07/33] Clear security warnings Issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAIT3Z Signed-off-by: yanzhiqi1 --- tooling/base/pt_types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/base/pt_types.cpp b/tooling/base/pt_types.cpp index b138d947..6d44cf8e 100644 --- a/tooling/base/pt_types.cpp +++ b/tooling/base/pt_types.cpp @@ -3216,7 +3216,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) std::unique_ptr syntheticDelays; ret = params.GetArray("syntheticDelays", &syntheticDelays); if (ret == Result::SUCCESS) { - int32_t syntheticDelaysLen = includedCategories->GetSize(); + int32_t syntheticDelaysLen = syntheticDelays->GetSize(); for (int32_t i = 0; i < syntheticDelaysLen; ++i) { std::string pSyntheticDelays = syntheticDelays->Get(i)->GetString(); traceConfig->syntheticDelays_.value().emplace_back(pSyntheticDelays); -- Gitee From 74cc0662393a6ded726494e3381fa11c079a6361 Mon Sep 17 00:00:00 2001 From: xwx1135370 Date: Fri, 9 Aug 2024 16:50:48 +0800 Subject: [PATCH 08/33] [Bug]: Fix the musl feature configured in part_config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAF3U3?from=project-issue Test:Source code compilation Signed-off-by: xwx1135370 --- build/third_party_gn/musl/BUILD.gn | 12 ++++++------ build/third_party_gn/musl/musl_config.gni | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/third_party_gn/musl/BUILD.gn b/build/third_party_gn/musl/BUILD.gn index 8cbfe3ec..73729d5e 100644 --- a/build/third_party_gn/musl/BUILD.gn +++ b/build/third_party_gn/musl/BUILD.gn @@ -162,7 +162,7 @@ action("create_syscall_h_file") { } uapi_from = "local" -uapi_full_path = rebase_path(uapi_dir) +uapi_full_path = rebase_path(musl_uapi_dir) arguments_uapi = [ "-c" ] # exclude these files because they need special treatment @@ -179,7 +179,7 @@ uspi_files = exec_script("/bin/sh", arguments_uapi, "list lines") # Generate a copy target for each file foreach(file, uspi_files) { copy("copy_uapi_${file}") { - sources = [ "${uapi_dir}/${file}" ] + sources = [ "${musl_uapi_dir}/${file}" ] outputs = [ "${target_out_dir}/${musl_inc_out_dir}/${file}" ] } } @@ -188,7 +188,7 @@ group("copy_uapi_scsi") { deps = [] sources = [] outputs = [] - uapi_scsi_dir = rebase_path("${uapi_dir}/scsi") + uapi_scsi_dir = rebase_path("${musl_uapi_dir}/scsi") arguments_scsi = [ "-c" ] arguments_scsi += [ "ls ${uapi_scsi_dir}" ] uapi_scsi_files = exec_script("/bin/sh", arguments_scsi, "list lines") @@ -196,7 +196,7 @@ group("copy_uapi_scsi") { # Generate a copy target for each file in scsi dir to avoid being influenced by musl_copy_inc_scsi output foreach(file, uapi_scsi_files) { copy("copy_uapi_scsi_${file}") { - sources += [ "${uapi_dir}/scsi/${file}" ] + sources += [ "${musl_uapi_dir}/scsi/${file}" ] outputs += [ "${target_out_dir}/${musl_inc_out_dir}/scsi/${file}" ] } deps += [ ":copy_uapi_scsi_${file}" ] @@ -210,9 +210,9 @@ copy("copy_uapi_asm") { } else { # aarch64 and x86_64 use same file file_name = "asm-arm64" } - sources = [ "${uapi_dir}/${file_name}/asm" ] + sources = [ "${musl_uapi_dir}/${file_name}/asm" ] } else { - sources = [ "${uapi_dir}/asm" ] + sources = [ "${musl_uapi_dir}/asm" ] } outputs = [ "${target_out_dir}/${musl_inc_out_dir}/asm" ] } diff --git a/build/third_party_gn/musl/musl_config.gni b/build/third_party_gn/musl/musl_config.gni index ceff6198..52814f23 100644 --- a/build/third_party_gn/musl/musl_config.gni +++ b/build/third_party_gn/musl/musl_config.gni @@ -45,10 +45,10 @@ declare_args() { declare_args() { runtime_lib_path = "//prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib" - use_jemalloc = false + musl_use_jemalloc = false musl_ported_dir = "intermidiates/${musl_target_os}/musl_src_ported" musl_inc_out_dir = "usr/include/${musl_target_triple}" - uapi_dir = "//kernel/linux/patches/linux-5.10/prebuilts/usr/include" + musl_uapi_dir = "//kernel/linux/patches/linux-5.10/prebuilts/usr/include" musl_dir = "//third_party/musl" musl_porting_dir = "//third_party/musl/porting/linux/user" } -- Gitee From 1102e06f32d1d1ed686d989182ed3ebad8d14d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=B1=9F=E6=B5=A9?= <5715935+Yejianghao1995@user.noreply.gitee.com> Date: Sat, 10 Aug 2024 09:12:41 +0800 Subject: [PATCH 09/33] debugger_impl.cpp dispatch testcase Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAIZQC Signed-off-by: yejianghao Change-Id: Ia42aeea0d12eeb4436c6bda13890b84893b5c8f0 --- tooling/test/debugger_impl_test.cpp | 307 ++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) diff --git a/tooling/test/debugger_impl_test.cpp b/tooling/test/debugger_impl_test.cpp index 4aaa0338..3367e691 100644 --- a/tooling/test/debugger_impl_test.cpp +++ b/tooling/test/debugger_impl_test.cpp @@ -1241,6 +1241,313 @@ HWTEST_F_L0(DebuggerImplTest, DispatcherImplCallFunctionOn) protocolChannel = nullptr; } } + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_SmartStepInto__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.smartStepInto", + "params":{} + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"wrong params"}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_SmartStepInto__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.smartStepInto", + "params":{ + "lineNumber":0, + "url":"url_str", + "urlRegex":"urlRegex_str", + "scriptHash":"scriptHash_str", + "columnNumber":0, + "condition":"condition_str" + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"Can only perform operation while paused"}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_SmartStepInto__003) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + debuggerImpl->SetDebuggerState(DebuggerState::PAUSED); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.smartStepInto", + "params":{ + "lineNumber":0, + "url":"url_str", + "urlRegex":"urlRegex_str", + "scriptHash":"scriptHash_str", + "columnNumber":0, + "condition":"condition_str" + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"SetBreakpointByUrl: debugger agent is not enabled"}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_SetNativeRange__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.setNativeRange", + "params":{ + "nativeRange":"" + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"wrong params"}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_SetNativeRange__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.setNativeRange", + "params":{} + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ResetSingleStepper__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.resetSingleStepper", + "params":{ + "resetSingleStepper":"test" + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"wrong params"}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ResetSingleStepper__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.resetSingleStepper", + "params":{ + "resetSingleStepper":true + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ClientDisconnect) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.clientDisconnect", + "params":{} + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), R"()"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_CallFunctionOn__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.callFunctionOn", + "params":{ + "callFrameId":"1", + "functionDeclaration":"test" + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"Invalid callFrameId."}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_CallFunctionOn__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.callFunctionOn", + "params":{ + "callFrameId":"0", + "functionDeclaration":0 + } + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"wrong params"}})"); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + HWTEST_F_L0(DebuggerImplTest, NativeOutTest) { std::string outStrForCallbackCheck = ""; -- Gitee From 179af440ed3980d46a9f82c6a834b82d1f808f66 Mon Sep 17 00:00:00 2001 From: yangxiaoshuai2022 Date: Sat, 10 Aug 2024 15:10:43 +0800 Subject: [PATCH 10/33] fix the non-standard naming of DLL Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAJ58U Signed-off-by: yangxiaoshuai2022 --- inspector/BUILD.gn | 2 ++ inspector/inspector.cpp | 6 +++--- tooling/BUILD.gn | 1 + tooling/test/client_utils/test_util.h | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/inspector/BUILD.gn b/inspector/BUILD.gn index 48d5efab..ed217326 100644 --- a/inspector/BUILD.gn +++ b/inspector/BUILD.gn @@ -69,6 +69,7 @@ ohos_shared_library("ark_debugger") { innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" + output_name = "ark_inspector" } ohos_source_set("connectserver_debugger_static") { @@ -118,4 +119,5 @@ ohos_shared_library("connectserver_debugger") { innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" + output_name = "ark_connect_inspector" } diff --git a/inspector/inspector.cpp b/inspector/inspector.cpp index 3292a9d6..265e1a1d 100644 --- a/inspector/inspector.cpp +++ b/inspector/inspector.cpp @@ -71,11 +71,11 @@ thread_local void* g_vm = nullptr; #if !defined(IOS_PLATFORM) #if defined(WINDOWS_PLATFORM) -constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.dll"; +constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_tooling.dll"; #elif defined(MAC_PLATFORM) -constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.dylib"; +constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_tooling.dylib"; #else -constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.so"; +constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_tooling.so"; #endif #endif diff --git a/tooling/BUILD.gn b/tooling/BUILD.gn index 2000fa87..9221adcb 100644 --- a/tooling/BUILD.gn +++ b/tooling/BUILD.gn @@ -127,6 +127,7 @@ ohos_shared_library("libark_ecma_debugger") { innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" + output_name = "libark_tooling" } ohos_shared_library("libark_ecma_debugger_test") { diff --git a/tooling/test/client_utils/test_util.h b/tooling/test/client_utils/test_util.h index 81375f99..5fe22bbe 100644 --- a/tooling/test/client_utils/test_util.h +++ b/tooling/test/client_utils/test_util.h @@ -36,9 +36,9 @@ using TestMap = CUnorderedMap>; using namespace OHOS::ArkCompiler::Toolchain; #ifdef OHOS_PLATFORM -#define DEBUGGER_LIBRARY "libark_debugger.z.so" +#define DEBUGGER_LIBRARY "libark_inspector.z.so" #else -#define DEBUGGER_LIBRARY "libark_debugger.so" +#define DEBUGGER_LIBRARY "libark_inspector.so" #endif class TestUtil { -- Gitee From 3ff55183a79002570091953d5141e5e01e9767fb Mon Sep 17 00:00:00 2001 From: swx1282997 Date: Sun, 11 Aug 2024 10:21:38 +0800 Subject: [PATCH 11/33] Coverage supplement Supplement the coverage of the profiler_impl heapprofiler_impl pt_types Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAHS46 Signed-off-by: swx1282997 --- tooling/test/heapprofiler_impl_test.cpp | 22 ++--- tooling/test/profiler_impl_test.cpp | 100 +++++++++++++------ tooling/test/pt_types_test.cpp | 124 ++++++++++++++++++++++++ 3 files changed, 206 insertions(+), 40 deletions(-) diff --git a/tooling/test/heapprofiler_impl_test.cpp b/tooling/test/heapprofiler_impl_test.cpp index fe021a45..b847cd83 100644 --- a/tooling/test/heapprofiler_impl_test.cpp +++ b/tooling/test/heapprofiler_impl_test.cpp @@ -177,13 +177,13 @@ HWTEST_F_L0(HeapProfilerImplTest, DispatcherImplAddInspectedHeapObject) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.disable","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.addInspectedHeapObject","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->AddInspectedHeapObject(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result.find("wrong params") != std::string::npos); - msg = std::string() + R"({"id":0,"method":"HeapProfiler.disable","params":{"heapObjectId":"0"}})"; + msg = std::string() + R"({"id":0,"method":"HeapProfiler.addInspectedHeapObject","params":{"heapObjectId":"0"}})"; DispatchRequest request1 = DispatchRequest(msg); - dispatcherImpl->AddInspectedHeapObject(request1); + dispatcherImpl->Dispatch(request1); if (channel) { delete channel; channel = nullptr; @@ -201,7 +201,7 @@ HWTEST_F_L0(HeapProfilerImplTest, DispatcherImplCollectGarbage) auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.collectGarbage","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->CollectGarbage(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result == "{\"id\":0,\"result\":{}}"); if (channel) { delete channel; @@ -219,7 +219,7 @@ HWTEST_F_L0(HeapProfilerImplTest, DispatcherImplEnable) auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.enable","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->Enable(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result.find("protocols") != std::string::npos); if (channel) { delete channel; @@ -237,7 +237,7 @@ HWTEST_F_L0(HeapProfilerImplTest, DispatcherImplDisable) auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.disable","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->Disable(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result == "{\"id\":0,\"result\":{}}"); if (channel) { delete channel; @@ -255,11 +255,11 @@ HWTEST_F_L0(HeapProfilerImplTest, DispatcherImplGetHeapObjectId) auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.getHeapObjectId","params":{"objectId":true}})"; DispatchRequest request(msg); - dispatcherImpl->GetHeapObjectId(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result.find("wrong params") != std::string::npos); msg = std::string() + R"({"id":0,"method":"HeapProfiler.getHeapObjectId","params":{"objectId":"0"}})"; DispatchRequest request1(msg); - dispatcherImpl->GetHeapObjectId(request1); + dispatcherImpl->Dispatch(request1); ASSERT_TRUE(result.find("GetHeapObjectId not support now") != std::string::npos); if (channel) { delete channel; @@ -278,12 +278,12 @@ HWTEST_F_L0(HeapProfilerImplTest, DispatcherImplGetObjectByHeapObjectId) std::string msg = std::string() + R"({"id":0,"method":"HeapProfiler.getObjectByHeapObjectId","params":{ "objectId":001}})"; DispatchRequest request(msg); - dispatcherImpl->GetObjectByHeapObjectId(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result.find("wrong params") != std::string::npos); msg = std::string() + R"({"id":0,"method":"HeapProfiler.getObjectByHeapObjectId","params":{"objectId":"001", "objectGroup":"000"}})"; DispatchRequest request1(msg); - dispatcherImpl->GetObjectByHeapObjectId(request1); + dispatcherImpl->Dispatch(request1); ASSERT_TRUE(result.find("GetObjectByHeapObjectId not support now") != std::string::npos); if (channel) { delete channel; diff --git a/tooling/test/profiler_impl_test.cpp b/tooling/test/profiler_impl_test.cpp index 1037493e..6d086956 100644 --- a/tooling/test/profiler_impl_test.cpp +++ b/tooling/test/profiler_impl_test.cpp @@ -186,11 +186,11 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplDispatch) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.Test","params":{}})"; DispatchRequest request(msg); dispatcherImpl->Dispatch(request); ASSERT_TRUE(result.find("Unknown method: Test") != std::string::npos); - msg = std::string() + R"({"id":0,"method":"Debugger.disable","params":{}})"; + msg = std::string() + R"({"id":0,"method":"Profiler.disable","params":{}})"; DispatchRequest request1 = DispatchRequest(msg); dispatcherImpl->Dispatch(request1); if (channel) { @@ -208,9 +208,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplEnable) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.enable","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->Enable(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -226,9 +226,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplDisable) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.disable","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->Disable(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -244,11 +244,13 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplStart) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.start","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->Start(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result == "{\"id\":0,\"result\":{}}"); - dispatcherImpl->Stop(request); + msg = std::string() + R"({"id":0,"method":"Profiler.stop","params":{}})"; + DispatchRequest request1 = DispatchRequest(msg); + dispatcherImpl->Dispatch(request1); if (channel) { delete channel; channel = nullptr; @@ -265,9 +267,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplStop) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.stop","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->Stop(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -283,13 +285,13 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplSetSamplingInterval) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.setSamplingInterval","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->SetSamplingInterval(request); + dispatcherImpl->Dispatch(request); ASSERT_TRUE(result.find("wrong params") != std::string::npos); - msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"interval":24}})"; + msg = std::string() + R"({"id":0,"method":"Profiler.setSamplingInterval","params":{"interval":24}})"; DispatchRequest request1(msg); - dispatcherImpl->SetSamplingInterval(request1); + dispatcherImpl->Dispatch(request1); if (channel) { delete channel; channel = nullptr; @@ -305,9 +307,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplGetBestEffortCoverage) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.getBestEffortCoverage","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->GetBestEffortCoverage(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -323,9 +325,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplStopPreciseCoverage) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.stopPreciseCoverage","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->StopPreciseCoverage(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -341,9 +343,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplTakePreciseCoverage) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.takePreciseCoverage","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->TakePreciseCoverage(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -359,9 +361,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplStartPreciseCoverage) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.startPreciseCoverage","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->StartPreciseCoverage(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -377,9 +379,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplStartTypeProfile) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.startTypeProfile","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->StartTypeProfile(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -395,9 +397,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplStopTypeProfile) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.stopTypeProfile","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->StopTypeProfile(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -413,9 +415,9 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplTakeTypeProfile) ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); auto tracing = std::make_unique(ecmaVm, channel); auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); - std::string msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})"; + std::string msg = std::string() + R"({"id":0,"method":"Profiler.takeTypeProfile","params":{}})"; DispatchRequest request(msg); - dispatcherImpl->TakeTypeProfile(request); + dispatcherImpl->Dispatch(request); if (channel) { delete channel; channel = nullptr; @@ -423,6 +425,46 @@ HWTEST_F_L0(ProfilerImplTest, DispatcherImplTakeTypeProfile) ASSERT_TRUE(result.find("TakeTypeProfile not support now") != std::string::npos); } +HWTEST_F_L0(ProfilerImplTest, DispatcherImplDisableSerializationTimeoutCheck) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) { result = temp; }; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, channel); + auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); + std::string msg = std::string() + R"({"id":0,"method":"Profiler.disableSerializationTimeoutCheck","params":{}})"; + DispatchRequest request(msg); + dispatcherImpl->Dispatch(request); + if (channel) { + delete channel; + channel = nullptr; + } + ASSERT_TRUE(result == "{\"id\":0,\"result\":{}}"); +} + +HWTEST_F_L0(ProfilerImplTest, DispatcherImplEnableSerializationTimeoutCheck) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) { result = temp; }; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, channel); + auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); + std::string msg = std::string() + R"({"id":0,"method":"Profiler.enableSerializationTimeoutCheck","params":{}})"; + DispatchRequest request(msg); + dispatcherImpl->Dispatch(request); + ASSERT_TRUE(result.find("wrong params") != std::string::npos); + msg = std::string() + R"({"id":0,"method":"Profiler.enableSerializationTimeoutCheck","params":{"threshold": 5}})"; + DispatchRequest request1(msg); + dispatcherImpl->Dispatch(request1); + if (channel) { + delete channel; + channel = nullptr; + } + ASSERT_TRUE(result == "{\"id\":0,\"result\":{}}"); +} + HWTEST_F_L0(ProfilerImplTest, FrontendPreciseCoverageDeltaUpdate) { std::string result = ""; diff --git a/tooling/test/pt_types_test.cpp b/tooling/test/pt_types_test.cpp index 02c2e543..2ec83070 100644 --- a/tooling/test/pt_types_test.cpp +++ b/tooling/test/pt_types_test.cpp @@ -901,4 +901,128 @@ HWTEST_F_L0(PtTypesTest, SamplingHeapProfileTransferHead) int32_t columnNumber = callFrame->GetColumnNumber(); ASSERT_TRUE(columnNumber == allocationNode.callFrameInfo_.columnNumber_); } + +HWTEST_F_L0(PtTypesTest, DescriptionForObjectTest) +{ + Local weakmap = WeakMapRef::New(ecmaVm); + std::string description = ObjectRemoteObject::DescriptionForObject(ecmaVm, weakmap); + ASSERT_TRUE(description.find("WeakMap") != std::string::npos); + + Local map = MapRef::New(ecmaVm); + Local mapiterator = MapIteratorRef::New(ecmaVm, map); + description = ObjectRemoteObject::DescriptionForObject(ecmaVm, mapiterator); + ASSERT_TRUE(description.find("MapIterator") != std::string::npos); + + Local set = SetRef::New(ecmaVm); + Local setiterator = SetIteratorRef::New(ecmaVm, set); + description = ObjectRemoteObject::DescriptionForObject(ecmaVm, setiterator); + ASSERT_TRUE(description.find("SetIterator") != std::string::npos); + + size_t size = 10; + Local nativepointer = NativePointerRef::New(ecmaVm, ecmaVm, size); + description = ObjectRemoteObject::DescriptionForObject(ecmaVm, nativepointer); + std::cout << description << std::endl; + ASSERT_TRUE(description.find("External") != std::string::npos); +} + +HWTEST_F_L0(PtTypesTest, FromTaggedTest) +{ + double input = 123456789.0; + Local date = DateRef::New(ecmaVm, input); + std::unique_ptr remoteObject = RemoteObject::FromTagged(ecmaVm, date); + std::string description = remoteObject->GetDescription(); + ASSERT_TRUE(description.find("GMT") != std::string::npos); + + Local weakmap = WeakMapRef::New(ecmaVm); + remoteObject = RemoteObject::FromTagged(ecmaVm, weakmap); + description = remoteObject->GetDescription(); + ASSERT_TRUE(description.find("WeakMap") != std::string::npos); + + Local map = MapRef::New(ecmaVm); + Local mapiterator = MapIteratorRef::New(ecmaVm, map); + remoteObject = RemoteObject::FromTagged(ecmaVm, mapiterator); + description = remoteObject->GetDescription(); + ASSERT_TRUE(description.find("MapIterator") != std::string::npos); + + Local set = SetRef::New(ecmaVm); + Local setiterator = SetIteratorRef::New(ecmaVm, set); + remoteObject = RemoteObject::FromTagged(ecmaVm, setiterator); + description = remoteObject->GetDescription(); + ASSERT_TRUE(description.find("SetIterator") != std::string::npos); + + Local capability = PromiseCapabilityRef::New(ecmaVm); + Local promise = capability->GetPromise(ecmaVm); + remoteObject = RemoteObject::FromTagged(ecmaVm, promise); + description = remoteObject->GetDescription(); + ASSERT_TRUE(description.find("Promise") != std::string::npos); + + size_t size = 10; + Local nativepointer = NativePointerRef::New(ecmaVm, ecmaVm, size); + remoteObject = RemoteObject::FromTagged(ecmaVm, nativepointer); + description = remoteObject->GetDescription(); + ASSERT_TRUE(description.find("External") != std::string::npos); +} + +HWTEST_F_L0(PtTypesTest, NativeRangeCreateTest) +{ + std::string msg; + std::unique_ptr nativeRange; + + msg = std::string() + R"({})"; + nativeRange = NativeRange::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(nativeRange, nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"start":20,"end":40}})"; + nativeRange = NativeRange::Create(DispatchRequest(msg).GetParams()); + ASSERT_TRUE(nativeRange != nullptr); +} + +HWTEST_F_L0(PtTypesTest, BreakpointInfoCreateTest) +{ + std::string msg; + std::unique_ptr breakpointInfo; + + msg = std::string() + R"({})"; + breakpointInfo = BreakpointInfo::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(breakpointInfo, nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"condition":"Test","urlRegex":"Test"}})"; + breakpointInfo = BreakpointInfo::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(breakpointInfo, nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test", + "params":{"scriptHash":"Test", "restrictToFunction": true}})"; + breakpointInfo = BreakpointInfo::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(breakpointInfo, nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"lineNumber":1,"columnNumber":2,"url":"Test", + "condition":"Test", "urlRegex":"Test", "scriptHash":"Test", "restrictToFunction": true}})"; + breakpointInfo = BreakpointInfo::Create(DispatchRequest(msg).GetParams()); + std::unique_ptr resultJson = breakpointInfo->ToJson(); + ASSERT_TRUE(resultJson != nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test", + "params":{"lineNumber":1, "columnNumber":2, "url":"Test"}})"; + breakpointInfo = BreakpointInfo::Create(DispatchRequest(msg).GetParams()); + resultJson = breakpointInfo->ToJson(); + ASSERT_TRUE(resultJson != nullptr); +} + +HWTEST_F_L0(PtTypesTest, BreakpointReturnInfoCreateTest) +{ + std::string msg; + std::unique_ptr breakpointReturnInfo; + + msg = std::string() + R"({})"; + breakpointReturnInfo = BreakpointReturnInfo::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(breakpointReturnInfo, nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"lineNumber":20,"columnNumber":40}})"; + breakpointReturnInfo = BreakpointReturnInfo::Create(DispatchRequest(msg).GetParams()); + ASSERT_TRUE(breakpointReturnInfo != nullptr); + + msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"id":"Test","scriptId":5}})"; + breakpointReturnInfo = BreakpointReturnInfo::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(breakpointReturnInfo, nullptr); +} } // namespace panda::test -- Gitee From fe54a38bce094bf409a687ad72d69f9fd45ed1af Mon Sep 17 00:00:00 2001 From: lixiaoyan Date: Fri, 9 Aug 2024 11:23:16 +0800 Subject: [PATCH 12/33] Add switch enable-rm Issue: IAHTXE Signed-off-by: lixiaoyan Change-Id: Id2b7be09a99f358119dc19f7c24665424d28025c --- build/compile_script/ark.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index 4da2ce07..ce690347 100755 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -481,10 +481,10 @@ class ArkPy: test_script_name, test_script_path) else: cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ - " --libs-dir ../../{1}/lib.unstripped/arkcompiler/ets_runtime" \ - ":../../{1}/lib.unstripped/thirdparty/icu" \ + " --libs-dir ../../{1}/arkcompiler/ets_runtime" \ + ":../../{1}/thirdparty/icu" \ ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - ":../../{1}/lib.unstripped/thirdparty/bounds_checking_function/" \ + ":../../{1}/thirdparty/bounds_checking_function/" \ " --run-baseline-jit" \ " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ @@ -508,6 +508,11 @@ class ArkPy: if threads_value: args_to_test262_cmd.extend([threads_name, threads_value]) + enable_rm = [arg for arg in arg_list if "enable-rm" in arg] + if enable_rm: + args_to_test262_cmd.append("--enable-rm") + arg_list.remove(enable_rm[0]) + if len(arg_list) == 0: args_to_test262_cmd.append("--es2021 all") elif len(arg_list) == 1: @@ -704,7 +709,8 @@ class ArkPy: " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --aot] " \ "[none or --pgo] [none or --litecg] [none, file or dir] [none or --threads=X] [option]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --jit] [none or --threads=X]\033[0m\n" - " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --baseline-jit] [none or --threads=X]\033[0m\n" + " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --baseline-jit] [none or --enable-rm] " \ + "[none or --threads=X]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [unittest] [option]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [regresstest] [none, file or dir] " \ "[none or --processes X and/or --test-list TEST_LIST_NAME]\033[0m\n") @@ -718,7 +724,7 @@ class ArkPy: " python3 ark.py \033[92mx64.release test262 --threads=16\033[0m\n" " python3 ark.py \033[92mx64.release test262 --aot --pgo --litecg\033[0m\n" " python3 ark.py \033[92mx64.release test262 --aot --pgo --litecg --threads=8\033[0m\n" - " python3 ark.py \033[92mx64.release test262 --jit\033[0m\n" + " python3 ark.py \033[92mx64.release test262 --jit --enable-rm\033[0m\n" " python3 ark.py \033[92mx64.release test262 --baseline-jit\033[0m\n" " python3 ark.py \033[92mx64.release test262 built-ins/Array\033[0m\n" " python3 ark.py \033[92mx64.release test262 built-ins/Array/name.js\033[0m\n" -- Gitee From 1be278a9f3a69be4d2cf7ecb14874b29c33ce593 Mon Sep 17 00:00:00 2001 From: bigtea Date: Tue, 13 Aug 2024 15:28:45 +0800 Subject: [PATCH 13/33] Fix static variable multithreading issue Issue: IAJP7E Signed-off-by: bigtea --- tooling/backend/js_pt_hooks.cpp | 3 +-- tooling/backend/js_pt_hooks.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tooling/backend/js_pt_hooks.cpp b/tooling/backend/js_pt_hooks.cpp index bcb05660..a54aa068 100644 --- a/tooling/backend/js_pt_hooks.cpp +++ b/tooling/backend/js_pt_hooks.cpp @@ -83,8 +83,7 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr [[maybe_unused]] LocalScope scope(debugger_->vm_); - static uint32_t scriptId = 0; - if (debugger_->NotifyScriptParsed(scriptId++, pandaFileName.data(), entryPoint)) { + if (debugger_->NotifyScriptParsed(g_scriptId++, pandaFileName.data(), entryPoint)) { firstTime_ = true; } } diff --git a/tooling/backend/js_pt_hooks.h b/tooling/backend/js_pt_hooks.h index cb5f7726..62c52cf9 100644 --- a/tooling/backend/js_pt_hooks.h +++ b/tooling/backend/js_pt_hooks.h @@ -25,6 +25,8 @@ namespace panda::ecmascript::tooling { class DebuggerImpl; +static std::atomic g_scriptId {0}; + class JSPtHooks : public PtHooks { public: explicit JSPtHooks(DebuggerImpl *debugger) : debugger_(debugger) {} -- Gitee From c7ed422b1f019957f3892f5ccac2f958a8e8fbde Mon Sep 17 00:00:00 2001 From: swx1282997 Date: Tue, 13 Aug 2024 18:19:10 +0800 Subject: [PATCH 14/33] Coverage supplement Supplement the coverage of the pt_json pt_returns pt_params debugger_service Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAJNH4 Signed-off-by: swx1282997 --- tooling/test/debugger_service_test.cpp | 15 +++++++++++++ tooling/test/pt_json_test.cpp | 31 ++++++++++++++++++++++++++ tooling/test/pt_params_test.cpp | 24 ++++++++++++++++++++ tooling/test/pt_returns_test.cpp | 14 ++++++++++++ 4 files changed, 84 insertions(+) diff --git a/tooling/test/debugger_service_test.cpp b/tooling/test/debugger_service_test.cpp index 694f0599..68b8796f 100644 --- a/tooling/test/debugger_service_test.cpp +++ b/tooling/test/debugger_service_test.cpp @@ -59,6 +59,9 @@ HWTEST_F_L0(DebuggerServiceTest, InitializeDebuggerTest) ASSERT_TRUE(handler != nullptr); InitializeDebugger(ecmaVm, nullptr); ASSERT_TRUE(handler != nullptr); + EcmaVM *vm = nullptr; + InitializeDebugger(vm, nullptr); + ASSERT_TRUE(handler != nullptr); } HWTEST_F_L0(DebuggerServiceTest, UninitializeDebuggerTest) @@ -70,6 +73,9 @@ HWTEST_F_L0(DebuggerServiceTest, UninitializeDebuggerTest) UninitializeDebugger(ecmaVm); handler = ecmaVm->GetJsDebuggerManager()->GetDebuggerHandler(); ASSERT_TRUE(handler == nullptr); + EcmaVM *vm = nullptr; + UninitializeDebugger(vm); + ASSERT_TRUE(handler == nullptr); } HWTEST_F_L0(DebuggerServiceTest, OnMessageTest) @@ -85,6 +91,9 @@ HWTEST_F_L0(DebuggerServiceTest, OnMessageTest) OnMessage(ecmaVm, msg + ""); ProcessMessage(ecmaVm); ASSERT_TRUE(result.find("Unknown method: Test") != std::string::npos); + EcmaVM *vm = nullptr; + OnMessage(vm, ""); + ASSERT_TRUE(result.find("Unknown method: Test") != std::string::npos); } HWTEST_F_L0(DebuggerServiceTest, WaitForDebuggerTest) @@ -107,6 +116,9 @@ HWTEST_F_L0(DebuggerServiceTest, ProcessMessageTest) OnMessage(ecmaVm, msg + ""); ProcessMessage(ecmaVm); ASSERT_TRUE(result.find("\"id\":0,") != std::string::npos); + EcmaVM *vm = nullptr; + ProcessMessage(vm); + ASSERT_TRUE(result.find("Stop is failure") != std::string::npos); } HWTEST_F_L0(DebuggerServiceTest, GetDispatchStatusTest) @@ -119,5 +131,8 @@ HWTEST_F_L0(DebuggerServiceTest, GetDispatchStatusTest) InitializeDebugger(ecmaVm, callback); status = ProtocolHandler::DispatchStatus(GetDispatchStatus(ecmaVm)); ASSERT_TRUE(status == ProtocolHandler::DispatchStatus::DISPATCHED); + EcmaVM *vm = nullptr; + int32_t GetDispatchStatusTest = GetDispatchStatus(vm); + ASSERT_TRUE(GetDispatchStatusTest == 0); } } // namespace panda::test \ No newline at end of file diff --git a/tooling/test/pt_json_test.cpp b/tooling/test/pt_json_test.cpp index 9157a8e0..9f42e46a 100644 --- a/tooling/test/pt_json_test.cpp +++ b/tooling/test/pt_json_test.cpp @@ -282,4 +282,35 @@ HWTEST_F_L0(PtJsonTest, AddTest) result = ptJson.Add(key, value2); ASSERT_EQ(result, false); } + +HWTEST_F_L0(PtJsonTest, UIntTest) +{ + std::string str = "UIntTest"; + std::unique_ptr json = PtJson::Parse(str.c_str()); + EXPECT_EQ(json->GetUInt(), 0); + str = "12345"; + json = PtJson::Parse(str.c_str()); + EXPECT_EQ(json->GetUInt(), 12345); +} + +HWTEST_F_L0(PtJsonTest, UInt64Test) +{ + std::string str = "UInt64Test"; + std::unique_ptr json = PtJson::Parse(str.c_str()); + EXPECT_EQ(json->GetUInt64(), 0); + str = "123456789012345"; + json = PtJson::Parse(str.c_str()); + EXPECT_EQ(json->GetUInt64(), 123456789012345); +} + +HWTEST_F_L0(PtJsonTest, ResultUInt64Test) +{ + auto test = PtJson::CreateObject(); + test->Add("a", "ResultUInt64Test"); + test->Add("b", 100); + uint64_t ui64; + ASSERT_EQ(test->GetUInt64("a", &ui64), Result::TYPE_ERROR); + ASSERT_EQ(test->GetUInt64("b", &ui64), Result::SUCCESS); + EXPECT_EQ(ui64, static_cast(100)); +} } \ No newline at end of file diff --git a/tooling/test/pt_params_test.cpp b/tooling/test/pt_params_test.cpp index 1ac83cfc..414158da 100644 --- a/tooling/test/pt_params_test.cpp +++ b/tooling/test/pt_params_test.cpp @@ -244,4 +244,28 @@ HWTEST_F_L0(PtParamsTest, StartParamsCreateTest) std::unique_ptr result1 = StartParams::Create(*ptJson1); ASSERT_TRUE(result1 == nullptr); } + +HWTEST_F_L0(PtParamsTest, AddRequireParamsTest) +{ + std::string msg; + std::unique_ptr smartStepIntoParams; + + msg = std::string() + R"({})"; + smartStepIntoParams = SmartStepIntoParams::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(smartStepIntoParams, nullptr); +} + +HWTEST_F_L0(PtParamsTest, SeriliazationTimeoutCheckEnableParamsCreateTest) +{ + std::string msg; + std::unique_ptr seriliazationParams; + + msg = std::string() + R"({})"; + seriliazationParams = SeriliazationTimeoutCheckEnableParams::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(seriliazationParams, nullptr); + + msg = std::string() + R"({"id":0,"method":"PtParams.Test","params":{"threshold":2}})"; + seriliazationParams = SeriliazationTimeoutCheckEnableParams::Create(DispatchRequest(msg).GetParams()); + ASSERT_TRUE(seriliazationParams != nullptr); +} } // namespace panda::test \ No newline at end of file diff --git a/tooling/test/pt_returns_test.cpp b/tooling/test/pt_returns_test.cpp index 5ab02806..017ef1e6 100644 --- a/tooling/test/pt_returns_test.cpp +++ b/tooling/test/pt_returns_test.cpp @@ -282,4 +282,18 @@ HWTEST_F_L0(PtReturnsTest, GetCategoriesReturns) ASSERT_NE(json, nullptr); EXPECT_EQ(json->GetSize(), 1); } + +HWTEST_F_L0(PtReturnsTest, GetHeapUsageReturnsCreateTest) +{ + std::string msg; + std::unique_ptr heapUsageReturns; + + msg = std::string() + R"({})"; + heapUsageReturns = GetHeapUsageReturns::Create(DispatchRequest(msg).GetParams()); + EXPECT_EQ(heapUsageReturns, nullptr); + + msg = std::string() + R"({"id":0,"method":"PtReturns.Test","params":{"usedSize":20,"totalSize":20}})"; + heapUsageReturns = GetHeapUsageReturns::Create(DispatchRequest(msg).GetParams()); + ASSERT_TRUE(heapUsageReturns != nullptr); +} } \ No newline at end of file -- Gitee From a1740c61dabf654a000e2911cd7d54c941d86c9d Mon Sep 17 00:00:00 2001 From: duning Date: Wed, 14 Aug 2024 15:18:47 +0800 Subject: [PATCH 15/33] add testcase add testcase Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAAHIB Signed-off-by: duning Change-Id: I9d69f06f3fd6c2f6a0c2f38caeaac07832ff4e3b --- tooling/agent/debugger_impl.h | 1 + tooling/agent/heapprofiler_impl.h | 2 + tooling/test/debugger_impl_test.cpp | 242 ++++++++++++++++++++++++ tooling/test/heapprofiler_impl_test.cpp | 161 ++++++++++++++++ 4 files changed, 406 insertions(+) diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 153f5d8f..61786a22 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -327,6 +327,7 @@ private: friend class JSPtHooks; friend class test::TestHooks; + friend class DebuggerImplFriendTest; }; } // namespace panda::ecmascript::tooling #endif \ No newline at end of file diff --git a/tooling/agent/heapprofiler_impl.h b/tooling/agent/heapprofiler_impl.h index b3cd4695..d0314759 100644 --- a/tooling/agent/heapprofiler_impl.h +++ b/tooling/agent/heapprofiler_impl.h @@ -197,6 +197,8 @@ private: #if defined(ECMASCRIPT_SUPPORT_HEAPPROFILER) uv_timer_t handle_ {}; #endif + + friend class HeapProfilerImplFriendTest; }; } // namespace panda::ecmascript::tooling #endif diff --git a/tooling/test/debugger_impl_test.cpp b/tooling/test/debugger_impl_test.cpp index 3367e691..69702164 100644 --- a/tooling/test/debugger_impl_test.cpp +++ b/tooling/test/debugger_impl_test.cpp @@ -20,6 +20,37 @@ using namespace panda::ecmascript; using namespace panda::ecmascript::tooling; +namespace panda::ecmascript::tooling { +class DebuggerImplFriendTest { +public: + explicit DebuggerImplFriendTest(std::unique_ptr &debuggerImpl) + { + debuggerImpl_ = std::move(debuggerImpl); + } + + void CheckAndGenerateCondFunc(const std::optional condition) + { + debuggerImpl_->CheckAndGenerateCondFunc(condition); + } + + Local ConvertToLocal(const std::string &varValue) + { + return debuggerImpl_->ConvertToLocal(varValue); + } + + bool GetMixStackEnabled() + { + return debuggerImpl_->mixStackEnabled_; + } + + bool DecodeAndCheckBase64(const std::string &src, std::vector &dest) + { + return debuggerImpl_->DecodeAndCheckBase64(src, dest); + } +private: + std::unique_ptr debuggerImpl_; +}; +} namespace panda::test { class DebuggerImplTest : public testing::Test { @@ -74,6 +105,28 @@ HWTEST_F_L0(DebuggerImplTest, NotifyScriptParsed__001) } } +HWTEST_F_L0(DebuggerImplTest, NotifyScriptParsed__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + ecmaVm->GetJsDebuggerManager()->SetIsDebugApp(true); + ecmaVm->GetJsDebuggerManager()->SetDebugMode(true); + // DebuggerImpl::NotifyScriptParsed -- fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH + std::string strFilename = ""; + EXPECT_FALSE(debuggerImpl->NotifyScriptParsed(0, strFilename, "")); + ecmaVm->GetJsDebuggerManager()->SetIsDebugApp(false); + ecmaVm->GetJsDebuggerManager()->SetDebugMode(false); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + HWTEST_F_L0(DebuggerImplTest, GenerateCallFrames__001) { } @@ -1566,4 +1619,193 @@ HWTEST_F_L0(DebuggerImplTest, NativeOutTest) ASSERT_TRUE(result2); ASSERT_NE(jspthooks, nullptr); } + +HWTEST_F_L0(DebuggerImplTest, NotifyNativeReturn__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + std::unique_ptr json = PtJson::CreateObject(); + json->Add("enabled", false); + json->Add("mixedStackEnabled", false); + std::unique_ptr params = SetMixedDebugParams::Create(*json); + debuggerImpl->SetMixedDebugEnabled(*params); + debuggerImpl->NotifyNativeReturn(nullptr); + auto debugger = std::make_unique(debuggerImpl); + ASSERT_TRUE(!debugger->GetMixStackEnabled()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, NotifyNativeReturn__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + std::unique_ptr json = PtJson::CreateObject(); + json->Add("enabled", false); + json->Add("mixedStackEnabled", true); + std::unique_ptr params = SetMixedDebugParams::Create(*json); + debuggerImpl->SetMixedDebugEnabled(*params); + debuggerImpl->NotifyNativeReturn(nullptr); + auto debugger = std::make_unique(debuggerImpl); + ASSERT_TRUE(debugger->GetMixStackEnabled()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, NotifyReturnNative__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + std::unique_ptr json = PtJson::CreateObject(); + json->Add("enabled", false); + json->Add("mixedStackEnabled", true); + std::unique_ptr params = SetMixedDebugParams::Create(*json); + debuggerImpl->SetMixedDebugEnabled(*params); + debuggerImpl->NotifyReturnNative(); + auto debugger = std::make_unique(debuggerImpl); + ASSERT_TRUE(debugger->GetMixStackEnabled()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, NotifyReturnNative__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + std::unique_ptr json = PtJson::CreateObject(); + json->Add("enabled", false); + json->Add("mixedStackEnabled", false); + std::unique_ptr params = SetMixedDebugParams::Create(*json); + debuggerImpl->SetMixedDebugEnabled(*params); + debuggerImpl->NotifyReturnNative(); + auto debugger = std::make_unique(debuggerImpl); + ASSERT_TRUE(!debugger->GetMixStackEnabled()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, NotifyNativeCalling__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + std::unique_ptr json = PtJson::CreateObject(); + json->Add("enabled", false); + json->Add("mixedStackEnabled", false); + std::unique_ptr params = SetMixedDebugParams::Create(*json); + debuggerImpl->SetMixedDebugEnabled(*params); + debuggerImpl->NotifyNativeCalling(nullptr); + auto debugger = std::make_unique(debuggerImpl); + ASSERT_TRUE(!debugger->GetMixStackEnabled()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, NotifyNativeCalling__002) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + std::unique_ptr json = PtJson::CreateObject(); + json->Add("enabled", false); + json->Add("mixedStackEnabled", true); + std::unique_ptr params = SetMixedDebugParams::Create(*json); + debuggerImpl->SetMixedDebugEnabled(*params); + debuggerImpl->NotifyNativeCalling(nullptr); + auto debugger = std::make_unique(debuggerImpl); + ASSERT_TRUE(debugger->GetMixStackEnabled()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + +HWTEST_F_L0(DebuggerImplTest, CheckAndGenerateCondFunc__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto debugger = std::make_unique(debuggerImpl); + std::vector dest; + debugger->CheckAndGenerateCondFunc(""); + ASSERT_TRUE(!debugger->DecodeAndCheckBase64("", dest)); + std::string msg = "UEFOREEAAAAAAAAADAACAEgBAAAAAAAAAAAAAAIAAAA8AAAAAQAA"; + msg += "AEQBAAAAAAARAAAAAEAAABEAAAAkQAAAMQAAAB8AAAASAEAAAIAAABsAAAAAgAAAHQAAAD//////////"; + debugger->CheckAndGenerateCondFunc(msg); + ASSERT_TRUE(debugger->DecodeAndCheckBase64(msg, dest)); +} + +HWTEST_F_L0(DebuggerImplTest, ConvertToLocal__001) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto debugger = std::make_unique(debuggerImpl); + Local taggedValue = debugger->ConvertToLocal(""); + ASSERT_TRUE(!taggedValue.IsEmpty()); + taggedValue = debugger->ConvertToLocal("false"); + ASSERT_TRUE(!taggedValue.IsEmpty()); + taggedValue = debugger->ConvertToLocal("true"); + ASSERT_TRUE(!taggedValue.IsEmpty()); + taggedValue = debugger->ConvertToLocal("undefined"); + ASSERT_TRUE(!taggedValue.IsEmpty()); + taggedValue = debugger->ConvertToLocal("\"test\""); + ASSERT_TRUE(!taggedValue.IsEmpty()); + taggedValue = debugger->ConvertToLocal("test"); + ASSERT_TRUE(taggedValue.IsEmpty()); + taggedValue = debugger->ConvertToLocal("1"); + ASSERT_TRUE(!taggedValue.IsEmpty()); +} } // namespace panda::test diff --git a/tooling/test/heapprofiler_impl_test.cpp b/tooling/test/heapprofiler_impl_test.cpp index b847cd83..80a2cb45 100644 --- a/tooling/test/heapprofiler_impl_test.cpp +++ b/tooling/test/heapprofiler_impl_test.cpp @@ -19,6 +19,42 @@ using namespace panda::ecmascript; using namespace panda::ecmascript::tooling; +namespace panda::ecmascript::tooling { +class HeapProfilerImplFriendTest { +public: + explicit HeapProfilerImplFriendTest(std::unique_ptr &heapprofilerImpl) + { + heapprofilerImpl_ = std::move(heapprofilerImpl); + } + + void ResetProfiles() + { + heapprofilerImpl_->frontend_.ResetProfiles(); + } + + void LastSeenObjectId(int32_t lastSeenObjectId, int64_t timeStampUs) + { + heapprofilerImpl_->frontend_.LastSeenObjectId(lastSeenObjectId, timeStampUs); + } + + void HeapStatsUpdate(HeapStat* updateData, int32_t count) + { + heapprofilerImpl_->frontend_.HeapStatsUpdate(updateData, count); + } + + void AddHeapSnapshotChunk(char *data, int32_t size) + { + heapprofilerImpl_->frontend_.AddHeapSnapshotChunk(data, size); + } + + void ReportHeapSnapshotProgress(int32_t done, int32_t total) + { + heapprofilerImpl_->frontend_.ReportHeapSnapshotProgress(done, total); + } +private: + std::unique_ptr heapprofilerImpl_; +}; +} namespace panda::test { class HeapProfilerImplTest : public testing::Test { @@ -409,4 +445,129 @@ HWTEST_F_L0(HeapProfilerImplTest, StopSamplingSuccessful) DispatchResponse result = heapProfiler->StopSampling(&samplingHeapProfile); ASSERT_TRUE(result.IsOk()); } + +HWTEST_F_L0(HeapProfilerImplTest, StartTrackingHeapObjects) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, channel); + auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); + std::string msg = ""; + msg += R"({"id":0,"method":"HeapProfiler.StartTrackingHeapObjects","params":{"trackAllocations":0}})"; + DispatchRequest request1(msg); + dispatcherImpl->StartTrackingHeapObjects(request1); + ASSERT_TRUE(result == "{\"id\":0,\"result\":{\"code\":1,\"message\":\"wrong params\"}}"); + if (channel) { + delete channel; + channel = nullptr; + } +} + +HWTEST_F_L0(HeapProfilerImplTest, StopTrackingHeapObjects) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, channel); + auto dispatcherImpl = std::make_unique(channel, std::move(tracing)); + std::string msg = ""; + msg += R"({"id":0,"method":"HeapProfiler.StopTrackingHeapObjects","params":{"reportProgress":0}})"; + DispatchRequest request1(msg); + dispatcherImpl->StopTrackingHeapObjects(request1); + ASSERT_TRUE(result == "{\"id\":0,\"result\":{\"code\":1,\"message\":\"wrong params\"}}"); + if (channel) { + delete channel; + channel = nullptr; + } +} + +HWTEST_F_L0(HeapProfilerImplTest, ResetProfiles) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, nullptr); + auto heapprofiler = std::make_unique(tracing); + heapprofiler->ResetProfiles(); + ASSERT_TRUE(result == ""); + tracing = std::make_unique(ecmaVm, channel); + heapprofiler = std::make_unique(tracing); + heapprofiler->ResetProfiles(); + ASSERT_TRUE(result == ""); + if (channel) { + delete channel; + channel = nullptr; + } +} + +HWTEST_F_L0(HeapProfilerImplTest, LastSeenObjectId) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, nullptr); + auto heapprofiler = std::make_unique(tracing); + heapprofiler->LastSeenObjectId(0, 0); + ASSERT_TRUE(result == ""); + tracing = std::make_unique(ecmaVm, channel); + heapprofiler = std::make_unique(tracing); + heapprofiler->LastSeenObjectId(0, 0); + std::string msg = "{\"method\":\"HeapProfiler.lastSeenObjectId\","; + msg += "\"params\":{\"lastSeenObjectId\":0,"; + msg += "\"timestamp\":0}}"; + ASSERT_TRUE(result == msg); + if (channel) { + delete channel; + channel = nullptr; + } +} + +HWTEST_F_L0(HeapProfilerImplTest, HeapStatsUpdate) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + ProtocolChannel *channel = new ProtocolHandler(callback, ecmaVm); + auto tracing = std::make_unique(ecmaVm, nullptr); + auto heapprofiler = std::make_unique(tracing); + heapprofiler->HeapStatsUpdate(nullptr, 0); + ASSERT_TRUE(result == ""); + tracing = std::make_unique(ecmaVm, channel); + heapprofiler = std::make_unique(tracing); + heapprofiler->HeapStatsUpdate(nullptr, 0); + std::string msg = "{\"method\":\"HeapProfiler.heapStatsUpdate\","; + msg += "\"params\":{\"statsUpdate\":[]}}"; + ASSERT_TRUE(result == msg); + if (channel) { + delete channel; + channel = nullptr; + } +} + +HWTEST_F_L0(HeapProfilerImplTest, AddHeapSnapshotChunk) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + auto tracing = std::make_unique(ecmaVm, nullptr); + auto heapprofiler = std::make_unique(tracing); + heapprofiler->AddHeapSnapshotChunk(nullptr, 0); + ASSERT_TRUE(result == ""); +} + +HWTEST_F_L0(HeapProfilerImplTest, ReportHeapSnapshotProgress) +{ + std::string result = ""; + std::function callback = + [&result]([[maybe_unused]] const void *ptr, const std::string &temp) {result = temp;}; + auto tracing = std::make_unique(ecmaVm, nullptr); + auto heapprofiler = std::make_unique(tracing); + heapprofiler->ReportHeapSnapshotProgress(0, 0); + ASSERT_TRUE(result == ""); +} } // namespace panda::test -- Gitee From 1e74cf2324db8811785e9363115fd475bcb5438e Mon Sep 17 00:00:00 2001 From: yanzhiqi1 Date: Wed, 14 Aug 2024 10:45:27 +0800 Subject: [PATCH 16/33] Fix traceconfig::create Fix traceconfig::create Issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAJVUA Signed-off-by: yanzhiqi1 --- tooling/base/pt_types.cpp | 5 +++- tooling/test/pt_types_test.cpp | 42 +++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/tooling/base/pt_types.cpp b/tooling/base/pt_types.cpp index 6d44cf8e..c000ff3f 100644 --- a/tooling/base/pt_types.cpp +++ b/tooling/base/pt_types.cpp @@ -3086,7 +3086,7 @@ std::unique_ptr ScriptTypeProfile::Create(const PtJson ¶m std::string error; auto scriptTypeProfile = std::make_unique(); Result ret; - + std::string scriptId; ret = params.GetString("scriptId", &scriptId); if (ret == Result::SUCCESS) { @@ -3193,6 +3193,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) ret = params.GetArray("includedCategories", &includedCategories); if (ret == Result::SUCCESS) { int32_t includedCategoriesLen = includedCategories->GetSize(); + traceConfig->includedCategories_= std::vector(); for (int32_t i = 0; i < includedCategoriesLen; ++i) { std::string pIncludedCategories = includedCategories->Get(i)->GetString(); traceConfig->includedCategories_.value().emplace_back(pIncludedCategories); @@ -3205,6 +3206,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) ret = params.GetArray("excludedCategories", &excludedCategories); if (ret == Result::SUCCESS) { int32_t excludedCategoriesLen = excludedCategories->GetSize(); + traceConfig->excludedCategories_ = std::vector(); for (int32_t i = 0; i < excludedCategoriesLen; ++i) { std::string pExcludedCategories = excludedCategories->Get(i)->GetString(); traceConfig->excludedCategories_.value().emplace_back(pExcludedCategories); @@ -3217,6 +3219,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) ret = params.GetArray("syntheticDelays", &syntheticDelays); if (ret == Result::SUCCESS) { int32_t syntheticDelaysLen = syntheticDelays->GetSize(); + traceConfig->syntheticDelays_ = std::vector(); for (int32_t i = 0; i < syntheticDelaysLen; ++i) { std::string pSyntheticDelays = syntheticDelays->Get(i)->GetString(); traceConfig->syntheticDelays_.value().emplace_back(pSyntheticDelays); diff --git a/tooling/test/pt_types_test.cpp b/tooling/test/pt_types_test.cpp index 02c2e543..0421c447 100644 --- a/tooling/test/pt_types_test.cpp +++ b/tooling/test/pt_types_test.cpp @@ -309,12 +309,9 @@ HWTEST_F_L0(PtTypesTest, TraceConfigToJsonTest) std::unique_ptr result = treceConfig.ToJson(); ASSERT_TRUE(result); } + HWTEST_F_L0(PtTypesTest, TraceConfigCreateTest) { - std::unique_ptr includedCategoriesArray = PtJson::CreateArray(); - std::unique_ptr excludedCategoriesArray = PtJson::CreateArray(); - std::unique_ptr syntheticDelaysArray = PtJson::CreateArray(); - std::unique_ptr object = PtJson::CreateObject(); std::string attribute = "test"; std::unique_ptr ptJson = PtJson::CreateObject(); ptJson->Add("recordMode", 0); @@ -327,23 +324,42 @@ HWTEST_F_L0(PtTypesTest, TraceConfigCreateTest) ptJson->Add("memoryDumpConfig", attribute.c_str()); std::unique_ptr traceConfig = TraceConfig::Create(*ptJson); ASSERT_TRUE(!traceConfig); - object->Add("test", 0); + std::unique_ptr ptJson1 = PtJson::CreateObject(); - ptJson1->Add("includedCategories", includedCategoriesArray); - ptJson1->Add("recordMode", attribute.c_str()); - ptJson1->Add("excludedCategories", excludedCategoriesArray); - ptJson1->Add("syntheticDelays", syntheticDelaysArray); - ptJson1->Add("memoryDumpConfig", object); + ptJson1->Add("recordMode", "test"); std::unique_ptr traceConfig1 = TraceConfig::Create(*ptJson1); ASSERT_TRUE(!traceConfig1); + std::unique_ptr ptJson2 = PtJson::CreateObject(); std::unique_ptr traceConfig2 = TraceConfig::Create(*ptJson2); ASSERT_TRUE(traceConfig2); + + std::unique_ptr includedCategoriesArray = PtJson::CreateArray(); + includedCategoriesArray->Push("includedCategory"); + std::unique_ptr excludedCategoriesArray = PtJson::CreateArray(); + excludedCategoriesArray->Push("excludedCategory1"); + excludedCategoriesArray->Push("excludedCategory2"); + std::unique_ptr syntheticDelaysArray = PtJson::CreateArray(); + syntheticDelaysArray->Push("syntheticDelay1"); + syntheticDelaysArray->Push("syntheticDelay2"); + syntheticDelaysArray->Push("syntheticDelay3"); std::unique_ptr ptJson3 = PtJson::CreateObject(); - std::unique_ptr memoryDumpConfig = PtJson::CreateArray(); - ptJson3->Add("memoryDumpConfig", std::move(memoryDumpConfig)); + ptJson3->Add("recordMode", "recordUntilFull"); + ptJson3->Add("enableSampling", true); + ptJson3->Add("enableSystrace", true); + ptJson3->Add("enableArgumentFilter", true); + ptJson3->Add("includedCategories", includedCategoriesArray); + ptJson3->Add("excludedCategories", excludedCategoriesArray); + ptJson3->Add("syntheticDelays", syntheticDelaysArray); + ptJson3->Add("memoryDumpConfig", PtJson::CreateObject()); std::unique_ptr traceConfig3 = TraceConfig::Create(*ptJson3); - ASSERT_TRUE(!traceConfig3); + ASSERT_TRUE(traceConfig3); + ASSERT_TRUE(traceConfig3->GetEnableSampling()); + ASSERT_TRUE(traceConfig3->GetEnableSystrace()); + ASSERT_TRUE(traceConfig3->GetEnableArgumentFilter()); + ASSERT_EQ(traceConfig3->GetIncludedCategories()->size(), 1); + ASSERT_EQ(traceConfig3->GetExcludedCategories()->size(), 2); + ASSERT_EQ(traceConfig3->GetSyntheticDelays()->size(), 3); } HWTEST_F_L0(PtTypesTest, ScriptTypeProfileCreateTest) -- Gitee From 8f428375f564682d63cff36260a0e0f0b8c2bac4 Mon Sep 17 00:00:00 2001 From: Viktoria Shirunova Date: Sun, 11 Aug 2024 12:59:38 +0300 Subject: [PATCH 17/33] Ark.py: fix test262 jit issue Issue: IAJ85T Testing: all required pre-merge tests passed. results are available in the ggwatcher. Signed-off-by: viktoria shirunova Change-id: ie6c303efe66bb4b0a1b29af8b41fde667684380b --- build/compile_script/ark.py | 118 ++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index ce690347..b3372939 100755 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -390,18 +390,19 @@ class ArkPy: print("running test262 in AotMode\n") if any('target_cpu="arm64"' in arg for arg in gn_args): if run_pgo: - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {4}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu:" \ - "../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + test262_cmd = f"cd arkcompiler/ets_frontend && python3 test262/run_test262.py {args_to_test262_cmd}" \ + f" --timeout {timeout}" \ + f" --libs-dir ../../{out_path}/arkcompiler/ets_runtime:../../{out_path}/thirdparty/icu:" \ + f"../../{out_path}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ " --ark-arch aarch64" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ + f" --ark-arch-root=../../{out_path}/common/common/libc/" \ + f" --ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm" \ + f" --ark-aot-tool=../../{out_path}/arkcompiler/ets_runtime/ark_aot_compiler" \ + f" --ark-frontend-binary=../../{x64_out_path}/arkcompiler/ets_frontend/es2abc" \ + f" --merge-abc-binary=../../{x64_out_path}/arkcompiler/ets_frontend/merge_abc" \ " --ark-aot" \ " --ark-frontend=es2panda" \ - "{3}".format(args_to_test262_cmd, out_path, x64_out_path, " --run-pgo", timeout) + " --run-pgo" else: test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{2}/thirdparty/icu/" \ @@ -414,16 +415,18 @@ class ArkPy: " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout) else: - test262_cmd = "cd arkcompiler/ets_frontend && python3 test262/run_test262.py {0} --timeout {3}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu" \ - ":../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-aot-tool=../../{1}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ + run_pgo_arg = " --run-pgo" if run_pgo else "" + test262_cmd = f"cd arkcompiler/ets_frontend && python3 test262/run_test262.py {args_to_test262_cmd}" \ + f" --timeout {timeout}" \ + f" --libs-dir ../../{out_path}/arkcompiler/ets_runtime:../../{out_path}/thirdparty/icu" \ + f":../../{out_path}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + f" --ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm" \ + f" --ark-aot-tool=../../{out_path}/arkcompiler/ets_runtime/ark_aot_compiler" \ + f" --ark-frontend-binary=../../{out_path}/arkcompiler/ets_frontend/es2abc" \ + f" --merge-abc-binary=../../{out_path}/arkcompiler/ets_frontend/merge_abc" \ " --ark-aot" \ " --ark-frontend=es2panda" \ - "{2}".format(args_to_test262_cmd, out_path, " --run-pgo" if run_pgo else "", timeout) + f" {run_pgo_arg}" if enable_litecg: test262_cmd = test262_cmd + " --enable-litecg" return test262_cmd @@ -433,29 +436,27 @@ class ArkPy: timeout): print(f"running {test_suite} in JIT mode\n") if any('target_cpu="arm64"' in arg for arg in gn_args): - cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ - " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{1}/thirdparty/icu/" \ - ":../../{1}/thirdparty/bounds_checking_function" \ - ":../../{1}/arkcompiler/ets_runtime:" \ + cmd = f"cd {test_script_path} && python3 {test_script_name} {args_to_cmd} --timeout {timeout}" \ + f" --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib:../../{out_path}/thirdparty/icu/" \ + f":../../{out_path}/thirdparty/bounds_checking_function" \ + f":../../{out_path}/arkcompiler/ets_runtime:" \ " --ark-arch aarch64" \ " --run-jit" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_cmd, out_path, x64_out_path, timeout, - test_script_name, test_script_path) + f" --ark-arch-root=../../{out_path}/common/common/libc/" \ + f" --ark-aot-tool=../../{x64_out_path}/arkcompiler/ets_runtime/ark_aot_compiler" \ + f" --ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm" \ + f" --ark-frontend-binary=../../{x64_out_path}/arkcompiler/ets_frontend/es2abc" \ + f" --merge-abc-binary=../../{x64_out_path}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda" else: - cmd = "cd arkcompiler/ets_frontend && python3 {4} {0} --timeout {3}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime:../../{1}/thirdparty/icu" \ - ":../../{1}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + cmd = f"cd arkcompiler/ets_frontend && python3 {test_script_name} {args_to_cmd} --timeout {timeout}" \ + f" --libs-dir ../../{out_path}/arkcompiler/ets_runtime:../../{out_path}/thirdparty/icu" \ + f":../../{out_path}/thirdparty/zlib:../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ " --run-jit" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda" \ - "{2}".format(args_to_cmd, out_path, x64_out_path, timeout, test_script_name) + f" --ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm" \ + f" --ark-frontend-binary=../../{out_path}/arkcompiler/ets_frontend/es2abc" \ + f" --merge-abc-binary=../../{out_path}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda" return cmd @staticmethod @@ -463,35 +464,32 @@ class ArkPy: args_to_test262_cmd, timeout): print(f"running {test_suite} in baseline JIT mode\n") if any('target_cpu="arm64"' in arg for arg in gn_args): - cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ - " --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - ":../../{1}/thirdparty/icu" \ - ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos" \ - ":../../{1}/thirdparty/bounds_checking_function" \ - ":../../{1}/arkcompiler/ets_runtime" \ - ":../../{1}/common/common/libc/lib" \ + cmd = f"cd {test_script_path} && python3 {test_script_name} {args_to_test262_cmd} --timeout {timeout}" \ + f" --libs-dir ../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ + f":../../{out_path}/thirdparty/icu" \ + f":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos" \ + f":../../{out_path}/thirdparty/bounds_checking_function" \ + f":../../{out_path}/arkcompiler/ets_runtime" \ + f":../../{out_path}/common/common/libc/lib" \ " --ark-arch aarch64" \ " --run-baseline-jit" \ - " --ark-arch-root=../../{1}/common/common/libc/" \ - " --ark-aot-tool=../../{2}/arkcompiler/ets_runtime/ark_aot_compiler" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{2}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{2}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda".format(args_to_test262_cmd, out_path, x64_out_path, timeout, - test_script_name, test_script_path) + f" --ark-arch-root=../../{out_path}/common/common/libc/" \ + f" --ark-aot-tool=../../{x64_out_path}/arkcompiler/ets_runtime/ark_aot_compiler" \ + f" --ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm" \ + f" --ark-frontend-binary=../../{x64_out_path}/arkcompiler/ets_frontend/es2abc" \ + f" --merge-abc-binary=../../{x64_out_path}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda" else: - cmd = "cd {5} && python3 {4} {0} --timeout {3}" \ - " --libs-dir ../../{1}/arkcompiler/ets_runtime" \ - ":../../{1}/thirdparty/icu" \ + cmd = f"cd {test_script_path} && python3 {test_script_name} {args_to_test262_cmd} --timeout {timeout}" \ + f" --libs-dir ../../{out_path}/lib.unstripped/arkcompiler/ets_runtime" \ + f":../../{out_path}/thirdparty/icu" \ ":../../prebuilts/clang/ohos/linux-x86_64/llvm/lib" \ - ":../../{1}/thirdparty/bounds_checking_function/" \ + f":../../{out_path}/thirdparty/bounds_checking_function/" \ " --run-baseline-jit" \ - " --ark-tool=../../{1}/arkcompiler/ets_runtime/ark_js_vm" \ - " --ark-frontend-binary=../../{1}/arkcompiler/ets_frontend/es2abc" \ - " --merge-abc-binary=../../{1}/arkcompiler/ets_frontend/merge_abc" \ - " --ark-frontend=es2panda" \ - "{2}".format(args_to_test262_cmd, out_path, x64_out_path, timeout, - test_script_name, test_script_path) + f" --ark-tool=../../{out_path}/arkcompiler/ets_runtime/ark_js_vm" \ + f" --ark-frontend-binary=../../{out_path}/arkcompiler/ets_frontend/es2abc" \ + f" --merge-abc-binary=../../{out_path}/arkcompiler/ets_frontend/merge_abc" \ + " --ark-frontend=es2panda" return cmd @staticmethod -- Gitee From a08caa285498d7b73429a684b95192b0288c2181 Mon Sep 17 00:00:00 2001 From: daiweihao Date: Mon, 5 Aug 2024 21:22:08 +0800 Subject: [PATCH 18/33] Add connect inspector testcase 1.Add test cases for connect inspector. 2.In the websocket test case, modify the use of different sock names to prevent resource preemption. Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAI0GV Signed-off-by: daiweihao Change-Id: Ia9842cde33fbfd18d2a782def05b9a0d7fb3dda9 --- BUILD.gn | 3 + inspector/test/BUILD.gn | 69 +++++++++++ inspector/test/connect_server_test.cpp | 155 +++++++++++++++++++++++++ test/resource/tooling/ohos_test.xml | 5 + websocket/test/websocket_test.cpp | 18 +-- 5 files changed, 242 insertions(+), 8 deletions(-) create mode 100644 inspector/test/BUILD.gn create mode 100644 inspector/test/connect_server_test.cpp diff --git a/BUILD.gn b/BUILD.gn index 5d98ae83..6dce3edb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -215,6 +215,7 @@ config("ark_toolchain_public_config") { # ecmascript unit testcase config config("toolchain_test_config") { visibility = [ + "./inspector/test/*", "./test/fuzztest/*", "./tooling/test/*", "./websocket/test/*", @@ -243,6 +244,7 @@ group("ark_toolchain_unittest") { testonly = true deps = [] deps += [ + "./inspector/test:unittest", "./tooling/test:unittest", "./websocket/test:unittest", ] @@ -257,6 +259,7 @@ group("ark_toolchain_host_unittest") { # js unittest deps += [ + "./inspector/test:host_unittest", "./tooling/test:host_unittest", "./websocket/test:host_unittest", ] diff --git a/inspector/test/BUILD.gn b/inspector/test/BUILD.gn new file mode 100644 index 00000000..4153eb43 --- /dev/null +++ b/inspector/test/BUILD.gn @@ -0,0 +1,69 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/toolchain/test/test_helper.gni") +import("//arkcompiler/toolchain/toolchain.gni") + +module_output_path = "arkcompiler/toolchain" + +host_unittest_action("InspectorConnectTest") { + module_out_path = module_output_path + + include_dirs = [ "$toolchain_root/inspector" ] + + sources = [ + # test file + "connect_server_test.cpp", + ] + + configs = [ "$toolchain_root:toolchain_test_config" ] + + deps = [ + "$toolchain_root/inspector:connectserver_debugger", + "$toolchain_root/websocket:websocket_client", + "$toolchain_root/websocket:websocket_server", + ] + + # hiviewdfx libraries + external_deps = hiviewdfx_ext_deps + if (is_arkui_x && target_os == "ios") { + external_deps += [ "openssl:libcrypto_static" ] + } else { + external_deps += [ "openssl:libcrypto_shared" ] + } + + external_deps += [ "bounds_checking_function:libsec_shared" ] + deps += hiviewdfx_deps +} + +group("unittest") { + testonly = true + + # deps file + deps = [ ":InspectorConnectTest" ] + + if (is_mac) { + deps -= [ ":InspectorConnectTest" ] + } +} + +group("host_unittest") { + testonly = true + + # deps file + deps = [ ":InspectorConnectTestAction" ] + + if (is_mac) { + deps -= [ ":InspectorConnectTestAction" ] + } +} diff --git a/inspector/test/connect_server_test.cpp b/inspector/test/connect_server_test.cpp new file mode 100644 index 00000000..1eeeba1a --- /dev/null +++ b/inspector/test/connect_server_test.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "inspector/connect_inspector.h" +#include "inspector/connect_server.h" +#include "websocket/client/websocket_client.h" +#include "websocket/server/websocket_server.h" + +using namespace OHOS::ArkCompiler::Toolchain; + +namespace panda::test { +class ConnectServerTest : public testing::Test { +public: + static void SetUpTestCase() + { + GTEST_LOG_(INFO) << "ConnectServerTest::SetUpTestCase"; + } + + static void TearDownTestCase() + { + GTEST_LOG_(INFO) << "ConnectServerTest::TearDownTestCase"; + } + + void SetUp() override {} + + void TearDown() override {} +#if defined(OHOS_PLATFORM) + static constexpr char CONNECTED_MESSAGE_TEST[] = "connected"; + static constexpr char OPEN_MESSAGE_TEST[] = "layoutOpen"; + static constexpr char CLOSE_MESSAGE_TEST[] = "layoutClose"; + static constexpr char REQUEST_MESSAGE_TEST[] = "tree"; + static constexpr char STOPDEBUGGER_MESSAGE_TEST[] = "stopDebugger"; + static constexpr char OPEN_ARKUI_STATE_PROFILER_TEST[] = "ArkUIStateProfilerOpen"; + static constexpr char CLOSE_ARKUI_STATE_PROFILER_TEST[] = "ArkUIStateProfilerClose"; + + static constexpr char HELLO_INSPECTOR_CLIENT[] = "hello inspector client"; + static constexpr char INSPECTOR_SERVER_OK[] = "inspector server ok"; + static constexpr char INSPECTOR_RUN[] = "inspector run"; + static constexpr char INSPECTOR_QUIT[] = "inspector quit"; +#endif +}; + +bool g_profilerFlag = false; +bool g_connectFlag = false; +bool g_switchStatus = false; +int32_t g_createInfoId = 0; +int32_t g_instanceId = 1; + +void CallbackInit() +{ + auto profilerCb = [](bool flag) -> void { + g_profilerFlag = flag; + }; + SetProfilerCallback(profilerCb); + + auto connectCb = [](bool flag) -> void { + g_connectFlag = flag; + }; + SetConnectCallback(connectCb); + + auto debugModeCb = []() -> void { + GTEST_LOG_(INFO) << "Execute DebugModeCallBack."; + }; + SetDebugModeCallBack(debugModeCb); + + auto switchStatusCb = [](bool flag) -> void { + g_switchStatus = flag; + }; + auto createInfoCb = [](int32_t id) -> void { + g_createInfoId = id; + }; + SetSwitchCallBack(switchStatusCb, createInfoCb, g_instanceId); + GTEST_LOG_(INFO) << "ConnectServerTest::CallbackInit finished"; +} + +HWTEST_F(ConnectServerTest, InspectorBasicTest, testing::ext::TestSize.Level0) +{ + ASSERT_TRUE(WaitForConnection()); +} + +HWTEST_F(ConnectServerTest, InspectorConnectTest, testing::ext::TestSize.Level0) +{ + CallbackInit(); +#if defined(OHOS_PLATFORM) + int appPid = getprocpid(); + int oldProcessfd = -2; + StartServerForSocketPair(oldProcessfd); + StoreMessage(g_instanceId, HELLO_INSPECTOR_CLIENT); + pid_t pid = fork(); + if (pid == 0) { + WebSocketClient clientSocket; + ASSERT_TRUE(clientSocket.InitToolchainWebSocketForSockName(std::to_string(appPid))); + ASSERT_TRUE(clientSocket.ClientSendWSUpgradeReq()); + ASSERT_TRUE(clientSocket.ClientRecvWSUpgradeRsp()); + EXPECT_TRUE(clientSocket.SendReply(OPEN_ARKUI_STATE_PROFILER_TEST)); + EXPECT_TRUE(clientSocket.SendReply(REQUEST_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(OPEN_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(CONNECTED_MESSAGE_TEST)); + + EXPECT_STREQ(clientSocket.Decode().c_str(), HELLO_INSPECTOR_CLIENT); + + std::string recv = clientSocket.Decode(); + EXPECT_STREQ(recv.c_str(), INSPECTOR_SERVER_OK); + if (strcmp(recv.c_str(), INSPECTOR_SERVER_OK) == 0) { + EXPECT_TRUE(clientSocket.SendReply(CLOSE_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(STOPDEBUGGER_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(CLOSE_ARKUI_STATE_PROFILER_TEST)); + } + + EXPECT_STREQ(clientSocket.Decode().c_str(), INSPECTOR_RUN); + EXPECT_STREQ(clientSocket.Decode().c_str(), INSPECTOR_QUIT); + clientSocket.Close(); + exit(0); + } else if (pid > 0) { + // Waiting for executing the message instruction sent by the client + sleep(2); + ASSERT_TRUE(g_profilerFlag); + ASSERT_EQ(g_createInfoId, g_instanceId); + ASSERT_TRUE(g_switchStatus); + ASSERT_TRUE(g_connectFlag); + ASSERT_FALSE(WaitForConnection()); + + SendMessage(INSPECTOR_SERVER_OK); + SendLayoutMessage(INSPECTOR_RUN); + + // Waiting for executing the message instruction sent by the client + sleep(2); + ASSERT_FALSE(g_profilerFlag); + ASSERT_FALSE(g_switchStatus); + ASSERT_FALSE(g_connectFlag); + + SendProfilerMessage(INSPECTOR_QUIT); + + StopServer("InspectorConnectTest"); + } else { + std::cerr << "InspectorConnectTest::fork failed" << std::endl; + } + RemoveMessage(g_instanceId); +#endif +} + +} // namespace panda::test \ No newline at end of file diff --git a/test/resource/tooling/ohos_test.xml b/test/resource/tooling/ohos_test.xml index a733d13e..5b9dc623 100755 --- a/test/resource/tooling/ohos_test.xml +++ b/test/resource/tooling/ohos_test.xml @@ -275,4 +275,9 @@