1 /*
2 * Copyright (c) 2022-2023 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 "b_process/b_process.h"
17 #include "test_manager.h"
18 #include "gtest/gtest.h"
19
20 namespace OHOS::FileManagement::Backup {
21 class ToolsTest : public testing::Test {
22 public:
SetUpTestCase(void)23 static void SetUpTestCase(void) {};
TearDownTestCase()24 static void TearDownTestCase() {};
SetUp()25 void SetUp() {};
TearDown()26 void TearDown() {};
27 };
28
29 /**
30 * @tc.number: SUB_backup_tool_help_0100
31 * @tc.name: tool_help_0100
32 * @tc.desc: 测试help命令常规用法
33 * @tc.size: MEDIUM
34 * @tc.type: FUNC
35 * @tc.level Level 0
36 * @tc.require: I6F3GV
37 */
HWTEST_F(ToolsTest, tool_help_0100, testing::ext::TestSize.Level0)38 HWTEST_F(ToolsTest, tool_help_0100, testing::ext::TestSize.Level0)
39 {
40 GTEST_LOG_(INFO) << "ToolsTest-begin tool_help_0100";
41 try {
42 auto [bFatalError, ret] = BProcess::ExecuteCmd({
43 "/system/bin/backup_tool",
44 "help",
45 });
46 EXPECT_EQ(ret, 0);
47 } catch (...) {
48 EXPECT_TRUE(false);
49 GTEST_LOG_(INFO) << "ToolsTest-an exception occurred.";
50 }
51 GTEST_LOG_(INFO) << "ToolsTest-end tool_help_0100";
52 }
53
54 /**
55 * @tc.number: SUB_backup_tool_help_0200
56 * @tc.name: tool_help_0200
57 * @tc.desc: 测试help命令错误使用
58 * @tc.size: MEDIUM
59 * @tc.type: FUNC
60 * @tc.level Level 0
61 * @tc.require: I6F3GV
62 */
HWTEST_F(ToolsTest, tool_help_0200, testing::ext::TestSize.Level0)63 HWTEST_F(ToolsTest, tool_help_0200, testing::ext::TestSize.Level0)
64 {
65 GTEST_LOG_(INFO) << "ToolsTest-begin tool_help_0200";
66 try {
67 auto [bFatalError, ret] = BProcess::ExecuteCmd({
68 "/system/bin/backup_tool",
69 "xxxx",
70 });
71 EXPECT_NE(ret, 0);
72 } catch (...) {
73 EXPECT_TRUE(false);
74 GTEST_LOG_(INFO) << "ToolsTest-an exception occurred.";
75 }
76 GTEST_LOG_(INFO) << "ToolsTest-end tool_help_0200";
77 }
78 } // namespace OHOS::FileManagement::Backup