1 /*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 #include <climits>
31 #include <gtest/gtest.h>
32 #include <cstdio>
33 #include <netinet/in.h>
34 #include <arpa/inet.h>
35 #include <net/if.h>
36 #include <net/route.h>
37 #include "It_container_test.h"
38
39 const char *USERDATA_DIR_NAME = "/userdata";
40 const char *ACCESS_FILE_NAME = "/userdata/mntcontainertest";
41 const char *MNT_ACCESS_FILE_NAME = "/mntcontainertest";
42 const char *USERDATA_DEV_NAME = "/dev/mmcblk0p2";
43 const char *FS_TYPE = "vfat";
44
45 const int BIT_ON_RETURN_VALUE = 8;
46 const int STACK_SIZE = 1024 * 1024;
47 const int CHILD_FUNC_ARG = 0x2088;
48 static const int TRY_COUNT = 5;
49 static const int OFFSET = 2;
50
ChildFunction(void * args)51 int ChildFunction(void *args)
52 {
53 (void)args;
54 const int sleep_time = 2;
55 sleep(sleep_time);
56 return 0;
57 }
58
CloneWrapper(int (* func)(void *),int flag,void * args)59 pid_t CloneWrapper(int (*func)(void *), int flag, void *args)
60 {
61 pid_t pid;
62 char *stack = (char *)mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK,
63 -1, 0);
64 if (stack == MAP_FAILED) {
65 return -1;
66 }
67 char *stackTop = stack + STACK_SIZE;
68
69 pid = clone(func, stackTop, flag, args);
70 munmap(stack, STACK_SIZE);
71 return pid;
72 }
73
WaitChild(pid_t pid,int * status,int errNo1,int errNo2)74 int WaitChild(pid_t pid, int *status, int errNo1, int errNo2)
75 {
76 int ret = waitpid(pid, status, 0);
77 if (ret != pid) {
78 printf("[ERR] WaitChild pid=%d return pid=%d\n", pid, ret);
79 return errNo1;
80 }
81 if (status == nullptr) {
82 return 0;
83 }
84 ret = WIFEXITED(*status);
85 if (ret == 0) {
86 printf("[ERR] WaitChild pid=%d WIFEXITED(status)=%d\n", pid, WIFEXITED(*status));
87 return errNo2;
88 }
89 ret = WEXITSTATUS(*status);
90 if (ret != 0) {
91 printf("[ERR] WaitChild pid=%d WEXITSTATUS(status)=%d\n", pid, WEXITSTATUS(*status));
92 return errNo2;
93 }
94 return 0;
95 }
96
ReadFile(const char * filepath,char * buf)97 int ReadFile(const char *filepath, char *buf)
98 {
99 FILE *fpid = nullptr;
100 fpid = fopen(filepath, "r");
101 if (fpid == nullptr) {
102 return -1;
103 }
104 size_t trd = fread(buf, 1, 512, fpid);
105 (void)fclose(fpid);
106 return trd;
107 }
108
WriteFile(const char * filepath,const char * buf)109 int WriteFile(const char *filepath, const char *buf)
110 {
111 int fd = open(filepath, O_WRONLY);
112 if (fd == -1) {
113 return -1;
114 }
115 size_t twd = write(fd, buf, strlen(buf));
116 if (twd == -1) {
117 (void)close(fd);
118 return -1;
119 }
120 (void)close(fd);
121 return twd;
122 }
123
GetLine(char * buf,int count,int maxLen,char ** array)124 int GetLine(char *buf, int count, int maxLen, char **array)
125 {
126 char *head = buf;
127 char *tail = buf;
128 char index = 0;
129 if ((buf == NULL) || (strlen(buf) == 0)) {
130 return 0;
131 }
132 while (*tail != '\0') {
133 if (*tail != '\n') {
134 tail++;
135 continue;
136 }
137 if (index >= count) {
138 return index + 1;
139 }
140
141 array[index] = head;
142 index++;
143 *tail = '\0';
144 if (strlen(head) > maxLen) {
145 return index + 1;
146 }
147 tail++;
148 head = tail;
149 tail++;
150 }
151 return (index + 1);
152 }
153
TryResetNetAddr(const char * ifname,const char * ip,const char * netmask,const char * gw)154 static int TryResetNetAddr(const char *ifname, const char *ip, const char *netmask, const char *gw)
155 {
156 int ret;
157 struct ifreq ifr;
158 struct rtentry rt;
159
160 int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
161 if (fd < 0) {
162 return -1;
163 }
164 ret = strncpy_s(ifr.ifr_name, sizeof(ifr.ifr_name), ifname, IFNAMSIZ);
165 if (ret != EOK) {
166 (void)close(fd);
167 return -1;
168 }
169 ifr.ifr_addr.sa_family = AF_INET;
170 inet_pton(AF_INET, netmask, ifr.ifr_addr.sa_data + OFFSET);
171 ret = ioctl(fd, SIOCSIFNETMASK, &ifr);
172 if (ret != 0) {
173 printf("[ERR][%s:%d] ioctl SIOCSIFNETMASK failed, %s!\n", __FUNCTION__, __LINE__, strerror(errno));
174 (void)close(fd);
175 return -1;
176 }
177 inet_pton(AF_INET, ip, ifr.ifr_addr.sa_data + OFFSET);
178 ret = ioctl(fd, SIOCSIFADDR, &ifr);
179 if (ret != 0) {
180 (void)close(fd);
181 printf("[ERR][%s:%d] ioctl SIOCGIFADDR failed, %s!\n", __FUNCTION__, __LINE__, strerror(errno));
182 return -1;
183 }
184 struct sockaddr_in *addr = reinterpret_cast<struct sockaddr_in *>(&rt.rt_gateway);
185 addr->sin_family = AF_INET;
186 addr->sin_addr.s_addr = inet_addr(gw);
187 rt.rt_flags = RTF_GATEWAY;
188 ret = ioctl(fd, SIOCADDRT, &rt);
189 if (ret != 0) {
190 (void)close(fd);
191 printf("[ERR][%s:%d] ioctl SIOCADDRT failed, %s!\n", __FUNCTION__, __LINE__, strerror(errno));
192 return ret;
193 }
194 ret = close(fd);
195 if (ret != 0) {
196 printf("[ERR][%s:%d] close failed, %s!\n", __FUNCTION__, __LINE__, strerror(errno));
197 return ret;
198 }
199 return ret;
200 }
201
NetContainerResetNetAddr(const char * ifname,const char * ip,const char * netmask,const char * gw)202 int NetContainerResetNetAddr(const char *ifname, const char *ip, const char *netmask, const char *gw)
203 {
204 int ret;
205 int try_count = TRY_COUNT;
206
207 while (try_count--) {
208 ret = TryResetNetAddr(ifname, ip, netmask, gw);
209 if (ret == 0) {
210 break;
211 }
212 sleep(1);
213 }
214 return ret;
215 }
216
NetContainerGetLocalIP(const char * ifname,char * ip,int ipLen)217 int NetContainerGetLocalIP(const char *ifname, char *ip, int ipLen)
218 {
219 struct ifreq ifr = {0};
220 int ret = strcpy_s(ifr.ifr_name, sizeof(ifr.ifr_name), ifname);
221 if (ret != EOK) {
222 return -1; /* -1: errno */
223 }
224 int inet_sock = socket(AF_INET, SOCK_DGRAM, 0);
225 if (inet_sock < 0) {
226 return -2; /* -2: errno */
227 }
228 ret = ioctl(inet_sock, SIOCGIFADDR, &ifr);
229 if (ret != 0) {
230 (void)close(inet_sock);
231 printf("[ERR][%s:%d] ioctl SIOCGIFADDR failed, %s!\n", __FUNCTION__, __LINE__, strerror(errno));
232 return -3; /* -3: errno */
233 }
234 ret = close(inet_sock);
235 if (ret != 0) {
236 return -4; /* -4: errno */
237 }
238 ret = strcpy_s(ip, ipLen, inet_ntoa((reinterpret_cast<struct sockaddr_in *>(&ifr.ifr_addr))->sin_addr));
239 if (ret != EOK) {
240 (void)close(inet_sock);
241 return -5; /* -5: errno */
242 }
243 return 0;
244 }
245
GenContainerLinkPath(int pid,const std::string & containerType)246 std::string GenContainerLinkPath(int pid, const std::string& containerType)
247 {
248 std::ostringstream buf;
249 buf << "/proc/" << pid << "/container/" << containerType;
250 return buf.str();
251 }
252
ReadlinkContainer(int pid,const std::string & containerType)253 std::string ReadlinkContainer(int pid, const std::string& containerType)
254 {
255 char buf[PATH_MAX] = {0};
256 auto path = GenContainerLinkPath(pid, containerType);
257 ssize_t nbytes = readlink(path.c_str(), buf, PATH_MAX);
258 if (nbytes == -1) {
259 printf("pid %d, ReadlinkContainer readlink %s failed, errno=%d\n", getpid(), path.c_str(), errno);
260 return path.c_str();
261 }
262 return buf;
263 }
264
265 using namespace testing::ext;
266 namespace OHOS {
267 class ContainerTest : public testing::Test {
268 public:
SetUpTestCase(void)269 static void SetUpTestCase(void) {}
TearDownTestCase(void)270 static void TearDownTestCase(void) {}
271
272 protected:
273 virtual void SetUp();
274 virtual void TearDown();
275 };
276
277 #if defined(LOSCFG_USER_TEST_SMOKE)
278 HWTEST_F(ContainerTest, ItContainer001, TestSize.Level0)
279 {
280 ItContainer001();
281 }
282 #if defined(LOSCFG_USER_TEST_NET_CONTAINER)
283 /**
284 * @tc.name: Container_NET_Test_001
285 * @tc.desc: uts container function test case
286 * @tc.type: FUNC
287 * @tc.require: issueI6HPH2
288 * @tc.author:
289 */
290 HWTEST_F(ContainerTest, ItNetContainer001, TestSize.Level0)
291 {
292 ItNetContainer001();
293 }
294
295 /**
296 * @tc.name: Container_NET_Test_002
297 * @tc.desc: uts container function test case
298 * @tc.type: FUNC
299 * @tc.require: issueI6HPH2
300 * @tc.author:
301 */
302 HWTEST_F(ContainerTest, ItNetContainer002, TestSize.Level0)
303 {
304 ItNetContainer002();
305 }
306
307 /**
308 * @tc.name: Container_NET_Test_003
309 * @tc.desc: uts container function test case
310 * @tc.type: FUNC
311 * @tc.require: issueI6HPH2
312 * @tc.author:
313 */
314 HWTEST_F(ContainerTest, ItNetContainer003, TestSize.Level0)
315 {
316 ItNetContainer003();
317 }
318
319 /**
320 * @tc.name: Container_NET_Test_004
321 * @tc.desc: uts container function test case
322 * @tc.type: FUNC
323 * @tc.require: issueI6HPH2
324 * @tc.author:
325 */
326 HWTEST_F(ContainerTest, ItNetContainer004, TestSize.Level0)
327 {
328 ItNetContainer004();
329 }
330
331 /**
332 * @tc.name: Container_NET_Test_005
333 * @tc.desc: uts container function test case
334 * @tc.type: FUNC
335 * @tc.require: issueI6HPH2
336 * @tc.author:
337 */
338 HWTEST_F(ContainerTest, ItNetContainer005, TestSize.Level0)
339 {
340 ItNetContainer005();
341 }
342
343 /**
344 * @tc.name: Container_NET_Test_006
345 * @tc.desc: uts container function test case
346 * @tc.type: FUNC
347 * @tc.require: issueI6HPH2
348 * @tc.author:
349 */
350 HWTEST_F(ContainerTest, ItNetContainer006, TestSize.Level0)
351 {
352 ItNetContainer006();
353 }
354
355 /**
356 * @tc.name: Container_NET_Test_007
357 * @tc.desc: uts container function test case
358 * @tc.type: FUNC
359 * @tc.require: issueI6HPH2
360 * @tc.author:
361 */
362 HWTEST_F(ContainerTest, ItNetContainer007, TestSize.Level0)
363 {
364 ItNetContainer007();
365 }
366
367 /**
368 * @tc.name: Container_NET_Test_008
369 * @tc.desc: uts container function test case
370 * @tc.type: FUNC
371 * @tc.require: issueI6HPH2
372 * @tc.author:
373 */
374 HWTEST_F(ContainerTest, ItNetContainer008, TestSize.Level0)
375 {
376 ItNetContainer008();
377 }
378
379 /**
380 * @tc.name: Container_NET_Test_009
381 * @tc.desc: uts container function test case
382 * @tc.type: FUNC
383 * @tc.require: issueI6HPH2
384 * @tc.author:
385 */
386 HWTEST_F(ContainerTest, ItNetContainer009, TestSize.Level0)
387 {
388 ItNetContainer009();
389 }
390
391 /**
392 * @tc.name: Container_NET_Test_011
393 * @tc.desc: uts container function test case
394 * @tc.type: FUNC
395 * @tc.require: issueI6HPH2
396 * @tc.author:
397 */
398 HWTEST_F(ContainerTest, ItNetContainer011, TestSize.Level0)
399 {
400 ItNetContainer011();
401 }
402
403 /**
404 * @tc.name: Container_NET_Test_012
405 * @tc.desc: uts container function test case
406 * @tc.type: FUNC
407 * @tc.require: issueI6HPH2
408 * @tc.author:
409 */
410 HWTEST_F(ContainerTest, ItNetContainer012, TestSize.Level0)
411 {
412 ItNetContainer012();
413 }
414 #endif
415 #if defined(LOSCFG_USER_TEST_USER_CONTAINER)
416 /**
417 * @tc.name: Container_UTS_Test_001
418 * @tc.desc: uts container function test case
419 * @tc.type: FUNC
420 * @tc.require: issueI6EC0A
421 * @tc.author:
422 */
423 HWTEST_F(ContainerTest, ItUserContainer001, TestSize.Level0)
424 {
425 ItUserContainer001();
426 }
427
428 /**
429 * @tc.name: Container_UTS_Test_002
430 * @tc.desc: uts container function test case
431 * @tc.type: FUNC
432 * @tc.require: issueI6EC0A
433 * @tc.author:
434 */
435 HWTEST_F(ContainerTest, ItUserContainer002, TestSize.Level0)
436 {
437 ItUserContainer002();
438 }
439
440 /**
441 * @tc.name: Container_UTS_Test_003
442 * @tc.desc: uts container function test case
443 * @tc.type: FUNC
444 * @tc.require: issueI6EC0A
445 * @tc.author:
446 */
447 HWTEST_F(ContainerTest, ItUserContainer003, TestSize.Level0)
448 {
449 ItUserContainer003();
450 }
451
452 /**
453 * @tc.name: Container_UTS_Test_004
454 * @tc.desc: uts container function test case
455 * @tc.type: FUNC
456 * @tc.require: issueI6EC0A
457 * @tc.author:
458 */
459 HWTEST_F(ContainerTest, ItUserContainer004, TestSize.Level0)
460 {
461 ItUserContainer004();
462 }
463
464 /**
465 * @tc.name: Container_UTS_Test_006
466 * @tc.desc: uts container function test case
467 * @tc.type: FUNC
468 * @tc.require: issueI6HDQK
469 * @tc.author:
470 */
471 HWTEST_F(ContainerTest, ItUserContainer006, TestSize.Level0)
472 {
473 ItUserContainer006();
474 }
475
476 /**
477 * @tc.name: Container_UTS_Test_007
478 * @tc.desc: uts container function test case
479 * @tc.type: FUNC
480 * @tc.require: issueI6HDQK
481 * @tc.author:
482 */
483 HWTEST_F(ContainerTest, ItUserContainer007, TestSize.Level0)
484 {
485 ItUserContainer007();
486 }
487 #endif
488 #if defined(LOSCFG_USER_TEST_PID_CONTAINER)
489 /**
490 * @tc.name: Container_Pid_Test_032
491 * @tc.desc: pid container function test case
492 * @tc.type: FUNC
493 * @tc.require: issueI6HDQK
494 * @tc.author:
495 */
496 HWTEST_F(ContainerTest, ItPidContainer032, TestSize.Level0)
497 {
498 ItPidContainer032();
499 }
500
501 /**
502 * @tc.name: Container_Pid_Test_033
503 * @tc.desc: pid container function test case
504 * @tc.type: FUNC
505 * @tc.require: issueI6HDQK
506 * @tc.author:
507 */
508 HWTEST_F(ContainerTest, ItPidContainer033, TestSize.Level0)
509 {
510 ItPidContainer033();
511 }
512
513 /**
514 * @tc.name: Container_Pid_Test_023
515 * @tc.desc: pid container function test case
516 * @tc.type: FUNC
517 * @tc.require: issueI68LVW
518 * @tc.author:
519 */
520 HWTEST_F(ContainerTest, ItPidContainer023, TestSize.Level0)
521 {
522 ItPidContainer023();
523 }
524
525 /**
526 * @tc.name: Container_Pid_Test_025
527 * @tc.desc: pid container function test case
528 * @tc.type: FUNC
529 * @tc.require: issueI68LVW
530 * @tc.author:
531 */
532 HWTEST_F(ContainerTest, ItPidContainer025, TestSize.Level0)
533 {
534 ItPidContainer025();
535 }
536
537 /**
538 * @tc.name: Container_Pid_Test_026
539 * @tc.desc: pid container function test case
540 * @tc.type: FUNC
541 * @tc.require: issueI68LVW
542 * @tc.author:
543 */
544 HWTEST_F(ContainerTest, ItPidContainer026, TestSize.Level0)
545 {
546 ItPidContainer026();
547 }
548
549 /**
550 * @tc.name: Container_Pid_Test_027
551 * @tc.desc: pid container function test case
552 * @tc.type: FUNC
553 * @tc.require: issueI6BE5A
554 * @tc.author:
555 */
556 HWTEST_F(ContainerTest, ItPidContainer027, TestSize.Level0)
557 {
558 ItPidContainer027();
559 }
560
561 /**
562 * @tc.name: Container_Pid_Test_028
563 * @tc.desc: pid container function test case
564 * @tc.type: FUNC
565 * @tc.require: issueI6BE5A
566 * @tc.author:
567 */
568 HWTEST_F(ContainerTest, ItPidContainer028, TestSize.Level0)
569 {
570 ItPidContainer028();
571 }
572
573 /**
574 * @tc.name: Container_Pid_Test_029
575 * @tc.desc: pid container function test case
576 * @tc.type: FUNC
577 * @tc.require: issueI6BE5A
578 * @tc.author:
579 */
580 HWTEST_F(ContainerTest, ItPidContainer029, TestSize.Level0)
581 {
582 ItPidContainer029();
583 }
584
585 /**
586 * @tc.name: Container_Pid_Test_030
587 * @tc.desc: pid container function test case
588 * @tc.type: FUNC
589 * @tc.require: issueI6BE5A
590 * @tc.author:
591 */
592 HWTEST_F(ContainerTest, ItPidContainer030, TestSize.Level0)
593 {
594 ItPidContainer030();
595 }
596
597 /**
598 * @tc.name: Container_Pid_Test_031
599 * @tc.desc: pid container function test case
600 * @tc.type: FUNC
601 * @tc.require: issueI6D9Y0
602 * @tc.author:
603 */
604 HWTEST_F(ContainerTest, ItPidContainer031, TestSize.Level0)
605 {
606 ItPidContainer031();
607 }
608 #endif
609 #if defined(LOSCFG_USER_TEST_UTS_CONTAINER)
610 /**
611 * @tc.name: Container_UTS_Test_001
612 * @tc.desc: uts container function test case
613 * @tc.type: FUNC
614 * @tc.require: issueI6A7C8
615 * @tc.author:
616 */
617 HWTEST_F(ContainerTest, ItUtsContainer001, TestSize.Level0)
618 {
619 ItUtsContainer001();
620 }
621
622 /**
623 * @tc.name: Container_UTS_Test_002
624 * @tc.desc: uts container function test case
625 * @tc.type: FUNC
626 * @tc.require: issueI6A7C8
627 * @tc.author:
628 */
629 HWTEST_F(ContainerTest, ItUtsContainer002, TestSize.Level0)
630 {
631 ItUtsContainer002();
632 }
633
634 /**
635 * @tc.name: Container_UTS_Test_004
636 * @tc.desc: uts container function test case
637 * @tc.type: FUNC
638 * @tc.require: issueI6BE5A
639 * @tc.author:
640 */
641 HWTEST_F(ContainerTest, ItUtsContainer004, TestSize.Level0)
642 {
643 ItUtsContainer004();
644 }
645
646 /**
647 * @tc.name: Container_UTS_Test_005
648 * @tc.desc: uts container function test case
649 * @tc.type: FUNC
650 * @tc.require: issueI6D9Y0
651 * @tc.author:
652 */
653 HWTEST_F(ContainerTest, ItUtsContainer005, TestSize.Level0)
654 {
655 ItUtsContainer005();
656 }
657
658 /**
659 * @tc.name: Container_UTS_Test_006
660 * @tc.desc: uts container function test case
661 * @tc.type: FUNC
662 * @tc.require: issueI6D9Y0
663 * @tc.author:
664 */
665 HWTEST_F(ContainerTest, ItUtsContainer006, TestSize.Level0)
666 {
667 ItUtsContainer006();
668 }
669
670 /**
671 * @tc.name: Container_UTS_Test_007
672 * @tc.desc: uts container function test case
673 * @tc.type: FUNC
674 * @tc.require: issueI6HDQK
675 * @tc.author:
676 */
677 HWTEST_F(ContainerTest, ItUtsContainer007, TestSize.Level0)
678 {
679 ItUtsContainer007();
680 }
681
682 /**
683 * @tc.name: Container_UTS_Test_008
684 * @tc.desc: uts container function test case
685 * @tc.type: FUNC
686 * @tc.require: issueI6HDQK
687 * @tc.author:
688 */
689 HWTEST_F(ContainerTest, ItUtsContainer008, TestSize.Level0)
690 {
691 ItUtsContainer008();
692 }
693 #endif
694
695 #if defined(LOSCFG_USER_TEST_MNT_CONTAINER)
696 /**
697 * @tc.name: Container_MNT_Test_001
698 * @tc.desc: mnt container function test case
699 * @tc.type: FUNC
700 * @tc.require: issueI6APW2
701 * @tc.author:
702 */
703 HWTEST_F(ContainerTest, ItMntContainer001, TestSize.Level0)
704 {
705 ItMntContainer001();
706 }
707
708 /**
709 * @tc.name: Container_MNT_Test_002
710 * @tc.desc: mnt container function test case
711 * @tc.type: FUNC
712 * @tc.require: issueI6APW2
713 * @tc.author:
714 */
715 HWTEST_F(ContainerTest, ItMntContainer002, TestSize.Level0)
716 {
717 ItMntContainer002();
718 }
719
720 /**
721 * @tc.name: Container_MNT_Test_003
722 * @tc.desc: mnt container function test case
723 * @tc.type: FUNC
724 * @tc.require: issueI6APW2
725 * @tc.author:
726 */
727 HWTEST_F(ContainerTest, ItMntContainer003, TestSize.Level0)
728 {
729 ItMntContainer003();
730 }
731
732 /**
733 * @tc.name: Container_MNT_Test_004
734 * @tc.desc: mnt container function test case
735 * @tc.type: FUNC
736 * @tc.require: issueI6APW2
737 * @tc.author:
738 */
739 HWTEST_F(ContainerTest, ItMntContainer004, TestSize.Level0)
740 {
741 ItMntContainer004();
742 }
743
744 /**
745 * @tc.name: Container_MNT_Test_005
746 * @tc.desc: mnt container function test case
747 * @tc.type: FUNC
748 * @tc.require: issueI6BE5A
749 * @tc.author:
750 */
751 HWTEST_F(ContainerTest, ItMntContainer005, TestSize.Level0)
752 {
753 ItMntContainer005();
754 }
755
756 /**
757 * @tc.name: Container_MNT_Test_006
758 * @tc.desc: mnt container function test case
759 * @tc.type: FUNC
760 * @tc.require: issueI6BE5A
761 * @tc.author:
762 */
763 HWTEST_F(ContainerTest, ItMntContainer006, TestSize.Level0)
764 {
765 ItMntContainer006();
766 }
767
768 /**
769 * @tc.name: Container_MNT_Test_007
770 * @tc.desc: mnt container function test case
771 * @tc.type: FUNC
772 * @tc.require: issueI6BE5A
773 * @tc.author:
774 */
775 HWTEST_F(ContainerTest, ItMntContainer007, TestSize.Level0)
776 {
777 ItMntContainer007();
778 }
779
780 /**
781 * @tc.name: Container_MNT_Test_008
782 * @tc.desc: mnt container function test case
783 * @tc.type: FUNC
784 * @tc.require: issueI6D9Y0
785 * @tc.author:
786 */
787 HWTEST_F(ContainerTest, ItMntContainer008, TestSize.Level0)
788 {
789 ItMntContainer008();
790 }
791
792 /**
793 * @tc.name: Container_MNT_Test_009
794 * @tc.desc: mnt container function test case
795 * @tc.type: FUNC
796 * @tc.require: issueI6HDQK
797 * @tc.author:
798 */
799 HWTEST_F(ContainerTest, ItMntContainer009, TestSize.Level0)
800 {
801 ItMntContainer009();
802 }
803
804 /**
805 * @tc.name: Container_MNT_Test_010
806 * @tc.desc: mnt container function test case
807 * @tc.type: FUNC
808 * @tc.require: issueI6HDQK
809 * @tc.author:
810 */
811 HWTEST_F(ContainerTest, ItMntContainer010, TestSize.Level0)
812 {
813 ItMntContainer010();
814 }
815
816 /**
817 * @tc.name: chroot_Test_001
818 * @tc.desc: chroot function test case
819 * @tc.type: FUNC
820 * @tc.require: issueI6APW2
821 * @tc.author:
822 */
823 HWTEST_F(ContainerTest, ItContainerChroot001, TestSize.Level0)
824 {
825 ItContainerChroot001();
826 }
827
828 /**
829 * @tc.name: chroot_Test_002
830 * @tc.desc: chroot function test case
831 * @tc.type: FUNC
832 * @tc.require: issueI6APW2
833 * @tc.author:
834 */
835 HWTEST_F(ContainerTest, ItContainerChroot002, TestSize.Level0)
836 {
837 ItContainerChroot002();
838 }
839 #endif /* LOSCFG_USER_TEST_MNT_CONTAINER */
840
841 #if defined(LOSCFG_USER_TEST_IPC_CONTAINER)
842 /**
843 * @tc.name: Container_IPC_Test_001
844 * @tc.desc: ipc container function test case
845 * @tc.type: FUNC
846 * @tc.require: issueI6AVMY
847 * @tc.author:
848 */
849 HWTEST_F(ContainerTest, ItIpcContainer001, TestSize.Level0)
850 {
851 ItIpcContainer001();
852 }
853
854 /**
855 * @tc.name: Container_IPC_Test_002
856 * @tc.desc: ipc container function test case
857 * @tc.type: FUNC
858 * @tc.require: issueI6D9Y0
859 * @tc.author:
860 */
861 HWTEST_F(ContainerTest, ItIpcContainer002, TestSize.Level0)
862 {
863 ItIpcContainer002();
864 }
865
866 /**
867 * @tc.name: Container_IPC_Test_003
868 * @tc.desc: ipc container function test case
869 * @tc.type: FUNC
870 * @tc.require: issueI6BE5A
871 * @tc.author:
872 */
873 HWTEST_F(ContainerTest, ItIpcContainer003, TestSize.Level0)
874 {
875 ItIpcContainer003();
876 }
877
878 /**
879 * @tc.name: Container_IPC_Test_004
880 * @tc.desc: ipc container function test case
881 * @tc.type: FUNC
882 * @tc.require: issueI6AVMY
883 * @tc.author:
884 */
885 HWTEST_F(ContainerTest, ItIpcContainer004, TestSize.Level0)
886 {
887 ItIpcContainer004();
888 }
889
890 /**
891 * @tc.name: Container_IPC_Test_005
892 * @tc.desc: ipc container function test case
893 * @tc.type: FUNC
894 * @tc.require: issueI6BE5A
895 * @tc.author:
896 */
897 HWTEST_F(ContainerTest, ItIpcContainer005, TestSize.Level0)
898 {
899 ItIpcContainer005();
900 }
901
902 /**
903 * @tc.name: Container_IPC_Test_006
904 * @tc.desc: ipc container function test case
905 * @tc.type: FUNC
906 * @tc.require: issueI6D9Y0
907 * @tc.author:
908 */
909 HWTEST_F(ContainerTest, ItIpcContainer006, TestSize.Level0)
910 {
911 ItIpcContainer006();
912 }
913
914 /**
915 * @tc.name: Container_IPC_Test_007
916 * @tc.desc: ipc container function test case
917 * @tc.type: FUNC
918 * @tc.require: issueI6HDQK
919 * @tc.author:
920 */
921 HWTEST_F(ContainerTest, ItIpcContainer007, TestSize.Level0)
922 {
923 ItIpcContainer007();
924 }
925
926 /**
927 * @tc.name: Container_IPC_Test_008
928 * @tc.desc: ipc container function test case
929 * @tc.type: FUNC
930 * @tc.require: issueI6HDQK
931 * @tc.author:
932 */
933 HWTEST_F(ContainerTest, ItIpcContainer008, TestSize.Level0)
934 {
935 ItIpcContainer008();
936 }
937 #endif
938
939 #if defined(LOSCFG_USER_TEST_TIME_CONTAINER)
940 /**
941 * @tc.name: Container_TIME_Test_001
942 * @tc.desc: time container function test case
943 * @tc.type: FUNC
944 * @tc.require: issueI6B0A3
945 * @tc.author:
946 */
947 HWTEST_F(ContainerTest, ItTimeContainer001, TestSize.Level0)
948 {
949 ItTimeContainer001();
950 }
951
952 /**
953 * @tc.name: Container_TIME_Test_002
954 * @tc.desc: time container function test case
955 * @tc.type: FUNC
956 * @tc.require: issueI6BE5A
957 * @tc.author:
958 */
959 HWTEST_F(ContainerTest, ItTimeContainer002, TestSize.Level0)
960 {
961 ItTimeContainer002();
962 }
963
964 /**
965 * @tc.name: Container_TIME_Test_003
966 * @tc.desc: time container function test case
967 * @tc.type: FUNC
968 * @tc.require: issueI6D9Y0
969 * @tc.author:
970 */
971 HWTEST_F(ContainerTest, ItTimeContainer003, TestSize.Level0)
972 {
973 ItTimeContainer003();
974 }
975
976 /**
977 * @tc.name: Container_TIME_Test_004
978 * @tc.desc: time container function test case
979 * @tc.type: FUNC
980 * @tc.require: issueI6BE5A
981 * @tc.author:
982 */
983 HWTEST_F(ContainerTest, ItTimeContainer004, TestSize.Level0)
984 {
985 ItTimeContainer004();
986 }
987
988 /**
989 * @tc.name: Container_TIME_Test_005
990 * @tc.desc: time container function test case
991 * @tc.type: FUNC
992 * @tc.require: issueI6BE5A
993 * @tc.author:
994 */
995 HWTEST_F(ContainerTest, ItTimeContainer005, TestSize.Level0)
996 {
997 ItTimeContainer005();
998 }
999
1000 /**
1001 * @tc.name: Container_TIME_Test_006
1002 * @tc.desc: time container function test case
1003 * @tc.type: FUNC
1004 * @tc.require: issueI6HDQK
1005 * @tc.author:
1006 */
1007 HWTEST_F(ContainerTest, ItTimeContainer006, TestSize.Level0)
1008 {
1009 ItTimeContainer006();
1010 }
1011
1012 /*
1013 * @tc.name: Container_TIME_Test_007
1014 * @tc.desc: time container function test case
1015 * @tc.type: FUNC
1016 * @tc.require: issueI6B0A3
1017 * @tc.author:
1018 */
1019 HWTEST_F(ContainerTest, ItTimeContainer007, TestSize.Level0)
1020 {
1021 ItTimeContainer007();
1022 }
1023
1024 /**
1025 * @tc.name: Container_TIME_Test_008
1026 * @tc.desc: time container function test case
1027 * @tc.type: FUNC
1028 * @tc.require: issueI6BE5A
1029 * @tc.author:
1030 */
1031 HWTEST_F(ContainerTest, ItTimeContainer008, TestSize.Level0)
1032 {
1033 ItTimeContainer008();
1034 }
1035
1036 /**
1037 * @tc.name: Container_TIME_Test_009
1038 * @tc.desc: time container function test case
1039 * @tc.type: FUNC
1040 * @tc.require: issueI6B0A3
1041 * @tc.author:
1042 */
1043 HWTEST_F(ContainerTest, ItTimeContainer009, TestSize.Level0)
1044 {
1045 ItTimeContainer009();
1046 }
1047
1048 /**
1049 * @tc.name: Container_TIME_Test_010
1050 * @tc.desc: time container function test case
1051 * @tc.type: FUNC
1052 * @tc.require: issueI6B0A3
1053 * @tc.author:
1054 */
1055 HWTEST_F(ContainerTest, ItTimeContainer010, TestSize.Level0)
1056 {
1057 ItTimeContainer010();
1058 }
1059 #endif
1060 #endif /* LOSCFG_USER_TEST_SMOKE */
1061
1062 #if defined(LOSCFG_USER_TEST_FULL)
1063 #if defined(LOSCFG_USER_TEST_PID_CONTAINER)
1064 /**
1065 * @tc.name: Container_Pid_Test_001
1066 * @tc.desc: pid container function test case
1067 * @tc.type: FUNC
1068 * @tc.require: issueI68LVW
1069 * @tc.author:
1070 */
1071 HWTEST_F(ContainerTest, ItPidContainer001, TestSize.Level0)
1072 {
1073 ItPidContainer001();
1074 }
1075
1076 /**
1077 * @tc.name: Container_Pid_Test_002
1078 * @tc.desc: pid container function test case
1079 * @tc.type: FUNC
1080 * @tc.require: issueI68LVW
1081 * @tc.author:
1082 */
1083 HWTEST_F(ContainerTest, ItPidContainer002, TestSize.Level0)
1084 {
1085 ItPidContainer002();
1086 }
1087
1088 /**
1089 * @tc.name: Container_Pid_Test_003
1090 * @tc.desc: pid container function test case
1091 * @tc.type: FUNC
1092 * @tc.require: issueI68LVW
1093 * @tc.author:
1094 */
1095 HWTEST_F(ContainerTest, ItPidContainer003, TestSize.Level0)
1096 {
1097 ItPidContainer003();
1098 }
1099
1100 /**
1101 * @tc.name: Container_Pid_Test_004
1102 * @tc.desc: pid container function test case
1103 * @tc.type: FUNC
1104 * @tc.require: issueI68LVW
1105 * @tc.author:
1106 */
1107 HWTEST_F(ContainerTest, ItPidContainer004, TestSize.Level0)
1108 {
1109 ItPidContainer004();
1110 }
1111
1112 #if defined(LOSCFG_USER_TEST_UTS_CONTAINER)
1113 /**
1114 * @tc.name: Container_Pid_Test_005
1115 * @tc.desc: pid container function test case
1116 * @tc.type: FUNC
1117 * @tc.require: issueI68LVW
1118 * @tc.author:
1119 */
1120 HWTEST_F(ContainerTest, ItPidContainer005, TestSize.Level0)
1121 {
1122 ItPidContainer005();
1123 }
1124 #endif
1125
1126 /**
1127 * @tc.name: Container_Pid_Test_006
1128 * @tc.desc: pid container function test case
1129 * @tc.type: FUNC
1130 * @tc.require: issueI68LVW
1131 * @tc.author:
1132 */
1133 HWTEST_F(ContainerTest, ItPidContainer006, TestSize.Level0)
1134 {
1135 ItPidContainer006();
1136 }
1137
1138 /**
1139 * @tc.name: Container_Pid_Test_007
1140 * @tc.desc: pid container function test case
1141 * @tc.type: FUNC
1142 * @tc.require: issueI68LVW
1143 * @tc.author:
1144 */
1145 HWTEST_F(ContainerTest, ItPidContainer007, TestSize.Level0)
1146 {
1147 ItPidContainer007();
1148 }
1149
1150 /**
1151 * @tc.name: Container_Pid_Test_008
1152 * @tc.desc: pid container function test case
1153 * @tc.type: FUNC
1154 * @tc.require: issueI68LVW
1155 * @tc.author:
1156 */
1157 HWTEST_F(ContainerTest, ItPidContainer008, TestSize.Level0)
1158 {
1159 ItPidContainer008();
1160 }
1161
1162 /**
1163 * @tc.name: Container_Pid_Test_009
1164 * @tc.desc: pid container function test case
1165 * @tc.type: FUNC
1166 * @tc.require: issueI68LVW
1167 * @tc.author:
1168 */
1169 HWTEST_F(ContainerTest, ItPidContainer009, TestSize.Level0)
1170 {
1171 ItPidContainer009();
1172 }
1173
1174 /**
1175 * @tc.name: Container_Pid_Test_010
1176 * @tc.desc: pid container function test case
1177 * @tc.type: FUNC
1178 * @tc.require: issueI68LVW
1179 * @tc.author:
1180 */
1181 HWTEST_F(ContainerTest, ItPidContainer010, TestSize.Level0)
1182 {
1183 ItPidContainer010();
1184 }
1185
1186 /**
1187 * @tc.name: Container_Pid_Test_011
1188 * @tc.desc: pid container function test case
1189 * @tc.type: FUNC
1190 * @tc.require: issueI68LVW
1191 * @tc.author:
1192 */
1193 HWTEST_F(ContainerTest, ItPidContainer011, TestSize.Level0)
1194 {
1195 ItPidContainer011();
1196 }
1197
1198 /**
1199 * @tc.name: Container_Pid_Test_012
1200 * @tc.desc: pid container function test case
1201 * @tc.type: FUNC
1202 * @tc.require: issueI68LVW
1203 * @tc.author:
1204 */
1205 HWTEST_F(ContainerTest, ItPidContainer012, TestSize.Level0)
1206 {
1207 ItPidContainer012();
1208 }
1209
1210 /**
1211 * @tc.name: Container_Pid_Test_013
1212 * @tc.desc: pid container function test case
1213 * @tc.type: FUNC
1214 * @tc.require: issueI68LVW
1215 * @tc.author:
1216 */
1217 HWTEST_F(ContainerTest, ItPidContainer013, TestSize.Level0)
1218 {
1219 ItPidContainer013();
1220 }
1221
1222 /**
1223 * @tc.name: Container_Pid_Test_014
1224 * @tc.desc: pid container function test case
1225 * @tc.type: FUNC
1226 * @tc.require: issueI68LVW
1227 * @tc.author:
1228 */
1229 HWTEST_F(ContainerTest, ItPidContainer014, TestSize.Level0)
1230 {
1231 ItPidContainer014();
1232 }
1233
1234 /**
1235 * @tc.name: Container_Pid_Test_015
1236 * @tc.desc: pid container function test case
1237 * @tc.type: FUNC
1238 * @tc.require: issueI68LVW
1239 * @tc.author:
1240 */
1241 HWTEST_F(ContainerTest, ItPidContainer015, TestSize.Level0)
1242 {
1243 ItPidContainer015();
1244 }
1245
1246 /**
1247 * @tc.name: Container_Pid_Test_016
1248 * @tc.desc: pid container function test case
1249 * @tc.type: FUNC
1250 * @tc.require: issueI68LVW
1251 * @tc.author:
1252 */
1253 HWTEST_F(ContainerTest, ItPidContainer016, TestSize.Level0)
1254 {
1255 ItPidContainer016();
1256 }
1257
1258 /**
1259 * @tc.name: Container_Pid_Test_017
1260 * @tc.desc: pid container function test case
1261 * @tc.type: FUNC
1262 * @tc.require: issueI68LVW
1263 * @tc.author:
1264 */
1265 HWTEST_F(ContainerTest, ItPidContainer017, TestSize.Level0)
1266 {
1267 ItPidContainer017();
1268 }
1269
1270 /**
1271 * @tc.name: Container_Pid_Test_018
1272 * @tc.desc: pid container function test case
1273 * @tc.type: FUNC
1274 * @tc.require: issueI68LVW
1275 * @tc.author:
1276 */
1277 HWTEST_F(ContainerTest, ItPidContainer018, TestSize.Level0)
1278 {
1279 ItPidContainer018();
1280 }
1281
1282 /**
1283 * @tc.name: Container_Pid_Test_019
1284 * @tc.desc: pid container function test case
1285 * @tc.type: FUNC
1286 * @tc.require: issueI68LVW
1287 * @tc.author:
1288 */
1289 HWTEST_F(ContainerTest, ItPidContainer019, TestSize.Level0)
1290 {
1291 ItPidContainer019();
1292 }
1293
1294 /**
1295 * @tc.name: Container_Pid_Test_020
1296 * @tc.desc: pid container function test case
1297 * @tc.type: FUNC
1298 * @tc.require: issueI68LVW
1299 * @tc.author:
1300 */
1301 HWTEST_F(ContainerTest, ItPidContainer020, TestSize.Level0)
1302 {
1303 ItPidContainer020();
1304 }
1305
1306 /**
1307 * @tc.name: Container_Pid_Test_021
1308 * @tc.desc: pid container function test case
1309 * @tc.type: FUNC
1310 * @tc.require: issueI68LVW
1311 * @tc.author:
1312 */
1313 HWTEST_F(ContainerTest, ItPidContainer021, TestSize.Level0)
1314 {
1315 ItPidContainer021();
1316 }
1317
1318 /**
1319 * @tc.name: Container_Pid_Test_022
1320 * @tc.desc: pid container function test case
1321 * @tc.type: FUNC
1322 * @tc.require: issueI68LVW
1323 * @tc.author:
1324 */
1325 HWTEST_F(ContainerTest, ItPidContainer022, TestSize.Level0)
1326 {
1327 ItPidContainer022();
1328 }
1329
1330 /**
1331 * @tc.name: Container_Pid_Test_024
1332 * @tc.desc: pid container function test case
1333 * @tc.type: FUNC
1334 * @tc.require: issueI68LVW
1335 * @tc.author:
1336 */
1337 HWTEST_F(ContainerTest, ItPidContainer024, TestSize.Level0)
1338 {
1339 ItPidContainer024();
1340 }
1341 #endif
1342 #if defined(LOSCFG_USER_TEST_UTS_CONTAINER)
1343 /**
1344 * @tc.name: Container_UTS_Test_003
1345 * @tc.desc: uts container function test case
1346 * @tc.type: FUNC
1347 * @tc.require: issueI6A7C8
1348 * @tc.author:
1349 */
1350 HWTEST_F(ContainerTest, ItUtsContainer003, TestSize.Level0)
1351 {
1352 ItUtsContainer003();
1353 }
1354 #endif
1355 #if defined(LOSCFG_USER_TEST_USER_CONTAINER)
1356 /**
1357 * @tc.name: Container_UTS_Test_005
1358 * @tc.desc: uts container function test case
1359 * @tc.type: FUNC
1360 * @tc.require: issueI6EC0A
1361 * @tc.author:
1362 */
1363 HWTEST_F(ContainerTest, ItUserContainer005, TestSize.Level0)
1364 {
1365 ItUserContainer005();
1366 }
1367 #endif
1368 #if defined(LOSCFG_USER_TEST_NET_CONTAINER)
1369 /**
1370 * @tc.name: Container_NET_Test_010
1371 * @tc.desc: uts container function test case
1372 * @tc.type: FUNC
1373 * @tc.require: issueI6HPH2
1374 * @tc.author:
1375 */
1376 HWTEST_F(ContainerTest, ItNetContainer010, TestSize.Level0)
1377 {
1378 ItNetContainer010();
1379 }
1380 #endif
1381 #endif
1382 } // namespace OHOS
1383
1384 namespace OHOS {
SetUp()1385 void ContainerTest::SetUp()
1386 {
1387 mode_t mode = 0;
1388 (void)mkdir(ACCESS_FILE_NAME, S_IFDIR | mode);
1389 }
TearDown()1390 void ContainerTest::TearDown()
1391 {
1392 (void)rmdir(ACCESS_FILE_NAME);
1393 }
1394 }
1395