1 /* 2 * Copyright (c) 2021-2024 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 constexpr int32_t USER_ID1 = 301; 33 constexpr int32_t USER_ID2 = 302; 34 constexpr int32_t USER_ID3 = 303; 35 constexpr int32_t USER_ID4 = 304; 36 constexpr int32_t USER_ID5 = 305; 37 constexpr mode_t MODE = 0711; 38 39 class StorageTestUtils { 40 public: 41 static const std::vector<Dir> gRootDirs; 42 static const std::vector<Dir> gSubDirs; 43 static const std::vector<Dir> gHmdfsDirs; 44 45 static bool CheckMount(const std::string& dstPath); 46 static bool CheckDir(const std::string &path); 47 static bool CheckUserDir(int32_t userId, uint32_t flags); 48 static bool CreateFile(const std::string &path); 49 static bool RmDirRecurse(const std::string &path); 50 static void RmDir(const int32_t userId); 51 static bool MkDir(const std::string &path, mode_t mode); 52 static void ClearTestResource(); 53 }; 54 } // StorageTest 55 } // STORAGE_DAEMON 56 } // OHOS 57 #endif // HELP_UTILS_H