• 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 #ifndef HELP_UTILS_H
16 #define HELP_UTILS_H
17 
18 #include <string>
19 #include <vector>
20 #include <sys/types.h>
21 
22 namespace OHOS {
23 namespace StorageDaemon {
24 namespace StorageTest {
25 struct Dir {
26     std::string path;
27     mode_t mode;
28     uid_t uid;
29     gid_t gid;
30 };
31 
32 class StorageTestUtils {
33 public:
34     static const uid_t OID_ROOT;
35     static const uid_t OID_SYSTEM;
36 
37     static const int32_t USER_ID1;
38     static const int32_t USER_ID2;
39     static const int32_t USER_ID3;
40     static const int32_t USER_ID4;
41     static const int32_t USER_ID5;
42     static const mode_t MODE;
43 
44     static const std::vector<Dir> g_rootDirs;
45     static const std::vector<Dir> g_subDirs;
46 
47     static const std::vector<Dir> g_hmdfsDirs;
48 
49     static const std::string HMDFS_SOURCE;
50     static const std::string HMDFS_TARGET;
51 
52     static bool CheckMount(const std::string& dstPath);
53     static bool CheckDir(const std::string &path);
54     static bool CheckUserDir(int32_t userId, uint32_t flags);
55     static bool CreateFile(const std::string &path);
56     static bool RmDirRecurse(const std::string &path);
57     static void RmDir(const int32_t userId);
58     static bool MkDir(const std::string &path, mode_t mode);
59     static void ClearTestResource();
60 };
61 } // StorageTest
62 } // STORAGE_DAEMON
63 } // OHOS
64 #endif // HELP_UTILS_H