Skip to content

Commit ade86ec

Browse files
move tests to be integration tests.
1 parent d97e1d0 commit ade86ec

29 files changed

+219
-137
lines changed

libc/src/sys/socket/accept.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_ACCEPT_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_ACCEPT_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
int accept(int domain, sockaddr *__restrict address,
1718
socklen_t *__restrict address_len);
1819

19-
} // namespace LIBC_NAMESPACE
20+
} // namespace LIBC_NAMESPACE_DECL
2021

2122
#endif // LLVM_LIBC_SRC_SYS_SOCKET_ACCEPT_H

libc/src/sys/socket/bind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace LIBC_NAMESPACE_DECL {
1616

17-
int bind(int domain, const struct sockaddr *address, socklen_t address_len);
17+
int bind(int socket, const struct sockaddr *address, socklen_t address_len);
1818

1919
} // namespace LIBC_NAMESPACE_DECL
2020

libc/src/sys/socket/connect.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
10-
#define LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
9+
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_CONNECT_H
10+
#define LLVM_LIBC_SRC_SYS_SOCKET_CONNECT_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
1718

18-
} // namespace LIBC_NAMESPACE
19+
} // namespace LIBC_NAMESPACE_DECL
1920

20-
#endif // LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
21+
#endif // LLVM_LIBC_SRC_SYS_SOCKET_CONNECT_H

libc/src/sys/socket/linux/accept.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <linux/net.h> // For SYS_SOCKET socketcall number.
1717
#include <sys/syscall.h> // For syscall numbers.
1818

