innerkits_unittest.cpp 15.5 KB
Newer Older
X
add ut  
xionglei6 已提交
1
/*
C
cheng_jinsong 已提交
2
 * Copyright (c) 2022 Huawei Device Co., Ltd.
X
add ut  
xionglei6 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <cinttypes>
#include <sys/mount.h>
#include "fs_manager/fs_manager.h"
X
xionglei6 已提交
19
#include "init_log.h"
C
cheng_jinsong 已提交
20
#include "init_param.h"
M
Mupceet 已提交
21
#include "param_stub.h"
X
add ut  
xionglei6 已提交
22
#include "securec.h"
C
cheng_jinsong 已提交
23 24
#include "systemcapability.h"
#include "service_control.h"
C
cheng_jinsong 已提交
25 26 27 28
#include "control_fd.h"
#include "loop_event.h"
#include "fd_holder.h"
#include "fd_holder_internal.h"
X
add ut  
xionglei6 已提交
29 30 31 32 33

using namespace testing::ext;
using namespace std;

namespace init_ut {
C
cheng_jinsong 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

extern "C" {
void CmdDisConnectComplete(const TaskHandle client);
void CmdOnSendMessageComplete(const TaskHandle task, const BufferHandle handle);
void CmdOnClose(const TaskHandle task);
void CmdOnConnectComplete(const TaskHandle client);
void CmdOnRecvMessage(const TaskHandle task, const uint8_t *buffer, uint32_t buffLen);
int InitPtyInterface(CmdAgent *agent, uint16_t type, const char *cmd);
void ProcessPtyRead(const WatcherHandle taskHandle, int fd, uint32_t *events, const void *context);
void ProcessPtyWrite(const WatcherHandle taskHandle, int fd, uint32_t *events, const void *context);
int CmdOnIncommingConnect(const LoopHandle loop, const TaskHandle server);
CmdAgent *CmdAgentCreate(const char *server);
void CmdClientOnRecvMessage(const TaskHandle task, const uint8_t *buffer, uint32_t buffLen);
int SendCmdMessage(const CmdAgent *agent, uint16_t type, const char *cmd, const char *ptyName);
int SendMessage(LoopHandle loop, TaskHandle task, const char *message);
int *GetFdsFromMsg(size_t *outFdCount, pid_t *requestPid, struct msghdr msghdr);
int BuildSendData(char *buffer, size_t size, const char *serviceName, bool hold, bool poll);
}

X
add ut  
xionglei6 已提交
53 54 55 56 57 58 59 60
class InnerkitsUnitTest : public testing::Test {
public:
    static void SetUpTestCase(void) {};
    static void TearDownTestCase(void) {};
    void SetUp() {};
    void TearDown() {};
};

C
chengjinsong 已提交
61 62 63 64 65 66 67
/**
* @tc.name: ReadFstabFromFile_unitest
* @tc.desc: read fstab from test file.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
X
add ut  
xionglei6 已提交
68 69 70 71 72 73
HWTEST_F(InnerkitsUnitTest, ReadFstabFromFile_unitest, TestSize.Level1)
{
    Fstab *fstab = nullptr;
    const std::string fstabFile1 = "/data/fstab.updater1";
    fstab = ReadFstabFromFile(fstabFile1.c_str(), false);
    EXPECT_EQ(fstab, nullptr);
C
cheng_jinsong 已提交
74
    const std::string fstabFile2 = STARTUP_INIT_UT_PATH"/mount_unitest/ReadFstabFromFile1.fstable";
X
add ut  
xionglei6 已提交
75 76
    fstab = ReadFstabFromFile(fstabFile2.c_str(), false);
    EXPECT_NE(fstab, nullptr);
L
laiguizhong 已提交
77
    ParseFstabPerLine(const_cast<char *>("test"), fstab, true, nullptr);
X
add ut  
xionglei6 已提交
78 79 80
    ReleaseFstab(fstab);
}

C
chengjinsong 已提交
81 82 83 84 85 86 87
/**
* @tc.name: FindFstabItemForPath_unitest
* @tc.desc: read fstab from test file, then find item according to path.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
X
add ut  
xionglei6 已提交
88 89
HWTEST_F(InnerkitsUnitTest, FindFstabItemForPath_unitest, TestSize.Level1)
{
C
cheng_jinsong 已提交
90
    const std::string fstabFile1 = STARTUP_INIT_UT_PATH"/mount_unitest/ReadFstabFromFile1.fstable";
X
add ut  
xionglei6 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    Fstab *fstab = nullptr;
    fstab = ReadFstabFromFile(fstabFile1.c_str(), false);
    ASSERT_NE(fstab, nullptr);
    FstabItem* item = nullptr;
    const std::string path1 = "";
    item = FindFstabItemForPath(*fstab, path1.c_str());
    if (item == nullptr) {
        SUCCEED();
    }
    const std::string path2 = "/data";
    item = FindFstabItemForPath(*fstab, path2.c_str());
    if (item != nullptr) {
        SUCCEED();
    }
    const std::string path3 = "/data2";
    item = FindFstabItemForPath(*fstab, path3.c_str());
    if (item == nullptr) {
        SUCCEED();
    }
    const std::string path4 = "/data2/test";
    item = FindFstabItemForPath(*fstab, path4.c_str());
    if (item != nullptr) {
        SUCCEED();
    }
    ReleaseFstab(fstab);
    fstab = nullptr;
}

C
chengjinsong 已提交
119 120 121 122 123 124 125
/**
* @tc.name: FindFstabItemForMountPoint_unitest
* @tc.desc: read fstab from test file, then find item that matches with the mount point.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
X
add ut  
xionglei6 已提交
126 127
HWTEST_F(InnerkitsUnitTest, FindFstabItemForMountPoint_unitest, TestSize.Level1)
{
C
cheng_jinsong 已提交
128
    const std::string fstabFile1 = STARTUP_INIT_UT_PATH"/mount_unitest/ReadFstabFromFile1.fstable";
X
add ut  
xionglei6 已提交
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
    Fstab *fstab = nullptr;
    fstab = ReadFstabFromFile(fstabFile1.c_str(), false);
    ASSERT_NE(fstab, nullptr);
    FstabItem* item = nullptr;
    const std::string mp1 = "/data";
    const std::string mp2 = "/data2";
    item = FindFstabItemForMountPoint(*fstab, mp2.c_str());
    if (item == nullptr) {
        SUCCEED();
    }
    const std::string mp3 = "/data";
    item = FindFstabItemForMountPoint(*fstab, mp3.c_str());
    if (item != nullptr) {
        SUCCEED();
    }
    ReleaseFstab(fstab);
    fstab = nullptr;
}

C
chengjinsong 已提交
148 149 150 151 152 153 154
/**
* @tc.name: GetMountFlags_unitest
* @tc.desc: read fstab from test file, then find the item and get mount flags.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
X
add ut  
xionglei6 已提交
155 156
HWTEST_F(InnerkitsUnitTest, GetMountFlags_unitest, TestSize.Level1)
{
C
cheng_jinsong 已提交
157
    const std::string fstabFile1 = STARTUP_INIT_UT_PATH"/mount_unitest/ReadFstabFromFile1.fstable";
X
add ut  
xionglei6 已提交
158
    Fstab *fstab = nullptr;
L
laiguizhong 已提交
159
    fstab = ReadFstabFromFile(fstabFile1.c_str(), true);
X
add ut  
xionglei6 已提交
160 161 162 163 164 165 166 167 168
    ASSERT_NE(fstab, nullptr);
    struct FstabItem* item = nullptr;
    const std::string mp = "/hos";
    item = FindFstabItemForMountPoint(*fstab, mp.c_str());
    if (item == nullptr) {
        SUCCEED();
    }
    const int bufferSize = 512;
    char fsSpecificOptions[bufferSize] = {0};
169
    unsigned long flags = GetMountFlags(item->mountOptions, fsSpecificOptions, bufferSize, item->mountPoint);
X
add ut  
xionglei6 已提交
170 171 172 173
    EXPECT_EQ(flags, static_cast<unsigned long>(MS_NOSUID | MS_NODEV | MS_NOATIME));
    ReleaseFstab(fstab);
    fstab = nullptr;
}
C
slot  
chengjinsong 已提交
174

C
chengjinsong 已提交
175 176 177 178 179 180 181
/**
* @tc.name: GetSlotInfo_unittest
* @tc.desc: get the number of slots and get current slot.
* @tc.type: FUNC
* @tc.require:issueI5NTX2
* @tc.author:
*/
C
slot  
chengjinsong 已提交
182 183 184 185 186 187
HWTEST_F(InnerkitsUnitTest, GetSlotInfo_unittest, TestSize.Level1)
{
    EXPECT_NE(GetBootSlots(), -1);
    EXPECT_NE(GetCurrentSlot(), -1);
}

