mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-12-04 05:41:28 +00:00
代码同步-OpenHarmony-5.0-Releas
Signed-off-by:wenlong12 <wenlong12@huawei.com> Signed-off-by: wenlong12 <wenlong12@huawei.com>
This commit is contained in:
parent
815a810f55
commit
fd07e6c6e5
4
OAT.xml
4
OAT.xml
@ -56,7 +56,7 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility, license header policies">
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/.*" desc="test resource file, no license header"/>
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/dwarf/.*" desc="test resource file, no license header"/>
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/report/.*" desc="test resource file, no license header"/>
|
||||
@ -119,8 +119,6 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/dwarf.uncompress.data" desc="the binary file for test, the file is self-developed"/>
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/fp.compress.data" desc="the binary file for test, the file is self-developed"/>
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/fp.uncompress.data" desc="the binary file for test, the file is self-developed"/>
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/invalid_perf.data.tar.gz" desc="the binary file for test, the file is self-developed"/>
|
||||
<filteritem type="filepath" name="test/unittest/resource/testdata/invalid_gzip_perf.data.tar.gz" desc="the binary file for test, the file is self-developed"/>
|
||||
<filteritem type="filepath" name="demo/js/entry/src/main/resources/base/media/icon.png" desc="the binary file, the file is self-picture"/>
|
||||
<filteritem type="filepath" name="figures/hiperf_architecture.png" desc="the binary file, the file is self-picture"/>
|
||||
<filteritem type="filepath" name="figures/hiperf_architecture_zh.png" desc="the binary file, the file is self-picture"/>
|
||||
|
@ -20,12 +20,6 @@
|
||||
|
||||
using namespace OHOS::Developtools::HiPerf;
|
||||
|
||||
#if defined(__aarch64__)
|
||||
const std::string TEST_PROCESSES = "com.ohos.sceneboard";
|
||||
#else
|
||||
const std::string TEST_PROCESSES = "com.ohos.launcher";
|
||||
#endif
|
||||
|
||||
namespace HiperfClientDemo {
|
||||
void TestCodeThread(int id)
|
||||
{
|
||||
@ -34,6 +28,7 @@ void TestCodeThread(int id)
|
||||
constexpr uint32_t k10 = 10 * k;
|
||||
constexpr uint32_t two = 2;
|
||||
constexpr uint64_t thousand = 1000;
|
||||
const std::string testProcesses = "com.ohos.sceneboard";
|
||||
|
||||
std::vector<std::unique_ptr<char[]>> mems;
|
||||
printf("TestCodeThread %d:++\n", id);
|
||||
@ -70,7 +65,7 @@ int main()
|
||||
printf("demo start\n");
|
||||
HiperfClient::RecordOption opt;
|
||||
const int timeout = 30;
|
||||
opt.SetAppPackage(TEST_PROCESSES);
|
||||
opt.SetAppPackage(testProcesses);
|
||||
opt.SetTimeStopSec(timeout);
|
||||
if (myHiperf.Start(opt)) {
|
||||
printf("demo start successfully\n");
|
||||
|
@ -56,11 +56,6 @@ static unsigned int SpePayloadLen(unsigned char hdr)
|
||||
static int SpeGetPayload(const unsigned char *buf, size_t len,
|
||||
unsigned char extHdr, struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
size_t payloadLen = SpePayloadLen(buf[extHdr]);
|
||||
if (len < 1 + extHdr + payloadLen) {
|
||||
return PERF_SPE_NEED_MORE_BYTES;
|
||||
@ -80,11 +75,6 @@ static int SpeGetPayload(const unsigned char *buf, size_t len,
|
||||
|
||||
static int SpeGetPad(struct SpePkt *packet)
|
||||
{
|
||||
if (packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_PAD;
|
||||
return 1;
|
||||
}
|
||||
@ -92,11 +82,6 @@ static int SpeGetPad(struct SpePkt *packet)
|
||||
static int SpeGetAlignment(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
unsigned int alignment = 1 << ((buf[0] & 0xf) + 1);
|
||||
|
||||
if (len < alignment)
|
||||
@ -108,11 +93,6 @@ static int SpeGetAlignment(const unsigned char *buf, size_t len,
|
||||
|
||||
static int SpeGetEnd(struct SpePkt *packet)
|
||||
{
|
||||
if (packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_END;
|
||||
return 1;
|
||||
}
|
||||
@ -120,11 +100,6 @@ static int SpeGetEnd(struct SpePkt *packet)
|
||||
static int SpeGetTimestamp(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_TIMESTAMP;
|
||||
return SpeGetPayload(buf, len, 0, packet);
|
||||
}
|
||||
@ -132,11 +107,6 @@ static int SpeGetTimestamp(const unsigned char *buf, size_t len,
|
||||
static int SpeGetEvents(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_EVENTS;
|
||||
packet->index = SpePayloadLen(buf[0]);
|
||||
return SpeGetPayload(buf, len, 0, packet);
|
||||
@ -145,11 +115,6 @@ static int SpeGetEvents(const unsigned char *buf, size_t len,
|
||||
static int SpeGetDataSource(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_DATA_SOURCE;
|
||||
return SpeGetPayload(buf, len, 0, packet);
|
||||
}
|
||||
@ -157,11 +122,6 @@ static int SpeGetDataSource(const unsigned char *buf, size_t len,
|
||||
static int SpeGetContext(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_CONTEXT;
|
||||
packet->index = PERF_SPE_CTX_PKT_HDR_INDEX(buf[0]);
|
||||
return SpeGetPayload(buf, len, 0, packet);
|
||||
@ -170,11 +130,6 @@ static int SpeGetContext(const unsigned char *buf, size_t len,
|
||||
static int SpeGetOpType(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_OP_TYPE;
|
||||
packet->index = PERF_SPE_OP_PKT_HDR_CLASS(buf[0]);
|
||||
return SpeGetPayload(buf, len, 0, packet);
|
||||
@ -183,11 +138,6 @@ static int SpeGetOpType(const unsigned char *buf, size_t len,
|
||||
static int SpeGetCounter(const unsigned char *buf, size_t len,
|
||||
const unsigned char extHdr, struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_COUNTER;
|
||||
if (extHdr) {
|
||||
packet->index = PERF_SPE_HDR_EXTENDED_INDEX(buf[0], buf[1]);
|
||||
@ -201,11 +151,6 @@ static int SpeGetCounter(const unsigned char *buf, size_t len,
|
||||
static int SpeGetAddr(const unsigned char *buf, size_t len,
|
||||
const unsigned char extHdr, struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
packet->type = PERF_SPE_ADDRESS;
|
||||
if (extHdr) {
|
||||
packet->index = PERF_SPE_HDR_EXTENDED_INDEX(buf[0], buf[1]);
|
||||
@ -219,11 +164,6 @@ static int SpeGetAddr(const unsigned char *buf, size_t len,
|
||||
static int SpeDoGetPacket(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
unsigned int hdr;
|
||||
unsigned char extHdr = 0;
|
||||
|
||||
@ -283,11 +223,6 @@ static int SpeDoGetPacket(const unsigned char *buf, size_t len,
|
||||
int SpeGetPacket(const unsigned char *buf, size_t len,
|
||||
struct SpePkt *packet)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
int ret = SpeDoGetPacket(buf, len, packet);
|
||||
/* put multiple consecutive PADs on the same line, up to
|
||||
* the fixed-width output format of 16 bytes per line.
|
||||
@ -303,11 +238,6 @@ int SpeGetPacket(const unsigned char *buf, size_t len,
|
||||
static int SpePktOutString(int *err, char **bufPtr, size_t *bufLen,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
if (*bufPtr == nullptr || bufLen == nullptr || fmt == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
va_list args;
|
||||
int ret = 0;
|
||||
|
||||
@ -350,11 +280,6 @@ static int SpePktOutString(int *err, char **bufPtr, size_t *bufLen,
|
||||
static int SpePktDescEvent(const struct SpePkt *packet,
|
||||
char *buf, size_t bufLen)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
u64 payload = packet->payload;
|
||||
int err = 0;
|
||||
|
||||
@ -408,11 +333,6 @@ static int SpePktDescEvent(const struct SpePkt *packet,
|
||||
static int SpePktDescOpType(const struct SpePkt *packet,
|
||||
char *buf, size_t bufLen)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
u64 payload = packet->payload;
|
||||
int err = 0;
|
||||
|
||||
@ -508,11 +428,6 @@ static int SpePktDescOpType(const struct SpePkt *packet,
|
||||
static int SpePktDescAddr(const struct SpePkt *packet,
|
||||
char *buf, size_t bufLen)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
int ns;
|
||||
int el;
|
||||
int idx = packet->index;
|
||||
@ -558,11 +473,6 @@ static int SpePktDescAddr(const struct SpePkt *packet,
|
||||
static int SpePktDesCont(const struct SpePkt *packet,
|
||||
char *buf, size_t bufLen)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
u64 payload = packet->payload;
|
||||
const char *name = SpePktName(packet->type);
|
||||
int err = 0;
|
||||
@ -590,11 +500,6 @@ static int SpePktDesCont(const struct SpePkt *packet,
|
||||
int SpePktDesc(const struct SpePkt *packet, char *buf,
|
||||
size_t bufLen)
|
||||
{
|
||||
if (buf == nullptr || packet == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
int idx = packet->index;
|
||||
unsigned long long payload = packet->payload;
|
||||
const char *name = SpePktName(packet->type);
|
||||
@ -705,11 +610,6 @@ static u64 SpeCalcIp(int index, u64 payload)
|
||||
|
||||
struct SpeDecoder *SpeDecoderNew(struct SpeParams *params)
|
||||
{
|
||||
if (params == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return NULL;
|
||||
}
|
||||
struct SpeDecoder *decoder;
|
||||
|
||||
decoder = static_cast<struct SpeDecoder*>(malloc(sizeof(struct SpeDecoder)));
|
||||
@ -724,21 +624,11 @@ struct SpeDecoder *SpeDecoderNew(struct SpeParams *params)
|
||||
|
||||
void SpeDecoderFree(struct SpeDecoder *decoder)
|
||||
{
|
||||
if (decoder == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return;
|
||||
}
|
||||
free(decoder);
|
||||
}
|
||||
|
||||
static int SpeGetNextPacket(struct SpeDecoder *decoder)
|
||||
{
|
||||
if (decoder == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
int ret = 1;
|
||||
|
||||
do {
|
||||
@ -894,21 +784,11 @@ static int SpeReadRecord(struct SpeDecoder *decoder)
|
||||
|
||||
int SpeDecode(struct SpeDecoder *decoder)
|
||||
{
|
||||
if (decoder == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return -1;
|
||||
}
|
||||
return SpeReadRecord(decoder);
|
||||
}
|
||||
|
||||
struct SpeDecoder *SpeDecoderDataNew(const unsigned char *speBuf, size_t speLen)
|
||||
{
|
||||
if (speBuf == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return NULL;
|
||||
}
|
||||
struct SpeDecoder *decoder;
|
||||
|
||||
decoder = reinterpret_cast<SpeDecoder *>(malloc(sizeof(struct SpeDecoder)));
|
||||
@ -925,11 +805,6 @@ struct SpeDecoder *SpeDecoderDataNew(const unsigned char *speBuf, size_t speLen)
|
||||
|
||||
void SpeDumpRawData(unsigned char *buf, size_t len, int indent, FILE *outputDump)
|
||||
{
|
||||
if (buf == nullptr) {
|
||||
printf("Invalid pointer!\n");
|
||||
HLOGV("Invalid pointer!");
|
||||
return;
|
||||
}
|
||||
if (outputDump != nullptr) {
|
||||
g_outputDump = outputDump;
|
||||
}
|
||||
|
@ -20,10 +20,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <hilog/log.h>
|
||||
|
||||
#if defined(__aarch64__)
|
||||
const std::string TEST_PROCESSES = "com.ohos.sceneboard";
|
||||
#else
|
||||
const std::string TEST_PROCESSES = "com.ohos.launcher";
|
||||
#endif
|
||||
|
||||
#endif // HIPERF_UTILITIES_TEST_H
|
||||
|
@ -1076,7 +1076,7 @@ HWTEST_F(SubCommandRecordTest, FileSizeOnFrequency500_DWARF_PROCESS, TestSize.Le
|
||||
*/
|
||||
HWTEST_F(SubCommandRecordTest, FileSizeOnFrequency1000_DWARF_PROCESS, TestSize.Level1)
|
||||
{
|
||||
ForkAndRunTest("-d 10 --app -f 1000 -s dwarf", true, true);
|
||||
ForkAndRunTest("-d 10 -f 1000 -s dwarf", true, true);
|
||||
std::string fileName = TEST_FILE;
|
||||
size_t fileSize = GetFileSize(fileName.c_str());
|
||||
EXPECT_LE(fileSize, TEST_SIZE_F1000_DWARF_PROCESS);
|
||||
|
@ -205,48 +205,6 @@ HWTEST_F(SubCommandReportTest, TestOnSubCommand_i, TestSize.Level1)
|
||||
EXPECT_EQ(FileCompare(stringOut, targetFile), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TestOnSubCommand_gzip_fail
|
||||
* @tc.desc:
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SubCommandReportTest, TestOnSubCommand_gzip_fail, TestSize.Level1)
|
||||
{
|
||||
StdoutRecord stdoutRecord;
|
||||
stdoutRecord.Start();
|
||||
const auto startTime = chrono::steady_clock::now();
|
||||
EXPECT_EQ(Command::DispatchCommand("report -i " + RESOURCE_PATH + "invalid_perf.data.tar.gz"), false);
|
||||
const auto costMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
chrono::steady_clock::now() - startTime);
|
||||
EXPECT_LE(costMs.count(), DEFAULT_RUN_TIMEOUT_MS);
|
||||
|
||||
std::string stringOut = stdoutRecord.Stop();
|
||||
if (HasFailure()) {
|
||||
printf("output:\n%s", stringOut.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TestOnSubCommand_gzip_fail1
|
||||
* @tc.desc:
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SubCommandReportTest, TestOnSubCommand_gzip_fail1, TestSize.Level1)
|
||||
{
|
||||
StdoutRecord stdoutRecord;
|
||||
stdoutRecord.Start();
|
||||
const auto startTime = chrono::steady_clock::now();
|
||||
EXPECT_EQ(Command::DispatchCommand("report -i " + RESOURCE_PATH + "invalid_gzip_perf.data.tar.gz"), false);
|
||||
const auto costMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
chrono::steady_clock::now() - startTime);
|
||||
EXPECT_LE(costMs.count(), DEFAULT_RUN_TIMEOUT_MS);
|
||||
|
||||
std::string stringOut = stdoutRecord.Stop();
|
||||
if (HasFailure()) {
|
||||
printf("output:\n%s", stringOut.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TestOnSubCommand_i1
|
||||
* @tc.desc:
|
||||
|
@ -274,7 +274,7 @@ HWTEST_F(SymbolsFileTest, LoadKernelSymbols, TestSize.Level1)
|
||||
|
||||
// add [kernel.kallsyms]
|
||||
if (modulesCount.size() != lines + 1u) {
|
||||
printf("warn: modulesCount != lines + 1, modulesCount: %zu\n", modulesCount.size());
|
||||
printf("warn: modulesCount != lines + 1\n");
|
||||
}
|
||||
if (HasFailure()) {
|
||||
for (auto &module : modulesCount) {
|
||||
@ -536,13 +536,6 @@ HWTEST_F(SymbolsFileTest, GetSymbolWithVaddrFullMatch, TestSize.Level1)
|
||||
EXPECT_EQ(elfSymbols->GetSymbolWithVaddr(addr).demangle_, "__libc_csu_init");
|
||||
}
|
||||
}
|
||||
#ifdef __arm__
|
||||
for (uint64_t addr = SymbolAddr::CSU_FINI; addr < SymbolAddr::THUNK_BP; ++addr) {
|
||||
if (elfSymbols->GetSymbolWithVaddr(addr).IsValid()) {
|
||||
EXPECT_EQ(elfSymbols->GetSymbolWithVaddr(addr).demangle_, "__libc_csu_fini");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (HasFailure()) {
|
||||
PrintSymbols(elfSymbols->GetSymbols());
|
||||
}
|
||||
|
@ -79,8 +79,6 @@
|
||||
|
||||
<option name="push" value="testdata/perfnew.data -> /data/test/resource/testdata/" src="res"/>
|
||||
<option name="push" value="testdata/report_test.data -> /data/test/resource/testdata/" src="res"/>
|
||||
<option name="push" value="testdata/invalid_gzip_perf.data.tar.gz -> /data/test/resource/testdata/" src="res"/>
|
||||
<option name="push" value="testdata/invalid_perf.data.tar.gz -> /data/test/resource/testdata/" src="res"/>
|
||||
<option name="push" value="testdata/report_test_i.txt -> /data/test/resource/testdata/" src="res"/>
|
||||
<option name="push" value="testdata/report_test_diff.txt -> /data/test/resource/testdata/" src="res"/>
|
||||
<option name="push" value="testdata/report_test_sort1.txt -> /data/test/resource/testdata/" src="res"/>
|
||||
|
Loading…
Reference in New Issue
Block a user