• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "subcommand_dump_test.h"
17 
18 #include <algorithm>
19 #include <chrono>
20 #include <cinttypes>
21 #include <sched.h>
22 #include <sstream>
23 #include <thread>
24 
25 #include "command.h"
26 #include "debug_logger.h"
27 #include "utilities.h"
28 
29 using namespace std::literals::chrono_literals;
30 using namespace testing::ext;
31 using namespace std;
32 using namespace OHOS::HiviewDFX;
33 namespace OHOS {
34 namespace Developtools {
35 namespace HiPerf {
36 class SubCommandDumpTest : public testing::Test {
37 public:
38     static void SetUpTestCase(void);
39     static void TearDownTestCase(void);
40     void SetUp();
41     void TearDown();
42 
43     void TestDumpCommand(const std::string &option, bool expect = true) const;
44 };
45 
SetUpTestCase()46 void SubCommandDumpTest::SetUpTestCase()
47 {
48     SubCommand::ClearSubCommands();
49 }
50 
TearDownTestCase()51 void SubCommandDumpTest::TearDownTestCase() {}
52 
SetUp()53 void SubCommandDumpTest::SetUp()
54 {
55     // clear the subCommands left from other UT
56     SubCommand::ClearSubCommands();
57     ASSERT_EQ(SubCommand::GetSubCommands().size(), 0u);
58     SubCommandDump::RegisterSubCommandDump();
59     ASSERT_EQ(SubCommand::GetSubCommands().size(), 1u);
60 }
61 
TearDown()62 void SubCommandDumpTest::TearDown()
63 {
64     ASSERT_EQ(SubCommand::GetSubCommands().size(), 1u);
65     SubCommand::ClearSubCommands();
66     ASSERT_EQ(SubCommand::GetSubCommands().size(), 0u);
67 }
68 
TestDumpCommand(const std::string & option,bool expect) const69 void SubCommandDumpTest::TestDumpCommand(const std::string &option, bool expect) const
70 {
71     StdoutRecord stdoutRecord;
72 
73     std::string cmdString = "dump";
74     cmdString += " " + option + " ";
75 
76     // it need load some symbols and much more log
77 
78     ScopeDebugLevel tempLogLevel {LEVEL_DEBUG};
79 
80     stdoutRecord.Start();
81     const auto startTime = chrono::steady_clock::now();
82     bool ret = Command::DispatchCommand(cmdString);
83     const auto costMs = std::chrono::duration_cast<std::chrono::milliseconds>(
84         chrono::steady_clock::now() - startTime);
85     std::string stringOut = stdoutRecord.Stop();
86 
87     printf("command : %s(run %" PRId64 " ms) return %s(expect %s)\n", cmdString.c_str(),
88            (uint64_t)costMs.count(), ret ? "true" : "false", expect ? "true" : "false");
89     EXPECT_EQ(expect, ret);
90     if (expect) {
91         EXPECT_EQ(SubStringCount(stringOut, "HILOG/E"), 0u);
92     }
93 }
94 
95 /**
96  * @tc.name:
97  * @tc.desc: record
98  * @tc.type: FUNC
99  */
100 
101 HWTEST_F(SubCommandDumpTest, Test_LibReport_Success, TestSize.Level1)
102 {
103     StdoutRecord stdoutRecord;
104     stdoutRecord.Start();
105     std::string cmdString = "dump -i /data/test/resource/testdata/report/perf.data.libreport";
106     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
107     std::string stringOut = stdoutRecord.Stop();
108     size_t symbolsCount = 39;
109     size_t buildIdCount = 32;
110     size_t sampleCount = 1000;
111     size_t featureCount = 10;
112 
113     EXPECT_EQ(stringOut.find("magic: PERFILE2") != std::string::npos, true);
114     EXPECT_EQ(SubStringCount(stringOut, "fileid:"), symbolsCount);
115     EXPECT_EQ(SubStringCount(stringOut, "buildId:"), buildIdCount);
116     EXPECT_EQ(SubStringCount(stringOut, "record sample:"), sampleCount);
117     EXPECT_EQ(SubStringCount(stringOut, "feature:"), featureCount);
118 }
119 
120 HWTEST_F(SubCommandDumpTest, DumpInputFilename1, TestSize.Level1)
121 {
122     TestDumpCommand("/data/test/resource/testdata/perf.data ", false);
123 }
124 
125 HWTEST_F(SubCommandDumpTest, DumpInputFilename2, TestSize.Level1)
126 {
127     TestDumpCommand("-i /data/test/resource/testdata/perf.data ");
128 }
129 
130 HWTEST_F(SubCommandDumpTest, DumpInputFilenamErr, TestSize.Level1)
131 {
132     TestDumpCommand("-i whatfile ", false);
133 }
134 
135 HWTEST_F(SubCommandDumpTest, DumpHeaderAttrs, TestSize.Level1)
136 {
137     TestDumpCommand("-i /data/test/resource/testdata/perf.data --head ");
138 }
139 
140 HWTEST_F(SubCommandDumpTest, DumpData, TestSize.Level1)
141 {
142     TestDumpCommand("-i /data/test/resource/testdata/perf.data -d ");
143 }
144 
145 HWTEST_F(SubCommandDumpTest, DumpFeatures, TestSize.Level1)
146 {
147     TestDumpCommand("-i /data/test/resource/testdata/perf.data -f ");
148 }
149 
150 HWTEST_F(SubCommandDumpTest, DumpSympath, TestSize.Level1)
151 {
152     TestDumpCommand("-i /data/test/resource/testdata/perf.data --sympath ./ ");
153 }
154 
155 HWTEST_F(SubCommandDumpTest, DumpSympathErr, TestSize.Level1)
156 {
157     TestDumpCommand("-i /data/test/resource/testdata/perf.data --sympath where ", false);
158 }
159 
160 HWTEST_F(SubCommandDumpTest, DumpExportUserdata0, TestSize.Level1)
161 {
162     TestDumpCommand("-i /data/test/resource/testdata/perf.data --export 0");
163 }
164 
165 HWTEST_F(SubCommandDumpTest, DumpExportUserdata1, TestSize.Level1)
166 {
167     TestDumpCommand("-i /data/test/resource/testdata/perf.data --export 1");
168 }
169 
170 HWTEST_F(SubCommandDumpTest, DumpElffile, TestSize.Level1)
171 {
172     TestDumpCommand("--elf /data/test/resource/testdata/elf_test ");
173 }
174 
175 HWTEST_F(SubCommandDumpTest, DumpElffileErr, TestSize.Level1)
176 {
177     TestDumpCommand("--elf whatfile ", false);
178 }
179 
180 HWTEST_F(SubCommandDumpTest, DumpInputElfConflict, TestSize.Level1)
181 {
182     TestDumpCommand("perf.data --elf elffile ", false);
183 }
184 
185 #if defined(HAVE_PROTOBUF) && HAVE_PROTOBUF
186 HWTEST_F(SubCommandDumpTest, DumpProtofile, TestSize.Level1)
187 {
188     TestDumpCommand("--proto /data/test/resource/testdata/proto_test ");
189 }
190 
191 HWTEST_F(SubCommandDumpTest, DumpProtofileErr, TestSize.Level1)
192 {
193     TestDumpCommand("--proto whatfile ", false);
194 }
195 
196 HWTEST_F(SubCommandDumpTest, DumpInputProtoConflict, TestSize.Level1)
197 {
198     TestDumpCommand("perf.data --proto ptotofile ", false);
199 }
200 
201 HWTEST_F(SubCommandDumpTest, DumpElfProtoConflict, TestSize.Level1)
202 {
203     TestDumpCommand("--elf elffile --proto ptotofile ", false);
204 }
205 #endif
206 
207 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfStackTable, TestSize.Level1)
208 {
209     StdoutRecord stdoutRecord;
210     stdoutRecord.Start();
211     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
212     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
213     std::string stringOut = stdoutRecord.Stop();
214 
215     EXPECT_EQ(stringOut.find("hiperf_stack_table") != std::string::npos, true);
216 }
217 
218 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfStackid, TestSize.Level1)
219 {
220     StdoutRecord stdoutRecord;
221     stdoutRecord.Start();
222     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
223     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
224     std::string stringOut = stdoutRecord.Stop();
225 
226     EXPECT_EQ(stringOut.find("stackid") != std::string::npos, true);
227 }
228 
229 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfTableNums, TestSize.Level1)
230 {
231     StdoutRecord stdoutRecord;
232     stdoutRecord.Start();
233     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
234     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
235     std::string stringOut = stdoutRecord.Stop();
236 
237     EXPECT_EQ(stringOut.find("TableNums") != std::string::npos, true);
238 }
239 
240 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfNumNodes, TestSize.Level1)
241 {
242     StdoutRecord stdoutRecord;
243     stdoutRecord.Start();
244     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
245     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
246     std::string stringOut = stdoutRecord.Stop();
247 
248     EXPECT_EQ(stringOut.find("numNodes") != std::string::npos, true);
249 }
250 
251 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfStackTableContent, TestSize.Level1)
252 {
253     StdoutRecord stdoutRecord;
254     stdoutRecord.Start();
255     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
256     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
257     std::string stringOut = stdoutRecord.Stop();
258 
259     EXPECT_EQ(stringOut.find("hiperf_stack_table content") != std::string::npos, true);
260 }
261 
262 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfTableid, TestSize.Level1)
263 {
264     StdoutRecord stdoutRecord;
265     stdoutRecord.Start();
266     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
267     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
268     std::string stringOut = stdoutRecord.Stop();
269 
270     EXPECT_EQ(stringOut.find("tableid") != std::string::npos, true);
271 }
272 
273 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfTableSize, TestSize.Level1)
274 {
275     StdoutRecord stdoutRecord;
276     stdoutRecord.Start();
277     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
278     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
279     std::string stringOut = stdoutRecord.Stop();
280 
281     EXPECT_EQ(stringOut.find("tableSize") != std::string::npos, true);
282 }
283 
284 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfKernelUpperBoundary, TestSize.Level1)
285 {
286     StdoutRecord stdoutRecord;
287     stdoutRecord.Start();
288     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
289     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
290     std::string stringOut = stdoutRecord.Stop();
291     std::string kernelUpperBoundary = "0xffffffffffffff80";
292     EXPECT_EQ(stringOut.find(kernelUpperBoundary) != std::string::npos, true);
293 }
294 
295 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfKernelLowerBoundary, TestSize.Level1)
296 {
297     StdoutRecord stdoutRecord;
298     stdoutRecord.Start();
299     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
300     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
301     std::string stringOut = stdoutRecord.Stop();
302     std::string kernelLowerBoundary = "0xfffffffffffffe00";
303     EXPECT_EQ(stringOut.find(kernelLowerBoundary) != std::string::npos, true);
304 }
305 
306 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfKernelIp, TestSize.Level1)
307 {
308     StdoutRecord stdoutRecord;
309     stdoutRecord.Start();
310     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
311     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
312     std::string stringOut = stdoutRecord.Stop();
313     std::string kernelIp = "0xffffffc011605050";
314     EXPECT_EQ(stringOut.find(kernelIp) != std::string::npos, true);
315 }
316 
317 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfUerIpFixZero, TestSize.Level1)
318 {
319     StdoutRecord stdoutRecord;
320     stdoutRecord.Start();
321     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
322     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
323     std::string stringOut = stdoutRecord.Stop();
324     std::string userIpFixZero = "0xffffffc0100fa3b0";
325     EXPECT_EQ(stringOut.find(userIpFixZero) != std::string::npos, true);
326 }
327 
328 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfUserIp, TestSize.Level1)
329 {
330     StdoutRecord stdoutRecord;
331     stdoutRecord.Start();
332     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
333     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
334     std::string stringOut = stdoutRecord.Stop();
335     std::string userIp = "0xf7b43f50";
336     EXPECT_EQ(stringOut.find(userIp) != std::string::npos, true);
337 }
338 
339 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfCallchain, TestSize.Level1)
340 {
341     StdoutRecord stdoutRecord;
342     stdoutRecord.Start();
343     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
344     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
345     std::string stringOut = stdoutRecord.Stop();
346     std::string callchain = "callchain nr=25";
347     EXPECT_EQ(stringOut.find(callchain) != std::string::npos, true);
348 }
349 
350 HWTEST_F(SubCommandDumpTest, DumpCompressDwarfSymbol, TestSize.Level1)
351 {
352     StdoutRecord stdoutRecord;
353     stdoutRecord.Start();
354     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.compress.data";
355     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
356     std::string stringOut = stdoutRecord.Stop();
357     std::string symbol = "0xffffffc01160072c : __schedule";
358     EXPECT_EQ(stringOut.find(symbol) != std::string::npos, true);
359 }
360 
361 HWTEST_F(SubCommandDumpTest, DumpCompressFpStackTable, TestSize.Level1)
362 {
363     StdoutRecord stdoutRecord;
364     stdoutRecord.Start();
365     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
366     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
367     std::string stringOut = stdoutRecord.Stop();
368 
369     EXPECT_EQ(stringOut.find("hiperf_stack_table") != std::string::npos, true);
370 }
371 
372 HWTEST_F(SubCommandDumpTest, DumpCompressFpStackid, TestSize.Level1)
373 {
374     StdoutRecord stdoutRecord;
375     stdoutRecord.Start();
376     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
377     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
378     std::string stringOut = stdoutRecord.Stop();
379 
380     EXPECT_EQ(stringOut.find("stackid") != std::string::npos, true);
381 }
382 
383 HWTEST_F(SubCommandDumpTest, DumpCompressFpTableNums, TestSize.Level1)
384 {
385     StdoutRecord stdoutRecord;
386     stdoutRecord.Start();
387     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
388     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
389     std::string stringOut = stdoutRecord.Stop();
390 
391     EXPECT_EQ(stringOut.find("TableNums") != std::string::npos, true);
392 }
393 
394 HWTEST_F(SubCommandDumpTest, DumpCompressFpNumNodes, TestSize.Level1)
395 {
396     StdoutRecord stdoutRecord;
397     stdoutRecord.Start();
398     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
399     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
400     std::string stringOut = stdoutRecord.Stop();
401 
402     EXPECT_EQ(stringOut.find("numNodes") != std::string::npos, true);
403 }
404 
405 HWTEST_F(SubCommandDumpTest, DumpCompressFpStackTableContent, TestSize.Level1)
406 {
407     StdoutRecord stdoutRecord;
408     stdoutRecord.Start();
409     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
410     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
411     std::string stringOut = stdoutRecord.Stop();
412 
413     EXPECT_EQ(stringOut.find("hiperf_stack_table content") != std::string::npos, true);
414 }
415 
416 HWTEST_F(SubCommandDumpTest, DumpCompressFpTableid, TestSize.Level1)
417 {
418     StdoutRecord stdoutRecord;
419     stdoutRecord.Start();
420     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
421     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
422     std::string stringOut = stdoutRecord.Stop();
423 
424     EXPECT_EQ(stringOut.find("tableid") != std::string::npos, true);
425 }
426 
427 HWTEST_F(SubCommandDumpTest, DumpCompressFpTableSize, TestSize.Level1)
428 {
429     StdoutRecord stdoutRecord;
430     stdoutRecord.Start();
431     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
432     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
433     std::string stringOut = stdoutRecord.Stop();
434 
435     EXPECT_EQ(stringOut.find("tableSize") != std::string::npos, true);
436 }
437 
438 HWTEST_F(SubCommandDumpTest, DumpCompressFpKernelUpperBoundary, TestSize.Level1)
439 {
440     StdoutRecord stdoutRecord;
441     stdoutRecord.Start();
442     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
443     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
444     std::string stringOut = stdoutRecord.Stop();
445     std::string kernelUpperBoundary = "0xffffffffffffff80";
446     EXPECT_EQ(stringOut.find(kernelUpperBoundary) != std::string::npos, true);
447 }
448 
449 HWTEST_F(SubCommandDumpTest, DumpCompressFpKernelLowerBoundary, TestSize.Level1)
450 {
451     StdoutRecord stdoutRecord;
452     stdoutRecord.Start();
453     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
454     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
455     std::string stringOut = stdoutRecord.Stop();
456     std::string kernelLowerBoundary = "0xfffffffffffffe00";
457     EXPECT_EQ(stringOut.find(kernelLowerBoundary) != std::string::npos, true);
458 }
459 
460 HWTEST_F(SubCommandDumpTest, DumpCompressFpKernelIp, TestSize.Level1)
461 {
462     StdoutRecord stdoutRecord;
463     stdoutRecord.Start();
464     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
465     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
466     std::string stringOut = stdoutRecord.Stop();
467     std::string kernelIp = "0xffffffc011605050";
468     EXPECT_EQ(stringOut.find(kernelIp) != std::string::npos, true);
469 }
470 
471 HWTEST_F(SubCommandDumpTest, DumpCompressFpUerIpFixZero, TestSize.Level1)
472 {
473     StdoutRecord stdoutRecord;
474     stdoutRecord.Start();
475     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
476     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
477     std::string stringOut = stdoutRecord.Stop();
478     std::string userIpFixZero = "0xffffffc0100fa3b0";
479     EXPECT_EQ(stringOut.find(userIpFixZero) != std::string::npos, true);
480 }
481 
482 HWTEST_F(SubCommandDumpTest, DumpCompressFpUserIp, TestSize.Level1)
483 {
484     StdoutRecord stdoutRecord;
485     stdoutRecord.Start();
486     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
487     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
488     std::string stringOut = stdoutRecord.Stop();
489     std::string userIp = "0xf7b43f50";
490     EXPECT_EQ(stringOut.find(userIp) != std::string::npos, true);
491 }
492 
493 HWTEST_F(SubCommandDumpTest, DumpCompressFpCallchain, TestSize.Level1)
494 {
495     StdoutRecord stdoutRecord;
496     stdoutRecord.Start();
497     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
498     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
499     std::string stringOut = stdoutRecord.Stop();
500     std::string callchain = "callchain nr=21";
501     EXPECT_EQ(stringOut.find(callchain) != std::string::npos, true);
502 }
503 
504 HWTEST_F(SubCommandDumpTest, DumpCompressFpSymbol, TestSize.Level1)
505 {
506     StdoutRecord stdoutRecord;
507     stdoutRecord.Start();
508     std::string cmdString = "dump -i /data/test/resource/testdata/fp.compress.data";
509     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
510     std::string stringOut = stdoutRecord.Stop();
511     std::string symbol = "0xffffffc011600984 : schedule";
512     EXPECT_EQ(stringOut.find(symbol) != std::string::npos, true);
513 }
514 
515 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfStackTable, TestSize.Level1)
516 {
517     StdoutRecord stdoutRecord;
518     stdoutRecord.Start();
519     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
520     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
521     std::string stringOut = stdoutRecord.Stop();
522 
523     EXPECT_EQ(stringOut.find("hiperf_stack_table") != std::string::npos, false);
524 }
525 
526 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfStackid, TestSize.Level1)
527 {
528     StdoutRecord stdoutRecord;
529     stdoutRecord.Start();
530     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
531     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
532     std::string stringOut = stdoutRecord.Stop();
533 
534     EXPECT_EQ(stringOut.find("stackid") != std::string::npos, false);
535 }
536 
537 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfTableNums, TestSize.Level1)
538 {
539     StdoutRecord stdoutRecord;
540     stdoutRecord.Start();
541     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
542     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
543     std::string stringOut = stdoutRecord.Stop();
544 
545     EXPECT_EQ(stringOut.find("TableNums") != std::string::npos, false);
546 }
547 
548 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfNumNodes, TestSize.Level1)
549 {
550     StdoutRecord stdoutRecord;
551     stdoutRecord.Start();
552     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
553     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
554     std::string stringOut = stdoutRecord.Stop();
555 
556     EXPECT_EQ(stringOut.find("numNodes") != std::string::npos, false);
557 }
558 
559 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfStackTableContent, TestSize.Level1)
560 {
561     StdoutRecord stdoutRecord;
562     stdoutRecord.Start();
563     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
564     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
565     std::string stringOut = stdoutRecord.Stop();
566 
567     EXPECT_EQ(stringOut.find("hiperf_stack_table content") != std::string::npos, false);
568 }
569 
570 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfTableid, TestSize.Level1)
571 {
572     StdoutRecord stdoutRecord;
573     stdoutRecord.Start();
574     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
575     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
576     std::string stringOut = stdoutRecord.Stop();
577 
578     EXPECT_EQ(stringOut.find("tableid") != std::string::npos, false);
579 }
580 
581 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfTableSize, TestSize.Level1)
582 {
583     StdoutRecord stdoutRecord;
584     stdoutRecord.Start();
585     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
586     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
587     std::string stringOut = stdoutRecord.Stop();
588 
589     EXPECT_EQ(stringOut.find("tableSize") != std::string::npos, false);
590 }
591 
592 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfKernelUpperBoundary, TestSize.Level1)
593 {
594     StdoutRecord stdoutRecord;
595     stdoutRecord.Start();
596     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
597     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
598     std::string stringOut = stdoutRecord.Stop();
599     std::string kernelUpperBoundary = "0xffffffffffffff80";
600     EXPECT_EQ(stringOut.find(kernelUpperBoundary) != std::string::npos, true);
601 }
602 
603 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfKernelLowerBoundary, TestSize.Level1)
604 {
605     StdoutRecord stdoutRecord;
606     stdoutRecord.Start();
607     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
608     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
609     std::string stringOut = stdoutRecord.Stop();
610     std::string kernelLowerBoundary = "0xfffffffffffffe00";
611     EXPECT_EQ(stringOut.find(kernelLowerBoundary) != std::string::npos, true);
612 }
613 
614 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfKernelIp, TestSize.Level1)
615 {
616     StdoutRecord stdoutRecord;
617     stdoutRecord.Start();
618     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
619     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
620     std::string stringOut = stdoutRecord.Stop();
621     std::string kernelIp = "0xffffffc011605050";
622     EXPECT_EQ(stringOut.find(kernelIp) != std::string::npos, true);
623 }
624 
625 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfUerIpFixZero, TestSize.Level1)
626 {
627     StdoutRecord stdoutRecord;
628     stdoutRecord.Start();
629     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
630     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
631     std::string stringOut = stdoutRecord.Stop();
632     std::string userIpFixZero = "0x00000000f7a70f67";
633     EXPECT_EQ(stringOut.find(userIpFixZero) != std::string::npos, true);
634 }
635 
636 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfUserIp, TestSize.Level1)
637 {
638     StdoutRecord stdoutRecord;
639     stdoutRecord.Start();
640     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
641     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
642     std::string stringOut = stdoutRecord.Stop();
643     std::string userIp = "0xf7a70f67";
644     EXPECT_EQ(stringOut.find(userIp) != std::string::npos, true);
645 }
646 
647 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfCallchain, TestSize.Level1)
648 {
649     StdoutRecord stdoutRecord;
650     stdoutRecord.Start();
651     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
652     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
653     std::string stringOut = stdoutRecord.Stop();
654     std::string callchain = "callchain nr=20";
655     EXPECT_EQ(stringOut.find(callchain) != std::string::npos, true);
656 }
657 
658 HWTEST_F(SubCommandDumpTest, DumpUncompressDwarfSymbol, TestSize.Level1)
659 {
660     StdoutRecord stdoutRecord;
661     stdoutRecord.Start();
662     std::string cmdString = "dump -i /data/test/resource/testdata/dwarf.uncompress.data";
663     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
664     std::string stringOut = stdoutRecord.Stop();
665     std::string symbol = "0xffffffc0102fafa0 : ksys_read";
666     EXPECT_EQ(stringOut.find(symbol) != std::string::npos, true);
667 }
668 
669 HWTEST_F(SubCommandDumpTest, DumpUncompressFpStackTable, TestSize.Level1)
670 {
671     StdoutRecord stdoutRecord;
672     stdoutRecord.Start();
673     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
674     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
675     std::string stringOut = stdoutRecord.Stop();
676 
677     EXPECT_EQ(stringOut.find("hiperf_stack_table") != std::string::npos, false);
678 }
679 
680 HWTEST_F(SubCommandDumpTest, DumpUncompressFpStackid, TestSize.Level1)
681 {
682     StdoutRecord stdoutRecord;
683     stdoutRecord.Start();
684     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
685     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
686     std::string stringOut = stdoutRecord.Stop();
687 
688     EXPECT_EQ(stringOut.find("stackid") != std::string::npos, false);
689 }
690 
691 HWTEST_F(SubCommandDumpTest, DumpUncompressFpTableNums, TestSize.Level1)
692 {
693     StdoutRecord stdoutRecord;
694     stdoutRecord.Start();
695     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
696     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
697     std::string stringOut = stdoutRecord.Stop();
698 
699     EXPECT_EQ(stringOut.find("TableNums") != std::string::npos, false);
700 }
701 
702 HWTEST_F(SubCommandDumpTest, DumpUncompressFpNumNodes, TestSize.Level1)
703 {
704     StdoutRecord stdoutRecord;
705     stdoutRecord.Start();
706     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
707     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
708     std::string stringOut = stdoutRecord.Stop();
709 
710     EXPECT_EQ(stringOut.find("numNodes") != std::string::npos, false);
711 }
712 
713 HWTEST_F(SubCommandDumpTest, DumpUncompressFpStackTableContent, TestSize.Level1)
714 {
715     StdoutRecord stdoutRecord;
716     stdoutRecord.Start();
717     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
718     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
719     std::string stringOut = stdoutRecord.Stop();
720 
721     EXPECT_EQ(stringOut.find("hiperf_stack_table content") != std::string::npos, false);
722 }
723 
724 HWTEST_F(SubCommandDumpTest, DumpUncompressFpTableid, TestSize.Level1)
725 {
726     StdoutRecord stdoutRecord;
727     stdoutRecord.Start();
728     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
729     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
730     std::string stringOut = stdoutRecord.Stop();
731 
732     EXPECT_EQ(stringOut.find("tableid") != std::string::npos, false);
733 }
734 
735 HWTEST_F(SubCommandDumpTest, DumpUncompressFpTableSize, TestSize.Level1)
736 {
737     StdoutRecord stdoutRecord;
738     stdoutRecord.Start();
739     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
740     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
741     std::string stringOut = stdoutRecord.Stop();
742 
743     EXPECT_EQ(stringOut.find("tableSize") != std::string::npos, false);
744 }
745 
746 HWTEST_F(SubCommandDumpTest, DumpUncompressFpKernelUpperBoundary, TestSize.Level1)
747 {
748     StdoutRecord stdoutRecord;
749     stdoutRecord.Start();
750     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
751     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
752     std::string stringOut = stdoutRecord.Stop();
753     std::string kernelUpperBoundary = "0xffffffffffffff80";
754     EXPECT_EQ(stringOut.find(kernelUpperBoundary) != std::string::npos, true);
755 }
756 
757 HWTEST_F(SubCommandDumpTest, DumpUncompressFpKernelLowerBoundary, TestSize.Level1)
758 {
759     StdoutRecord stdoutRecord;
760     stdoutRecord.Start();
761     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
762     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
763     std::string stringOut = stdoutRecord.Stop();
764     std::string kernelLowerBoundary = "0xfffffffffffffe00";
765     EXPECT_EQ(stringOut.find(kernelLowerBoundary) != std::string::npos, true);
766 }
767 
768 HWTEST_F(SubCommandDumpTest, DumpUncompressFpKernelIp, TestSize.Level1)
769 {
770     StdoutRecord stdoutRecord;
771     stdoutRecord.Start();
772     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
773     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
774     std::string stringOut = stdoutRecord.Stop();
775     std::string kernelIp = "0xffffffc011605050";
776     EXPECT_EQ(stringOut.find(kernelIp) != std::string::npos, true);
777 }
778 
779 HWTEST_F(SubCommandDumpTest, DumpUncompressFpUerIpFixZero, TestSize.Level1)
780 {
781     StdoutRecord stdoutRecord;
782     stdoutRecord.Start();
783     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
784     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
785     std::string stringOut = stdoutRecord.Stop();
786     std::string userIpFixZero = "0x00000000f6ebfd24";
787     EXPECT_EQ(stringOut.find(userIpFixZero) != std::string::npos, true);
788 }
789 
790 HWTEST_F(SubCommandDumpTest, DumpUncompressFpUserIp, TestSize.Level1)
791 {
792     StdoutRecord stdoutRecord;
793     stdoutRecord.Start();
794     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
795     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
796     std::string stringOut = stdoutRecord.Stop();
797     std::string userIp = "0xf6ebfd24";
798     EXPECT_EQ(stringOut.find(userIp) != std::string::npos, true);
799 }
800 
801 HWTEST_F(SubCommandDumpTest, DumpUncompressFpCallchain, TestSize.Level1)
802 {
803     StdoutRecord stdoutRecord;
804     stdoutRecord.Start();
805     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
806     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
807     std::string stringOut = stdoutRecord.Stop();
808     std::string callchain = "callchain nr=16";
809     EXPECT_EQ(stringOut.find(callchain) != std::string::npos, true);
810 }
811 
812 HWTEST_F(SubCommandDumpTest, DumpUncompressFpSymbol, TestSize.Level1)
813 {
814     StdoutRecord stdoutRecord;
815     stdoutRecord.Start();
816     std::string cmdString = "dump -i /data/test/resource/testdata/fp.uncompress.data";
817     EXPECT_EQ(Command::DispatchCommand(cmdString), true);
818     std::string stringOut = stdoutRecord.Stop();
819     std::string symbol = "0xffffffc0100030c4 : el0_sync_compat";
820     EXPECT_EQ(stringOut.find(symbol) != std::string::npos, true);
821 }
822 } // namespace HiPerf
823 } // namespace Developtools
824 } // namespace OHOS
825