diff --git a/test/7AAA1B2C-4394-4BB8-84A8-487922B86361.png b/test/7AAA1B2C-4394-4BB8-84A8-487922B86361.png new file mode 100644 index 0000000000000000000000000000000000000000..b824e7c9a67aa66dbce4660bcd1f48e9ad69f1fa Binary files /dev/null and b/test/7AAA1B2C-4394-4BB8-84A8-487922B86361.png differ diff --git a/test/B7FFA994-6519-4B05-EF61-BFB8268240E7.png b/test/B7FFA994-6519-4B05-EF61-BFB8268240E7.png new file mode 100644 index 0000000000000000000000000000000000000000..a135c76ec5bb3e3e66839e902482c78ee32fbd72 Binary files /dev/null and b/test/B7FFA994-6519-4B05-EF61-BFB8268240E7.png differ diff --git a/test/DD687168-F3BD-4BCF-9626-3B20DF7B6BB9.png b/test/DD687168-F3BD-4BCF-9626-3B20DF7B6BB9.png new file mode 100644 index 0000000000000000000000000000000000000000..cf1615700354b75c52f38c60834e73e3c6dedaae Binary files /dev/null and b/test/DD687168-F3BD-4BCF-9626-3B20DF7B6BB9.png differ diff --git a/test/E999BAB3-B23A-4945-B7CC-FA2EB6882EAE.png b/test/E999BAB3-B23A-4945-B7CC-FA2EB6882EAE.png new file mode 100644 index 0000000000000000000000000000000000000000..d564e30017ef03f719b5660e3e2ec0c7db8557ef Binary files /dev/null and b/test/E999BAB3-B23A-4945-B7CC-FA2EB6882EAE.png differ diff --git a/test/ut_build.patch b/test/ut_build.patch new file mode 100644 index 0000000000000000000000000000000000000000..c6ae29be85636d23806327c806403d67ebdd9a3d --- /dev/null +++ b/test/ut_build.patch @@ -0,0 +1,342 @@ +diff --git a/src/common/define_enum.h b/src/common/define_enum.h +index a9739217..5ebd09bc 100644 +--- a/src/common/define_enum.h ++++ b/src/common/define_enum.h +@@ -23,7 +23,7 @@ enum MessageLevel { + }; + + enum ConnType { CONN_USB = 0, CONN_TCP, CONN_SERIAL, CONN_BT, CONN_UNKNOWN }; +-const string conTypeDetail[] = { "USB", "TCP", "UART", "BT", "UNKNOWN" }; ++const std::string conTypeDetail[] = { "USB", "TCP", "UART", "BT", "UNKNOWN" }; + + #ifdef HDC_SUPPORT_UART + enum UartTimeConst { +@@ -51,7 +51,7 @@ enum UartSetSerialNStop { + }; + #endif + enum ConnStatus { STATUS_UNKNOW = 0, STATUS_READY, STATUS_CONNECTED, STATUS_OFFLINE, STATUS_UNAUTH }; +-const string conStatusDetail[] = { "Unknown", "Ready", "Connected", "Offline", "Unauthorized" }; ++const std::string conStatusDetail[] = { "Unknown", "Ready", "Connected", "Offline", "Unauthorized" }; + + enum AuthVerifyType { RSA_ENCRYPT = 0, RSA_3072_SHA512 = 1, UNKNOWN = 100 }; + +diff --git a/src/common/define_plus.h b/src/common/define_plus.h +index 8fef88ee..82d7df86 100644 +--- a/src/common/define_plus.h ++++ b/src/common/define_plus.h +@@ -23,6 +23,9 @@ + #include "define_enum.h" + #include "uv_status.h" + #include "heartbeat.h" ++#include "securec.h" ++#include ++#include + + namespace Hdc { + +@@ -131,7 +134,7 @@ struct HostUSBEndpoint { + uint32_t sizeEpBuf; + std::mutex mutexIo; + std::mutex mutexCb; +- condition_variable cv; ++ std::condition_variable cv; + libusb_transfer *transfer; + }; + #endif +@@ -255,6 +258,24 @@ struct HdcSession { + uv_timer_t heartbeatTimer; + + HdcSessionStat stat; ++#ifdef HDC_HOST ++ bool isRunningOk; ++ std::string faultInfo; ++ uint64_t commandCount = 0; ++ std::string ToDisplayConnectionStr() ++ { ++ std::ostringstream oss; ++ oss << "HdcServer ["; ++ oss << " sessionId:" << sessionId; ++ oss << " connectKey:" << Hdc::MaskString(connectKey); ++ oss << " connType:" << unsigned(connType); ++ oss << " connect state:" << isRunningOk; ++ oss << " faultInfo:" << faultInfo; ++ oss << " commandCount:" << commandCount; ++ oss << " ]"; ++ return oss.str(); ++ } ++#endif + std::string ToDebugString() + { + std::ostringstream oss; +@@ -358,6 +379,34 @@ struct HdcChannel { + bool connectLocalDevice = false; + bool isStableBuf = false; + std::atomic writeFailedTimes; ++#ifdef HDC_HOST ++ uint64_t startTime = 0; ++ uint64_t endTime = 0; ++ bool isSuccess = false; ++ std::string faultInfo = ""; ++ uint16_t commandFlag = 0; ++ std::string commandParameters = ""; ++ ++ std::string ToDisplayChannelStr() ++ { ++ std::ostringstream oss; ++ oss << "HdcServerForClient ["; ++ oss << " channelId:" << channelId; ++ oss << " connectKey:" << Hdc::MaskString(connectKey); ++ oss << " command flag:" << commandFlag; ++ int i = commandParameters.size() - 1; ++ while (i >= 0 && commandParameters[i] == '\0') { ++ commandParameters[i] = ' '; ++ i--; ++ } ++ oss << " command parameters:" << commandParameters; ++ oss << " command result:" << isSuccess; ++ oss << " command take time:" << (endTime - startTime) << "ms"; ++ oss << " faultInfo:" << faultInfo; ++ oss << " ]"; ++ return oss.str(); ++ } ++#endif + }; + using HChannel = struct HdcChannel *; + +diff --git a/test/BUILD.gn b/test/BUILD.gn +index f8b99365..20528e2a 100644 +--- a/test/BUILD.gn ++++ b/test/BUILD.gn +@@ -118,6 +118,13 @@ config("hdc_host_common_config") { + # both linux and ohos is same linux syscall + defines += [ "HOST_LINUX" ] + defines += [ "HARMONY_PROJECT" ] ++ ++ include_dirs = [ ++ "${hdc_path}/src/common", ++ "${hdc_path}/src/daemon", ++ "${hdc_path}/src/host", ++ "${hdc_path}/test/unittest/common/include", ++ ] + } + + ohos_source_set("hdc_common") { +@@ -127,8 +134,8 @@ ohos_source_set("hdc_common") { + if (hdc_support_uart) { + sources += [ "${hdc_path}/src/common/uart.cpp" ] + } +- public_external_deps = common_external_deps +- external_deps = [ "init:libbegetutil" ] ++ external_deps = common_external_deps ++ external_deps += [ "init:libbegetutil" ] + public_configs = [ + ":hdc_common_config", + ":hdc_ut_config", +@@ -153,8 +160,8 @@ ohos_source_set("hdc_daemon") { + sources += [ "${hdc_path}/src/common/uart.cpp" ] + sources += [ "${hdc_path}/src/daemon/daemon_uart.cpp" ] + } +- public_external_deps = common_external_deps +- external_deps = [ ++ external_deps = common_external_deps ++ external_deps += [ + "init:libbegetutil", + "c_utils:utils", + ] +@@ -178,8 +185,8 @@ ohos_source_set("hdc_host") { + sources += [ "${hdc_path}/src/common/uart.cpp" ] + sources += [ "${hdc_path}/src/host/host_uart.cpp" ] + } +- public_external_deps = common_external_deps +- public_external_deps += [ "libusb:libusb" ] ++ external_deps = common_external_deps ++ external_deps += [ "libusb:libusb" ] + public_configs = [ + ":hdc_common_config", + ":hdc_host_common_config", +@@ -213,15 +220,13 @@ ohos_source_set("hdc_daemon_platform") { + "${hdc_path}/src/daemon/jdwp.cpp", + ] + +- public_external_deps = [ ++ external_deps = [ + "bounds_checking_function:libsec_static", + "googletest:gtest", + "libuv:uv", + "openssl:libcrypto_static", + ] + +- external_deps = [ "init:libbegetutil" ] +- + include_dirs = [ "${hdc_path}/daemon" ] + } + +@@ -256,6 +261,7 @@ ohos_unittest("hdc_jdwp_unittest") { + "init:libbegetutil", + "bounds_checking_function:libsec_static", + "libuv:uv", ++ "openssl:libcrypto_static", + ] + + if (is_linux) { +@@ -284,9 +290,8 @@ ohos_unittest("hdc_uart_unittest") { + ":hdc_ut_config", + ] + deps = [ ":hdc_daemon" ] +- public_external_deps = common_external_deps +- +- external_deps = [ "googletest:gmock_main" ] ++ external_deps = common_external_deps ++ external_deps += [ "googletest:gmock_main" ] + } + + ohos_unittest("hdc_host_uart_unittest") { +@@ -310,8 +315,11 @@ ohos_unittest("hdc_host_uart_unittest") { + deps = [ ":hdc_host" ] + + defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ] +- +- external_deps = [ "googletest:gmock_main" ] ++ external_deps = common_external_deps ++ external_deps += [ ++ "libusb:libusb", ++ "googletest:gmock_main", ++ ] + } + + ohos_unittest("hdc_base_unittest") { +@@ -337,16 +345,36 @@ ohos_unittest("hdc_base_unittest") { + ":hdc_ut_code_flag", + ":hdc_ut_config", + ] +- public_external_deps = common_external_deps +- external_deps = [ ++ external_deps = common_external_deps ++ external_deps += [ + "googletest:gmock_main", + "init:libbegetutil", +- "libuv:uv", + "huks:libhukssdk", + ] + defines = [ "HDC_SUPPORT_ENCRYPT_PRIVATE_KEY" ] + } + ++ohos_unittest("hdc_host_base_unittest") { ++ use_exceptions = true ++ module_out_path = module_output_path ++ resource_config_file = "unittest/resource/ohos_test.xml" ++ defines = [ "HDC_HOST" ] ++ sources = hdc_common_sources ++ sources += [ "unittest/common/define_ut.cpp" ] ++ ++ configs = [ ++ ":hdc_host_common_config", ++ ":hdc_ut_code_flag", ++ ":hdc_ut_config", ++ ] ++ external_deps = common_external_deps ++ external_deps += [ ++ "googletest:gmock_main", ++ "init:libbegetutil", ++ "libusb:libusb", ++ ] ++} ++ + group("HdcJdwpTest") { + testonly = true + deps = [ ":hdc_jdwp_unittest" ] +@@ -360,6 +388,7 @@ group("hdc_unittest") { + ":hdc_jdwp_unittest", + ":hdc_register_unittest", + ":hdc_uart_unittest", ++ ":hdc_host_base_unittest", + ] + } + +@@ -422,15 +451,12 @@ ohos_fuzztest("JdwpReadStreamFuzzTest") { + "fuzztest/jdwpreadstream_fuzzer/JdwpReadStream_fuzzer.cpp", + ] + deps = [ ":hdc_common" ] +- external_deps = [ ++ external_deps = common_external_deps ++ external_deps += [ + "hilog:libhilog", + "init:libbeget_proxy", + "init:libbegetutil", + ] +- public_external_deps = [ +- "bounds_checking_function:libsec_static", +- "libuv:uv", +- ] + } + + ohos_fuzztest("ForwardReadStreamFuzzTest") { +@@ -442,14 +468,8 @@ ohos_fuzztest("ForwardReadStreamFuzzTest") { + deps = [ ":hdc_common" ] + subsystem_name = "developtools" + part_name = "hdc" +- external_deps = [ +- "hilog:libhilog", +- "libuv:uv", +- ] +- public_external_deps = [ +- "bounds_checking_function:libsec_static", +- "libuv:uv", +- ] ++ external_deps = common_external_deps ++ external_deps += [ "hilog:libhilog" ] + } + + ohos_fuzztest("DaemonUsbReadFuzzTest") { +@@ -463,14 +483,11 @@ ohos_fuzztest("DaemonUsbReadFuzzTest") { + "fuzztest/daemonusbread_fuzzer/DaemonUsbRead_fuzzer.cpp", + ] + deps = [ ":hdc_common" ] +- external_deps = [ ++ external_deps = common_external_deps ++ external_deps += [ + "init:libbeget_proxy", + "init:libbegetutil", + ] +- public_external_deps = [ +- "bounds_checking_function:libsec_static", +- "libuv:uv", +- ] + } + + ohos_fuzztest("DecompressToLocalFuzzTest") { +@@ -485,15 +502,12 @@ ohos_fuzztest("DecompressToLocalFuzzTest") { + "fuzztest/decompresstolocal_fuzzer/DecompressToLocal_fuzzer.cpp", + ] + deps = [ ":hdc_common" ] +- external_deps = [ ++ external_deps = common_external_deps ++ external_deps += [ + "hilog:libhilog", + "init:libbeget_proxy", + "init:libbegetutil", + ] +- public_external_deps = [ +- "bounds_checking_function:libsec_static", +- "libuv:uv", +- ] + } + + group("hdc_fuzztest") { +@@ -520,13 +534,12 @@ ohos_unittest("hdc_register_unittest") { + include_dirs = [ "${hdc_path}/src/register/" ] + + configs = [ ":hdc_register_config" ] +- public_external_deps = common_external_deps +- external_deps = [ ++ external_deps = common_external_deps ++ external_deps += [ + "c_utils:utils", + "googletest:gmock_main", + "hilog:libhilog", + "init:libbeget_proxy", + "init:libbegetutil", +- "libuv:uv", + ] + } +\ No newline at end of file diff --git "a/test/\345\244\232TCP\350\277\236\346\216\245\351\252\214\350\257\201\346\227\245\345\277\227.7z" "b/test/\345\244\232TCP\350\277\236\346\216\245\351\252\214\350\257\201\346\227\245\345\277\227.7z" new file mode 100644 index 0000000000000000000000000000000000000000..d582e584f0dea7e779d8a51131c9ee5247c2bb5a Binary files /dev/null and "b/test/\345\244\232TCP\350\277\236\346\216\245\351\252\214\350\257\201\346\227\245\345\277\227.7z" differ