C
chengjinsong 已提交
188 189 190 191 192 193 194
/**
* @tc.name: LoadFstabFromCommandLine_unittest
* @tc.desc: get fstab from command line.
* @tc.type: FUNC
* @tc.require:issueI5NTX2
* @tc.author:
*/
C
slot  
chengjinsong 已提交
195 196 197 198 199
HWTEST_F(InnerkitsUnitTest, LoadFstabFromCommandLine_unittest, TestSize.Level1)
{
    EXPECT_NE(LoadFstabFromCommandLine(), (Fstab *)NULL);
}

C
chengjinsong 已提交
200 201 202 203 204 205 206
/**
* @tc.name: GetBlockDevicePath_unittest
* @tc.desc: get block device path according to valid or invalid partition.
* @tc.type: FUNC
* @tc.require:issueI5NTX2
* @tc.author:
*/
C
slot  
chengjinsong 已提交
207 208 209 210 211 212
HWTEST_F(InnerkitsUnitTest, GetBlockDevicePath_unittest, TestSize.Level1)
{
    char devicePath[MAX_BUFFER_LEN] = {0};
    EXPECT_EQ(GetBlockDevicePath("/vendor", devicePath, MAX_BUFFER_LEN), 0);
    EXPECT_EQ(GetBlockDevicePath("/misc", devicePath, MAX_BUFFER_LEN), 0);
    EXPECT_EQ(GetBlockDevicePath("/invalid", devicePath, MAX_BUFFER_LEN), -1);
C
cheng_jinsong 已提交
213 214
    unlink(BOOT_CMD_LINE);
    EXPECT_EQ(GetBlockDevicePath("/invalid", devicePath, MAX_BUFFER_LEN), -1);
C
cheng_jinsong 已提交
215
    GetCurrentSlot();
C
cheng_jinsong 已提交
216 217
    // restore cmdline
    PrepareCmdLineData();
C
slot  
chengjinsong 已提交
218
}
C
chengjinsong 已提交
219

