1 /*
2  * Copyright (c) 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 
16 #include <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 
19 #include "fuse_operations.h"
20 #include "cloud_disk_inode.h"
21 #include "cloud_file_utils.h"
22 #include "file_operations_helper.h"
23 #include "file_operations_base.h"
24 #include "parameters.h"
25 #include "utils_log.h"
26 #include "assistant.h"
27 
28 namespace OHOS::FileManagement::CloudDisk::Test {
29 using namespace testing;
30 using namespace testing::ext;
31 using namespace std;
32 
33 class FuseOperationsTest : public testing::Test {
34 public:
35     static void SetUpTestCase(void);
36     static void TearDownTestCase(void);
37     void SetUp();
38     void TearDown();
39     static inline shared_ptr<FuseOperations> fuseoperations_ = nullptr;
40     static inline shared_ptr<AssistantMock> insMock = nullptr;
41 };
42 
SetUpTestCase(void)43 void FuseOperationsTest::SetUpTestCase(void)
44 {
45     GTEST_LOG_(INFO) << "SetUpTestCase";
46     fuseoperations_ = make_shared<FuseOperations>();
47     insMock = make_shared<AssistantMock>();
48     Assistant::ins = insMock;
49 }
50 
TearDownTestCase(void)51 void FuseOperationsTest::TearDownTestCase(void)
52 {
53     GTEST_LOG_(INFO) << "TearDownTestCase";
54     fuseoperations_ = nullptr;
55     Assistant::ins = nullptr;
56     insMock = nullptr;
57 }
58 
SetUp(void)59 void FuseOperationsTest::SetUp(void)
60 {
61     GTEST_LOG_(INFO) << "SetUp";
62 }
63 
TearDown(void)64 void FuseOperationsTest::TearDown(void)
65 {
66     GTEST_LOG_(INFO) << "TearDown";
67 }
68 
69 /**
70  * @tc.name: LookupTest001
71  * @tc.desc: Verify the Lookup function
72  * @tc.type: FUNC
73  * @tc.require: issuesI92WQP
74  */
75 HWTEST_F(FuseOperationsTest, LookupTest001, TestSize.Level1)
76 {
77     GTEST_LOG_(INFO) << "LookupTest001 Start";
78     try {
79         fuse_req_t req = nullptr;
80         const char *name = "";
81 
82         fuseoperations_->Lookup(req, FUSE_ROOT_ID, name);
83         EXPECT_TRUE(true);
84     } catch (...) {
85         EXPECT_TRUE(false);
86         GTEST_LOG_(INFO) << "LookupTest001  ERROR";
87     }
88     GTEST_LOG_(INFO) << "LookupTest001 End";
89 }
90 
91 /**
92  * @tc.name: LookupTest002
93  * @tc.desc: Verify the Lookup function
94  * @tc.type: FUNC
95  * @tc.require: issuesI92WQP
96  */
97 HWTEST_F(FuseOperationsTest, LookupTest002, TestSize.Level1)
98 {
99     GTEST_LOG_(INFO) << "LookupTest001 Start";
100     try {
101         CloudDiskFuseData data;
102         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
103         fuse_req_t req = nullptr;
104         const char *name = "";
105 
106         fuseoperations_->Lookup(req, 0, name);
107         EXPECT_TRUE(true);
108     } catch (...) {
109         EXPECT_TRUE(false);
110         GTEST_LOG_(INFO) << "LookupTest001  ERROR";
111     }
112     GTEST_LOG_(INFO) << "LookupTest001 End";
113 }
114 
115 /**
116  * @tc.name:AccessTest001
117  * @tc.desc: Verify the Access function
118  * @tc.type: FUNC
119  * @tc.require: issuesI92WQP
120  */
121 HWTEST_F(FuseOperationsTest, AccessTest001, TestSize.Level1)
122 {
123     GTEST_LOG_(INFO) << "AccessTest001 Start";
124     try {
125         fuse_req_t req = nullptr;
126         int mask = 0;
127 
128         fuseoperations_->Access(req, FUSE_ROOT_ID, mask);
129         EXPECT_TRUE(true);
130     } catch (...) {
131         EXPECT_TRUE(false);
132         GTEST_LOG_(INFO) << "AccessTest001  ERROR";
133     }
134     GTEST_LOG_(INFO) << "AccessTest001 End";
135 }
136 
137 /**
138  * @tc.name:AccessTest002
139  * @tc.desc: Verify the Access function
140  * @tc.type: FUNC
141  * @tc.require: issuesI92WQP
142  */
143 HWTEST_F(FuseOperationsTest, AccessTest002, TestSize.Level1)
144 {
145     GTEST_LOG_(INFO) << "AccessTest002 Start";
146     try {
147         CloudDiskFuseData data;
148         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
149         fuse_req_t req = nullptr;
150         int mask = 0;
151 
152         fuseoperations_->Access(req, 0, mask);
153         EXPECT_TRUE(true);
154     } catch (...) {
155         EXPECT_TRUE(false);
156         GTEST_LOG_(INFO) << "AccessTest002  ERROR";
157     }
158     GTEST_LOG_(INFO) << "AccessTest002 End";
159 }
160 
161 /**
162  * @tc.name:GetAttrTest001
163  * @tc.desc: Verify the GetAttr function
164  * @tc.type: FUNC
165  * @tc.require: issuesI92WQP
166  */
167 HWTEST_F(FuseOperationsTest, GetAttrTest001, TestSize.Level1)
168 {
169     GTEST_LOG_(INFO) << "GetAttrTest001 Start";
170     try {
171         CloudDiskFuseData data;
172         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
173         fuse_req_t req = nullptr;
174         struct fuse_file_info *fi = nullptr;
175 
176         fuseoperations_->GetAttr(req, FUSE_ROOT_ID, fi);
177         EXPECT_TRUE(true);
178     } catch (...) {
179         EXPECT_TRUE(false);
180         GTEST_LOG_(INFO) << "GetAttrTest001  ERROR";
181     }
182     GTEST_LOG_(INFO) << "GetAttrTest001 End";
183 }
184 
185 /**
186  * @tc.name:GetAttrTest002
187  * @tc.desc: Verify the GetAttr function
188  * @tc.type: FUNC
189  * @tc.require: issuesI92WQP
190  */
191 HWTEST_F(FuseOperationsTest, GetAttrTest002, TestSize.Level1)
192 {
193     GTEST_LOG_(INFO) << "GetAttrTest002 Start";
194     try {
195         CloudDiskFuseData data;
196         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
197         fuse_req_t req = nullptr;
198         struct fuse_file_info *fi = nullptr;
199 
200         fuseoperations_->GetAttr(req, 0, fi);
201         EXPECT_TRUE(true);
202     } catch (...) {
203         EXPECT_TRUE(false);
204         GTEST_LOG_(INFO) << "GetAttrTest002  ERROR";
205     }
206     GTEST_LOG_(INFO) << "GetAttrTest002 End";
207 }
208 
209 /**
210  * @tc.name:OpenTest001
211  * @tc.desc: Verify the Open function
212  * @tc.type: FUNC
213  * @tc.require: issuesI92WQP
214  */
215 HWTEST_F(FuseOperationsTest, OpenTest001, TestSize.Level1)
216 {
217     GTEST_LOG_(INFO) << "OpenTest001 Start";
218     try {
219         fuse_req_t req = nullptr;
220         struct fuse_file_info *fi = nullptr;
221 
222         fuseoperations_->Open(req, FUSE_ROOT_ID, fi);
223         EXPECT_TRUE(true);
224     } catch (...) {
225         EXPECT_TRUE(false);
226         GTEST_LOG_(INFO) << "OpenTest001  ERROR";
227     }
228     GTEST_LOG_(INFO) << "OpenTest001 End";
229 }
230 
231 /**
232  * @tc.name:OpenTest002
233  * @tc.desc: Verify the Open function
234  * @tc.type: FUNC
235  * @tc.require: issuesI92WQP
236  */
237 HWTEST_F(FuseOperationsTest, OpenTest002, TestSize.Level1)
238 {
239     GTEST_LOG_(INFO) << "OpenTest002 Start";
240     try {
241         CloudDiskFuseData data;
242         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
243         fuse_req_t req = nullptr;
244         struct fuse_file_info *fi = nullptr;
245 
246         fuseoperations_->Open(req, 0, fi);
247         EXPECT_TRUE(true);
248     } catch (...) {
249         EXPECT_TRUE(false);
250         GTEST_LOG_(INFO) << "OpenTest002  ERROR";
251     }
252     GTEST_LOG_(INFO) << "OpenTest002 End";
253 }
254 
255 /**
256  * @tc.name:ForgetTest001
257  * @tc.desc: Verify the Forget function
258  * @tc.type: FUNC
259  * @tc.require: issuesI92WQP
260  */
261 HWTEST_F(FuseOperationsTest, ForgetTest001, TestSize.Level1)
262 {
263     GTEST_LOG_(INFO) << "ForgetTest001 Start";
264     try {
265         CloudDiskFuseData data;
266         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
267         fuse_req_t req = nullptr;
268         uint64_t nLookup = 0;
269 
270         fuseoperations_->Forget(req, FUSE_ROOT_ID, nLookup);
271         EXPECT_TRUE(true);
272     } catch (...) {
273         EXPECT_TRUE(false);
274         GTEST_LOG_(INFO) << "ForgetTest001  ERROR";
275     }
276     GTEST_LOG_(INFO) << "ForgetTest001 End";
277 }
278 
279 /**
280  * @tc.name:ForgetTest002
281  * @tc.desc: Verify the Forget function
282  * @tc.type: FUNC
283  * @tc.require: issuesI92WQP
284  */
285 HWTEST_F(FuseOperationsTest, ForgetTest002, TestSize.Level1)
286 {
287     GTEST_LOG_(INFO) << "ForgetTest002 Start";
288     try {
289         CloudDiskFuseData data;
290         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
291         fuse_req_t req = nullptr;
292         uint64_t nLookup = 0;
293 
294         fuseoperations_->Forget(req, 0, nLookup);
295         EXPECT_TRUE(true);
296     } catch (...) {
297         EXPECT_TRUE(false);
298         GTEST_LOG_(INFO) << "ForgetTest002  ERROR";
299     }
300     GTEST_LOG_(INFO) << "ForgetTest002 End";
301 }
302 
303 /**
304  * @tc.name:ForgetMultiTest001
305  * @tc.desc: Verify the ForgetMulti function
306  * @tc.type: FUNC
307  * @tc.require: issuesI92WQP
308  */
309 HWTEST_F(FuseOperationsTest, ForgetMultiTest001, TestSize.Level1)
310 {
311     GTEST_LOG_(INFO) << "ForgetMultiTest001 Start";
312     try {
313         fuse_req_t req = nullptr;
314         struct fuse_forget_data forgets = {
315             FUSE_ROOT_ID,
316             1,
317         };
318 
319         fuseoperations_->ForgetMulti(req, 1, &forgets);
320         EXPECT_TRUE(true);
321     } catch (...) {
322         EXPECT_TRUE(false);
323         GTEST_LOG_(INFO) << "ForgetMultiTest001  ERROR";
324     }
325     GTEST_LOG_(INFO) << "ForgetMultiTest001 End";
326 }
327 
328 /**
329  * @tc.name:ForgetMultiTest002
330  * @tc.desc: Verify the ForgetMulti function
331  * @tc.type: FUNC
332  * @tc.require: issuesI92WQP
333  */
334 HWTEST_F(FuseOperationsTest, ForgetMultiTest002, TestSize.Level1)
335 {
336     GTEST_LOG_(INFO) << "ForgetMultiTest002 Start";
337     try {
338         fuse_req_t req = nullptr;
339         struct fuse_forget_data forgets = {
340             0,
341             1,
342         };
343 
344         fuseoperations_->ForgetMulti(req, 0, &forgets);
345         EXPECT_TRUE(true);
346     } catch (...) {
347         EXPECT_TRUE(false);
348         GTEST_LOG_(INFO) << "ForgetMultiTest002  ERROR";
349     }
350     GTEST_LOG_(INFO) << "ForgetMultiTest002 End";
351 }
352 
353 /**
354  * @tc.name:MkNodTest001
355  * @tc.desc: Verify the MkNod function
356  * @tc.type: FUNC
357  * @tc.require: issuesI92WQP
358  */
359 HWTEST_F(FuseOperationsTest, MkNodTest001, TestSize.Level1)
360 {
361     GTEST_LOG_(INFO) << "MkNodTest001 Start";
362     try {
363         fuse_req_t req = nullptr;
364         const char *name = "";
365         mode_t mode = 0;
366         dev_t rdev = 0;
367 
368         fuseoperations_->MkNod(req, FUSE_ROOT_ID, name, mode, rdev);
369         EXPECT_TRUE(true);
370     } catch (...) {
371         EXPECT_TRUE(false);
372         GTEST_LOG_(INFO) << "MkNodTest001  ERROR";
373     }
374     GTEST_LOG_(INFO) << "MkNodTest001 End";
375 }
376 
377 /**
378  * @tc.name:MkNodTest002
379  * @tc.desc: Verify the MkNod function
380  * @tc.type: FUNC
381  * @tc.require: issuesI92WQP
382  */
383 HWTEST_F(FuseOperationsTest, MkNodTest002, TestSize.Level1)
384 {
385     GTEST_LOG_(INFO) << "MkNodTest002 Start";
386     try {
387         CloudDiskFuseData data;
388         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
389         fuse_req_t req = nullptr;
390         const char *name = "";
391         mode_t mode = 0;
392         dev_t rdev = 0;
393 
394         fuseoperations_->MkNod(req, 0, name, mode, rdev);
395         EXPECT_TRUE(true);
396     } catch (...) {
397         EXPECT_TRUE(false);
398         GTEST_LOG_(INFO) << "MkNodTest002  ERROR";
399     }
400     GTEST_LOG_(INFO) << "MkNodTest002 End";
401 }
402 
403 /**
404  * @tc.name:CreateTest001
405  * @tc.desc: Verify the Create function
406  * @tc.type: FUNC
407  * @tc.require: issuesI92WQP
408  */
409 HWTEST_F(FuseOperationsTest, CreateTest001, TestSize.Level1)
410 {
411     GTEST_LOG_(INFO) << "CreateTest001 Start";
412     try {
413         fuse_req_t req = nullptr;
414         const char *name = "";
415         mode_t mode = 0;
416         struct fuse_file_info fi;
417 
418         fuseoperations_->Create(req, FUSE_ROOT_ID, name, mode, &fi);
419         EXPECT_TRUE(true);
420     } catch (...) {
421         EXPECT_TRUE(false);
422         GTEST_LOG_(INFO) << "CreateTest001  ERROR";
423     }
424     GTEST_LOG_(INFO) << "CreateTest001 End";
425 }
426 
427 /**
428  * @tc.name:CreateTest002
429  * @tc.desc: Verify the Create function
430  * @tc.type: FUNC
431  * @tc.require: issuesI92WQP
432  */
433 HWTEST_F(FuseOperationsTest, CreateTest002, TestSize.Level1)
434 {
435     GTEST_LOG_(INFO) << "CreateTest002 Start";
436     try {
437         CloudDiskFuseData data;
438         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
439         fuse_req_t req = nullptr;
440         const char *name = "";
441         mode_t mode = 0;
442         struct fuse_file_info fi;
443 
444         fuseoperations_->Create(req, 0, name, mode, &fi);
445         EXPECT_TRUE(true);
446     } catch (...) {
447         EXPECT_TRUE(false);
448         GTEST_LOG_(INFO) << "CreateTest002  ERROR";
449     }
450     GTEST_LOG_(INFO) << "CreateTest002 End";
451 }
452 
453 /**
454  * @tc.name:ReadDirTest001
455  * @tc.desc: Verify the ReadDir function
456  * @tc.type: FUNC
457  * @tc.require: issuesI92WQP
458  */
459 HWTEST_F(FuseOperationsTest, ReadDirTest001, TestSize.Level1)
460 {
461     GTEST_LOG_(INFO) << "ReadDirTest001 Start";
462     try {
463         CloudDiskFuseData data;
464         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
465         fuse_req_t req = nullptr;
466         size_t size = 0;
467         off_t off = 0;
468         struct fuse_file_info fi;
469 
470         fuseoperations_->ReadDir(req, FUSE_ROOT_ID, size, off, &fi);
471         EXPECT_TRUE(true);
472     } catch (...) {
473         EXPECT_TRUE(false);
474         GTEST_LOG_(INFO) << "ReadDirTest001  ERROR";
475     }
476     GTEST_LOG_(INFO) << "ReadDirTest001 End";
477 }
478 
479 /**
480  * @tc.name:ReadDirTest002
481  * @tc.desc: Verify the ReadDir function
482  * @tc.type: FUNC
483  * @tc.require: issuesI92WQP
484  */
485 HWTEST_F(FuseOperationsTest, ReadDirTest002, TestSize.Level1)
486 {
487     GTEST_LOG_(INFO) << "ReadDirTest002 Start";
488     try {
489         CloudDiskFuseData data;
490         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
491         fuse_req_t req = nullptr;
492         size_t size = 0;
493         off_t off = 0;
494         struct fuse_file_info fi;
495 
496         fuseoperations_->ReadDir(req, 0, size, off, &fi);
497         EXPECT_TRUE(true);
498     } catch (...) {
499         EXPECT_TRUE(false);
500         GTEST_LOG_(INFO) << "ReadDirTest002  ERROR";
501     }
502     GTEST_LOG_(INFO) << "ReadDirTest002 End";
503 }
504 
505 /**
506  * @tc.name:SetXattrTest001
507  * @tc.desc: Verify the SetXattr function
508  * @tc.type: FUNC
509  * @tc.require: issuesI92WQP
510  */
511 HWTEST_F(FuseOperationsTest, SetXattrTest001, TestSize.Level1)
512 {
513     GTEST_LOG_(INFO) << "SetXattrTest001 Start";
514     try {
515         fuse_req_t req = nullptr;
516         string name = HMDFS_PERMISSION_XATTR;
517         const char *value = "";
518         size_t size = 0;
519         int flags = 0;
520 
521         fuseoperations_->SetXattr(req, FUSE_ROOT_ID, name.c_str(), value, size, flags);
522         EXPECT_TRUE(true);
523     } catch (...) {
524         EXPECT_TRUE(false);
525         GTEST_LOG_(INFO) << "SetXattrTest001  ERROR";
526     }
527     GTEST_LOG_(INFO) << "SetXattrTest001 End";
528 }
529 
530 /**
531  * @tc.name:SetXattrTest002
532  * @tc.desc: Verify the SetXattr function
533  * @tc.type: FUNC
534  * @tc.require: issuesI92WQP
535  */
536 HWTEST_F(FuseOperationsTest, SetXattrTest002, TestSize.Level1)
537 {
538     GTEST_LOG_(INFO) << "SetXattrTest002 Start";
539     try {
540         CloudDiskFuseData data;
541         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
542         fuse_req_t req = nullptr;
543         string name = HMDFS_PERMISSION_XATTR;
544         const char *value = "";
545         size_t size = 0;
546         int flags = 0;
547 
548         fuseoperations_->SetXattr(req, 0, name.c_str(), value, size, flags);
549         EXPECT_TRUE(true);
550     } catch (...) {
551         EXPECT_TRUE(false);
552         GTEST_LOG_(INFO) << "SetXattrTest002  ERROR";
553     }
554     GTEST_LOG_(INFO) << "SetXattrTest002 End";
555 }
556 
557 /**
558  * @tc.name:GetXattrTest001
559  * @tc.desc: Verify the GetXattr function
560  * @tc.type: FUNC
561  * @tc.require: issuesI92WQP
562  */
563 HWTEST_F(FuseOperationsTest, GetXattrTest001, TestSize.Level1)
564 {
565     GTEST_LOG_(INFO) << "GetXattrTest001 Start";
566     try {
567         fuse_req_t req = nullptr;
568         size_t size = 0;
569         string name = HMDFS_PERMISSION_XATTR;
570 
571         fuseoperations_->GetXattr(req, FUSE_ROOT_ID, name.c_str(), size);
572         EXPECT_TRUE(true);
573     } catch (...) {
574         EXPECT_TRUE(false);
575         GTEST_LOG_(INFO) << "GetXattrTest001  ERROR";
576     }
577     GTEST_LOG_(INFO) << "GetXattrTest001 End";
578 }
579 
580 /**
581  * @tc.name:GetXattrTest002
582  * @tc.desc: Verify the GetXattr function
583  * @tc.type: FUNC
584  * @tc.require: issuesI92WQP
585  */
586 HWTEST_F(FuseOperationsTest, GetXattrTest002, TestSize.Level1)
587 {
588     GTEST_LOG_(INFO) << "GetXattrTest002 Start";
589     try {
590         CloudDiskFuseData data;
591         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
592         fuse_req_t req = nullptr;
593         size_t size = 0;
594         string name = HMDFS_PERMISSION_XATTR;
595 
596         fuseoperations_->GetXattr(req, 0, name.c_str(), size);
597         EXPECT_TRUE(true);
598     } catch (...) {
599         EXPECT_TRUE(false);
600         GTEST_LOG_(INFO) << "GetXattrTest002  ERROR";
601     }
602     GTEST_LOG_(INFO) << "GetXattrTest002 End";
603 }
604 
605 /**
606  * @tc.name:MkDirTest001
607  * @tc.desc: Verify the MkDir function
608  * @tc.type: FUNC
609  * @tc.require: issuesI92WQP
610  */
611 HWTEST_F(FuseOperationsTest, MkDirTest001, TestSize.Level1)
612 {
613     GTEST_LOG_(INFO) << "MkDirTest001 Start";
614     try {
615         fuse_req_t req = nullptr;
616         const char *name = nullptr;
617         mode_t mode = 0;
618 
619 
620         fuseoperations_->MkDir(req, FUSE_ROOT_ID, name, mode);
621         EXPECT_TRUE(true);
622     } catch (...) {
623         EXPECT_TRUE(false);
624         GTEST_LOG_(INFO) << "MkDirTest001  ERROR";
625     }
626     GTEST_LOG_(INFO) << "MkDirTest001 End";
627 }
628 
629 /**
630  * @tc.name:MkDirTest002
631  * @tc.desc: Verify the MkDir function
632  * @tc.type: FUNC
633  * @tc.require: issuesI92WQP
634  */
635 HWTEST_F(FuseOperationsTest, MkDirTest002, TestSize.Level1)
636 {
637     GTEST_LOG_(INFO) << "MkDirTest002 Start";
638     try {
639         CloudDiskFuseData data;
640         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
641         fuse_req_t req = nullptr;
642         const char *name = nullptr;
643         mode_t mode = 0;
644 
645 
646         fuseoperations_->MkDir(req, 0, name, mode);
647         EXPECT_TRUE(true);
648     } catch (...) {
649         EXPECT_TRUE(false);
650         GTEST_LOG_(INFO) << "MkDirTest002  ERROR";
651     }
652     GTEST_LOG_(INFO) << "MkDirTest002 End";
653 }
654 
655 /**
656  * @tc.name:RmDirTest001
657  * @tc.desc: Verify the RmDir function
658  * @tc.type: FUNC
659  * @tc.require: issuesI92WQP
660  */
661 HWTEST_F(FuseOperationsTest, RmDirTest001, TestSize.Level1)
662 {
663     GTEST_LOG_(INFO) << "RmDirTest001 Start";
664     try {
665         fuse_req_t req = nullptr;
666         const char *name = nullptr;
667 
668         fuseoperations_->RmDir(req, FUSE_ROOT_ID, name);
669         EXPECT_TRUE(true);
670     } catch (...) {
671         EXPECT_TRUE(false);
672         GTEST_LOG_(INFO) << "RmDirTest001  ERROR";
673     }
674     GTEST_LOG_(INFO) << "RmDirTest001 End";
675 }
676 
677 /**
678  * @tc.name:RmDirTest002
679  * @tc.desc: Verify the RmDir function
680  * @tc.type: FUNC
681  * @tc.require: issuesI92WQP
682  */
683 HWTEST_F(FuseOperationsTest, RmDirTest002, TestSize.Level1)
684 {
685     GTEST_LOG_(INFO) << "RmDirTest002 Start";
686     try {
687         CloudDiskFuseData data;
688         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
689         fuse_req_t req = nullptr;
690         const char *name = nullptr;
691 
692         fuseoperations_->RmDir(req, 0, name);
693         EXPECT_TRUE(true);
694     } catch (...) {
695         EXPECT_TRUE(false);
696         GTEST_LOG_(INFO) << "RmDirTest002  ERROR";
697     }
698     GTEST_LOG_(INFO) << "RmDirTest002 End";
699 }
700 
701 /**
702  * @tc.name:UnlinkTest001
703  * @tc.desc: Verify the Unlink function
704  * @tc.type: FUNC
705  * @tc.require: issuesI92WQP
706  */
707 HWTEST_F(FuseOperationsTest, UnlinkTest001, TestSize.Level1)
708 {
709     GTEST_LOG_(INFO) << "UnlinkTest001 Start";
710     try {
711         fuse_req_t req = nullptr;
712         const char *name = nullptr;
713 
714         fuseoperations_->Unlink(req, FUSE_ROOT_ID, name);
715         EXPECT_TRUE(true);
716     } catch (...) {
717         EXPECT_TRUE(false);
718         GTEST_LOG_(INFO) << "UnlinkTest001  ERROR";
719     }
720     GTEST_LOG_(INFO) << "UnlinkTest001 End";
721 }
722 
723 /**
724  * @tc.name:UnlinkTest002
725  * @tc.desc: Verify the Unlink function
726  * @tc.type: FUNC
727  * @tc.require: issuesI92WQP
728  */
729 HWTEST_F(FuseOperationsTest, UnlinkTest002, TestSize.Level1)
730 {
731     GTEST_LOG_(INFO) << "UnlinkTest002 Start";
732     try {
733         CloudDiskFuseData data;
734         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
735         fuse_req_t req = nullptr;
736         const char *name = nullptr;
737 
738         fuseoperations_->Unlink(req, 0, name);
739         EXPECT_TRUE(true);
740     } catch (...) {
741         EXPECT_TRUE(false);
742         GTEST_LOG_(INFO) << "UnlinkTest002  ERROR";
743     }
744     GTEST_LOG_(INFO) << "UnlinkTest002 End";
745 }
746 
747 /**
748  * @tc.name:RenameTest001
749  * @tc.desc: Verify the Rename function
750  * @tc.type: FUNC
751  * @tc.require: issuesI92WQP
752  */
753 HWTEST_F(FuseOperationsTest, RenameTest001, TestSize.Level1)
754 {
755     GTEST_LOG_(INFO) << "RenameTest001 Start";
756     try {
757         fuse_req_t req = nullptr;
758         const char *name = "";
759         const char *newName = "";
760         unsigned int flags = 1;
761 
762         fuseoperations_->Rename(req, FUSE_ROOT_ID, name, FUSE_ROOT_ID, newName, flags);
763         EXPECT_TRUE(true);
764     } catch (...) {
765         EXPECT_TRUE(false);
766         GTEST_LOG_(INFO) << "RenameTest001  ERROR";
767     }
768     GTEST_LOG_(INFO) << "RenameTest001 End";
769 }
770 
771 /**
772  * @tc.name:RenameTest002
773  * @tc.desc: Verify the Rename function
774  * @tc.type: FUNC
775  * @tc.require: issuesI92WQP
776  */
777 HWTEST_F(FuseOperationsTest, RenameTest002, TestSize.Level1)
778 {
779     GTEST_LOG_(INFO) << "RenameTest002 Start";
780     try {
781         CloudDiskFuseData data;
782         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
783         fuse_req_t req = nullptr;
784         const char *name = "";
785         const char *newName = "";
786         unsigned int flags = 1;
787 
788         fuseoperations_->Rename(req, 0, name, FUSE_ROOT_ID, newName, flags);
789         EXPECT_TRUE(true);
790     } catch (...) {
791         EXPECT_TRUE(false);
792         GTEST_LOG_(INFO) << "RenameTest002  ERROR";
793     }
794     GTEST_LOG_(INFO) << "RenameTest002 End";
795 }
796 
797 /**
798  * @tc.name:ReadTest001
799  * @tc.desc: Verify the Read function
800  * @tc.type: FUNC
801  * @tc.require: issuesI92WQP
802  */
803 HWTEST_F(FuseOperationsTest, ReadTest001, TestSize.Level1)
804 {
805     GTEST_LOG_(INFO) << "ReadTest001 Start";
806     try {
807         fuse_req_t req = nullptr;
808         size_t size = 0;
809         off_t off = 0;
810         struct fuse_file_info fi;
811 
812         fuseoperations_->Read(req, FUSE_ROOT_ID, size, off, &fi);
813         EXPECT_TRUE(true);
814     } catch (...) {
815         EXPECT_TRUE(false);
816         GTEST_LOG_(INFO) << "ReadTest001  ERROR";
817     }
818     GTEST_LOG_(INFO) << "ReadTest001 End";
819 }
820 
821 /**
822  * @tc.name:ReadTest002
823  * @tc.desc: Verify the Read function
824  * @tc.type: FUNC
825  * @tc.require: issuesI92WQP
826  */
827 HWTEST_F(FuseOperationsTest, ReadTest002, TestSize.Level1)
828 {
829     GTEST_LOG_(INFO) << "ReadTest002 Start";
830     try {
831         CloudDiskFuseData data;
832         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
833         fuse_req_t req = nullptr;
834         size_t size = 0;
835         off_t off = 0;
836         struct fuse_file_info fi;
837 
838         fuseoperations_->Read(req, 0, size, off, &fi);
839         EXPECT_TRUE(true);
840     } catch (...) {
841         EXPECT_TRUE(false);
842         GTEST_LOG_(INFO) << "ReadTest002  ERROR";
843     }
844     GTEST_LOG_(INFO) << "ReadTest002 End";
845 }
846 
847 /**
848  * @tc.name:WriteBufTest001
849  * @tc.desc: Verify the WriteBuf function
850  * @tc.type: FUNC
851  * @tc.require: issuesI92WQP
852  */
853 HWTEST_F(FuseOperationsTest, WriteBufTest001, TestSize.Level1)
854 {
855     GTEST_LOG_(INFO) << "WriteBufTest001 Start";
856     try {
857         fuse_req_t req = nullptr;
858         struct fuse_bufvec *bufv = nullptr;
859         off_t offset = 0;
860         struct fuse_file_info fi;
861 
862         fuseoperations_->WriteBuf(req, FUSE_ROOT_ID, bufv, offset, &fi);
863         EXPECT_TRUE(true);
864     } catch (...) {
865         EXPECT_TRUE(false);
866         GTEST_LOG_(INFO) << "WriteBufTest001  ERROR";
867     }
868     GTEST_LOG_(INFO) << "WriteBufTest001 End";
869 }
870 
871 /**
872  * @tc.name:WriteBufTest002
873  * @tc.desc: Verify the WriteBuf function
874  * @tc.type: FUNC
875  * @tc.require: issuesI92WQP
876  */
877 HWTEST_F(FuseOperationsTest, WriteBufTest002, TestSize.Level1)
878 {
879     GTEST_LOG_(INFO) << "WriteBufTest002 Start";
880     try {
881         CloudDiskFuseData data;
882         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
883         fuse_req_t req = nullptr;
884         struct fuse_bufvec *bufv = nullptr;
885         off_t offset = 0;
886         struct fuse_file_info fi;
887 
888         fuseoperations_->WriteBuf(req, 0, bufv, offset, &fi);
889         EXPECT_TRUE(true);
890     } catch (...) {
891         EXPECT_TRUE(false);
892         GTEST_LOG_(INFO) << "WriteBufTest002  ERROR";
893     }
894     GTEST_LOG_(INFO) << "WriteBufTest002 End";
895 }
896 
897 /**
898  * @tc.name:ReleaseTest001
899  * @tc.desc: Verify the Release function
900  * @tc.type: FUNC
901  * @tc.require: issuesI92WQP
902  */
903 HWTEST_F(FuseOperationsTest, ReleaseTest001, TestSize.Level1)
904 {
905     GTEST_LOG_(INFO) << "ReleaseTest001 Start";
906     try {
907         fuse_req_t req = nullptr;
908         struct fuse_file_info fi;
909 
910         fuseoperations_->Release(req, FUSE_ROOT_ID, &fi);
911         EXPECT_TRUE(true);
912     } catch (...) {
913         EXPECT_TRUE(false);
914         GTEST_LOG_(INFO) << "ReleaseTest001  ERROR";
915     }
916     GTEST_LOG_(INFO) << "ReleaseTest001 End";
917 }
918 
919 /**
920  * @tc.name:ReleaseTest002
921  * @tc.desc: Verify the Release function
922  * @tc.type: FUNC
923  * @tc.require: issuesI92WQP
924  */
925 HWTEST_F(FuseOperationsTest, ReleaseTest002, TestSize.Level1)
926 {
927     GTEST_LOG_(INFO) << "ReleaseTest002 Start";
928     try {
929         CloudDiskFuseData data;
930         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
931         fuse_req_t req = nullptr;
932         struct fuse_file_info fi;
933 
934         fuseoperations_->Release(req, 0, &fi);
935         EXPECT_TRUE(true);
936     } catch (...) {
937         EXPECT_TRUE(false);
938         GTEST_LOG_(INFO) << "ReleaseTest002  ERROR";
939     }
940     GTEST_LOG_(INFO) << "ReleaseTest002 End";
941 }
942 
943 /**
944  * @tc.name:SetAttrTest001
945  * @tc.desc: Verify the SetAttr function
946  * @tc.type: FUNC
947  * @tc.require: issuesI92WQP
948  */
949 HWTEST_F(FuseOperationsTest, SetAttrTest001, TestSize.Level1)
950 {
951     GTEST_LOG_(INFO) << "SetAttrTest001 Start";
952     try {
953         fuse_req_t req = nullptr;
954         struct fuse_file_info fi;
955         struct stat attr;
956         int valid = 0;
957 
958         fuseoperations_->SetAttr(req, FUSE_ROOT_ID, &attr, valid, &fi);
959         EXPECT_TRUE(true);
960     } catch (...) {
961         EXPECT_TRUE(false);
962         GTEST_LOG_(INFO) << "SetAttrTest001  ERROR";
963     }
964     GTEST_LOG_(INFO) << "SetAttrTest001 End";
965 }
966 
967 /**
968  * @tc.name:SetAttrTest002
969  * @tc.desc: Verify the SetAttr function
970  * @tc.type: FUNC
971  * @tc.require: issuesI92WQP
972  */
973 HWTEST_F(FuseOperationsTest, SetAttrTest002, TestSize.Level1)
974 {
975     GTEST_LOG_(INFO) << "SetAttrTest002 Start";
976     try {
977         CloudDiskFuseData data;
978         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
979         fuse_req_t req = nullptr;
980         struct fuse_file_info fi;
981         struct stat attr;
982         int valid = 0;
983 
984         fuseoperations_->SetAttr(req, 0, &attr, valid, &fi);
985         EXPECT_TRUE(true);
986     } catch (...) {
987         EXPECT_TRUE(false);
988         GTEST_LOG_(INFO) << "SetAttrTest002  ERROR";
989     }
990     GTEST_LOG_(INFO) << "SetAttrTest002 End";
991 }
992 
993 /**
994  * @tc.name:LseekTest001
995  * @tc.desc: Verify the Lseek function
996  * @tc.type: FUNC
997  * @tc.require: issuesI92WQP
998  */
999 HWTEST_F(FuseOperationsTest, LseekTest001, TestSize.Level1)
1000 {
1001     GTEST_LOG_(INFO) << "LseekTest001 Start";
1002     try {
1003         fuse_req_t req = nullptr;
1004         off_t off = 0;
1005         int whence = 0;
1006         struct fuse_file_info fi;
1007 
1008         fuseoperations_->Lseek(req, FUSE_ROOT_ID, off, whence, &fi);
1009         EXPECT_TRUE(true);
1010     } catch (...) {
1011         EXPECT_TRUE(false);
1012         GTEST_LOG_(INFO) << "LseekTest001  ERROR";
1013     }
1014     GTEST_LOG_(INFO) << "LseekTest001 End";
1015 }
1016 
1017 /**
1018  * @tc.name:LseekTest002
1019  * @tc.desc: Verify the Lseek function
1020  * @tc.type: FUNC
1021  * @tc.require: issuesI92WQP
1022  */
1023 HWTEST_F(FuseOperationsTest, LseekTest002, TestSize.Level1)
1024 {
1025     GTEST_LOG_(INFO) << "LseekTest002 Start";
1026     try {
1027         CloudDiskFuseData data;
1028         EXPECT_CALL(*insMock, fuse_req_userdata(_)).WillOnce(Return(reinterpret_cast<void*>(&data)));
1029         fuse_req_t req = nullptr;
1030         off_t off = 0;
1031         int whence = 0;
1032         struct fuse_file_info fi;
1033 
1034         fuseoperations_->Lseek(req, 0, off, whence, &fi);
1035         EXPECT_TRUE(true);
1036     } catch (...) {
1037         EXPECT_TRUE(false);
1038         GTEST_LOG_(INFO) << "LseekTest002  ERROR";
1039     }
1040     GTEST_LOG_(INFO) << "LseekTest002 End";
1041 }
1042 } // namespace OHOS::FileManagement::CloudDisk::Test