29 lines · cpp
1//===-- Unittests for socket ----------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/sys/socket/socket.h"10 11#include "src/unistd/close.h"12 13#include "test/UnitTest/ErrnoCheckingTest.h"14#include "test/UnitTest/ErrnoSetterMatcher.h"15#include "test/UnitTest/Test.h"16 17#include <sys/socket.h> // For AF_UNIX and SOCK_DGRAM18 19using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;20using LlvmLibcSocketTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;21 22TEST_F(LlvmLibcSocketTest, LocalSocket) {23 int sock = LIBC_NAMESPACE::socket(AF_UNIX, SOCK_DGRAM, 0);24 ASSERT_GE(sock, 0);25 ASSERT_ERRNO_SUCCESS();26 27 ASSERT_THAT(LIBC_NAMESPACE::close(sock), Succeeds(0));28}29