C
chengjinsong 已提交
220 221 222 223 224 225 226
/**
* @tc.name: DoFormat_unittest
* @tc.desc: format file system, includes ext4 and f2fs type.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
C
chengjinsong 已提交
227 228
HWTEST_F(InnerkitsUnitTest, DoFormat_unittest, TestSize.Level1)
{
C
cheng_jinsong 已提交
229 230
    EXPECT_NE(DoFormat("/testpath", "ext4"), -1);
    EXPECT_NE(DoFormat("/testpath", "f2fs"), -1);
C
cheng_jinsong 已提交
231 232
    EXPECT_EQ(DoFormat("/testpath", "notFs"), -1);
    EXPECT_EQ(DoFormat(nullptr, nullptr), -1);
C
chengjinsong 已提交
233 234
}

C
chengjinsong 已提交
235 236 237 238 239 240 241
/**
* @tc.name: MountAllWithFstabFile_unittest
* @tc.desc: mount partitions according to fstab that read from file.
* @tc.type: FUNC
* @tc.require:issueI5NTX2
* @tc.author:
*/
C
chengjinsong 已提交
242 243
HWTEST_F(InnerkitsUnitTest, MountAllWithFstabFile_unittest, TestSize.Level1)
{
C
cheng_jinsong 已提交
244 245 246 247 248 249 250 251 252 253 254 255 256
    EXPECT_NE(MountAllWithFstabFile(STARTUP_INIT_UT_PATH"/etc/fstab.required", 0), 1);
    EXPECT_NE(UmountAllWithFstabFile(STARTUP_INIT_UT_PATH"/etc/fstab.required"), 1);
    EXPECT_EQ(MountAllWithFstabFile("/testErrorFile", 0), -1);
    EXPECT_EQ(MountAllWithFstabFile(nullptr, 0), -1);
    EXPECT_EQ(GetMountStatusForMountPoint(nullptr), -1);
    FstabItem fstabItem;
    fstabItem.fsType = strdup("notSupport");
    EXPECT_EQ(MountOneItem(nullptr), -1);
    EXPECT_EQ(MountOneItem(&fstabItem), 0);
    if (fstabItem.fsType != nullptr) {
        free(fstabItem.fsType);
        fstabItem.fsType = nullptr;
    }
C
chengjinsong 已提交
257
}
C
cheng_jinsong 已提交
258

