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_record_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 <poll.h>
26 #include <unistd.h>
27
28 #include "command.h"
29 #include "debug_logger.h"
30 #include "utilities.h"
31
32 using namespace std::literals::chrono_literals;
33 using namespace testing::ext;
34 using namespace std;
35 using namespace OHOS::HiviewDFX;
36 namespace OHOS {
37 namespace Developtools {
38 namespace HiPerf {
39 class SubCommandRecordTest : public testing::Test {
40 public:
41 static void SetUpTestCase(void);
42 static void TearDownTestCase(void);
43 void SetUp();
44 void TearDown();
45
46 void TestEvents(std::string &opt, std::string &uk);
47
48 static void TestRecordCommand(const std::string &option, bool expect = true,
49 bool fixPid = true);
50 };
51
SetUpTestCase()52 void SubCommandRecordTest::SetUpTestCase() {}
53
TearDownTestCase()54 void SubCommandRecordTest::TearDownTestCase() {}
55
SetUp()56 void SubCommandRecordTest::SetUp()
57 {
58 SubCommand::ClearSubCommands(); // clear the subCommands left from other UT
59 ASSERT_EQ(SubCommand::GetSubCommands().size(), 0u);
60 SubCommandRecord::RegisterSubCommandRecord();
61 ASSERT_EQ(SubCommand::GetSubCommands().size(), 1u);
62 }
63
TearDown()64 void SubCommandRecordTest::TearDown()
65 {
66 ASSERT_EQ(SubCommand::GetSubCommands().size(), 1u);
67 SubCommand::ClearSubCommands();
68 ASSERT_EQ(SubCommand::GetSubCommands().size(), 0u);
69 MemoryHold::Get().Clean();
70 }
71
TestRecordCommand(const std::string & option,bool expect,bool fixPid)72 void SubCommandRecordTest::TestRecordCommand(const std::string &option, bool expect, bool fixPid)
73 {
74 StdoutRecord stdoutRecord;
75
76 std::string cmdString = "record ";
77 if (fixPid) {
78 cmdString += "--app com.ohos.launcher ";
79 }
80 cmdString += " " + option;
81 printf("command : %s\n", cmdString.c_str());
82
83 // it need load some symbols and much more log
84 stdoutRecord.Start();
85 const auto startTime = chrono::steady_clock::now();
86 bool ret = Command::DispatchCommand(cmdString);
87 const auto costMs = std::chrono::duration_cast<std::chrono::milliseconds>(
88 chrono::steady_clock::now() - startTime);
89 std::string stringOut = stdoutRecord.Stop();
90
91 printf("run %" PRId64 " ms return %s(expect %s)\n", (uint64_t)costMs.count(), ret ? "true" : "false",
92 expect ? "true" : "false");
93 EXPECT_EQ(expect, ret);
94 }
95
96 // app package name
97 HWTEST_F(SubCommandRecordTest, PackageName, TestSize.Level1)
98 {
99 TestRecordCommand("-d 2 --app com.ohos.launcher ", true, false);
100 }
101
102 HWTEST_F(SubCommandRecordTest, PackageNameErr, TestSize.Level1)
103 {
104 TestRecordCommand("-d 2 --app package_name ", false, false);
105 }
106
107 // check app milliseconds
108 /**
109 * @tc.name: CheckAppMsMin
110 * @tc.desc: Test chkms minimum value
111 * @tc.type: FUNC
112 * @tc.require: issueI5R305
113 */
114 HWTEST_F(SubCommandRecordTest, CheckAppMsMin, TestSize.Level1)
115 {
116 TestRecordCommand("-d 0.5 --chkms 1 ");
117 }
118
119 /**
120 * @tc.name: CheckAppMsMinErr
121 * @tc.desc: Test chkms less than minimum value
122 * @tc.type: FUNC
123 * @tc.require: issueI5R305
124 */
125 HWTEST_F(SubCommandRecordTest, CheckAppMsMinErr, TestSize.Level1)
126 {
127 TestRecordCommand("-d 0.5 --chkms 0 ", false);
128 }
129
130 /**
131 * @tc.name: CheckAppMsMax
132 * @tc.desc: Test chkms maximum value
133 * @tc.type: FUNC
134 * @tc.require: issueI5R305
135 */
136 HWTEST_F(SubCommandRecordTest, CheckAppMsMax, TestSize.Level1)
137 {
138 TestRecordCommand("-d 0.5 --chkms 200 ");
139 }
140
141 /**
142 * @tc.name: CheckAppMsMaxErr
143 * @tc.desc: Test chkms more than maximum value
144 * @tc.type: FUNC
145 * @tc.require: issueI5R305
146 */
147 HWTEST_F(SubCommandRecordTest, CheckAppMsMaxErr, TestSize.Level1)
148 {
149 TestRecordCommand("-d 0.5 --chkms 201 ", false);
150 }
151
152 /**
153 * @tc.name: CheckAppMsInputErr
154 * @tc.desc: Test erro type of chkms
155 * @tc.type: FUNC
156 * @tc.require: issueI5R305
157 */
158 HWTEST_F(SubCommandRecordTest, CheckAppMsInputErr, TestSize.Level1)
159 {
160 TestRecordCommand("-d 0.5 --chkms abc ", false);
161 }
162 // stop seconds
163 HWTEST_F(SubCommandRecordTest, StopSecondsMin, TestSize.Level1)
164 {
165 TestRecordCommand("-d 0.1 ");
166 }
167
168 HWTEST_F(SubCommandRecordTest, StopSecondsMinErr, TestSize.Level1)
169 {
170 TestRecordCommand("-d 0.099 ", false);
171 }
172
173 HWTEST_F(SubCommandRecordTest, StopSecondsMax, TestSize.Level1)
174 {
175 std::string opt = "-d 10000.0 ";
176 opt += " ls "; // because UT don't need wait so long
177 TestRecordCommand(opt, true, false);
178 }
179
180 HWTEST_F(SubCommandRecordTest, StopSecondsMaxErr, TestSize.Level1)
181 {
182 std::string opt = "-d 10000.1 ";
183 opt += " ";
184 TestRecordCommand(opt, false);
185 }
186
187 // system wide
188 HWTEST_F(SubCommandRecordTest, SystemWide, TestSize.Level1)
189 {
190 TestRecordCommand("-d 2 -a ", true, false);
191 }
192
193 // exclude hiperf
194 HWTEST_F(SubCommandRecordTest, ExcludePerf, TestSize.Level1)
195 {
196 TestRecordCommand("-d 2 -a --exclude-hiperf ", true, false);
197 }
198
199 // select cpu
200 HWTEST_F(SubCommandRecordTest, SelectCpu, TestSize.Level1)
201 {
202 TestRecordCommand("-d 2 -c 0 ");
203 }
204
205 HWTEST_F(SubCommandRecordTest, SelectCpuMulti, TestSize.Level1)
206 {
207 int maxCpuid = GetProcessorNum();
208 std::string opt = "-d 2 -e sw-task-clock -c ";
209 for (int i = 0; i < maxCpuid; i++) {
210 opt += std::to_string(i);
211 opt += ",";
212 }
213 opt.pop_back();
214 opt += " ";
215 TestRecordCommand(opt);
216 }
217
218 HWTEST_F(SubCommandRecordTest, SelectCpuMinErr, TestSize.Level1)
219 {
220 TestRecordCommand("-d 2 -c -1 ", false);
221 }
222
223 HWTEST_F(SubCommandRecordTest, SelectCpuMaxErr, TestSize.Level1)
224 {
225 int maxCpuid = GetProcessorNum();
226 std::string opt = "-d 2 -c ";
227 opt += std::to_string(maxCpuid);
228 opt += " ";
229 TestRecordCommand(opt, false);
230 }
231
232 HWTEST_F(SubCommandRecordTest, SelectCpuInputErr, TestSize.Level1)
233 {
234 TestRecordCommand("-d 2 -c abc ", false);
235 }
236
237 // cpu percent
238 HWTEST_F(SubCommandRecordTest, CpuLimitMin, TestSize.Level1)
239 {
240 TestRecordCommand("-d 2 --cpu-limit 1 ");
241 }
242
243 HWTEST_F(SubCommandRecordTest, CpuLimitErr, TestSize.Level1)
244 {
245 TestRecordCommand("-d 2 --cpu-limit 0 ", false);
246 }
247
248 HWTEST_F(SubCommandRecordTest, CpuLimitMax, TestSize.Level1)
249 {
250 TestRecordCommand("-d 2 --cpu-limit 100 ");
251 }
252
253 HWTEST_F(SubCommandRecordTest, CpuLimitMaxErr, TestSize.Level1)
254 {
255 TestRecordCommand("-d 2 --cpu-limit 101 ", false);
256 }
257
258 HWTEST_F(SubCommandRecordTest, CpuLimitInputErr, TestSize.Level1)
259 {
260 TestRecordCommand("-d 2 --cpu-limit abc ", false);
261 }
262
263 // frequency
264 HWTEST_F(SubCommandRecordTest, FrequncyMin, TestSize.Level1)
265 {
266 TestRecordCommand("-d 2 -f 1 ");
267 }
268
269 HWTEST_F(SubCommandRecordTest, FrequncyMinErr, TestSize.Level1)
270 {
271 TestRecordCommand("-d 2 -f 0 ", false);
272 }
273
274 HWTEST_F(SubCommandRecordTest, FrequncyMax, TestSize.Level1)
275 {
276 TestRecordCommand("-d 2 -f 100000 ");
277 }
278
279 HWTEST_F(SubCommandRecordTest, FrequncyMaxErr, TestSize.Level1)
280 {
281 TestRecordCommand("-d 2 -f 100001 ", false);
282 }
283
284 HWTEST_F(SubCommandRecordTest, FrequncyInputErr, TestSize.Level1)
285 {
286 TestRecordCommand("-d 2 -f abc ", false);
287 }
288
289 // period
290 HWTEST_F(SubCommandRecordTest, PeriodMin, TestSize.Level1)
291 {
292 TestRecordCommand("-d 2 --period 1 ");
293 }
294
295 HWTEST_F(SubCommandRecordTest, PeriodMinErr, TestSize.Level1)
296 {
297 TestRecordCommand("-d 2 --period 0 ", false);
298 }
299
300 HWTEST_F(SubCommandRecordTest, PeriodMax, TestSize.Level1)
301 {
302 std::string opt = "-d 2 --period ";
303 opt += std::to_string(INT_MAX);
304 opt += " ";
305 TestRecordCommand(opt);
306 }
307
308 HWTEST_F(SubCommandRecordTest, PeriodMaxErr, TestSize.Level1)
309 {
310 std::string opt = "-d 2 --period ";
311 uint32_t value = static_cast<uint32_t>(INT_MAX) + 1;
312 opt += std::to_string(value);
313 opt += " ";
314 TestRecordCommand(opt, false);
315 }
316
317 HWTEST_F(SubCommandRecordTest, PeriodInputErr, TestSize.Level1)
318 {
319 TestRecordCommand("-d 2 --period abc ", false);
320 }
321
322 HWTEST_F(SubCommandRecordTest, PeriodAndFrequncyConflict, TestSize.Level1)
323 {
324 TestRecordCommand("-d 2 -f 2000 --period 10 ", false);
325 }
326
TestEvents(std::string & opt,std::string & uk)327 void SubCommandRecordTest::TestEvents(std::string &opt, std::string &uk)
328 {
329 PerfEvents perfEvents;
330 for (auto type : TYPE_CONFIGS) {
331 auto configs = perfEvents.GetSupportEvents(type.first);
332 if (configs.empty()) {
333 continue;
334 }
335
336 const int MAX_TESTEVENT = 5;
337 int testEventCount = MAX_TESTEVENT;
338 std::string cmdline = opt;
339 for (auto config : configs) {
340 if (testEventCount <= 0) {
341 break;
342 }
343 cmdline += config.second;
344 cmdline += uk;
345 cmdline += ",";
346 testEventCount--;
347 }
348 cmdline.pop_back(); // remove the last ','
349 TestRecordCommand(cmdline);
350 TearDown();
351 SetUp();
352 }
353 }
354
355 // select events
356 HWTEST_F(SubCommandRecordTest, SelectEvents, TestSize.Level1)
357 {
358 std::string opt = "-d 2 -c 0 -e ";
359 std::string uk = "";
360 TestEvents(opt, uk);
361 }
362
363 HWTEST_F(SubCommandRecordTest, SelectEventsUser, TestSize.Level1)
364 {
365 std::string opt = "-d 2 -c 0 -e ";
366 std::string uk = ":u";
367 TestEvents(opt, uk);
368 }
369
370 HWTEST_F(SubCommandRecordTest, SelectEventsKernel, TestSize.Level1)
371 {
372 std::string opt = "-d 2 -c 0 -e ";
373 std::string uk = ":k";
374 TestEvents(opt, uk);
375 }
376
377 HWTEST_F(SubCommandRecordTest, SelectEventsErr, TestSize.Level1)
378 {
379 TestRecordCommand("-d 2 -c 0 -e what ", false);
380 }
381
382 // select group events
383 HWTEST_F(SubCommandRecordTest, GroupEvents, TestSize.Level1)
384 {
385 std::string opt = "-d 2 -c 0 -g ";
386 std::string uk = "";
387 TestEvents(opt, uk);
388 }
389
390 HWTEST_F(SubCommandRecordTest, GroupEventsUser, TestSize.Level1)
391 {
392 std::string opt = "-d 2 -c 0 -g ";
393 std::string uk = ":u";
394 TestEvents(opt, uk);
395 }
396
397 HWTEST_F(SubCommandRecordTest, GroupEventsKernal, TestSize.Level1)
398 {
399 std::string opt = "-d 2 -c 0 -g ";
400 std::string uk = ":k";
401 TestEvents(opt, uk);
402 }
403
404 HWTEST_F(SubCommandRecordTest, GroupEventsErr, TestSize.Level1)
405 {
406 TestRecordCommand("-d 2 -c 0 -g what ", false);
407 }
408
409 HWTEST_F(SubCommandRecordTest, NoInherit, TestSize.Level1)
410 {
411 TestRecordCommand("-d 2 --no-inherit ");
412 }
413
414 // select pid
415 HWTEST_F(SubCommandRecordTest, SelectPid, TestSize.Level1)
416 {
417 TestRecordCommand("-d 2 -p 1 ", true, false);
418 }
419
420 HWTEST_F(SubCommandRecordTest, SelectPidMulti, TestSize.Level1)
421 {
422 TestRecordCommand("-d 2 -p 1,2,3 ", true, false);
423 }
424
425 HWTEST_F(SubCommandRecordTest, SelectPidMinErr, TestSize.Level1)
426 {
427 TestRecordCommand("-d 2 -p 0 ", false, false);
428 }
429
430 HWTEST_F(SubCommandRecordTest, SelectPidErr, TestSize.Level1)
431 {
432 TestRecordCommand("-d 2 -p 99999999 ", false, false);
433 }
434
435 HWTEST_F(SubCommandRecordTest, SelectPidInputErr, TestSize.Level1)
436 {
437 TestRecordCommand("-d 2 -p abc ", false, false);
438 }
439
440 // select tid
441 HWTEST_F(SubCommandRecordTest, SelectTid, TestSize.Level1)
442 {
443 TestRecordCommand("-d 2 -t 1 ", true, false);
444 }
445
446 HWTEST_F(SubCommandRecordTest, SelectTidMulti, TestSize.Level1)
447 {
448 TestRecordCommand("-d 2 -t 1,2,3 ", true, false);
449 }
450
451 HWTEST_F(SubCommandRecordTest, SelectTidMinErr, TestSize.Level1)
452 {
453 TestRecordCommand("-d 2 -t 0 ", false, false);
454 }
455
456 HWTEST_F(SubCommandRecordTest, SelectTidErr, TestSize.Level1)
457 {
458 TestRecordCommand("-d 2 -t 99999999 ", false, false);
459 }
460
461 HWTEST_F(SubCommandRecordTest, SelectTidInputErr, TestSize.Level1)
462 {
463 TestRecordCommand("-d 2 -t abc ", false, false);
464 }
465
466 // cpu off
467 HWTEST_F(SubCommandRecordTest, CpuOff, TestSize.Level1)
468 {
469 TestRecordCommand("-d 2 --offcpu ");
470 }
471
472 HWTEST_F(SubCommandRecordTest, BranchFilterAny, TestSize.Level1)
473 {
474 #if is_ohos
475 TestRecordCommand("-d 2 -j any ", false); // broad doesn't support
476 #else
477 TestRecordCommand("-d 2 -j any ");
478 #endif
479 }
480
481 HWTEST_F(SubCommandRecordTest, BranchFilterAnyCall, TestSize.Level1)
482 {
483 #if is_ohos
484 TestRecordCommand("-d 2 -j any_call ", false); // broad doesn't support
485 #else
486 TestRecordCommand("-d 2 -j any_call ");
487 #endif
488 }
489
490 HWTEST_F(SubCommandRecordTest, BranchFilterIndCall, TestSize.Level1)
491 {
492 #if is_ohos
493 TestRecordCommand("-d 2 -j ind_call ", false); // broad doesn't support
494 #else
495 TestRecordCommand("-d 2 -j ind_call ");
496 #endif
497 }
498
499 HWTEST_F(SubCommandRecordTest, BranchFilterAnyRet, TestSize.Level1)
500 {
501 #if is_ohos
502 TestRecordCommand("-d 2 -j any_ret ", false); // broad doesn't support
503 #else
504 TestRecordCommand("-d 2 -j any_ret ");
505 #endif
506 }
507
508 HWTEST_F(SubCommandRecordTest, BranchFilterOnlyCall, TestSize.Level1)
509 {
510 TestRecordCommand("-d 2 -j call ", false);
511 }
512
513 HWTEST_F(SubCommandRecordTest, BranchFilterAll, TestSize.Level1)
514 {
515 #if is_ohos
516 TestRecordCommand("-d 2 -j any,any_call,any_ret,ind_call,u,k ", false); // broad doesn't support
517 #else
518 TestRecordCommand("-d 2 -j any,any_call,any_ret,ind_call,u,k ");
519 #endif
520 }
521
522 HWTEST_F(SubCommandRecordTest, BranchFilterInputErr, TestSize.Level1)
523 {
524 TestRecordCommand("-d 2 -j what ", false);
525 }
526
527 HWTEST_F(SubCommandRecordTest, BranchFilterInputMoreErr, TestSize.Level1)
528 {
529 TestRecordCommand("-d 2 -j any,n ", false);
530 }
531
532 // call stack
533 HWTEST_F(SubCommandRecordTest, CallStackFp, TestSize.Level1)
534 {
535 TestRecordCommand("-d 2 --call-stack fp ");
536 TearDown();
537 SetUp();
538 TestRecordCommand("-d 2 -s fp ");
539 }
540
541 HWTEST_F(SubCommandRecordTest, CallStackFpInputMoreErr, TestSize.Level1)
542 {
543 TestRecordCommand("-d 2 --call-stack fp,abc ", false);
544 TearDown();
545 SetUp();
546 TestRecordCommand("-d 2 -s fp,abc ", false);
547 }
548
549 HWTEST_F(SubCommandRecordTest, CallStackInputErr, TestSize.Level1)
550 {
551 TestRecordCommand("-d 2 --call-stack what ", false);
552 TearDown();
553 SetUp();
554 TestRecordCommand("-d 2 -s what ", false);
555 }
556
557 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeMin, TestSize.Level1)
558 {
559 // it will cause some crash in -fprofile-arcs and -ftest-coverage
560 // we will fix it latter
561 TestRecordCommand("-d 2 --call-stack dwarf,8 ");
562 TearDown();
563 SetUp();
564 TestRecordCommand("-d 2 -s dwarf,8 ");
565 }
566
567 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeMinErr, TestSize.Level1)
568 {
569 TestRecordCommand("-d 2 --call-stack dwarf,7 ", false);
570 TearDown();
571 SetUp();
572 TestRecordCommand("-d 2 -s dwarf,7 ", false);
573 }
574
575 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeMax, TestSize.Level1)
576 {
577 TestRecordCommand("-d 2 --call-stack dwarf,65528 ");
578 TearDown();
579 SetUp();
580 TestRecordCommand("-d 2 -s dwarf,65528 ");
581 }
582
583 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeMaxErr, TestSize.Level1)
584 {
585 TestRecordCommand("-d 2 --call-stack dwarf,65529 ", false);
586 TearDown();
587 SetUp();
588 TestRecordCommand("-d 2 -s dwarf,65529 ", false);
589 }
590
591 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeErr, TestSize.Level1)
592 {
593 TestRecordCommand("-d 2 --call-stack dwarf,15 ", false);
594 TearDown();
595 SetUp();
596 TestRecordCommand("-d 2 -s dwarf,15 ", false);
597 }
598
599 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeInputErr, TestSize.Level1)
600 {
601 TestRecordCommand("-d 2 --call-stack dwarf,abc ", false);
602 TearDown();
603 SetUp();
604 TestRecordCommand("-d 2 -s dwarf,abc ", false);
605 }
606
607 HWTEST_F(SubCommandRecordTest, CallStackDwarfSizeInputMoreErr, TestSize.Level1)
608 {
609 TestRecordCommand("-d 2 --call-stack dwarf,16,32 ", false);
610 TearDown();
611 SetUp();
612 TestRecordCommand("-d 2 -s dwarf,16,32 ", false);
613 }
614
615 // unwind
616 HWTEST_F(SubCommandRecordTest, DlayUnwind, TestSize.Level1)
617 {
618 TestRecordCommand("-d 2 -s dwarf,16 --delay-unwind ");
619 }
620
621 HWTEST_F(SubCommandRecordTest, DisableUnwind, TestSize.Level1)
622 {
623 TestRecordCommand("-d 2 -s dwarf,16 --disable-unwind ");
624 }
625
626 HWTEST_F(SubCommandRecordTest, DisableCallstackMerge, TestSize.Level1)
627 {
628 TestRecordCommand("-d 2 -s dwarf,16 --disable-callstack-expand ");
629 }
630
631 // symbol dir
632 HWTEST_F(SubCommandRecordTest, SymbolDir, TestSize.Level1)
633 {
634 TestRecordCommand("-d 2 --symbol-dir ./ ");
635 }
636
637 HWTEST_F(SubCommandRecordTest, SymbolDirErr, TestSize.Level1)
638 {
639 TestRecordCommand("-d 2 --symbol-dir where ", false);
640 }
641
642 // clock id
643 HWTEST_F(SubCommandRecordTest, ClockIdMonotonic, TestSize.Level1)
644 {
645 TestRecordCommand("-d 2 --clockid monotonic ");
646 }
647
648 HWTEST_F(SubCommandRecordTest, ClockIdMonotonicRaw, TestSize.Level1)
649 {
650 TestRecordCommand("-d 2 --clockid monotonic_raw ");
651 }
652
653 HWTEST_F(SubCommandRecordTest, ClockIdBoottime, TestSize.Level1)
654 {
655 TestRecordCommand("-c 0 -d 2 -e sw-task-clock --clockid boottime ");
656 }
657
658 HWTEST_F(SubCommandRecordTest, ClockIdRealtime, TestSize.Level1)
659 {
660 TestRecordCommand("-c 0 -d 2 -e sw-task-clock --clockid realtime ");
661 }
662
663 HWTEST_F(SubCommandRecordTest, ClockIdClockTai, TestSize.Level1)
664 {
665 TestRecordCommand("-c 0 -d 2 -e sw-task-clock --clockid clock_tai ");
666 }
667
668 HWTEST_F(SubCommandRecordTest, ClockIdInputErr, TestSize.Level1)
669 {
670 TestRecordCommand("-c 0 -d 2 --clockid what ", false);
671 }
672
673 // mmap pages
674 HWTEST_F(SubCommandRecordTest, MmapPagesPower2Err, TestSize.Level1)
675 {
676 TestRecordCommand("-d 2 -m 101 ", false);
677 }
678
679 HWTEST_F(SubCommandRecordTest, MmapPagesMin, TestSize.Level1)
680 {
681 TestRecordCommand("-d 2 -m 2 ");
682 }
683
684 HWTEST_F(SubCommandRecordTest, MmapPagesMinErr, TestSize.Level1)
685 {
686 TestRecordCommand("-d 2 -m 1 ", false);
687 }
688
689 HWTEST_F(SubCommandRecordTest, MmapPagesMax, TestSize.Level1)
690 {
691 TestRecordCommand("-d 2 -m 1024 ");
692 }
693
694 HWTEST_F(SubCommandRecordTest, MmapPagesMaxErr, TestSize.Level1)
695 {
696 TestRecordCommand("-d 2 -m 1025 ", false);
697 }
698
699 HWTEST_F(SubCommandRecordTest, MmapPagesInputErr, TestSize.Level1)
700 {
701 TestRecordCommand("-d 2 -m abc ", false);
702 }
703
704 // output file name
705 HWTEST_F(SubCommandRecordTest, OutputFileName, TestSize.Level1)
706 {
707 TestRecordCommand("-d 2 -o /data/local/tmp/output.perf.data ");
708 }
709
710 HWTEST_F(SubCommandRecordTest, OutputFileNameErr, TestSize.Level1)
711 {
712 TestRecordCommand("-d 2 -o nopath/output.perf.data ", false);
713 }
714
715 // data size limit
716 HWTEST_F(SubCommandRecordTest, DataLimit, TestSize.Level1)
717 {
718 TestRecordCommand("-d 2 --data-limit 1K ");
719 TearDown();
720 SetUp();
721 TestRecordCommand("-d 2 --data-limit 1M ");
722 TearDown();
723 SetUp();
724 TestRecordCommand("-d 2 --data-limit 1G ");
725 }
726
727 HWTEST_F(SubCommandRecordTest, DataLimitErr, TestSize.Level1)
728 {
729 TestRecordCommand("-d 2 --data-limit 10A ", false);
730 TearDown();
731 SetUp();
732 TestRecordCommand("-d 2 --data-limit 0G ", false);
733 }
734
735 HWTEST_F(SubCommandRecordTest, RecordCompress, TestSize.Level1)
736 {
737 TestRecordCommand("-d 2 -z ");
738 }
739
740 HWTEST_F(SubCommandRecordTest, Verbose, TestSize.Level1)
741 {
742 TestRecordCommand("-d 2 --verbose ");
743 }
744
745 HWTEST_F(SubCommandRecordTest, DumpOptions, TestSize.Level1)
746 {
747 StdoutRecord stdoutRecord;
748 stdoutRecord.Start();
749 SubCommandRecord cmd;
750 cmd.DumpOptions();
751 stdoutRecord.Stop();
752 }
753 } // namespace HiPerf
754 } // namespace Developtools
755 } // namespace OHOS
756