mirror of
https://gitee.com/openharmony/developtools_hdc
synced 2024-11-23 23:20:43 +00:00
Merge branch 'master' of gitee.com:openharmony/developtools_hdc into master
Signed-off-by: maliang <maliang87@huawei.com>
This commit is contained in:
commit
eca0939814
2
BUILD.gn
2
BUILD.gn
@ -106,7 +106,7 @@ template("hdcd_source_set") {
|
||||
defines += [ "JS_JDWP_CONNECT" ]
|
||||
}
|
||||
if (use_musl) {
|
||||
if (use_jemalloc && use_jemalloc_dfx_intf) {
|
||||
if (musl_use_jemalloc && musl_use_jemalloc_dfx_intf) {
|
||||
defines += [ "CONFIG_USE_JEMALLOC_DFX_INIF" ]
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import pytest
|
||||
from dev_hdc_test import GP
|
||||
from dev_hdc_test import check_library_installation, check_hdc_version, check_cmd_time
|
||||
from dev_hdc_test import check_hdc_cmd, check_hdc_targets, get_local_path, get_remote_path, run_command_with_timeout
|
||||
from dev_hdc_test import check_app_install, check_app_uninstall, prepare_source, pytest_run, update_source, check_rate
|
||||
from dev_hdc_test import check_app_install, check_app_uninstall, prepare_source, pytest_run, update_source, check_rate, get_shell_result
|
||||
from dev_hdc_test import make_multiprocess_file, rmdir
|
||||
from dev_hdc_test import check_app_install_multi, check_app_uninstall_multi
|
||||
from dev_hdc_test import check_rom, check_shell
|
||||
@ -223,7 +223,11 @@ def test_target_cmd():
|
||||
assert check_hdc_targets()
|
||||
time.sleep(3)
|
||||
check_hdc_cmd("target boot")
|
||||
time.sleep(60) # reboot needs at least 60 seconds
|
||||
start_time = time.time()
|
||||
run_command_with_timeout("hdc wait", 60) # reboot takes up to 60 seconds
|
||||
end_time = time.time()
|
||||
print(f"command exec time {end_time - start_time}")
|
||||
assert (end_time - start_time) > 5 # Reboot takes at least 5 seconds
|
||||
assert (check_hdc_cmd("target mount", "Mount finish") or
|
||||
check_hdc_cmd("target mount", "[Fail]Operate need running as root") or
|
||||
check_hdc_cmd("target mount", "Remount successful.")
|
||||
@ -248,6 +252,18 @@ def test_file_switch_on():
|
||||
assert check_hdc_cmd(f"file recv {get_remote_path('it_small')} {get_local_path('small_recv')}")
|
||||
|
||||
|
||||
def test_target_mount():
|
||||
check_shell(f"target mount")
|
||||
mount_after = get_shell_result(f'shell "mount |grep /vendor |head -1"')
|
||||
assert "rw" in mount_after
|
||||
|
||||
|
||||
def test_target_key():
|
||||
device_key = get_shell_result(f"list targets").split("\r\n")[0]
|
||||
hdcd_pid = get_shell_result(f"-t {device_key} shell pgrep -x hdcd").split("\r\n")[0]
|
||||
assert hdcd_pid.isdigit()
|
||||
|
||||
|
||||
def test_version_cmd():
|
||||
version = "Ver: 2.0.0a"
|
||||
assert check_hdc_version("-v", version)
|
||||
|
@ -1951,14 +1951,8 @@ void PrintLogEx(const char *functionName, int line, uint8_t logLevel, const char
|
||||
}
|
||||
return _wfopen(resolvedPath, wideMode.c_str());
|
||||
#else
|
||||
char resolvedPath[PATH_MAX + 1] = { 0 };
|
||||
std::string filePath(fileName);
|
||||
if (!realpath(filePath.c_str(), resolvedPath)) {
|
||||
WRITE_LOG(LOG_FATAL, "realpath %s failed", filePath.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
// unix paltform open file with default char
|
||||
return fopen(resolvedPath, mode);
|
||||
return fopen(fileName, mode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ private:
|
||||
void CheckMaster(CtxFile *context) override;
|
||||
void WhenTransferFinish(CtxFile *context) override;
|
||||
bool BeginTransfer(CtxFile *context, const string &command);
|
||||
void TransferSummary(CtxFile *context) override;
|
||||
void TransferSummary(CtxFile *context);
|
||||
bool SetMasterParameters(CtxFile *context, const char *command, int argc, char **argv);
|
||||
bool FileModeSync(const uint16_t cmd, uint8_t *payload, const int payloadSize);
|
||||
};
|
||||
|
@ -202,19 +202,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void HdcTransferBase::Next(HdcTransferBase *thisClass, CtxFile *context)
|
||||
{
|
||||
if (context->isDir) {
|
||||
uint8_t payload = 1;
|
||||
uint16_t cmdFinish = (thisClass->commandBegin == CMD_FILE_BEGIN ? CMD_FILE_FINISH : CMD_APP_FINISH);
|
||||
thisClass->CommandDispatch(cmdFinish, &payload, 1);
|
||||
} else {
|
||||
thisClass->TransferSummary(context);
|
||||
thisClass->TaskFinish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void HdcTransferBase::OnFileIO(uv_fs_t *req)
|
||||
{
|
||||
CtxFileIO *contextIO = reinterpret_cast<CtxFileIO *>(req->data);
|
||||
@ -243,11 +230,6 @@ void HdcTransferBase::OnFileIO(uv_fs_t *req)
|
||||
WRITE_LOG(LOG_DEBUG, "read file data %" PRIu64 "/%" PRIu64 "", context->indexIO,
|
||||
context->fileSize);
|
||||
#endif // HDC_DEBUG
|
||||
|
||||
if (req->result == 0 && context->fileSize > 0) {
|
||||
Next(thisClass, context);
|
||||
return;
|
||||
}
|
||||
if (!thisClass->SendIOPayload(context, context->indexIO - req->result, bufIO, req->result)) {
|
||||
context->ioFinish = true;
|
||||
break;
|
||||
@ -751,7 +733,7 @@ bool HdcTransferBase::CheckFeatures(CtxFile *context, uint8_t *payload, const in
|
||||
{
|
||||
if (payloadSize == FEATURE_FLAG_MAX_SIZE) {
|
||||
union FeatureFlagsUnion feature{};
|
||||
if (memcpy_s(&feature, sizeof(feature), payload, payloadSize)) {
|
||||
if (memcpy_s(&feature, sizeof(feature), payload, payloadSize) != EOK) {
|
||||
WRITE_LOG(LOG_FATAL, "CheckFeatures memcpy_s failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -121,9 +121,6 @@ protected:
|
||||
virtual void WhenTransferFinish(CtxFile *context)
|
||||
{
|
||||
}
|
||||
virtual void TransferSummary(CtxFile *context)
|
||||
{
|
||||
}
|
||||
bool MatchPackageExtendName(string fileName, string extName);
|
||||
bool ResetCtx(CtxFile *context, bool full = false);
|
||||
bool SmartSlavePath(string &cwd, string &localPath, const char *optName);
|
||||
@ -150,7 +147,6 @@ private:
|
||||
};
|
||||
static const uint8_t payloadPrefixReserve = 64;
|
||||
static void OnFileIO(uv_fs_t *req);
|
||||
static void Next(HdcTransferBase *thisClass, CtxFile *context);
|
||||
int SimpleFileIO(CtxFile *context, uint64_t index, uint8_t *sendBuf, int bytes);
|
||||
bool SendIOPayload(CtxFile *context, uint64_t index, uint8_t *data, int dataSize);
|
||||
bool RecvIOPayload(CtxFile *context, uint8_t *data, int dataSize);
|
||||
|
@ -21,6 +21,7 @@ HdcHostApp::HdcHostApp(HTaskInfo hTaskInfo)
|
||||
{
|
||||
commandBegin = CMD_APP_BEGIN;
|
||||
commandData = CMD_APP_DATA;
|
||||
originLocalDir = "";
|
||||
}
|
||||
|
||||
HdcHostApp::~HdcHostApp()
|
||||
@ -77,6 +78,7 @@ bool HdcHostApp::BeginInstall(CtxFile *context, const char *command)
|
||||
string tarpath = Dir2Tar(path.c_str());
|
||||
if (!tarpath.empty()) {
|
||||
context->taskQueue.push_back(tarpath);
|
||||
originLocalDir = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,8 +169,11 @@ bool HdcHostApp::CheckInstallContinue(AppModType mode, bool lastResult, const ch
|
||||
WRITE_LOG(LOG_DEBUG, "unlink path:%s", path.c_str());
|
||||
}
|
||||
}
|
||||
LogMsg(MSG_INFO, "%s path:%s, queuesize:%d, msg:%s", modeDesc.c_str(), ctxNow.localPath.c_str(),
|
||||
ctxNow.taskQueue.size(), msg + printedMsgLen);
|
||||
string path = ctxNow.localPath;
|
||||
if (!originLocalDir.empty()) {
|
||||
path = originLocalDir;
|
||||
}
|
||||
LogMsg(MSG_INFO, "%s path:%s msg:%s", modeDesc.c_str(), path.c_str(), msg + printedMsgLen);
|
||||
printedMsgLen = strlen(msg);
|
||||
if (singalStop || !ctxNow.taskQueue.size()) {
|
||||
LogMsg(MSG_OK, "AppMod finish");
|
||||
|
@ -31,6 +31,7 @@ private:
|
||||
bool BeginSideload(CtxFile *context, const char *localPath);
|
||||
string Dir2Tar(const char *dir);
|
||||
size_t printedMsgLen = 0;
|
||||
string originLocalDir = "";
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -219,24 +219,25 @@ ohos_unittest("hdc_jdwp_unittest") {
|
||||
}
|
||||
public_deps = [ ":hdc_daemon_platform" ]
|
||||
|
||||
deps = [ "//third_party/googletest:gmock_main" ]
|
||||
|
||||
sources = [ "unittest/common/HdcJdwpTest.cpp" ]
|
||||
deps += [ ":hdc_common" ]
|
||||
deps = [ ":hdc_common" ]
|
||||
|
||||
include_dirs = [
|
||||
"${hdc_path}/test/unittest/common/include",
|
||||
"${hdc_path}/src/daemon",
|
||||
"${hdc_path}/src/common",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//third_party/libuv",
|
||||
]
|
||||
external_deps = [ "googletest:gmock_main" ]
|
||||
|
||||
if (is_linux) {
|
||||
static_link = false
|
||||
}
|
||||
subsystem_name = "developtools"
|
||||
defines += [ "OPENSSL_SUPPRESS_DEPRECATED" ]
|
||||
public_external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"libuv:uv",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("hdc_uart_unittest") {
|
||||
@ -251,9 +252,9 @@ ohos_unittest("hdc_uart_unittest") {
|
||||
configs = [ ":hdc_common_config" ]
|
||||
configs += [ ":hdc_ut_code_flag" ]
|
||||
deps = [ ":hdc_daemon" ]
|
||||
|
||||
deps += [ "//third_party/googletest:gmock_main" ]
|
||||
defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
|
||||
|
||||
external_deps = [ "googletest:gmock_main" ]
|
||||
}
|
||||
|
||||
ohos_unittest("hdc_host_uart_unittest") {
|
||||
@ -273,8 +274,9 @@ ohos_unittest("hdc_host_uart_unittest") {
|
||||
|
||||
deps = [ ":hdc_host" ]
|
||||
|
||||
deps += [ "//third_party/googletest:gmock_main" ]
|
||||
defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
|
||||
|
||||
external_deps = [ "googletest:gmock_main" ]
|
||||
}
|
||||
|
||||
group("HdcJdwpTest") {
|
||||
@ -315,8 +317,6 @@ config("hdc_test_config") {
|
||||
"${hdc_path}/test/fuzztest/forwardreadstream_fuzzer",
|
||||
"${hdc_path}/src/daemon",
|
||||
"${hdc_path}/src/common",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//third_party/libuv/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -349,17 +349,20 @@ ohos_fuzztest("JdwpReadStreamFuzzTest") {
|
||||
fuzz_config_file = "${hdc_path}/test/fuzztest/jdwpreadstream_fuzzer"
|
||||
configs = [ ":hdc_test_config" ]
|
||||
cflags = fuzz_cflags
|
||||
deps = [ "//third_party/libuv:uv" ]
|
||||
sources = [
|
||||
"${hdc_path}/src/daemon/jdwp.cpp",
|
||||
"${hdc_path}/src/daemon/system_depend.cpp",
|
||||
"fuzztest/jdwpreadstream_fuzzer/JdwpReadStream_fuzzer.cpp",
|
||||
]
|
||||
deps += [ ":hdc_common" ]
|
||||
deps = [ ":hdc_common" ]
|
||||
external_deps = [
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
public_external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"libuv:uv",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_fuzztest("ForwardReadStreamFuzzTest") {
|
||||
@ -367,11 +370,15 @@ ohos_fuzztest("ForwardReadStreamFuzzTest") {
|
||||
fuzz_config_file = "${hdc_path}/test/fuzztest/forwardreadstream_fuzzer"
|
||||
configs = [ ":hdc_test_config" ]
|
||||
cflags = fuzz_cflags
|
||||
deps = [ "//third_party/libuv:uv" ]
|
||||
sources = [ "fuzztest/forwardreadstream_fuzzer/ForwardReadStream_fuzzer.cpp" ]
|
||||
deps += [ ":hdc_common" ]
|
||||
deps = [ ":hdc_common" ]
|
||||
subsystem_name = "developtools"
|
||||
part_name = "hdc"
|
||||
external_deps = [ "libuv:uv" ]
|
||||
public_external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"libuv:uv",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_fuzztest("DaemonUsbReadFuzzTest") {
|
||||
@ -379,17 +386,20 @@ ohos_fuzztest("DaemonUsbReadFuzzTest") {
|
||||
fuzz_config_file = "${hdc_path}/test/fuzztest/daemonusbread_fuzzer"
|
||||
configs = [ ":hdc_test_config" ]
|
||||
cflags = fuzz_cflags
|
||||
deps = [ "//third_party/libuv:uv" ]
|
||||
sources = [
|
||||
"${hdc_path}/src/daemon/daemon_usb.cpp",
|
||||
"${hdc_path}/src/daemon/system_depend.cpp",
|
||||
"fuzztest/daemonusbread_fuzzer/DaemonUsbRead_fuzzer.cpp",
|
||||
]
|
||||
deps += [ ":hdc_common" ]
|
||||
deps = [ ":hdc_common" ]
|
||||
external_deps = [
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
public_external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"libuv:uv",
|
||||
]
|
||||
}
|
||||
|
||||
group("hdc_fuzztest") {
|
||||
@ -415,15 +425,13 @@ ohos_unittest("hdc_register_unittest") {
|
||||
|
||||
configs = [ ":hdc_register_config" ]
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/libuv:uv",
|
||||
]
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"googletest:gmock_main",
|
||||
"hilog:libhilog",
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
"libuv:uv",
|
||||
]
|
||||
|
||||
subsystem_name = "developtools"
|
||||
|
Loading…
Reference in New Issue
Block a user