C
cheng_jinsong 已提交
259 260
#define SYSCAP_MAX_SIZE 100

C
cheng_jinsong 已提交
261 262
// TestSysCap
HWTEST_F(InnerkitsUnitTest, TestSysCap, TestSize.Level1)
C
cheng_jinsong 已提交
263
{
C
cheng_jinsong 已提交
264 265 266 267 268 269 270 271
    bool ret = HasSystemCapability("test.cap");
    EXPECT_EQ(ret, false);
    ret = HasSystemCapability(nullptr);
    EXPECT_EQ(ret, false);
    ret = HasSystemCapability("ArkUI.ArkUI.Napi");
    EXPECT_EQ(ret, true);
    ret = HasSystemCapability("SystemCapability.ArkUI.ArkUI.Napi");
    EXPECT_EQ(ret, true);
C
cheng_jinsong 已提交
272
    char *wrongName = reinterpret_cast<char *>(malloc(SYSCAP_MAX_SIZE));
C
cheng_jinsong 已提交
273 274 275 276
    ASSERT_NE(wrongName, nullptr);
    EXPECT_EQ(memset_s(wrongName, SYSCAP_MAX_SIZE, 1, SYSCAP_MAX_SIZE), 0);
    HasSystemCapability(wrongName);
    free(wrongName);
C
cheng_jinsong 已提交
277
}
C
cheng_jinsong 已提交
278 279 280 281

// TestControlService
HWTEST_F(InnerkitsUnitTest, TestControlService, TestSize.Level1)
{
C
cheng_jinsong 已提交
282
    TestSetParamCheckResult("startup.service.ctl.", 0777, 0);
C
cheng_jinsong 已提交
283
    ServiceControl("deviceinfoservice", START);
C
cheng_jinsong 已提交
284
    SystemWriteParam("startup.service.ctl.deviceinfoservice", "2");
C
cheng_jinsong 已提交
285
    ServiceControl("deviceinfoservice", RESTART);
C
cheng_jinsong 已提交
286 287
    ServiceControl("deviceinfoservice", STOP);
    SystemWriteParam("startup.service.ctl.deviceinfoservice", "0");
C
cheng_jinsong 已提交
288 289 290 291 292 293 294
    ServiceControl("param_watcher", RESTART);
    EXPECT_EQ(ServiceControl(nullptr, RESTART), -1);
    const char *argv[] = {"testArg"};
    ServiceControlWithExtra("deviceinfoservice", RESTART, argv, 1);
    ServiceControlWithExtra(nullptr, RESTART, argv, 1);
    ServiceControlWithExtra(nullptr, 3, argv, 1); // 3 is action
    ServiceControlWithExtra("notservie", RESTART, argv, 1);
C
cheng_jinsong 已提交
295
    ServiceControlWithExtra("deviceinfoservice", 3, argv, 1); // 3 is action
C
cheng_jinsong 已提交
296 297 298 299 300 301 302 303 304 305 306
    ServiceSetReady("deviceinfoservice");
    ServiceSetReady(nullptr);
    ServiceWaitForStatus("deviceinfoservice", SERVICE_READY, 1);
    ServiceWaitForStatus("deviceinfoservice", SERVICE_READY, -1);
    ServiceWaitForStatus(nullptr, SERVICE_READY, 1);
    StartServiceByTimer("deviceinfoservice", 1);
    StartServiceByTimer("deviceinfoservice", 0);
    StartServiceByTimer(nullptr, 0);
    StopServiceTimer("deviceinfoservice");
}

