mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-27 00:51:47 +00:00
use on device hiperf and refine testcases
Signed-off-by: anderskov <zangleizhen@huawei.com>
This commit is contained in:
parent
deee7398b3
commit
9655ba2f24
@ -32,6 +32,8 @@ using namespace testing::ext;
|
||||
namespace {
|
||||
const std::string DEFAULT_HIPROFILERD_PATH("/system/bin/hiprofilerd");
|
||||
const std::string DEFAULT_HIPROFILER_PLUGINS_PATH("/system/bin/hiprofiler_plugins");
|
||||
const std::string DEFAULT_HIPROFILERD_NAME("hiprofilerd");
|
||||
const std::string DEFAULT_HIPROFILER_PLUGINS_NAME("hiprofiler_plugins");
|
||||
const std::string DEFAULT_HIPROFILER_CMD_PATH("/system/bin/hiprofiler_cmd");
|
||||
const std::string FTRACE_PLUGIN_PATH("/data/local/tmp/libftrace_plugin.z.so");
|
||||
std::string DEFAULT_PATH("/data/local/tmp/");
|
||||
@ -39,6 +41,7 @@ constexpr uint32_t READ_BUFFER_SIZE = 1024;
|
||||
constexpr int SLEEP_TIME = 3;
|
||||
constexpr int FILE_READ_CHUNK_SIZE = 4096;
|
||||
constexpr char HEX_CHARS[] = "0123456789abcdef";
|
||||
constexpr int LINE_SIZE = 1000;
|
||||
|
||||
|
||||
class HiprofilerCmdTest : public ::testing::Test {
|
||||
@ -136,11 +139,11 @@ public:
|
||||
configStr = configStr + sha256 + "\"\n";
|
||||
configStr +=
|
||||
" sample_interval: 2000\n"
|
||||
" config_data: \"\\n\\022sched/sched_waking\\n \\020task/task_rename\\n"
|
||||
" \\022sched/sched_switch\\n \\030sched/sched_process_exit\\n"
|
||||
" \\024power/suspend_resume\\n\\030sched/sched_process_free\\n"
|
||||
" \\021task/task_newtask\\n\\022sched/sched_wakeup\\n"
|
||||
" \\026sched/sched_wakeup_new \\200P(\\350\\a0\\200 8\\001B\\004monoP\\310\\001\"\n"
|
||||
" config_data: \"\\n\\022sched/sched_waking\\n\\020task/task_rename\\n"
|
||||
"\\022sched/sched_switch\\n\\030sched/sched_process_exit\\n"
|
||||
"\\024power/suspend_resume\\n\\030sched/sched_process_free\\n"
|
||||
"\\021task/task_newtask\\n\\022sched/sched_wakeup\\n"
|
||||
"\\026sched/sched_wakeup_new \\200P(\\350\\a0\\200 8\\001B\\004monoP\\310\\001\"\n"
|
||||
"}\n";
|
||||
|
||||
// 根据构建的config写文件
|
||||
@ -170,6 +173,29 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void KillProcess(const std::string processName)
|
||||
{
|
||||
int pid = -1;
|
||||
std::string findpid = "pidof " + processName;
|
||||
HILOG_INFO(LOG_CORE, "find pid command : %s", findpid.c_str());
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(findpid.c_str(), "r"), pclose);
|
||||
|
||||
char line[LINE_SIZE];
|
||||
do {
|
||||
if (fgets(line, sizeof(line), pipe.get()) == nullptr) {
|
||||
HILOG_INFO(LOG_CORE, "not find processName : %s", processName.c_str());
|
||||
return;
|
||||
} else if (strlen(line) > 0 && isdigit((unsigned char)(line[0]))) {
|
||||
pid = atoi(line);
|
||||
HILOG_INFO(LOG_CORE, "find processName : %s, pid: %d", processName.c_str(), pid);
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
if (pid != -1) {
|
||||
StopProcessStub(pid);
|
||||
}
|
||||
}
|
||||
private:
|
||||
int g_hiprofilerdPid = -1;
|
||||
int g_hiprofilerPluginsPid = -1;
|
||||
@ -182,6 +208,9 @@ private:
|
||||
*/
|
||||
HWTEST_F(HiprofilerCmdTest, DFX_DFR_Hiprofiler_0110, Function | MediumTest | Level1)
|
||||
{
|
||||
KillProcess(DEFAULT_HIPROFILERD_NAME);
|
||||
KillProcess(DEFAULT_HIPROFILER_PLUGINS_NAME);
|
||||
|
||||
std::string cmd = DEFAULT_HIPROFILER_CMD_PATH + " -h";
|
||||
std::string content = "";
|
||||
EXPECT_TRUE(RunCommand(cmd, content));
|
||||
@ -210,6 +239,9 @@ HWTEST_F(HiprofilerCmdTest, DFX_DFR_Hiprofiler_0110, Function | MediumTest | Lev
|
||||
*/
|
||||
HWTEST_F(HiprofilerCmdTest, DFX_DFR_Hiprofiler_0120, Function | MediumTest | Level1)
|
||||
{
|
||||
KillProcess(DEFAULT_HIPROFILERD_NAME);
|
||||
KillProcess(DEFAULT_HIPROFILER_PLUGINS_NAME);
|
||||
|
||||
std::string cmd = "cp /system/lib/libftrace_plugin.z.so " + DEFAULT_PATH;
|
||||
system(cmd.c_str());
|
||||
|
||||
|
@ -24,10 +24,7 @@ namespace {
|
||||
constexpr int SLEEP_TIME = 10;
|
||||
}
|
||||
|
||||
CommandPoller::CommandPoller(const ManagerInterfacePtr& p) : requestIdAutoIncrease_(1), pluginManager_(p)
|
||||
{
|
||||
Connect(DEFAULT_UNIX_SOCKET_PATH);
|
||||
}
|
||||
CommandPoller::CommandPoller(const ManagerInterfacePtr& p) : requestIdAutoIncrease_(1), pluginManager_(p) {}
|
||||
|
||||
CommandPoller::~CommandPoller() {}
|
||||
|
||||
@ -36,6 +33,11 @@ uint32_t CommandPoller::GetRequestId()
|
||||
return requestIdAutoIncrease_++;
|
||||
}
|
||||
|
||||
bool CommandPoller::OnConnect()
|
||||
{
|
||||
return Connect(DEFAULT_UNIX_SOCKET_PATH);
|
||||
}
|
||||
|
||||
bool CommandPoller::OnCreateSessionCmd(const CreateSessionCmd& cmd, SocketContext& context) const
|
||||
{
|
||||
HILOG_DEBUG(LOG_CORE, "%s:proc", __func__);
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
bool OnStopSessionCmd(const StopSessionCmd& cmd) const;
|
||||
|
||||
uint32_t GetRequestId();
|
||||
bool OnConnect();
|
||||
|
||||
protected:
|
||||
bool OnGetCommandResponse(SocketContext& context, ::GetCommandResponse& response) override;
|
||||
|
@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "command_poller.h"
|
||||
#include "logging.h"
|
||||
#include "plugin_manager.h"
|
||||
@ -33,6 +35,8 @@ const int SLEEP_ONE_SECOND = 1000;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const int connectRetrySeconds = 3;
|
||||
|
||||
std::string pluginDir(DEFAULT_PLUGIN_PATH);
|
||||
if (argv[1] != nullptr) {
|
||||
HILOG_DEBUG(LOG_CORE, "%s:pluginDir = %s", __func__, argv[1]);
|
||||
@ -44,6 +48,14 @@ int main(int argc, char* argv[])
|
||||
|
||||
auto commandPoller = std::make_shared<CommandPoller>(pluginManager);
|
||||
CHECK_NOTNULL(commandPoller, 1, "create CommandPoller FAILED!");
|
||||
|
||||
while (true) {
|
||||
if (commandPoller->OnConnect()) {
|
||||
break;
|
||||
}
|
||||
HILOG_DEBUG(LOG_CORE, "%s:connect failed, try again", __func__);
|
||||
sleep(connectRetrySeconds);
|
||||
}
|
||||
pluginManager->SetCommandPoller(commandPoller);
|
||||
|
||||
PluginWatcher watcher(pluginManager);
|
||||
|
@ -105,7 +105,7 @@ bool PluginManager::AddPlugin(const std::string& pluginPath)
|
||||
RegisterPluginResponse response;
|
||||
|
||||
if (commandPoller_->RegisterPlugin(request, response)) {
|
||||
if (response.status() == 0) {
|
||||
if (response.status() == ResponseStatus::OK) {
|
||||
HILOG_DEBUG(LOG_CORE, "%s:response.plugin_id() = %d", __func__, response.plugin_id());
|
||||
pluginIds_[pluginPath] = response.plugin_id();
|
||||
pluginModules_.insert(std::pair<uint32_t, std::shared_ptr<PluginModule>>(response.plugin_id(), plugin));
|
||||
@ -161,7 +161,7 @@ bool PluginManager::RemovePlugin(const std::string& pluginPath)
|
||||
request.set_plugin_id(index);
|
||||
UnregisterPluginResponse response;
|
||||
if (commandPoller_->UnregisterPlugin(request, response)) {
|
||||
if (response.status() != 0) {
|
||||
if (response.status() != ResponseStatus::OK) {
|
||||
HILOG_DEBUG(LOG_CORE, "%s:registerPlugin fail 1", __func__);
|
||||
return false;
|
||||
}
|
||||
@ -338,7 +338,7 @@ bool PluginManager::SubmitResult(const PluginResult& pluginResult)
|
||||
HILOG_DEBUG(LOG_CORE, "%s:fail 1", __func__);
|
||||
return false;
|
||||
}
|
||||
if (response.status() != 0) {
|
||||
if (response.status() != ResponseStatus::OK) {
|
||||
HILOG_DEBUG(LOG_CORE, "%s:fail 2", __func__);
|
||||
return false;
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ HWTEST_F(PluginManagerTest, SuccessPlugin, TestSize.Level1)
|
||||
{
|
||||
auto pluginManage = std::make_shared<PluginManager>();
|
||||
auto commandPoller = std::make_shared<CommandPoller>(pluginManage);
|
||||
EXPECT_TRUE(commandPoller->OnConnect());
|
||||
pluginManage->SetCommandPoller(commandPoller);
|
||||
|
||||
const uint8_t configData[] = {0x30, 0x01, 0x38, 0x01, 0x42, 0x01, 0x01};
|
||||
|
@ -67,7 +67,7 @@ bool HookManager::RegisterAgentPlugin(const std::string& pluginPath)
|
||||
RegisterPluginResponse response;
|
||||
|
||||
if (commandPoller_->RegisterPlugin(request, response)) {
|
||||
if (response.status() == 0) {
|
||||
if (response.status() == ResponseStatus::OK) {
|
||||
HILOG_DEBUG(LOG_CORE, "response.plugin_id() = %d", response.plugin_id());
|
||||
agentIndex_ = response.plugin_id();
|
||||
HILOG_DEBUG(LOG_CORE, "RegisterPlugin OK");
|
||||
@ -90,7 +90,7 @@ bool HookManager::UnregisterAgentPlugin(const std::string& pluginPath)
|
||||
request.set_plugin_id(agentIndex_);
|
||||
UnregisterPluginResponse response;
|
||||
if (commandPoller_->UnregisterPlugin(request, response)) {
|
||||
if (response.status() != 0) {
|
||||
if (response.status() != ResponseStatus::OK) {
|
||||
HILOG_DEBUG(LOG_CORE, "RegisterPlugin FAIL 1");
|
||||
return false;
|
||||
}
|
||||
|
@ -25,23 +25,18 @@
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace {
|
||||
const int SLEEP_TIME = 30000;
|
||||
const std::string DEFAULT_HIPROFILERD_PATH("/system/bin/hiprofilerd");
|
||||
const std::string DEFAULT_HIPROFILER_PLUGINS_PATH("/system/bin/hiprofiler_plugins");
|
||||
int g_hiprofilerdProcessNum = -1;
|
||||
int g_hiprofilerPluginsProcessNum = -1;
|
||||
|
||||
class HookManagerTest : public ::testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
StartServerStub(DEFAULT_HIPROFILERD_PATH);
|
||||
sleep(1); // 睡眠1s确保hiprofilerd进程启动之后再启动hiprofiler_plugins进程
|
||||
StartServerStub(DEFAULT_HIPROFILER_PLUGINS_PATH);
|
||||
sleep(1); // 睡眠1s确保hiprofilerd进程启动
|
||||
}
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
StopServerStub(g_hiprofilerPluginsProcessNum);
|
||||
StopServerStub(g_hiprofilerdProcessNum);
|
||||
}
|
||||
|
||||
@ -53,15 +48,10 @@ public:
|
||||
if (DEFAULT_HIPROFILERD_PATH == name) {
|
||||
// start running hiprofilerd
|
||||
execl(name.c_str(), nullptr, nullptr);
|
||||
} else if (DEFAULT_HIPROFILER_PLUGINS_PATH == name) {
|
||||
// start running hiprofiler_plugins
|
||||
execl(name.c_str(), "/data/local/tmp/", nullptr);
|
||||
}
|
||||
_exit(1);
|
||||
} else if (DEFAULT_HIPROFILERD_PATH == name) {
|
||||
g_hiprofilerdProcessNum = processNum;
|
||||
} else if (DEFAULT_HIPROFILER_PLUGINS_PATH == name) {
|
||||
g_hiprofilerPluginsProcessNum = processNum;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +74,7 @@ HWTEST_F(HookManagerTest, RegisterPlugin, TestSize.Level1)
|
||||
ASSERT_TRUE(hookManager != nullptr);
|
||||
std::shared_ptr<CommandPoller> commandPoller = std::make_shared<CommandPoller>(hookManager);
|
||||
ASSERT_TRUE(commandPoller != nullptr);
|
||||
EXPECT_TRUE(commandPoller->OnConnect());
|
||||
hookManager->SetCommandPoller(commandPoller);
|
||||
ASSERT_TRUE(hookManager->RegisterAgentPlugin("hookdaemon"));
|
||||
ASSERT_TRUE(hookManager->UnregisterAgentPlugin("hookdaemon"));
|
||||
@ -100,6 +91,7 @@ HWTEST_F(HookManagerTest, LoadPlugin, TestSize.Level1)
|
||||
ASSERT_TRUE(hookManager != nullptr);
|
||||
std::shared_ptr<CommandPoller> commandPoller = std::make_shared<CommandPoller>(hookManager);
|
||||
ASSERT_TRUE(commandPoller != nullptr);
|
||||
EXPECT_TRUE(commandPoller->OnConnect());
|
||||
hookManager->SetCommandPoller(commandPoller);
|
||||
ASSERT_TRUE(hookManager->RegisterAgentPlugin("hookdaemon"));
|
||||
ASSERT_TRUE(hookManager->LoadPlugin("hookdaemon"));
|
||||
@ -118,6 +110,7 @@ HWTEST_F(HookManagerTest, UnloadPlugin, TestSize.Level1)
|
||||
ASSERT_TRUE(hookManager != nullptr);
|
||||
std::shared_ptr<CommandPoller> commandPoller = std::make_shared<CommandPoller>(hookManager);
|
||||
ASSERT_TRUE(commandPoller != nullptr);
|
||||
EXPECT_TRUE(commandPoller->OnConnect());
|
||||
hookManager->SetCommandPoller(commandPoller);
|
||||
ASSERT_TRUE(hookManager->RegisterAgentPlugin("hookdaemon"));
|
||||
ASSERT_TRUE(hookManager->LoadPlugin("hookdaemon"));
|
||||
@ -136,6 +129,7 @@ HWTEST_F(HookManagerTest, PluginSession, TestSize.Level1)
|
||||
ASSERT_TRUE(hookManager != nullptr);
|
||||
std::shared_ptr<CommandPoller> commandPoller = std::make_shared<CommandPoller>(hookManager);
|
||||
ASSERT_TRUE(commandPoller != nullptr);
|
||||
EXPECT_TRUE(commandPoller->OnConnect());
|
||||
hookManager->SetCommandPoller(commandPoller);
|
||||
|
||||
std::vector<uint32_t> pluginIds(1);
|
||||
|
@ -198,12 +198,12 @@ int VirtualThreadTest::PhdrCallBack(struct dl_phdr_info *info, size_t size, void
|
||||
for (const MemMapItem &item : *thread->GetMaps()) {
|
||||
HLOGV("%s", item.ToString().c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (memMaps.size() > 0 and phdrMaps.size() > 0) {
|
||||
if (memMaps.size() == phdrMaps.size()) {
|
||||
EXPECT_EQ(memMaps.front().begin_, phdrMaps.front().begin_);
|
||||
EXPECT_EQ(memMaps.front().pageoffset_, phdrMaps.front().pageoffset_);
|
||||
EXPECT_EQ(memMaps.front().end_, phdrMaps.front().end_);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ GetCommandResponsePtr PluginCommandBuilder::BuildCreateSessionCmd(const Profiler
|
||||
uint32_t bufferSize)
|
||||
{
|
||||
auto cmd = std::make_shared<GetCommandResponse>();
|
||||
cmd->set_status(0);
|
||||
cmd->set_status(ResponseStatus::OK);
|
||||
cmd->set_has_more(false);
|
||||
cmd->set_command_id(cmdIdAutoIncrease_);
|
||||
CreateSessionCmd* csc = cmd->mutable_create_session_cmd();
|
||||
@ -44,7 +44,7 @@ GetCommandResponsePtr PluginCommandBuilder::BuildCreateSessionCmd(const Profiler
|
||||
GetCommandResponsePtr PluginCommandBuilder::BuildDestroySessionCmd(uint32_t pluginId)
|
||||
{
|
||||
auto cmd = std::make_shared<GetCommandResponse>();
|
||||
cmd->set_status(0);
|
||||
cmd->set_status(ResponseStatus::OK);
|
||||
cmd->set_has_more(false);
|
||||
cmd->set_command_id(cmdIdAutoIncrease_);
|
||||
|
||||
@ -59,7 +59,7 @@ GetCommandResponsePtr PluginCommandBuilder::BuildDestroySessionCmd(uint32_t plug
|
||||
GetCommandResponsePtr PluginCommandBuilder::BuildStartSessionCmd(const ProfilerPluginConfig& config, uint32_t pluginId)
|
||||
{
|
||||
auto cmd = std::make_shared<GetCommandResponse>();
|
||||
cmd->set_status(0);
|
||||
cmd->set_status(ResponseStatus::OK);
|
||||
cmd->set_has_more(false);
|
||||
cmd->set_command_id(cmdIdAutoIncrease_);
|
||||
|
||||
@ -76,7 +76,7 @@ GetCommandResponsePtr PluginCommandBuilder::BuildStartSessionCmd(const ProfilerP
|
||||
GetCommandResponsePtr PluginCommandBuilder::BuildStopSessionCmd(uint32_t pluginId)
|
||||
{
|
||||
auto cmd = std::make_shared<GetCommandResponse>();
|
||||
cmd->set_status(0);
|
||||
cmd->set_status(ResponseStatus::OK);
|
||||
cmd->set_has_more(false);
|
||||
cmd->set_command_id(cmdIdAutoIncrease_);
|
||||
|
||||
|
@ -36,12 +36,12 @@ bool PluginServiceImpl::RegisterPlugin(SocketContext& context,
|
||||
pluginInfo.context = &context;
|
||||
|
||||
if (pluginService->AddPluginInfo(pluginInfo)) {
|
||||
response.set_status(0);
|
||||
response.set_status(ResponseStatus::OK);
|
||||
response.set_plugin_id(pluginService->GetPluginIdByName(pluginInfo.name));
|
||||
HILOG_DEBUG(LOG_CORE, "RegisterPlugin OK");
|
||||
return true;
|
||||
}
|
||||
response.set_status(1);
|
||||
response.set_status(ResponseStatus::ERR);
|
||||
HILOG_DEBUG(LOG_CORE, "RegisterPlugin FAIL");
|
||||
return false;
|
||||
}
|
||||
@ -53,11 +53,11 @@ bool PluginServiceImpl::UnregisterPlugin(SocketContext& context,
|
||||
pluginInfo.id = request.plugin_id();
|
||||
|
||||
if (pluginService->RemovePluginInfo(pluginInfo)) {
|
||||
response.set_status(0);
|
||||
response.set_status(ResponseStatus::OK);
|
||||
HILOG_DEBUG(LOG_CORE, "UnregisterPlugin OK");
|
||||
return true;
|
||||
}
|
||||
response.set_status(1);
|
||||
response.set_status(ResponseStatus::ERR);
|
||||
HILOG_DEBUG(LOG_CORE, "UnregisterPlugin FAIL");
|
||||
return false;
|
||||
}
|
||||
@ -73,10 +73,10 @@ bool PluginServiceImpl::NotifyResult(SocketContext& context,
|
||||
{
|
||||
HILOG_DEBUG(LOG_CORE, "NotifyResult");
|
||||
if (pluginService->AppendResult(request)) {
|
||||
response.set_status(0);
|
||||
response.set_status(ResponseStatus::OK);
|
||||
return true;
|
||||
}
|
||||
response.set_status(1);
|
||||
response.set_status(ResponseStatus::ERR);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ HWTEST_F(ModuleTestPluginService, RegisterPlugin, TestSize.Level1)
|
||||
request.set_path("abc.so");
|
||||
request.set_sha256("ADSFAFASFASFASF");
|
||||
request.set_name("abc.so");
|
||||
ASSERT_TRUE(response.status() == 0);
|
||||
ASSERT_TRUE(response.status() != ResponseStatus::OK);
|
||||
g_pluginId = response.plugin_id();
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ HWTEST_F(UnitTestPluginService, AddPluginInfo, TestSize.Level1)
|
||||
request.set_path("abc.so");
|
||||
request.set_sha256("asdfasdfasdfasfd");
|
||||
request.set_name("abc.so");
|
||||
ASSERT_TRUE(response.status() == 0);
|
||||
ASSERT_TRUE(response.status() != ResponseStatus::OK);
|
||||
pluginId_ = response.plugin_id();
|
||||
|
||||
plugin.name = "abc.so";
|
||||
@ -216,7 +216,7 @@ HWTEST_F(UnitTestPluginService, AddPluginInfo2, TestSize.Level1)
|
||||
request.set_path("mem.so");
|
||||
request.set_sha256("asdfasdfasdfasfd");
|
||||
request.set_name("mem.so");
|
||||
ASSERT_TRUE(response.status() == 0);
|
||||
ASSERT_TRUE(response.status() != ResponseStatus::OK);
|
||||
pluginId_ = response.plugin_id();
|
||||
|
||||
plugin.name = "mem.so";
|
||||
@ -359,7 +359,7 @@ HWTEST_F(UnitTestPluginService, AddPluginInfo3, TestSize.Level1)
|
||||
request.set_path("cpu.so");
|
||||
request.set_sha256("asdfasdfasdfasfd");
|
||||
request.set_name("cpu.so");
|
||||
ASSERT_TRUE(response.status() == 0);
|
||||
ASSERT_TRUE(response.status() != ResponseStatus::OK);
|
||||
pluginId_ = response.plugin_id();
|
||||
|
||||
plugin.name = "cpu.so";
|
||||
@ -502,7 +502,7 @@ HWTEST_F(UnitTestPluginService, AddPluginInfo4, TestSize.Level1)
|
||||
request.set_path("stream.so");
|
||||
request.set_sha256("asdfasdfasdfasfd");
|
||||
request.set_name("stream.so");
|
||||
ASSERT_TRUE(response.status() == 0);
|
||||
ASSERT_TRUE(response.status() != ResponseStatus::OK);
|
||||
pluginId_ = response.plugin_id();
|
||||
|
||||
plugin.name = "stream.so";
|
||||
@ -645,7 +645,7 @@ HWTEST_F(UnitTestPluginService, AddPluginInfo5, TestSize.Level1)
|
||||
request.set_path("sample.so");
|
||||
request.set_sha256("asdfasdfasdfasfd");
|
||||
request.set_name("sample.so");
|
||||
ASSERT_TRUE(response.status() == 0);
|
||||
ASSERT_TRUE(response.status() != ResponseStatus::OK);
|
||||
pluginId_ = response.plugin_id();
|
||||
|
||||
plugin.name = "sample.so";
|
||||
|
@ -158,20 +158,20 @@ HWTEST_F(SharedMemoryBlockTest, PutMessage, TestSize.Level1)
|
||||
ASSERT_TRUE(shareMemoryBlock.GetDataSize() == 0);
|
||||
|
||||
NotifyResultResponse response;
|
||||
response.set_status(123);
|
||||
response.set_status(ResponseStatus::OK);
|
||||
ASSERT_TRUE(shareMemoryBlock.PutMessage(response));
|
||||
EXPECT_EQ(shareMemoryBlock.GetDataSize(), response.ByteSizeLong());
|
||||
response.ParseFromArray(shareMemoryBlock.GetDataPoint(), shareMemoryBlock.GetDataSize());
|
||||
ASSERT_TRUE(response.status() == 123);
|
||||
ASSERT_TRUE(response.status() == ResponseStatus::OK);
|
||||
|
||||
// 调用next移动指针,取值正常
|
||||
shareMemoryBlock.Next();
|
||||
NotifyResultResponse response2;
|
||||
response2.set_status(2345);
|
||||
response2.set_status(ResponseStatus::OK);
|
||||
ASSERT_TRUE(shareMemoryBlock.PutMessage(response2));
|
||||
EXPECT_EQ(shareMemoryBlock.GetDataSize(), response2.ByteSizeLong());
|
||||
response2.ParseFromArray(shareMemoryBlock.GetDataPoint(), shareMemoryBlock.GetDataSize());
|
||||
EXPECT_TRUE(response2.status() == 2345);
|
||||
EXPECT_TRUE(response2.status() == ResponseStatus::OK);
|
||||
|
||||
// 调用next,设置空message
|
||||
shareMemoryBlock.Next();
|
||||
@ -194,21 +194,21 @@ HWTEST_F(SharedMemoryBlockTest, PutMessageAbnormal, TestSize.Level1)
|
||||
ASSERT_TRUE(shareMemoryBlock.GetDataSize() == 0);
|
||||
|
||||
NotifyResultResponse response;
|
||||
response.set_status(123);
|
||||
response.set_status(ResponseStatus::OK);
|
||||
ASSERT_TRUE(shareMemoryBlock.PutMessage(response));
|
||||
EXPECT_EQ(shareMemoryBlock.GetDataSize(), response.ByteSizeLong());
|
||||
response.ParseFromArray(shareMemoryBlock.GetDataPoint(), shareMemoryBlock.GetDataSize());
|
||||
ASSERT_TRUE(response.status() == 123);
|
||||
ASSERT_TRUE(response.status() == ResponseStatus::OK);
|
||||
|
||||
// 不调用next无法移动指针,取值出错
|
||||
NotifyResultResponse response2;
|
||||
response2.set_status(2345);
|
||||
response2.set_status(ResponseStatus::ERR);
|
||||
ASSERT_TRUE(shareMemoryBlock.PutMessage(response2));
|
||||
EXPECT_NE(shareMemoryBlock.GetDataSize(), response2.ByteSizeLong());
|
||||
EXPECT_EQ(shareMemoryBlock.GetDataSize(), response2.ByteSizeLong());
|
||||
EXPECT_EQ(shareMemoryBlock.GetDataSize(), response.ByteSizeLong());
|
||||
response2.ParseFromArray(shareMemoryBlock.GetDataPoint(), shareMemoryBlock.GetDataSize());
|
||||
EXPECT_FALSE(response2.status() == 2345);
|
||||
EXPECT_TRUE(response2.status() == 123);
|
||||
EXPECT_FALSE(response2.status() == ResponseStatus::ERR);
|
||||
EXPECT_TRUE(response2.status() == ResponseStatus::OK);
|
||||
|
||||
ASSERT_TRUE(shareMemoryBlock.ReleaseBlock());
|
||||
}
|
||||
@ -267,7 +267,7 @@ HWTEST_F(SharedMemoryBlockTest, TakeData, TestSize.Level1)
|
||||
// 不匹配的非空message
|
||||
shareMemoryBlock.Next();
|
||||
NotifyResultResponse response;
|
||||
response.set_status(123);
|
||||
response.set_status(ResponseStatus::OK);
|
||||
ASSERT_TRUE(shareMemoryBlock.PutMessage(response));
|
||||
EXPECT_FALSE(shareMemoryBlock.GetDataSize() == 0);
|
||||
EXPECT_FALSE(shareMemoryBlock.TakeData(function));
|
||||
|
@ -270,7 +270,6 @@ public class MultiDeviceManager {
|
||||
if (pushDevToolsShell(deviceIPPortInfo)) {
|
||||
boolean pushShellResult = pushHiProfilerTools(deviceIPPortInfo);
|
||||
if (pushShellResult) {
|
||||
pushHiPerfFIle(deviceIPPortInfo);
|
||||
pushDevTools(deviceIPPortInfo);
|
||||
}
|
||||
String cap = isServiceCapability(deviceIPPortInfo, false, 0);
|
||||
|
@ -31,7 +31,7 @@ import java.util.Map;
|
||||
* @since 2021/8/22
|
||||
*/
|
||||
public class HiPerfCommand extends PerfCommand {
|
||||
private static final String HIPERF_COMMAND = "/data/local/tmp/hiperf";
|
||||
private static final String HIPERF_COMMAND = "hiperf";
|
||||
private static final Logger LOGGER = LogManager.getLogger(HiPerfCommand.class);
|
||||
|
||||
/**
|
||||
@ -80,10 +80,6 @@ public class HiPerfCommand extends PerfCommand {
|
||||
recordCommand.add(config.getCpuPercent() + "");
|
||||
}
|
||||
recordEvent(config, recordCommand);
|
||||
if (config.getPeriod() != 0) {
|
||||
recordCommand.add("--period");
|
||||
recordCommand.add(config.getPeriod() + "");
|
||||
}
|
||||
recordEnum(config, recordCommand);
|
||||
if (config.isOffCpu()) {
|
||||
recordCommand.add("--offcpu");
|
||||
|
@ -219,7 +219,6 @@ function unzip_start_daemon(){
|
||||
|
||||
function untar_start_daemon(){
|
||||
uzip_std_file $1
|
||||
init_hiperf
|
||||
start_std_daemon
|
||||
exit 0
|
||||
}
|
||||
|
@ -17,6 +17,13 @@ import "common_types.proto";
|
||||
|
||||
// Message define for IPC interface, imported by plugin service proto file.
|
||||
// for RegisterPlugin API
|
||||
|
||||
enum ResponseStatus {
|
||||
STATUS_UNSPECIFIED = 0;
|
||||
OK = 1;
|
||||
ERR = 2;
|
||||
}
|
||||
|
||||
message RegisterPluginRequest {
|
||||
uint32 request_id = 1;
|
||||
string path = 2;
|
||||
@ -27,7 +34,7 @@ message RegisterPluginRequest {
|
||||
}
|
||||
|
||||
message RegisterPluginResponse {
|
||||
uint32 status = 1;
|
||||
ResponseStatus status = 1;
|
||||
uint32 plugin_id = 2;
|
||||
}
|
||||
|
||||
@ -38,7 +45,7 @@ message UnregisterPluginRequest {
|
||||
}
|
||||
|
||||
message UnregisterPluginResponse {
|
||||
uint32 status = 1;
|
||||
ResponseStatus status = 1;
|
||||
}
|
||||
|
||||
// for GetCommand API
|
||||
@ -65,7 +72,7 @@ message StopSessionCmd {
|
||||
}
|
||||
|
||||
message GetCommandResponse {
|
||||
uint32 status = 1;
|
||||
ResponseStatus status = 1;
|
||||
bool has_more = 2;
|
||||
uint32 command_id = 3;
|
||||
oneof command {
|
||||
@ -99,5 +106,5 @@ message NotifyResultRequest {
|
||||
}
|
||||
|
||||
message NotifyResultResponse {
|
||||
uint32 status = 1;
|
||||
ResponseStatus status = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user