diff --git a/test/unittest/common/native/subcommand_record_test.cpp b/test/unittest/common/native/subcommand_record_test.cpp index 25a5f80a1e73da68621df1192a4d2416138e92b8..72effd61488ba1234cb0481c59568aa5d14eec6f 100644 --- a/test/unittest/common/native/subcommand_record_test.cpp +++ b/test/unittest/common/native/subcommand_record_test.cpp @@ -2264,6 +2264,27 @@ HWTEST_F(SubCommandRecordTest, TestOnSubCommand_control03, TestSize.Level1) EXPECT_EQ(CheckTraceCommandOutput("hiperf record --control stop", {"stop sampling failed"}), true); } + +/** + * @tc.name: TestOnSubCommand_WrongStopSeconds + * @tc.type: FUNC + */ +HWTEST_F(SubCommandRecordTest, WrongStopSeconds, TestSize.Level2) +{ + std::string opt = "-d 123abc "; + opt += " "; + TestRecordCommand(opt, false); +} + +/** + * @tc.name: TestOnSubCommand_OutPutFileName + * @tc.type: FUNC + */ +HWTEST_F(SubCommandRecordTest, OutPutFileName, TestSize.Level2) +{ + EXPECT_EQ(CheckTraceCommandOutput("hiperf record -d 3 -a -o /data/log/hiperflog/perf.data", + {"Invalid output file path, permission denied"}), true); +} } // namespace HiPerf } // namespace Developtools } // namespace OHOS diff --git a/test/unittest/common/native/subcommand_stat_test.cpp b/test/unittest/common/native/subcommand_stat_test.cpp index ea0e6c638e3b0321af99c068f576e066c452f662..6efc44203f7eed5ce1a07c67f6917c7063902bf5 100644 --- a/test/unittest/common/native/subcommand_stat_test.cpp +++ b/test/unittest/common/native/subcommand_stat_test.cpp @@ -2383,6 +2383,37 @@ HWTEST_F(SubCommandStatTest, TestOnSubCommand_control03, TestSize.Level1) EXPECT_EQ(CheckTraceCommandOutput("hiperf stat --control stop", {"stop counting failed"}), true); } + +/** + * @tc.name: TestOnSubCommand_control04 + * @tc.desc: --control without prepare, start, stop + * @tc.type: FUNC + */ +HWTEST_F(SubCommandStatTest, TestOnSubCommand_control04, TestSize.Level1) +{ + EXPECT_EQ(CheckTraceCommandOutput("hiperf stat --control pause", + {"command should be: prepare, start, stop"}), true); +} + +/** + * @tc.name: TestOnSubCommand_OutPutFileName01 + * @tc.type: FUNC + */ +HWTEST_F(SubCommandStatTest, OutPutFileName01, TestSize.Level1) +{ + EXPECT_EQ(CheckTraceCommandOutput("hiperf stat -d 10 -a -o /data/local/tmp/stat.txt", + {"-o option must use with --control prepare option"}), true); +} + +/** + * @tc.name: TestOnSubCommand_OutPutFileName02 + * @tc.type: FUNC + */ +HWTEST_F(SubCommandStatTest, OutPutFileName02, TestSize.Level1) +{ + EXPECT_EQ(CheckTraceCommandOutput("hiperf stat --control prepare -a -o /data/log/hiperflog/stat.txt", + {"Invalid output file path, permission denied"}), true); +} } // namespace HiPerf } // namespace Developtools } // namespace OHOS