C
cheng_jinsong 已提交
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
static int TestIncommingConnect(const LoopHandle loop, const TaskHandle server)
{
    UNUSED(loop);
    UNUSED(server);
    return 0;
}

// TestControlFd
HWTEST_F(InnerkitsUnitTest, TestControlFd, TestSize.Level1)
{
    CmdClientInit("/data/testSock1", ACTION_DUMP, "cmd");
    CmdClientInit("/data/testSock1", ACTION_DUMP, "cmd");
    CmdClientInit(INIT_CONTROL_FD_SOCKET_PATH, ACTION_DUMP, nullptr);
    CmdClientInit(nullptr, ACTION_DUMP, "cmd");
    CmdDisConnectComplete(nullptr);
    CmdOnSendMessageComplete(nullptr, nullptr);
    CmdOnConnectComplete(nullptr);
    CmdClientOnRecvMessage(nullptr, nullptr, 0);
    CmdAgentCreate(nullptr);
    CmdAgent *agent = CmdAgentCreate(INIT_CONTROL_FD_SOCKET_PATH);
    EXPECT_NE(agent, nullptr);
    SendCmdMessage(agent, ACTION_DUMP, "cmd", "test");
    SendCmdMessage(agent, ACTION_DUMP, "cmd", nullptr);
    SendMessage(nullptr, nullptr, nullptr);
    uint32_t events = 0;
    InitPtyInterface(agent, 0, "cmd");
    InitPtyInterface(agent, 0, nullptr);
    InitPtyInterface(nullptr, 0, nullptr);
    mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
    CheckAndCreatFile("/data/init_ut/testInput", mode);
    int fd = open("/data/init_ut/testInput", O_RDWR);
    perror("write failed");
    EXPECT_GT(fd, 0);
    EXPECT_GT(write(fd, "test", strlen("test")), 0);
    perror("write failed");
    lseek(fd, 0, SEEK_SET);
    ProcessPtyRead(nullptr, fd, &events, (void *)agent);
    ProcessPtyRead(nullptr, fd, &events, (void *)agent);
    ProcessPtyRead(nullptr, STDERR_FILENO, &events, nullptr);
    lseek(fd, 0, SEEK_SET);
    ProcessPtyWrite(nullptr, fd, &events, (void *)agent);
    ProcessPtyWrite(nullptr, fd, &events, (void *)agent);
    ProcessPtyWrite(nullptr, STDERR_FILENO, &events, nullptr);
    close(fd);

    CmdOnClose(agent->task);
}