19-
namespace LIBC_NAMESPACE {
19+
namespace LIBC_NAMESPACE_DECL {
2020

2121
LLVM_LIBC_FUNCTION(int, accept,
2222
(int domain, sockaddr *__restrict address,
@@ -40,4 +40,4 @@ LLVM_LIBC_FUNCTION(int, accept,
4040
return ret;
4141
}
4242

43-
} // namespace LIBC_NAMESPACE
43+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/bind.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
namespace LIBC_NAMESPACE_DECL {
2121

2222
LLVM_LIBC_FUNCTION(int, bind,
23-
(int domain, const struct sockaddr *address,
23+
(int socket, const struct sockaddr *address,
2424
socklen_t address_len)) {
2525
#ifdef SYS_bind
2626
int ret =
27-
LIBC_NAMESPACE::syscall_impl<int>(SYS_bind, domain, address, address_len);
27+
LIBC_NAMESPACE::syscall_impl<int>(SYS_bind, socket, address, address_len);
2828
#elif defined(SYS_socketcall)
29-
unsigned long sockcall_args[3] = {static_cast<unsigned long>(domain),
29+
unsigned long sockcall_args[3] = {static_cast<unsigned long>(socket),
3030
reinterpret_cast<unsigned long>(address),
3131
static_cast<unsigned long>(address_len)};
3232
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_socketcall, SYS_BIND,

libc/src/sys/socket/linux/connect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <sys/socket.h> // For the types
1717
#include <sys/syscall.h> // For syscall numbers.
1818

19-
namespace LIBC_NAMESPACE {
19+
namespace LIBC_NAMESPACE_DECL {
2020

2121
LLVM_LIBC_FUNCTION(int, connect,
2222
(int sockfd, const struct sockaddr *addr,
@@ -40,4 +40,4 @@ LLVM_LIBC_FUNCTION(int, connect,
4040
return ret;
4141
}
4242

43-
} // namespace LIBC_NAMESPACE
43+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/listen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/net.h> // For SYS_SOCKET socketcall number.
1818
#include <sys/syscall.h> // For syscall numbers.
1919

20-
namespace LIBC_NAMESPACE {
20+
namespace LIBC_NAMESPACE_DECL {
2121

2222
LLVM_LIBC_FUNCTION(int, listen, (int socket, int backlog)) {
2323
#ifdef SYS_listen
@@ -37,4 +37,4 @@ LLVM_LIBC_FUNCTION(int, listen, (int socket, int backlog)) {
3737
return ret;
3838
}
3939

40-
} // namespace LIBC_NAMESPACE
40+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/recv.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/socket.h> // For the types
1616
#include <sys/syscall.h> // For syscall numbers.
1717

18-
namespace LIBC_NAMESPACE {
18+
namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(ssize_t, recv,
2121
(int sockfd, const void *buf, size_t len, int flags)) {
@@ -42,4 +42,4 @@ LLVM_LIBC_FUNCTION(ssize_t, recv,
4242
return ret;
4343
}
4444

45-
} // namespace LIBC_NAMESPACE
45+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/recvfrom.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/socket.h> // For the types
1616
#include <sys/syscall.h> // For syscall numbers.
1717

18-
namespace LIBC_NAMESPACE {
18+
namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(ssize_t, recvfrom,
2121
(int sockfd, const void *buf, size_t len, int flags,
@@ -44,4 +44,4 @@ LLVM_LIBC_FUNCTION(ssize_t, recvfrom,
4444
return ret;
4545
}
4646

47-
} // namespace LIBC_NAMESPACE
47+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/recvmsg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/socket.h> // For the types
1616
#include <sys/syscall.h> // For syscall numbers.
1717

18-
namespace LIBC_NAMESPACE {
18+
namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(ssize_t, recvmsg,
2121
(int sockfd, const struct msghdr *msg, int flags)) {
@@ -38,4 +38,4 @@ LLVM_LIBC_FUNCTION(ssize_t, recvmsg,
3838
return ret;
3939
}
4040

41-
} // namespace LIBC_NAMESPACE
41+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/send.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/socket.h> // For the types
1616
#include <sys/syscall.h> // For syscall numbers.
1717

18-
namespace LIBC_NAMESPACE {
18+
namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(ssize_t, send,
2121
(int sockfd, const void *buf, size_t len, int flags)) {
@@ -41,4 +41,4 @@ LLVM_LIBC_FUNCTION(ssize_t, send,
4141
return ret;
4242
}
4343

44-
} // namespace LIBC_NAMESPACE
44+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/sendmsg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/socket.h> // For the types
1616
#include <sys/syscall.h> // For syscall numbers.
1717

18-
namespace LIBC_NAMESPACE {
18+
namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(ssize_t, sendmsg,
2121
(int sockfd, const struct msghdr *msg, int flags)) {
@@ -38,4 +38,4 @@ LLVM_LIBC_FUNCTION(ssize_t, sendmsg,
3838
return ret;
3939
}
4040

41-
} // namespace LIBC_NAMESPACE
41+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/linux/sendto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/socket.h> // For the types
1616
#include <sys/syscall.h> // For syscall numbers.
1717

18-
namespace LIBC_NAMESPACE {
18+
namespace LIBC_NAMESPACE_DECL {
1919

2020
LLVM_LIBC_FUNCTION(ssize_t, sendto,
2121
(int sockfd, const void *buf, size_t len, int flags,
@@ -44,4 +44,4 @@ LLVM_LIBC_FUNCTION(ssize_t, sendto,
4444
return ret;
4545
}
4646

47-
} // namespace LIBC_NAMESPACE
47+
} // namespace LIBC_NAMESPACE_DECL

libc/src/sys/socket/listen.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_LISTEN_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_LISTEN_H
1111

12-
namespace LIBC_NAMESPACE {
12+
#include "src/__support/macros/config.h"
13+
namespace LIBC_NAMESPACE_DECL {
1314

1415
int listen(int socket, int backlog);
1516

16-
} // namespace LIBC_NAMESPACE
17+
} // namespace LIBC_NAMESPACE_DECL
1718

1819
#endif // LLVM_LIBC_SRC_SYS_SOCKET_LISTEN_H

libc/src/sys/socket/recv.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_RECV_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
ssize_t recv(int sockfd, const void *buf, size_t len, int flags);
1718

18-
} // namespace LIBC_NAMESPACE
19+
} // namespace LIBC_NAMESPACE_DECL
1920

2021
#endif // LLVM_LIBC_SRC_SYS_SOCKET_RECV_H

libc/src/sys/socket/recvfrom.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECVFROM_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_RECVFROM_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
ssize_t recvfrom(int sockfd, const void *buf, size_t len, int flags,
1718
const struct sockaddr *address, socklen_t addrlen);
1819

19-
} // namespace LIBC_NAMESPACE
20+
} // namespace LIBC_NAMESPACE_DECL
2021

2122
#endif // LLVM_LIBC_SRC_SYS_SOCKET_RECVFROM_H

libc/src/sys/socket/recvmsg.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_RECVMSG_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_RECVMSG_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
ssize_t recvmsg(int sockfd, const struct msghdr *msg, int flags);
1718

18-
} // namespace LIBC_NAMESPACE
19+
} // namespace LIBC_NAMESPACE_DECL
1920

2021
#endif // LLVM_LIBC_SRC_SYS_SOCKET_RECVMSG_H

libc/src/sys/socket/send.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_SEND_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_SEND_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
ssize_t send(int sockfd, const void *buf, size_t len, int flags);
1718

18-
} // namespace LIBC_NAMESPACE
19+
} // namespace LIBC_NAMESPACE_DECL
1920

2021
#endif // LLVM_LIBC_SRC_SYS_SOCKET_SEND_H

libc/src/sys/socket/sendmsg.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_SENDMSG_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_SENDMSG_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
1718

18-
} // namespace LIBC_NAMESPACE
19+
} // namespace LIBC_NAMESPACE_DECL
1920

2021
#endif // LLVM_LIBC_SRC_SYS_SOCKET_SENDMSG_H

libc/src/sys/socket/sendto.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
#ifndef LLVM_LIBC_SRC_SYS_SOCKET_SENDTO_H
1010
#define LLVM_LIBC_SRC_SYS_SOCKET_SENDTO_H
1111

12+
#include "src/__support/macros/config.h"
1213
#include <sys/socket.h>
1314

14-
namespace LIBC_NAMESPACE {
15+
namespace LIBC_NAMESPACE_DECL {
1516

1617
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
1718
const struct sockaddr *dest_addr, socklen_t addrlen);
1819

19-
} // namespace LIBC_NAMESPACE
20+
} // namespace LIBC_NAMESPACE_DECL
2021

2122
#endif // LLVM_LIBC_SRC_SYS_SOCKET_SENDTO_H

libc/test/integration/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ add_subdirectory(stdio)
55
add_subdirectory(stdlib)
66
add_subdirectory(threads)
77
add_subdirectory(unistd)
8+
add_subdirectory(sys)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(socket)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
2+
add_subdirectory(${LIBC_TARGET_OS})
3+
endif()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
add_custom_target(sys-socket-integration-tests)
2+
add_dependencies(libc-integration-tests sys-socket-integration-tests)
3+
4+
5+
add_integration_test(
6+
socket_send_recv_test
7+
SUITE
8+
sys-socket-integration-tests
9+
SRCS
10+
socket_send_recv_test.cpp
11+
DEPENDS
12+
libc.include.sys_socket
13+
libc.src.errno.errno
14+
libc.src.sys.socket.send
15+
libc.src.sys.socket.recv
16+
libc.src.sys.socket.socket
17+
libc.src.sys.socket.bind
18+
libc.src.sys.socket.connect
19+
libc.src.sys.socket.listen
20+
libc.src.sys.socket.accept
21+
libc.src.stdio.remove
22+
libc.src.unistd.close
23+
libc.src.unistd.fork
24+
)

0 commit comments

Comments
 (0)