• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  * conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  * of conditions and the following disclaimer in the documentation and/or other materials
13  * provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  * to endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 #include "stdio.h"
32 #include <climits>
33 #include <gtest/gtest.h>
34 
35 #include "lt_net_socket.h"
36 
37 using namespace testing::ext;
38 namespace OHOS {
39 class NetSocketTest : public testing::Test {
40 public:
SetUpTestCase(void)41     static void SetUpTestCase(void)
42     {
43         struct sched_param param = { 0 };
44         int currThreadPolicy, ret;
45         ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, &param);
46         ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
47         param.sched_priority = TASK_PRIO_TEST;
48         ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
49         ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
50     }
TearDownTestCase(void)51     static void TearDownTestCase(void) {}
52 };
53 
54 #if defined(LOSCFG_USER_TEST_SMOKE) && defined(LOSCFG_USER_TEST_NET_SOCKET)
55 /* *
56  * @tc.name: NetSocketTest001
57  * @tc.desc: function for NetSocketTest
58  * @tc.type: FUNC
59  */
60 HWTEST_F(NetSocketTest, NetSocketTest001, TestSize.Level0)
61 {
62     NetSocketTest001();
63 }
64 
65 /* *
66  * @tc.name: NetSocketTest002
67  * @tc.desc: function for NetSocketTest
68  * @tc.type: FUNC
69  */
70 HWTEST_F(NetSocketTest, NetSocketTest002, TestSize.Level0)
71 {
72     NetSocketTest002();
73 }
74 
75 #if TEST_ON_LINUX
76 /* *
77  * @tc.name: NetSocketTest003
78  * @tc.desc: function for NetSocketTest
79  * @tc.type: FUNC
80  */
81 HWTEST_F(NetSocketTest, NetSocketTest003, TestSize.Level0)
82 {
83     NetSocketTest003(); // getifaddrs need PF_NETLINK which was not supported by lwip currently
84 }
85 #endif
86 
87 /* *
88  * @tc.name: NetSocketTest004
89  * @tc.desc: function for NetSocketTest
90  * @tc.type: FUNC
91  */
92 HWTEST_F(NetSocketTest, NetSocketTest004, TestSize.Level0)
93 {
94     NetSocketTest004();
95 }
96 
97 /* *
98  * @tc.name: NetSocketTest005
99  * @tc.desc: function for NetSocketTest
100  * @tc.type: FUNC
101  */
102 HWTEST_F(NetSocketTest, NetSocketTest005, TestSize.Level0)
103 {
104     NetSocketTest005();
105 }
106 
107 /* *
108  * @tc.name: NetSocketTest006
109  * @tc.desc: function for NetSocketTest
110  * @tc.type: FUNC
111  */
112 HWTEST_F(NetSocketTest, NetSocketTest006, TestSize.Level0)
113 {
114     NetSocketTest006();
115 }
116 
117 #if TEST_ON_LINUX
118 /* *
119  * @tc.name: NetSocketTest007
120  * @tc.desc: function for NetSocketTest
121  * @tc.type: FUNC
122  */
123 HWTEST_F(NetSocketTest, NetSocketTest007, TestSize.Level0)
124 {
125     NetSocketTest007();
126 }
127 #endif
128 
129 /* *
130  * @tc.name: NetSocketTest008
131  * @tc.desc: function for NetSocketTest
132  * @tc.type: FUNC
133  */
134 HWTEST_F(NetSocketTest, NetSocketTest008, TestSize.Level0)
135 {
136     NetSocketTest008();
137 }
138 
139 /* *
140  * @tc.name: NetSocketTest009
141  * @tc.desc: function for NetSocketTest
142  * @tc.type: FUNC
143  */
144 HWTEST_F(NetSocketTest, NetSocketTest009, TestSize.Level0)
145 {
146     NetSocketTest009();
147 }
148 
149 /* *
150  * @tc.name: NetSocketTest010
151  * @tc.desc: function for NetSocketTest
152  * @tc.type: FUNC
153  */
154 HWTEST_F(NetSocketTest, NetSocketTest010, TestSize.Level0)
155 {
156     NetSocketTest010();
157 }
158 
159 /* *
160  * @tc.name: NetSocketTest011
161  * @tc.desc: function for NetSocketTest
162  * @tc.type: FUNC
163  */
164 HWTEST_F(NetSocketTest, NetSocketTest011, TestSize.Level0)
165 {
166     NetSocketTest011();
167 }
168 
169 /* *
170  * @tc.name: NetSocketTest012
171  * @tc.desc: function for NetSocketTest
172  * @tc.type: FUNC
173  */
174 HWTEST_F(NetSocketTest, NetSocketTest012, TestSize.Level0)
175 {
176     NetSocketTest012();
177 }
178 
179 #endif
180 }
181