From 89b66b0a435a2ea6a6623d92e062c2457fa3c922 Mon Sep 17 00:00:00 2001 From: jiangwei Date: Thu, 5 Jun 2025 16:55:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=96=B0=E5=A2=9E=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E4=BB=A3=E7=A0=81=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangwei --- .../common/native/subcommand_record_test.cpp | 21 +++++++++++++ .../common/native/subcommand_stat_test.cpp | 31 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/test/unittest/common/native/subcommand_record_test.cpp b/test/unittest/common/native/subcommand_record_test.cpp index 25a5f80..72effd6 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 ea0e6c6..6efc442 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 -- Gitee