HWTEST_F(InnerkitsUnitTest, TestControlFdServer, TestSize.Level1)
{
    CmdServiceInit(nullptr, nullptr);
    CmdServiceInit("/data/testSock1", [](uint16_t type, const char *serviceCmd, const void *context) {
        UNUSED(type);
        UNUSED(serviceCmd);
        UNUSED(context);
        });

    TaskHandle testServer;
    LE_StreamServerInfo info = {};
    info.baseInfo.flags = TASK_STREAM | TASK_SERVER | TASK_PIPE | TASK_TEST;
    info.server = (char *)"/data/testSock1";
    info.socketId = -1;
    info.baseInfo.close = NULL;
    info.disConnectComplete = NULL;
    info.incommingConnect = TestIncommingConnect;
    info.sendMessageComplete = NULL;
    info.recvMessage = NULL;
    (void)LE_CreateStreamServer(LE_GetDefaultLoop(), &testServer, &info);
    CmdOnIncommingConnect(LE_GetDefaultLoop(), testServer);

    CmdOnRecvMessage(testServer, nullptr, 0);
    CmdMessage *cmdMsg = (CmdMessage *)malloc(sizeof(CmdMessage) + strlen("test"));
    cmdMsg->type = ACTION_DUMP;
    cmdMsg->ptyName[0] = '\0';;
    CmdOnRecvMessage(testServer, (uint8_t *)(&cmdMsg), 0);
    cmdMsg->type = ACTION_DUMP;
    cmdMsg->cmd[0] = 'a';
    cmdMsg->ptyName[0] = 'a';
    CmdOnRecvMessage(testServer, (uint8_t *)(&cmdMsg), 0);
    CmdServiceProcessDelClient(0);
    CmdServiceProcessDelClient(0);
    free(cmdMsg);
}

HWTEST_F(InnerkitsUnitTest, TestHoldFd, TestSize.Level1)
{
    int fds1[] = {1, 0};
    ServiceSaveFd("testServiceName", fds1, ARRAY_LENGTH(fds1));
    ServiceSaveFd(nullptr, fds1, ARRAY_LENGTH(fds1));
    ServiceSaveFdWithPoll("testServiceName", fds1, 0);
    ServiceSaveFdWithPoll(nullptr, fds1, 0);
    ServiceSaveFdWithPoll("testServiceName", fds1, ARRAY_LENGTH(fds1));
    EXPECT_EQ(setenv("OHOS_FD_HOLD_testServiceName", "1 0", 0), 0);

    size_t fdCount = 0;
    int *fds = nullptr;
    ServiceGetFd("testService", nullptr);
    ServiceGetFd("testService", &fdCount);
    char *wrongName = (char *)malloc(MAX_FD_HOLDER_BUFFER + 1);
    ASSERT_NE(wrongName, nullptr);
    EXPECT_EQ(memset_s(wrongName, MAX_FD_HOLDER_BUFFER + 1, 1, MAX_FD_HOLDER_BUFFER + 1), 0);
    ServiceGetFd(wrongName, &fdCount);
    BuildSendData(wrongName, 1, "testService", 0, 1);
    BuildSendData(wrongName, 1, "testService", 0, 0);
    BuildSendData(nullptr, 1, "testService", 0, 0);
    free(wrongName);

    fds = ServiceGetFd("testServiceName", &fdCount);
    EXPECT_NE(fds, nullptr);
    struct msghdr msghdr;
    BuildControlMessage(nullptr, nullptr, 1, 0);
    BuildControlMessage(&msghdr, nullptr, 1, 0);
    BuildControlMessage(&msghdr, fds, -1, 0);
    BuildControlMessage(&msghdr, fds, -1, 1);

    if (fds != nullptr)
    {
        free(fds);
        fds = nullptr;
    }
}

HWTEST_F(InnerkitsUnitTest, TestHoldFd2, TestSize.Level1)
{
    size_t fdCount = 0;
    int *fds = nullptr;
    char buffer[MAX_FD_HOLDER_BUFFER + 1] = {};
    pid_t requestPid = -1;
    struct msghdr msghdr;
    GetFdsFromMsg(&fdCount, &requestPid, msghdr);
    msghdr.msg_flags = MSG_TRUNC;
    GetFdsFromMsg(&fdCount, &requestPid, msghdr);
    struct iovec iovec = {
        .iov_base = buffer,
        .iov_len = MAX_FD_HOLDER_BUFFER,
    };
    ReceiveFds(0, iovec, &fdCount, false, &requestPid);
    fds = ReceiveFds(0, iovec, &fdCount, true, &requestPid);
    if (fds != nullptr)
    {
        free(fds);
        fds = nullptr;
    }
    if (msghdr.msg_control != nullptr) {
        free(msghdr.msg_control);
    }
}

X
add ut  
xionglei6 已提交
455
} // namespace init_ut