psxhdrs: Add tests for <sys/socket.h> API compliance

This commit is contained in:
Joel Sherrill
2015-02-11 14:00:35 -06:00
parent 547c2282ee
commit eedaf9baba
19 changed files with 620 additions and 1 deletions

View File

@@ -24,8 +24,11 @@ RTEMS_CANONICALIZE_TOOLS
RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP)
RTEMS_CHECK_CXX(RTEMS_BSP)
RTEMS_CHECK_CPUOPTS([RTEMS_POSIX_API])
RTEMS_CHECK_CPUOPTS([RTEMS_NETWORKING])
AM_CONDITIONAL([HAS_NETWORKING],[test x"$HAS_NETWORKING" = x"yes"])
AM_CONDITIONAL(HAS_CXX,test "$rtems_cv_HAS_CPLUSPLUS" = "yes")
AM_CONDITIONAL([HAS_NETWORKING],test "$rtems_cv_RTEMS_NETWORKING" = "yes")
AM_CONDITIONAL([HAS_CPLUSPLUS],[test x"$HAS_CPLUSPLUS" = x"yes"])
RTEMS_CHECK_CPUOPTS([RTEMS_POSIX_API])

View File

@@ -22,6 +22,27 @@ lib_a_SOURCES = clock01.c clock02.c clock03.c clock04.c clock05.c clock06.c \
time08.c time09.c time10.c time11.c time12.c time13.c timer01.c \
timer02.c timer03.c timer04.c timer05.c timer06.c timer07.c
if HAS_NETWORKING
# methods in <sys/socket.h>
lib_a_SOURCES += sys/socket/accept.c
lib_a_SOURCES += sys/socket/bind.c
lib_a_SOURCES += sys/socket/connect.c
lib_a_SOURCES += sys/socket/getpeername.c
lib_a_SOURCES += sys/socket/getsockname.c
lib_a_SOURCES += sys/socket/getsockopt.c
lib_a_SOURCES += sys/socket/listen.c
lib_a_SOURCES += sys/socket/recv.c
lib_a_SOURCES += sys/socket/recvfrom.c
lib_a_SOURCES += sys/socket/recvmsg.c
lib_a_SOURCES += sys/socket/send.c
lib_a_SOURCES += sys/socket/sendmsg.c
lib_a_SOURCES += sys/socket/sendto.c
lib_a_SOURCES += sys/socket/setsockopt.c
lib_a_SOURCES += sys/socket/shutdown.c
lib_a_SOURCES += sys/socket/socket.c
lib_a_SOURCES += sys/socket/socketpair.c
endif
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/leaf.am

View File

@@ -0,0 +1,32 @@
/**
* @file
*
* This test file is used to verify that the accept() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
socklen_t addrlen;
return accept(sockfd, &addr, &addrlen);
}

View File

@@ -0,0 +1,32 @@
/**
* @file
*
* This test file is used to verify that the bind() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
socklen_t addrlen = sizeof(addr);
return bind(sockfd, &addr, addrlen);
}

View File

@@ -0,0 +1,32 @@
/**
* @file
*
* This test file is used to verify that the connect() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
socklen_t addrlen = sizeof(addr);
return connect(sockfd, &addr, addrlen);
}

View File

@@ -0,0 +1,32 @@
/**
* @file
*
* This test file is used to verify that the getpeername() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
socklen_t addrlen;
return getpeername(sockfd, &addr, &addrlen);
}

View File

@@ -0,0 +1,32 @@
/**
* @file
*
* This test file is used to verify that the getsockname() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
socklen_t addrlen;
return getsockname(sockfd, &addr, &addrlen);
}

View File

@@ -0,0 +1,35 @@
/**
* @file
*
* This test file is used to verify that the getsockopt() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
int level = SOL_SOCKET;
int optname = 67;
int value;
void *optval = &value;
socklen_t optlen;
return getsockopt(sockfd, level, optname, optval, &optlen);
}

View File

@@ -0,0 +1,31 @@
/**
* @file
*
* This test file is used to verify that the listen() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int backlog = 7;
return listen(sockfd, backlog);
}

View File

@@ -0,0 +1,35 @@
/**
* @file
*
* This test file is used to verify that the recv() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int buffer;
void *buf = &buffer;
size_t len = sizeof(buffer);
int flags = 7;
return recv(sockfd, buf, len, flags);
}

View File

@@ -0,0 +1,37 @@
/**
* @file
*
* This test file is used to verify that the recvfrom() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int buffer;
void *buf = &buffer;
size_t len = sizeof(buffer);
int flags = 7;
struct sockaddr src_addr;
socklen_t addrlen;
return recvfrom(sockfd, buf, len, flags, &src_addr, &addrlen);
}

View File

@@ -0,0 +1,33 @@
/**
* @file
*
* This test file is used to verify that the recvmsg() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
struct msghdr msg;
int flags = 7;
return recvmsg(sockfd, &msg, flags);
}

View File

@@ -0,0 +1,35 @@
/**
* @file
*
* This test file is used to verify that the send() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int buffer;
void *buf = &buffer;
size_t len = sizeof(buffer);
int flags = 7;
return send(sockfd, buf, len, flags);
}

View File

@@ -0,0 +1,33 @@
/**
* @file
*
* This test file is used to verify that the sendmsg() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
struct msghdr msg;
int flags = 7;
return sendmsg(sockfd, &msg, flags);
}

View File

@@ -0,0 +1,36 @@
/**
* @file
*
* This test file is used to verify that the sendto() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int buffer;
const void *buf = &buffer;
size_t len = sizeof(buffer);
int flags = 7;
struct sockaddr dest_addr;
socklen_t addrlen = sizeof(dest_addr);
return sendto(sockfd, buf, len, flags, &dest_addr, addrlen);
}

View File

@@ -0,0 +1,35 @@
/**
* @file
*
* This test file is used to verify that the setsockopt() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
int test(void);
int test(void)
{
int sockfd = 4;
int level = SOL_SOCKET;
int optname = 67;
int value;
void *optval = &value;
socklen_t optlen = sizeof(value);
return setsockopt(sockfd, level, optname, optval, optlen);
}

View File

@@ -0,0 +1,36 @@
/**
* @file
*
* This test file is used to verify that the shutdown() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int how;
/* use all values */
how = SHUT_RD;
how = SHUT_WR;
how = SHUT_RDWR;
return shutdown(sockfd, how);
}

View File

@@ -0,0 +1,44 @@
/**
* @file
*
* This test file is used to verify that the socket() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int domain;
int type;
int protocol = 1;
/* use primary values */
domain = AF_UNIX;
domain = AF_LOCAL;
domain = AF_INET;
/* use some types */
type = SOCK_STREAM;
type = SOCK_DGRAM;
type = SOCK_SEQPACKET;
type = SOCK_RAW;
type = SOCK_RDM;
return socket(domain, type, protocol);
}

View File

@@ -0,0 +1,45 @@
/**
* @file
*
* This test file is used to verify that the socketpair() method has the
* correct signature.
*/
/*
* COPYRIGHT (c) 2015.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/socket.h>
ssize_t test(void);
ssize_t test(void)
{
int domain;
int type;
int protocol = 1;
int sv[2] = { 2, 3 };
/* use primary values */
domain = AF_UNIX;
domain = AF_LOCAL;
domain = AF_INET;
/* use some types */
type = SOCK_STREAM;
type = SOCK_DGRAM;
type = SOCK_SEQPACKET;
type = SOCK_RAW;
type = SOCK_RDM;
return socketpair(domain, type, protocol, sv);
}