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, ¶m); 46 ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret); 47 param.sched_priority = TASK_PRIO_TEST; 48 ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); 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 * @tc.require: AR000EEMQ9 60 */ 61 HWTEST_F(NetSocketTest, NetSocketTest001, TestSize.Level0) 62 { 63 NetSocketTest001(); 64 } 65 66 /* * 67 * @tc.name: NetSocketTest002 68 * @tc.desc: function for NetSocketTest 69 * @tc.type: FUNC 70 * @tc.require: AR000EEMQ9 71 */ 72 HWTEST_F(NetSocketTest, NetSocketTest002, TestSize.Level0) 73 { 74 NetSocketTest002(); 75 } 76 77 #if TEST_ON_LINUX 78 /* * 79 * @tc.name: NetSocketTest003 80 * @tc.desc: function for NetSocketTest 81 * @tc.type: FUNC 82 * @tc.require: AR000EEMQ9 83 */ 84 HWTEST_F(NetSocketTest, NetSocketTest003, TestSize.Level0) 85 { 86 NetSocketTest003(); // getifaddrs need PF_NETLINK which was not supported by lwip currently 87 } 88 #endif 89 90 /* * 91 * @tc.name: NetSocketTest004 92 * @tc.desc: function for NetSocketTest 93 * @tc.type: FUNC 94 * @tc.require: AR000EEMQ9 95 */ 96 HWTEST_F(NetSocketTest, NetSocketTest004, TestSize.Level0) 97 { 98 NetSocketTest004(); 99 } 100 101 /* * 102 * @tc.name: NetSocketTest005 103 * @tc.desc: function for NetSocketTest 104 * @tc.type: FUNC 105 * @tc.require: AR000EEMQ9 106 */ 107 HWTEST_F(NetSocketTest, NetSocketTest005, TestSize.Level0) 108 { 109 NetSocketTest005(); 110 } 111 112 /* * 113 * @tc.name: NetSocketTest006 114 * @tc.desc: function for NetSocketTest 115 * @tc.type: FUNC 116 * @tc.require: AR000EEMQ9 117 */ 118 HWTEST_F(NetSocketTest, NetSocketTest006, TestSize.Level0) 119 { 120 NetSocketTest006(); 121 } 122 123 #if TEST_ON_LINUX 124 /* * 125 * @tc.name: NetSocketTest007 126 * @tc.desc: function for NetSocketTest 127 * @tc.type: FUNC 128 * @tc.require: AR000EEMQ9 129 */ 130 HWTEST_F(NetSocketTest, NetSocketTest007, TestSize.Level0) 131 { 132 NetSocketTest007(); 133 } 134 #endif 135 136 /* * 137 * @tc.name: NetSocketTest008 138 * @tc.desc: function for NetSocketTest 139 * @tc.type: FUNC 140 * @tc.require: AR000EEMQ9 141 */ 142 HWTEST_F(NetSocketTest, NetSocketTest008, TestSize.Level0) 143 { 144 NetSocketTest008(); 145 } 146 147 /* * 148 * @tc.name: NetSocketTest009 149 * @tc.desc: function for NetSocketTest 150 * @tc.type: FUNC 151 * @tc.require: AR000EEMQ9 152 */ 153 HWTEST_F(NetSocketTest, NetSocketTest009, TestSize.Level0) 154 { 155 NetSocketTest009(); 156 } 157 158 /* * 159 * @tc.name: NetSocketTest010 160 * @tc.desc: function for NetSocketTest 161 * @tc.type: FUNC 162 * @tc.require: AR000EEMQ9 163 */ 164 HWTEST_F(NetSocketTest, NetSocketTest010, TestSize.Level0) 165 { 166 NetSocketTest010(); 167 } 168 169 /* * 170 * @tc.name: NetSocketTest011 171 * @tc.desc: function for NetSocketTest 172 * @tc.type: FUNC 173 * @tc.require: AR000EEMQ9 174 */ 175 HWTEST_F(NetSocketTest, NetSocketTest011, TestSize.Level0) 176 { 177 NetSocketTest011(); 178 } 179 180 /* * 181 * @tc.name: NetSocketTest012 182 * @tc.desc: function for NetSocketTest 183 * @tc.type: FUNC 184 * @tc.require: AR000EEMQ9 185 */ 186 HWTEST_F(NetSocketTest, NetSocketTest012, TestSize.Level0) 187 { 188 NetSocketTest012(); 189 } 190 191 /* * 192 * @tc.name: NetSocketTest013 193 * @tc.desc: function for NetSocketTest 194 * @tc.type: FUNC 195 * @tc.require: AR000EEMQ9 196 */ 197 /* 198 HWTEST_F(NetSocketTest, NetSocketTest013, TestSize.Level0) 199 { 200 //NetSocketTest013(); // broadcast to self to be supported. 201 } 202 */ 203 #endif 204 } 205