The io_tc is not used and duplicated with le_tc/network.
And we don't have any plan to use it.
+++ /dev/null
-#
-# For a description of the syntax of this configuration file,
-# see kconfig-language at https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt
-#
-
-menuconfig EXAMPLES_TESTCASE_NETWORK
- bool "Network TestCase Example"
- default n
- ---help---
- Enable the Network TestCase Example
-
-if EXAMPLES_TESTCASE_NETWORK
-
-config TC_NET_ALL
- bool "All"
- default n
- select TC_NET_SOCKET
- select TC_NET_SETSOCKOPT
- select TC_NET_CONNECT
- select TC_NET_CLOSE
- select TC_NET_BIND
- select TC_NET_LISTEN
- select TC_NET_GETSOCKNAME
- select TC_NET_GETSOCKOPT
- select TC_NET_FCNTL
- select TC_NET_IOCTL
- select TC_NET_ACCEPT
- select TC_NET_SEND
- select TC_NET_RECV
- select TC_NET_GETPEERNAME
- select TC_NET_SENDTO
- select TC_NET_RECVFROM
- select TC_NET_SHUTDOWN
- select TC_NET_DHCPC
- select TC_NET_DHCPS
-
-config TC_NET_SOCKET
- bool "socket() api"
- default n
-
-config TC_NET_SETSOCKOPT
- bool "setsockopt() api"
- default n
-
-config TC_NET_CONNECT
- bool "connect() api"
- default n
-
-config TC_NET_CLOSE
- bool "close() api"
- default n
-
-config TC_NET_BIND
- bool "bind() api"
- default n
-
-config TC_NET_LISTEN
- bool "listen() api"
- default n
-
-config TC_NET_GETSOCKNAME
- bool "getsockname() api"
- default n
-
-config TC_NET_GETSOCKOPT
- bool "getsockopt() api"
- default n
-
-config TC_NET_FCNTL
- bool "fcntl() api"
- default n
-
-config TC_NET_IOCTL
- bool "ioctl() api"
- default n
-
-config TC_NET_ACCEPT
- bool "accept() api"
- default n
-
-config TC_NET_SEND
- bool "send() api"
- default n
-
-config TC_NET_RECV
- bool "recv() api"
- default n
-
-config TC_NET_GETPEERNAME
- bool "getpeername() api"
- default n
-
-config TC_NET_SENDTO
- bool "sendto() api"
- default n
-
-config TC_NET_RECVFROM
- bool "recvfrom() api"
- default n
-
-config TC_NET_SHUTDOWN
- bool "shutdown() api"
- default n
-
-config TC_NET_DHCPC
- bool "dhcpc() api"
- default n
-
-config TC_NET_DHCPS
- bool "dhcps() api"
- default n
-
-
-
-
-endif #EXAMPLES_TESTCASE_NETWORK
+++ /dev/null
-###########################################################################
-#
-# Copyright 2016 Samsung Electronics All Rights Reserved.
-#
-# 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.
-#
-###########################################################################
-
-############################################################################
-# apps/examples/testcase/network/Make.defs
-#
-# Copyright (C) 2014 Gregory Nutt. All rights reserved.
-# Author: Gregory Nutt <gnutt@nuttx.org>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# 3. Neither the name NuttX nor the names of its contributors may be
-# used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-############################################################################
-
-ifeq ($(CONFIG_EXAMPLES_TESTCASE_NETWORK),y)
-CSRCS += network_tc_main.c
-ifeq ($(CONFIG_TC_NET_SOCKET),y)
-CSRCS +=tc_net_socket.c
-endif
-ifeq ($(CONFIG_TC_NET_SETSOCKOPT),y)
-CSRCS += tc_net_setsockopt.c
-endif
-ifeq ($(CONFIG_TC_NET_CONNECT),y)
-CSRCS +=tc_net_connect.c
-endif
-ifeq ($(CONFIG_TC_NET_CLOSE),y)
-CSRCS +=tc_net_close.c
-endif
-ifeq ($(CONFIG_TC_NET_BIND),y)
-CSRCS +=tc_net_bind.c
-endif
-ifeq ($(CONFIG_TC_NET_LISTEN),y)
-CSRCS +=tc_net_listen.c
-endif
-ifeq ($(CONFIG_TC_NET_GETSOCKNAME),y)
-CSRCS +=tc_net_getsockname.c
-endif
-ifeq ($(CONFIG_TC_NET_GETSOCKOPT),y)
-CSRCS +=tc_net_getsockopt.c
-endif
-ifeq ($(CONFIG_TC_NET_FCNTL),y)
-CSRCS +=tc_net_fcntl.c
-endif
-ifeq ($(CONFIG_TC_NET_IOCTL),y)
-CSRCS +=tc_net_ioctl.c
-endif
-ifeq ($(CONFIG_TC_NET_ACCEPT),y)
-CSRCS +=tc_net_accept.c
-endif
-ifeq ($(CONFIG_TC_NET_SEND),y)
-CSRCS +=tc_net_send.c
-endif
-ifeq ($(CONFIG_TC_NET_RECV),y)
-CSRCS +=tc_net_recv.c
-endif
-ifeq ($(CONFIG_TC_NET_GETPEERNAME),y)
-CSRCS +=tc_net_getpeername.c
-endif
-ifeq ($(CONFIG_TC_NET_SENDTO),y)
-CSRCS +=tc_net_sendto.c
-endif
-ifeq ($(CONFIG_TC_NET_RECVFROM),y)
-CSRCS +=tc_net_recvfrom.c
-endif
-ifeq ($(CONFIG_TC_NET_SHUTDOWN),y)
-CSRCS +=tc_net_shutdown.c
-endif
-ifeq ($(CONFIG_TC_NET_DHCPC),y)
-CSRCS +=tc_net_dhcpc.c
-endif
-ifeq ($(CONFIG_TC_NET_DHCPS),y)
-CSRCS +=tc_net_dhcps.c
-endif
-
-# Include network build support
-
-DEPPATH += --dep-path io_tc/network
-VPATH += :io_tc/network
-endif
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file network_tc_main.c
-
-/// @brief Main Function for Network TestCase Example
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <semaphore.h>
-#include "tc_internal.h"
-
-int nw_total_pass = 0;
-int nw_total_fail = 0;
-
-extern sem_t tc_sem;
-extern int working_tc;
-
-/****************************************************************************
- * Name: network_tc_main
- ****************************************************************************/
-#ifdef CONFIG_BUILD_KERNEL
-int main(int argc, FAR char *argv[])
-#else
-int network_tc_main(int argc, char *argv[])
-#endif
-{
- sem_wait(&tc_sem);
- working_tc++;
-
- printf("=== TINYARA Network TC START! ===\n");
-
-#ifdef CONFIG_TC_NET_SOCKET
- net_socket_main();
-#endif
-#ifdef CONFIG_TC_NET_SETSOCKOPT
- net_setsockopt_main();
-#endif
-#ifdef CONFIG_TC_NET_CONNECT
- net_connect_main();
-#endif
-#ifdef CONFIG_TC_NET_CLOSE
- net_close_main();
-#endif
-#ifdef CONFIG_TC_NET_BIND
- net_bind_main();
-#endif
-#ifdef CONFIG_TC_NET_LISTEN
- net_listen_main();
-#endif
-#ifdef CONFIG_TC_NET_GETSOCKNAME
- net_getsockname_main();
-#endif
-#ifdef CONFIG_TC_NET_GETSOCKOPT
- net_getsockopt_main();
-#endif
-#ifdef CONFIG_TC_NET_FCNTL
- net_fcntl_main();
-#endif
-#ifdef CONFIG_TC_NET_IOCTL
- net_ioctl_main();
-#endif
-#ifdef CONFIG_TC_NET_ACCEPT
- net_accept_main();
-#endif
-#ifdef CONFIG_TC_NET_SEND
- net_send_main();
-#endif
-#ifdef CONFIG_TC_NET_RECV
- net_recv_main();
-#endif
-#ifdef CONFIG_TC_NET_GETPEERNAME
- net_getpeername_main();
-#endif
-#ifdef CONFIG_TC_NET_SENDTO
- net_sendto_main();
-#endif
-#ifdef CONFIG_TC_NET_RECVFROM
- net_recvfrom_main();
-#endif
-#ifdef CONFIG_TC_NET_SHUTDOWN
- net_shutdown_main();
-#endif
-#ifdef CONFIG_TC_NET_DHCPC
- net_dhcpc_main();
-#endif
-#ifdef CONFIG_TC_NET_DHCPS
- net_dhcps_main();
-#endif
-
- printf("\n=== TINYARA Network TC COMPLETE ===\n");
- printf("\t\tTotal pass : %d\n\t\tTotal fail : %d\n", nw_total_pass, nw_total_fail);
-
- working_tc--;
- sem_post(&tc_sem);
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_internal.h
-
-/// @brief Header file for Network TestCase Example
-#ifndef __EXAMPLES_TESTCASE_NETWORK_TC_INTERNAL_H
-#define __EXAMPLES_TESTCASE_NETWORK_TC_INTERNAL_H
-
-#define RETURN_ERR return
-
-extern int nw_total_pass;
-extern int nw_total_fail;
-
-/**********************************************************
-* TC Function Declarations
-**********************************************************/
-
-#ifdef CONFIG_TC_NET_SOCKET
-int net_socket_main(void);
-#endif
-#ifdef CONFIG_TC_NET_GETSOCKOPT
-void net_getsockopt_main(void);
-#endif
-#ifdef CONFIG_TC_NET_SETSOCKOPT
-int net_setsockopt_main(void);
-#endif
-#ifdef CONFIG_TC_NET_CONNECT
-int net_connect_main(void);
-#endif
-#ifdef CONFIG_TC_NET_CLOSE
-int net_close_main(void);
-#endif
-#ifdef CONFIG_TC_NET_BIND
-int net_bind_main(void);
-#endif
-#ifdef CONFIG_TC_NET_LISTEN
-int net_listen_main(void);
-#endif
-#ifdef CONFIG_TC_NET_GETSOCKNAME
-int net_getsockname_main(void);
-#endif
-#ifdef CONFIG_TC_NET_FCNTL
-int net_fcntl_main(void);
-#endif
-#ifdef CONFIG_TC_NET_IOCTL
-int net_ioctl_main(void);
-#endif
-#ifdef CONFIG_TC_NET_ACCEPT
-int net_accept_main(void);
-#endif
-#ifdef CONFIG_TC_NET_SEND
-int net_send_main(void);
-#endif
-#ifdef CONFIG_TC_NET_RECV
-int net_recv_main(void);
-#endif
-#ifdef CONFIG_TC_NET_GETPEERNAME
-int net_getpeername_main(void);
-#endif
-#ifdef CONFIG_TC_NET_SENDTO
-int net_sendto_main(void);
-#endif
-#ifdef CONFIG_TC_NET_RECVFROM
-int net_recvfrom_main(void);
-#endif
-#ifdef CONFIG_TC_NET_SHUTDOWN
-int net_shutdown_main(void);
-#endif
-#endif /* __EXAMPLES_TESTCASE_NETWORK_TC_INTERNAL_H */
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_accept.c
-// @brief Test Case Example for accept() API
-#include <tinyara/config.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <net/if.h>
-#include <apps/netutils/netlib.h>
-#include "tc_internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include<pthread.h>
-
-#define PORTNUM 1108
-#define MAXRCVLEN 20
-int s = 0;
-/**
- * @fn :wait
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void wait(void)
-{
- while (s <= 0) {
-
- printf("");
- }
- s--;
-}
-
-/**
- * @fn :signal
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void signal(void)
-{
- s++;
-}
-
-/**
- * @fn :tc_net_accept_p
- * @brief :
- * @scenario :
- * API's covered :accept()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_accept_p(int fd)
-{
- int ConnectFD = accept(fd, NULL, NULL);
-
- if (ConnectFD < 0) {
- printf(" \ntc_net_accept_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_accept_p:PASS\n");
- nw_total_pass++;
- close(ConnectFD);
-}
-
-/**
- * @fn :tc_net_accept_socket_n
- * @brief :
- * @scenario :
- * API's covered :accept()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_accept_socket_n(int fd)
-{
- int ConnectFD = accept(-1, NULL, NULL);
-
- if (ConnectFD == 0) {
- printf("\ntc_net_accept_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" tc_net_accept_p:PASS\n");
- nw_total_pass++;
- close(ConnectFD);
-}
-
-/**
- * @fn :Server
- * @brief :
- * @scenario :
- * API's covered :socket,bind,listen,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *Server(void *args)
-{
-
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 1);
-
- signal();
- tc_net_accept_p(SocketFD);
- tc_net_accept_socket_n(SocketFD);
-
- close(SocketFD);
- return 0;
-}
-
-/**
- * @fn :Client
- * @brief :
- * @scenario :
- * API's covered :socket,connect,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *Client(void *args)
-{
-
- int mysocket;
- struct sockaddr_in dest;
-
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
-
- wait();
-
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
-
- close(mysocket);
- return 0;
-
-}
-
-/****************************************************************************
- * Name: accept()
- ****************************************************************************/
-int net_accept_main(void)
-{
-
- pthread_t server, client;
-
- pthread_create(&server, NULL, Server, NULL);
- pthread_create(&client, NULL, Client, NULL);
- pthread_join(server, NULL);
-
- pthread_join(client, NULL);
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_bind.c
-/// @brief Test Case Example for bind() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-/**
- * @fn :tc_net_bind_p
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_bind_p(void)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1100);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- int ret = bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- close(SocketFD);
-
- if (ret == -1) {
- printf("tc_net_bind_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_bind_udp_p
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_bind_udp_p(void)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1100);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- int ret = bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- close(SocketFD);
-
- if (ret == -1) {
- printf("tc_net_bind_udp_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_udp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_bind_broadcast_p
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
-*/
-static void tc_net_bind_broadcast_p(void)
-{
-
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1105);
- sa.sin_addr.s_addr = htonl(INADDR_BROADCAST);
-
- int ret = bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- close(SocketFD);
-
- if (ret == -1) {
- printf("tc_net_bind_broadcast_p: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_broadcast_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_bind_fd_n
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_bind_fd_n(void)
-{
- struct sockaddr_in sa;
- int fd = -1;
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1110);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- int ret = bind(fd, (struct sockaddr *)&sa, sizeof(sa));
-
- if (ret == 0) {
- printf("tc_net_bind_fd_n: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_fd_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_bind_addrfamily_n
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_bind_addrfamily_n(void)
-{
- struct sockaddr_in sa;
- int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_UNIX;
- sa.sin_port = htons(5123);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- int ret = bind(fd, (struct sockaddr *)&sa, sizeof(sa));
- close(fd);
-
- if (ret == 0) {
- printf("tc_net_bind_addrfamily_n: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_addrfamily_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_bind_size_n
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
-*/
-static void tc_net_bind_size_n(void)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1109);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- int ret = bind(SocketFD, (struct sockaddr *)&sa, -1);
- close(SocketFD);
-
- if (ret == 0) {
- printf("tc_net_bind_size_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_size_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_bind_fd_size_n
- * @brief :
- * @scenario :
- * API's covered :bind()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_bind_fd_size_n(void)
-{
- struct sockaddr_in sa;
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1108);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- int ret = bind(-1, (struct sockaddr *)&sa, 0);
-
- if (ret == 0) {
- printf("tc_net_bind_fd_size_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_bind_fd_size_n: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: bind()
- ****************************************************************************/
-
-int net_bind_main(void)
-{
-
- tc_net_bind_p();
- tc_net_bind_fd_n();
- tc_net_bind_fd_size_n();
- tc_net_bind_udp_p();
- tc_net_bind_broadcast_p();
- tc_net_bind_size_n();
- tc_net_bind_addrfamily_n();
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_socket.c
-/// @brief Test Case Example for close() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-/**
- * @fn :tc_net_close_p
- * @brief :
- * @scenario :
- * API's covered :close()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_close_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- int ret = close(fd);
-
- if (ret == -1) {
- printf("tc_net_close_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_close_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_close_n
- * @brief :
- * @scenario :
- * API's covered :close()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_close_n(void)
-{
-
- int fd = -1;
- int ret = close(fd);
-
- if (ret == 0) {
- printf("tc_net_close_n: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_close_n: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: close()
- ****************************************************************************/
-
-int net_close_main(void)
-{
-
- tc_net_close_p();
- tc_net_close_n();
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_connect.c
-/// @brief Test Case Example for connect() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-/**
- * @fn :tc_net_connect_fd_n
- * @brief :
- * @scenario :
- * API's covered :connect()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_connect_fd_n(struct sockaddr_in *sa)
-{
- inet_pton(AF_INET, "192.168.1.3", &(sa->sin_addr));
-
- int ret = connect(0, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
- if (ret == 0) {
- printf("tc_net_connect_fd_n FAIL: TCP connect failure\n");
- nw_total_fail++;
- } else if (ret == -1) {
- printf("tc_net_connect_fd_n PASS\n");
- nw_total_pass++;
- RETURN_ERR;
- }
-}
-
-/**
- * @fn :tc_net_connect_broadcastaddr_n
- * @brief :
- * @scenario :
- * API's covered :connect()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_connect_broadcastaddr_n(struct sockaddr_in *sa)
-{
- int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- struct in_addr ad;
- ad.s_addr = INADDR_BROADCAST;
- sa->sin_addr = ad;
- int ret = connect(fd, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
- close(fd);
- if (ret == 0) {
- printf("tc_net_connect_broadcastaddr_nFAIL: TCP connect failure\n");
- nw_total_fail++;
- } else if (ret == -1) {
- printf("tc_net_connect_broadcastaddr_n PASS\n");
- nw_total_pass++;
- RETURN_ERR;
- }
-}
-
-/**
- * @fn :tc_net_connect_loopbackaddr_n
- * @brief :
- * @scenario :
- * API's covered :connect()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_connect_loopbackaddr_n(struct sockaddr_in *sa)
-{
- int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- struct in_addr ad;
- ad.s_addr = INADDR_LOOPBACK;
- sa->sin_addr = ad;
- int ret = connect(fd, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
- close(fd);
- if (ret == -1) {
- printf("tc_net_connect_loopbackaddr_n PASS\n");
- nw_total_pass++;
- } else if (ret == 0) {
- printf("tc_net_connect_loopbackaddr_n FAIL: TCP connect failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-}
-
-/**
- * @fn :tc_net_connect_addr_socklen_n
- * @brief :
- * @scenario :
- * API's covered :connect()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_connect_socklen_n(struct sockaddr_in *sa)
-{
- int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- struct in_addr ad;
- ad.s_addr = INADDR_LOOPBACK;
- sa->sin_addr = ad;
- int ret = connect(fd, (struct sockaddr *)sa, -1);
- close(fd);
- if (ret == -1) {
- printf("tc_net_connect_addr_socklen_n PASS\n");
- nw_total_pass++;
- } else if (ret == 0) {
- printf("tc_net_connect_addr_socklen_n: TCP connect failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-}
-
-/****************************************************************************
- * Name: connect()
- ****************************************************************************/
-
-int net_connect_main(void)
-{
- struct sockaddr_in sa;
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1100);
-
- tc_net_connect_fd_n(&sa);
- tc_net_connect_broadcastaddr_n(&sa);
- tc_net_connect_loopbackaddr_n(&sa);
- tc_net_connect_socklen_n(&sa);
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_dhcpc.c
-/// @brief Test Case Example for dhcpc() API
-
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-
-int net_dhcpc_main(void)
-{
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_dhcps.c
-/// @brief Test Case Example for dhcps() API
-
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-
-#include <net/lwip/dhcp.h>
-
-#if defined(CONFIG_ARCH_BOARD_SIDK_S5JT200)
-#if LWIP_HAVE_LOOPIF
-#define NET_DEVNAME "wl1"
-#else
-#define NET_DEVNAME "wl0"
-#endif
-#else
-#error "undefined CONFIG_NET_<type>, check your .config"
-#endif
-
-#define SOFT_AP_IPADDR "192.168.0.1\0"
-#define SOFT_AP_NETMASK "255.255.255.0\0"
-#define SOFT_AP_GW "192.168.0.1\0"
-
-int net_dhcps_main(void)
-{
- struct netif *netif;
- ip_addr_t ipaddr, netmask, gateway;
- uint8_t key_length;
- int channel;
- int result;
-
- netif = netif_find(NET_DEVNAME);
- if (netif != NULL) {
- ipaddr.addr = inet_addr(SOFT_AP_IPADDR);
- netmask.addr = inet_addr(SOFT_AP_NETMASK);
- gateway.addr = inet_addr(SOFT_AP_GW);
- netif_set_addr(netif, &ipaddr, &netmask, &gateway);
- if (netif->ip_addr.addr == inet_addr(SOFT_AP_IPADDR)) {
- printf("tc_net_netif_set_addr: PASS\n");
- total_pass++;
- } else {
- printf("tc_net_netif_set_addr: FAIL\n");
- total_fail++;
- }
- netif_set_up(netif);
- if (netif_is_up(netif)) {
- printf("tc_net_dhcps_set_up: PASS\n");
- total_pass++;
- } else {
- printf("tc_net_dhcps_set_up: FAIL\n");
- total_fail++;
- }
- } else {
- printf("cannot find netif name %s\n", NET_DEVNAME);
- }
-
- if (dhcps_start(netif) == 0) {
- printf("tc_net_dhcps_start: PASS\n");
- total_pass++;
- } else {
- printf("tc_net_dhcps_start: FAIL\n");
- total_fail++;
- }
-
- netif_set_down(netif);
- if (netif_is_up(netif)) {
- printf("tc_net_netif_set_down: FAIL\n");
- total_fail++;
-
- } else {
- printf("tc_net_netif_set_down: PASS\n");
- total_pass++;
- }
-
- dhcps_stop(netif);
- if (netif->dhcps_pcb != NULL) {
- printf("tc_net_dhcps_stop: FAIL\n");
- total_fail++;
- } else {
- printf("tc_net_dhcps_stop: PASS\n");
- total_pass++;
- }
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_fcntl.c
-/// @brief Test Case Example for fcntl() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-/**
- * @fn :tc_net_fcntl_p
- * @brief :
- * @scenario :
- * API's covered :fcntl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_fcntl_nonblock_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- int ret = fcntl(fd, F_SETFL, O_NONBLOCK);
- close(fd);
-
- if (ret == -1) {
- printf("tc_net_fcntl_nonblock_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_fcntl_nonblock_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_fcntl_p
- * @brief :
- * @scenario :
- * API's covered :fcntl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_fcntl_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- int ret = fcntl(fd, F_SETFL, 0);
- close(fd);
-
- if (ret == -1) {
- printf("tc_net_fcntl_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_fcntl_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_fcntl_n
- * @brief :
- * @scenario :
- * API's covered :fcntl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_fcntl_n(void)
-{
-
- int fd = -1;
- int ret = fcntl(fd, F_SETFL, O_NONBLOCK);
-
- if (ret == 0) {
- printf("tc_net_fcntl_n: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_fcntl_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_fcntl_ndelay_p
- * @brief :
- * @scenario :
- * API's covered :fcntl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_fcntl_ndelay_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- int ret = fcntl(fd, F_SETFL, O_NDELAY);
- close(fd);
-
- if (ret == -1) {
- printf("tc_net_fcntl_ndelay_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_fcntl_ndelay_p: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: fcntl()
- ****************************************************************************/
-
-int net_fcntl_main(void)
-{
-
- tc_net_fcntl_nonblock_p();
- tc_net_fcntl_p();
- tc_net_fcntl_n();
- tc_net_fcntl_ndelay_p();
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_getpeername.c
-// @brief Test Case Example for getpeername() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-#include<pthread.h>
-
-#define PORTNUM 1115
-#define MAXRCVLEN 20
-int sem = 0;
-/**
- * @fn :getpeername_wait
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void getpeername_wait(void)
-{
- while (sem <= 0) {
-
- printf("");
- }
- sem--;
-}
-
-/**
- * @fn :getpeername_signal
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void getpeername_signal(void)
-{
- sem++;
-}
-
-/**
- * @fn :tc_net_getpeername_p1
- * @brief :positive test cases wthout client server model
- * @scenario :
- * API's covered :getpeername()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_p1(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_INET, SOCK_STREAM, 0);
- int ret = getpeername(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getpeername_p1: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getpeername_p1: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getpeername_sock_n
- * @brief :negative test case wthout client server model
- * @scenario :
- * API's covered :getpeername()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_sock_n(void)
-{
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
- int ret = getpeername(-1, &foo, (socklen_t *)&len);
- if (ret != -1) {
- printf("tc_net_getpeername_sock_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getpeername_sock_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getpeername_close_n
- * @brief :negative test case wthout client server model
- * @scenario :
- * API's covered :getpeername()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_close_n(void)
-{
- int sock;
- sock = socket(AF_INET, SOCK_STREAM, 0);
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
- close(sock);
- int ret = getpeername(sock, &foo, (socklen_t *)&len);
- if (ret != -1) {
- printf("tc_net_getpeername_close_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getpeername_close_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getpeername_unix_p
- * @brief :
- * @scenario :
- * API's covered :getpeername()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_unix_p(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_UNIX, SOCK_STREAM, 0);
- int ret = getpeername(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getpeername_unix_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("tc_net_getpeername_unix_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getpeername_udp_p
- * @brief :
- * @scenario :
- * API's covered :getpeername()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_udp_p(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- int ret = getpeername(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getpeername_udp_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getpeername_udp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getpeername_p
- * @brief :positive testcase for getpeername api with client server model
- * @scenario :
- * API's covered :getpeername
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_p(int fd)
-{
- socklen_t len;
- struct sockaddr_storage addr;
- len = sizeof(addr);
-
- int ret = getpeername(fd, (struct sockaddr *)&addr, &len);
-
- if (ret == -1) {
- printf(" \ntc_net_getpeername_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("\ntc_net_getpeername_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_getpeername_n
- * @brief :negative testcase for getpeername api with client server model
- * @scenario :
- * API's covered :getpeername
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getpeername_n(int fd)
-{
- socklen_t len;
- struct sockaddr_storage addr;
- len = sizeof(addr);
-
- int ret = getpeername(-1, (struct sockaddr *)&addr, &len);
-
- if (ret != -1) {
- printf(" \ntc_net_getpeername_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_getpeername_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :getpeername_server
- * @brief :
- * @scenario :
- * API's covered :socket,bind,listen,accept,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *getpeername_server(void *args)
-{
-
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 1);
- getpeername_signal();
- int ConnectFD = accept(SocketFD, NULL, NULL);
-
- close(ConnectFD);
-
- close(SocketFD);
- return 0;
-}
-
-/**
- * @fn :getpeername_client
- * @brief :
- * @scenario :
- * API's covered :socket,connect,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *getpeername_client(void *args)
-{
-
- int mysocket;
- struct sockaddr_in dest;
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
-
- getpeername_wait();
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
-
- tc_net_getpeername_p(mysocket);
- tc_net_getpeername_n(mysocket);
-
- close(mysocket);
- return 0;
-
-}
-
-/****************************************************************************
- * Name: getpeername()
- ****************************************************************************/
-int net_getpeername_main(void)
-{
-
- pthread_t Server, Client;
-
- pthread_create(&Server, NULL, getpeername_server, NULL);
- pthread_create(&Client, NULL, getpeername_client, NULL);
-
- pthread_join(Server, NULL);
-
- pthread_join(Client, NULL);
- tc_net_getpeername_p1();
- tc_net_getpeername_sock_n();
- tc_net_getpeername_close_n();
- tc_net_getpeername_unix_p();
- tc_net_getpeername_udp_p();
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_getsockname.c
-/// @brief Test Case Example for getsockname() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-/**
- * @fn :tc_net_getsockname_p
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_p(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_INET, SOCK_STREAM, 0);
-
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getsockname_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockname_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getsockname_unix_p
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_unix_p(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_UNIX, SOCK_STREAM, 0);
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getsockname_unix_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockname_unix_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getsockname_n
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_n(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = -1;
-
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == 0) {
- printf("tc_net_getsockname_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockname_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getsockname_close_n
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_close_n(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- close(sock);
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == 0) {
- printf("tc_net_getsockname_close_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("tc_net_getsockname_close_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getsockname_udp_p
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_udp_p(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getsockname_udp_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockname_udp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getsockname_icmp_p
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_icmp_p(void)
-{
- int sock;
- int len = sizeof(struct sockaddr);
- struct sockaddr foo;
-
- sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == -1) {
- printf("tc_net_getsockname_icmp_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockname_icmp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_getsockname_len_sock_n
- * @brief :
- * @scenario :
- * API's covered :getsockname()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_getsockname_len_sock_n(void)
-{
- int sock;
- int len = -1;
- struct sockaddr foo;
-
- sock = -1;
- int ret = getsockname(sock, &foo, (socklen_t *)&len);
- if (ret == 0) {
- printf("tc_net_getsockname_len_sock_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockname_len_sock_n: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: getsockname()
- ****************************************************************************/
-
-int net_getsockname_main(void)
-{
- tc_net_getsockname_p();
- tc_net_getsockname_n();
- tc_net_getsockname_len_sock_n();
- tc_net_getsockname_udp_p();
- tc_net_getsockname_icmp_p();
- tc_net_getsockname_close_n();
- tc_net_getsockname_unix_p();
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_getsockopt.c
-/// @brief Test Case Example for getsockopt() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-
-/**
-* @fn :tc_net_getsockopt_multicast_ttl_p
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_multicast_ttl_p(int s)
-{
- int ret = -1;
- socklen_t optval = 1;
- socklen_t optlen = sizeof(optval);
- setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &optval, optlen);
- ret = getsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &optval, &optlen);
- if (ret < 0) {
- printf("tc_net_getsockopt_multicast_ttl_p: GETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_multicast_ttl_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_multicast_ttl_loop_own_p
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_multicast_ttl_loop_own_p(int s)
-{
- int ret = -1;
- socklen_t loop = 1;
- socklen_t looplen = sizeof(loop);
- setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, looplen);
- ret = getsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &loop, &looplen);
- if (ret < 0) {
- printf("tc_net_getsockopt_multicast_ttl_loop_own_p: GETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_multicast_ttl_loop_own_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_getsockopt_multicast_ttl_loop_p
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_multicast_ttl_loop_p(int s)
-{
- int ret = -1;
- socklen_t loop = 250;
- socklen_t looplen = sizeof(loop);
- setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, looplen);
- ret = getsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &loop, &looplen);
- if (ret < 0) {
- printf("tc_net_getsockopt_multicast_ttl_loop_p: GETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_multicast_ttl_loop_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_getsockopt_invalid_filedesc_n
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_invalid_filedesc_n(void)
-{
- int ret = -1;
- socklen_t optval = 1;
- socklen_t optlen = sizeof(optval);
-
- setsockopt(0, SOL_SOCKET, 0, 0, 0);
- ret = getsockopt(0, IPPROTO_IP, IP_MULTICAST_TTL, &optval, &optlen);
- if (ret != -1) {
- printf("tc_net_getsockopt_invalid_filedesc_n FAIL: getopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_invalid_filedesc_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_getsockopt_optval_n
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_optval_n(int s)
-{
- int ret = -1;
- socklen_t optval = 1;
- socklen_t optlen = sizeof(optval);
-
- setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &optval, optlen);
- ret = getsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, NULL, &optlen);
- if (ret != -1) {
- printf("tc_net_getsockopt_invalid_filedesc_n FAIL: getopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_optval_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_getsockopt_sol_socket_so_acceptconn_p
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_sol_socket_so_acceptconn_p(int s)
-{
- int ret = -1;
- socklen_t optval = 1;
- socklen_t optlen = sizeof(optval);
- setsockopt(s, SOL_SOCKET, SO_ACCEPTCONN, &optval, optlen);
- ret = getsockopt(s, SOL_SOCKET, SO_ACCEPTCONN, &optval, &optlen);
- if (ret < 0) {
- printf("tc_net_getsockopt_sol_socket_so_acceptconn_p: FAIL \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_sol_socket_so_acceptconn_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_getsockopt_sol_socket_so_broadcast_p
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_sol_socket_so_broadcast_p(int s)
-{
- int ret = -1;
- socklen_t optval = 1;
- socklen_t optlen = sizeof(optval);
- setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, optlen);
- ret = getsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, &optlen);
- if (ret < 0) {
- printf("tc_net_getsockopt_sol_socket_so_broadcast_p: FAIL \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_sol_socket_so_broadcast_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_getsockopt_sol_socket_so_keepalive_p
-* @brief :
-* @Scenario :
-* @API's covered :getsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_getsockopt_sol_socket_so_keepalive_p(int s)
-{
- int ret = -1;
- socklen_t optval = 1;
- socklen_t optlen = sizeof(optval);
- setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen);
- ret = getsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen);
- if (ret < 0) {
- printf("tc_net_getsockopt_sol_socket_so_keepalive_p: FAIL \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_getsockopt_sol_socket_so_kepalive_p: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: getsockopt()
- ****************************************************************************/
-
-void net_getsockopt_main(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- tc_net_getsockopt_invalid_filedesc_n();
- tc_net_getsockopt_optval_n(fd);
- tc_net_getsockopt_multicast_ttl_loop_p(fd);
- tc_net_getsockopt_multicast_ttl_loop_own_p(fd);
- tc_net_getsockopt_multicast_ttl_p(fd);
- tc_net_getsockopt_sol_socket_so_acceptconn_p(fd);
- tc_net_getsockopt_sol_socket_so_broadcast_p(fd);
- tc_net_getsockopt_sol_socket_so_keepalive_p(fd);
-
- close(fd);
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_ioctl.c
-/// @brief Test Case Example for ioctl() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-
-extern int ioctlsocket(int s, long cmd, void *argp);
-
-/**
- * @fn :tc_net_ioctl_p
- * @brief :
- * @scenario :
- * API's covered :ioctl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_ioctl_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- long a = 0;
-
- int ret = ioctlsocket(fd, FIONBIO, &a);
- close(fd);
-
- if (ret == -1) {
- printf("tc_net_ioctl_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_ioctl_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_ioctl_fionread_n
- * @brief :
- * @scenario :
- * API's covered :ioctl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_ioctl_fionread_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- long a = 10;
-
- int ret = ioctlsocket(fd, FIONREAD, &a);
- close(fd);
-
- if (ret == 0) {
- printf("tc_net_ioctl_fionread_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_ioctl_fionread_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_ioctl_n
- * @brief :
- * @scenario :
- * API's covered :ioctl()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_ioctl_n(void)
-{
-
- int fd = -1;
- int ret = ioctlsocket(fd, FIONBIO, 0);
-
- if (ret == 0) {
- printf("tc_net_ioctl_n: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_ioctl_n: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: ioctl()
- ****************************************************************************/
-
-int net_ioctl_main(void)
-{
-
- tc_net_ioctl_p();
- tc_net_ioctl_fionread_n();
-
- tc_net_ioctl_n();
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_listen.c
-/// @brief Test Case Example for listen() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-/**
- * @fn :tc_net_listen_p
- * @brief :
- * @scenario :
- * API's covered :listen()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_listen_p(void)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1100);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- int ret = (listen(SocketFD, 10));
- close(SocketFD);
-
- if (ret == -1) {
- printf("tc_net_listen_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_listen_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_listen_fd_n
- * @brief :
- * @scenario :
- * API's covered :listen()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_listen_fd_n(void)
-{
- struct sockaddr_in sa;
- int fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1101);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- bind(fd, (struct sockaddr *)&sa, sizeof(sa));
- int ret = (listen(-1, 10));
-
- if (ret == 0) {
- printf("tc_net_listen_fd_n: FAIL\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_listen_fd_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_listen_backlog_p
- * @brief :
- * @scenario :
- * API's covered :listen()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_listen_backlog_p(void)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1100);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- int ret = (listen(SocketFD, -1));
- close(SocketFD);
-
- if (ret == -1) {
- printf("tc_net_listen_backlog_p: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_listen_backlog_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
- * @fn :tc_net_listen_fd_backlog_n
- * @brief :
- * @scenario :
- * API's covered :listen()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-static void tc_net_listen_fd_backlog_n(void)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof sa);
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(1100);
- sa.sin_addr.s_addr = htonl(INADDR_ANY);
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- int ret = (listen(-1, -1));
- if (ret == 0) {
- printf("tc_net_listen_fd_backlog_n: fail\n");
-
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_listen_fd_backlog_n: PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: listen()
- ****************************************************************************/
-
-int net_listen_main(void)
-{
- tc_net_listen_p();
- tc_net_listen_fd_n();
- tc_net_listen_backlog_p();
- tc_net_listen_fd_backlog_n();
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_recv.c
-// @brief Test Case Example for recv() API
-#include <tinyara/config.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <net/if.h>
-#include <apps/netutils/netlib.h>
-#include "tc_internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include<pthread.h>
-
-#define PORTNUM 1109
-#define MAXRCVLEN 20
-int mutex = 0;
-/**
- * @fn :recv_wait
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void recv_wait(void)
-{
- while (mutex <= 0) {
-
- printf("");
- }
- mutex--;
-}
-
-/**
- * @fn :recv_signal
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void recv_signal(void)
-{
- mutex++;
-}
-
-/**
- * @fn :tc_net_recv_p
- * @brief :
- * @scenario :
- * API's covered :recv()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recv_p(int fd)
-{
- char buffer[MAXRCVLEN];
- int ret = recv(fd, buffer, MAXRCVLEN, 0);
- buffer[ret] = '\0';
- if (ret == -1) {
- printf(" \ntc_net_recv_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recv_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recv_n
- * @brief :
- * @scenario :
- * API's covered :recv
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recv_n(int fd)
-{
- char buffer[MAXRCVLEN];
-
- int ret = recv(-1, buffer, MAXRCVLEN, 0);
- buffer[ret] = '\0';
- if (ret != -1) {
- printf(" \ntc_net_recv_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recv_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recv_shutdown_n
- * @brief :
- * @scenario :
- * API's covered :recv()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recv_shutdown_n(int fd)
-{
- char buffer[MAXRCVLEN];
- shutdown(fd, SHUT_RD);
- int ret = recv(fd, buffer, MAXRCVLEN, 0);
- buffer[ret] = '\0';
- if (ret != -1) {
- printf(" \ntc_net_recv_shutdown_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recv_shutdown_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recv_close_n
- * @brief :
- * @scenario :
- * API's covered :recv()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recv_close_n(int fd)
-{
- char buffer[MAXRCVLEN];
- close(fd);
- int ret = recv(fd, buffer, MAXRCVLEN, 0);
- buffer[ret] = '\0';
- if (ret != -1) {
- printf(" \ntc_net_recv_close_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recv_close_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :recv_server
- * @brief :
- * @scenario :
- * API's covered :socket,bind,listen,accept,send,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *recv_server(void *args)
-{
-
- char *msg = "Hello World !\n";
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 2);
- recv_signal();
- int ConnectFD = accept(SocketFD, NULL, NULL);
- int i;
- for (i = 0; i < 6; i++)
- send(ConnectFD, msg, strlen(msg), 0);
-
- close(ConnectFD);
-
- close(SocketFD);
- return 0;
-
-}
-
-/**
- * @fn :recv_client
- * @brief :
- * @scenario :
- * API's covered :socket,connect,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *recv_client(void *args)
-{
-
- int mysocket;
- struct sockaddr_in dest;
-
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
-
- recv_wait();
-
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
- tc_net_recv_p(mysocket);
- tc_net_recv_n(mysocket);
- tc_net_recv_shutdown_n(mysocket);
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
- tc_net_recv_close_n(mysocket);
- close(mysocket);
- return 0;
-
-}
-
-/****************************************************************************
- * Name: recv()
- ****************************************************************************/
-int net_recv_main(void)
-{
-
- pthread_t Server, Client;
-
- pthread_create(&Server, NULL, recv_server, NULL);
- pthread_create(&Client, NULL, recv_client, NULL);
-
- pthread_join(Server, NULL);
-
- pthread_join(Client, NULL);
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_recvfrom.c
-// @brief Test Case Example for recvfrom() API
-#include <tinyara/config.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <net/if.h>
-#include <apps/netutils/netlib.h>
-#include "tc_internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include<pthread.h>
-
-#define PORTNUM 1111
-#define MAXRCVLEN 20
-int mutex1 = 0;
-/**
- * @fn :tc_net_recvfrom_p
- * @brief :positive testcase using udp
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_p(int fd)
-{
- char buffer[MAXRCVLEN];
- struct sockaddr_storage serverStorage;
- socklen_t addr_size;
- int ret = recvfrom(fd, buffer, MAXRCVLEN, 0, (struct sockaddr *)&serverStorage,
- &addr_size);
-
- if (ret == -1) {
- printf(" \ntc_net_recvfrom_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("\ntc_net_recvfrom_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recvfrom_sock_n
- * @brief :negative testcase using udp
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_sock_n(void)
-{
- char buffer[MAXRCVLEN];
- struct sockaddr_storage serverStorage;
- socklen_t addr_size;
- int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_UDP);
- int ret = recvfrom(fd, buffer, MAXRCVLEN, 0, (struct sockaddr *)&serverStorage,
- &addr_size);
-
- if (ret != -1) {
- printf(" \ntc_net_recvfrom_sock_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("\ntc_net_recvfrom_sock_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recvfrom_n
- * @brief :negative testcase using udp
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_n(int fd)
-{
- char buffer[MAXRCVLEN];
- struct sockaddr_storage serverStorage;
- socklen_t addr_size;
- int ret = recvfrom(-1, buffer, MAXRCVLEN, 0, (struct sockaddr *)&serverStorage,
- &addr_size);
-
- if (ret != -1) {
- printf(" \ntc_net_recvfrom_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("\ntc_net_recvfrom_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :recvfrom_server
- * @brief :udp server
- * @scenario :
- * API's covered :socket,bind
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *recvfrom_udpserver(void *args)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- tc_net_recvfrom_p(SocketFD);
- tc_net_recvfrom_sock_n();
- tc_net_recvfrom_n(SocketFD);
-
- return 0;
-
-}
-
-/**
- * @fn :recvfrom_client
- * @brief :udp client
- * @scenario :
- * API's covered :socket,sendto
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *recvfrom_udpclient(void *args)
-{
-
- int mysocket;
- mysocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
- char *buffer = "hello";
- int len = strlen(buffer) + 1;
- struct sockaddr_in dest;
- socklen_t fromlen;
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
- fromlen = sizeof(dest);
- sendto(mysocket, buffer, len, 0, (struct sockaddr *)&dest, fromlen);
-
- return 0;
-
-}
-
-/**
- * @fn :recvfrom_wait
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void recvfrom_wait(void)
-{
- while (mutex1 <= 0) {
-
- printf("");
- }
- mutex1--;
-}
-
-/**
- * @fn :recvfrom_signal
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void recvfrom_signal(void)
-{
- mutex1++;
-}
-
-/**
- * @fn :tc_net_recvfrom_p
- * @brief :positive testcase for recvfrom api
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_tcp_p(int fd)
-{
- char buffer[MAXRCVLEN];
-
- int ret = recvfrom(fd, buffer, MAXRCVLEN, 0, NULL, NULL);
-
- if (ret == -1) {
- printf(" \ntc_net_recvfrom_tcp_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("\ntc_net_recvfrom_tcp_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recvfrom_tcp_conn_n
- * @brief :negative testcase for recvfrom api
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_tcp_conn_n(int fd)
-{
- char buffer[MAXRCVLEN];
-
- shutdown(fd, SHUT_RD);
- int ret = recvfrom(fd, buffer, MAXRCVLEN, 0, NULL, NULL);
-
- if (ret != -1) {
- printf(" \ntc_net_recvfrom_tcp_conn_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recvfrom_tcp_conn_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recvfrom_tcp_sock_n
- * @brief :negative testcase for recvfrom api
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_tcp_sock_n(int fd)
-{
- char buffer[MAXRCVLEN];
-
- int ret = recvfrom(fd, buffer, MAXRCVLEN, 0, NULL, NULL);
-
- if (ret != -1) {
- printf(" \ntc_net_recvfrom_tcp_sock_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recvfrom_tcp_sock_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_recvfrom_tcp_n
- * @brief :negative testcase using tcp
- * @scenario :
- * API's covered :recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_recvfrom_tcp_n(void)
-{
- char buffer[MAXRCVLEN];
-
- int ret = recvfrom(-1, buffer, MAXRCVLEN, 0, NULL, NULL);
-
- if (ret != -1) {
- printf(" \ntc_net_recvfrom_tcp_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_recvfrom_tcp_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :recvfrom_server
- * @brief :
- * @scenario :
- * API's covered :socket,bind,listen,accept,sendto,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *recvfrom_tcpserver(void *args)
-{
-
- char *msg = "Hello World !\n";
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 1);
- recvfrom_signal();
- int ConnectFD = accept(SocketFD, NULL, NULL);
- int i;
- for (i = 0; i < 4; i++)
- sendto(ConnectFD, msg, strlen(msg), 0, (struct sockaddr *)&sa, sizeof(sa));
-
- close(ConnectFD);
-
- close(SocketFD);
- return 0;
-}
-
-/**
- * @fn :recvfrom_client
- * @brief :
- * @scenario :
- * API's covered :socket,connect,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *recvfrom_tcpclient(void *args)
-{
-
- int mysocket, newsoc;
- struct sockaddr_in dest;
-
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(1111);
-
- recvfrom_wait();
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
-
- tc_net_recvfrom_tcp_p(mysocket);
-
- tc_net_recvfrom_tcp_n();
- tc_net_recvfrom_tcp_sock_n(newsoc);
- tc_net_recvfrom_tcp_conn_n(mysocket);
-
- close(mysocket);
- return 0;
-
-}
-
-/****************************************************************************
- * Name: recvfrom()
- ****************************************************************************/
-int net_recvfrom_main(void)
-{
-
- pthread_t Server, Client, tcpserver, tcpclient;
-
- pthread_create(&Server, NULL, recvfrom_udpserver, NULL);
- pthread_create(&Client, NULL, recvfrom_udpclient, NULL);
-
- pthread_join(Server, NULL);
-
- pthread_join(Client, NULL);
-
- pthread_create(&tcpserver, NULL, recvfrom_tcpserver, NULL);
- pthread_create(&tcpclient, NULL, recvfrom_tcpclient, NULL);
-
- pthread_join(tcpserver, NULL);
-
- pthread_join(tcpclient, NULL);
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_send.c
-// @brief Test Case Example for send() API
-#include <tinyara/config.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <net/if.h>
-#include <apps/netutils/netlib.h>
-#include "tc_internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include<pthread.h>
-
-#define PORTNUM 1110
-#define MAXRCVLEN 20
-int s1 = 0;
-/**
- * @fn :wait1
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void wait1(void)
-{
- while (s1 <= 0) {
-
- printf("");
- }
- s1--;
-}
-
-/**
- * @fn :signal1
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void signal1(void)
-{
- s1++;
-}
-
-/**
- * @fn :tc_net_send_p
- * @brief :
- * @scenario :
- * API's covered :accept(),send()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_send_p(int fd)
-{
-
- char *msg = "Hello World !\n";
- int ConnectFD = accept(fd, NULL, NULL);
- int ret = send(ConnectFD, msg, strlen(msg), 0);
- if (ret == -1) {
- printf(" \ntc_net_send_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_send_p:PASS\n");
- nw_total_pass++;
- close(ConnectFD);
-
-}
-
-/**
- * @fn :server
- * @brief :
- * @scenario :
- * API's covered :socket,bind,listen,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *server(void *args)
-{
-
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 2);
-
- signal1();
- tc_net_send_p(SocketFD);
-
- close(SocketFD);
- return 0;
-}
-
-/**
- * @fn :client
- * @brief :
- * @scenario :
- * API's covered :socket,connect,recv,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *client(void *args)
-{
-
- char buffer[MAXRCVLEN];
- int len, mysocket;
- struct sockaddr_in dest;
-
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
-
- wait1();
-
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
- len = recv(mysocket, buffer, MAXRCVLEN, 0);
- buffer[len] = '\0';
-
- close(mysocket);
- return 0;
-
-}
-
-/****************************************************************************
- * Name: send()
- ****************************************************************************/
-int net_send_main(void)
-{
-
- pthread_t Server, Client;
-
- pthread_create(&Server, NULL, server, NULL);
- pthread_create(&Client, NULL, client, NULL);
-
- pthread_join(Server, NULL);
-
- pthread_join(Client, NULL);
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_sendto.c
-// @brief Test Case Example for sendto() API
-#include <tinyara/config.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <net/if.h>
-#include <apps/netutils/netlib.h>
-#include "tc_internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include<pthread.h>
-
-#define PORTNUM 7891
-#define TCPPORT 7890
-#define MAXRCVLEN 20
-int sp = 0;
-void tc_net_sendto_tcp_n(int ConnectFD);
-void tc_net_sendto_tcp_shutdown_n(int ConnectFD);
-/**
- * @fn :tc_net_sendto_p
- * @brief :positive testcase for sendto api using udp
- * @scenario :
- * API's covered :sendto
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_p(int fd)
-{
- char *buffer = "hello";
- int len = strlen(buffer) + 1;
- struct sockaddr_in dest;
- socklen_t fromlen;
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
- fromlen = sizeof(dest);
- int ret = sendto(fd, buffer, len, 0, (struct sockaddr *)&dest, fromlen);
- if (ret == -1) {
- printf(" \ntc_net_sendto_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_sendto_n
- * @brief :negative testcase for sendto api using udp
- * @scenario :
- * API's covered :sendto
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_n(void)
-{
- char *buffer = "hello";
- int len = strlen(buffer) + 1;
- struct sockaddr_in dest;
- socklen_t fromlen;
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
- fromlen = sizeof(dest);
- int ret = sendto(-1, buffer, len, 0, (struct sockaddr *)&dest, fromlen);
- if (ret != -1) {
- printf(" \ntc_net_sendto_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_sendto_af_unix_n
- * @brief :negative testcase for sendto api using udp
- * @scenario :
- * API's covered :sendto
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_af_unix_n(int fd)
-{
- char *buffer = "hello";
- int len = strlen(buffer) + 1;
- struct sockaddr_in dest;
- socklen_t fromlen;
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = AF_UNIX;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
- fromlen = sizeof(dest);
- int ret = sendto(fd, buffer, len, 0, (struct sockaddr *)&dest, fromlen);
- if (ret != -1) {
- printf(" \ntc_net_sendto_af_unix_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_af_unix_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_sendto_shutdown_n
- * @brief :negative testcase for sendto api using udp
- * @scenario :
- * API's covered :sendto
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_shutdown_n(int fd)
-{
- char *buffer = "hello";
- int len = strlen(buffer) + 1;
- struct sockaddr_in dest;
- socklen_t fromlen;
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = AF_UNIX;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
- fromlen = sizeof(dest);
- shutdown(fd, SHUT_WR);
- int ret = sendto(fd, buffer, len, 0, (struct sockaddr *)&dest, fromlen);
- if (ret != -1) {
- printf(" \ntc_net_sendto_shutdown_n FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_shutdown_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :sendto_server
- * @brief :udp server
- * @scenario :
- * API's covered :socket,bind,recvfrom
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-
-void *sendto_udpserver(void *args)
-{
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
- char buffer[MAXRCVLEN];
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
- struct sockaddr_storage serverStorage;
- socklen_t addr_size;
-
- recvfrom(SocketFD, buffer, MAXRCVLEN, 0, (struct sockaddr *)&serverStorage, &addr_size);
-
- return 0;
-
-}
-
-/**
- * @fn :sendto_client
- * @brief :udp client
- * @scenario :
- * API's covered :socket
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *sendto_udpclient(void *args)
-{
- int mysocket;
- mysocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
- tc_net_sendto_p(mysocket);
- tc_net_sendto_n();
- tc_net_sendto_af_unix_n(mysocket);
- tc_net_sendto_shutdown_n(mysocket);
-
- return 0;
-
-}
-
-/**
- * @fn :sendto_wait
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void sendto_wait(void)
-{
- while (sp <= 0) {
-
- printf("");
- }
- sp--;
-}
-
-/**
- * @fn :sendto_signal
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void sendto_signal(void)
-{
- sp++;
-}
-
-/**
- * @fn :tc_net_sendto_p
- * @brief :positive testcase for sendto api using tcp
- * @scenario :
- * API's covered :accept,sendto
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_tcp_p(int fd)
-{
-
- char *msg = "Hello World !\n";
- socklen_t fromlen = 0;
- int ConnectFD = accept(fd, NULL, NULL);
- int ret = sendto(ConnectFD, msg, strlen(msg), 0, NULL, fromlen);
- if (ret == -1) {
- printf(" \ntc_net_sendto_tcp_p FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_tcp_p:PASS\n");
- nw_total_pass++;
- tc_net_sendto_tcp_n(ConnectFD);
- tc_net_sendto_tcp_shutdown_n(ConnectFD);
-
-}
-
-/**
- * @fn :tc_net_sendto_n
- * @brief :negative testcase for sendto api using tcp
- * @scenario :
- * API's covered :sendto,close
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_tcp_n(int ConnectFD)
-{
-
- char *msg = "Hello World !\n";
- socklen_t fromlen = 0;
-
- int ret = sendto(-1, msg, strlen(msg), 0, NULL, fromlen);
- if (ret != -1) {
- printf(" \ntc_net_sendto_tcp_n: FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_tcp_n:PASS\n");
- nw_total_pass++;
- close(ConnectFD);
-
-}
-
-/**
- * @fn :tc_net_sendto_tcp_shutdown_n
- * @brief :negative testcase for sendto api using tcp
- * @scenario :
- * API's covered :sendto,close
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_sendto_tcp_shutdown_n(int ConnectFD)
-{
-
- char *msg = "Hello World !\n";
- socklen_t fromlen = 0;
- shutdown(ConnectFD, SHUT_WR);
- int ret = sendto(ConnectFD, msg, strlen(msg), 0, NULL, fromlen);
- if (ret != -1) {
- printf(" \ntc_net_sendto_tcp_shutdown_n: FAIL\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_sendto_tcp_shutdown_n:PASS\n");
- nw_total_pass++;
- close(ConnectFD);
-
-}
-
-/**
- * @fn :sendto_server
- * @brief :tcp server
- * @scenario :
- * API's covered :socket,bind,listen,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-
-void *sendto_tcpserver(void *args)
-{
-
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(TCPPORT);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 2);
-
- sendto_signal();
- tc_net_sendto_tcp_p(SocketFD);
-
- close(SocketFD);
- pthread_exit(NULL);
-
-}
-
-/**
- * @fn :sendto_client
- * @brief :tcp client
- * @scenario :
- * API's covered :socket,connect,recvfrom,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *sendto_tcpclient(void *args)
-{
-
- char buffer[MAXRCVLEN];
- int len, mysocket;
- struct sockaddr_in dest;
-
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(TCPPORT);
-
- sendto_wait();
-
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
- while ((len = recvfrom(mysocket, buffer, MAXRCVLEN, 0, NULL, NULL)) > 0) {
- buffer[len] = '\0';
- }
-
- close(mysocket);
- pthread_exit(NULL);
-
-}
-
-/****************************************************************************
- * Name: sendto()
- ****************************************************************************/
-
-int net_sendto_main(void)
-{
-
- pthread_t Server, Client, tcpserver, tcpclient;
-
- pthread_create(&Server, NULL, sendto_udpserver, NULL);
- pthread_create(&Client, NULL, sendto_udpclient, NULL);
- pthread_create(&tcpserver, NULL, sendto_tcpserver, NULL);
- pthread_create(&tcpclient, NULL, sendto_tcpclient, NULL);
-
- pthread_join(Server, NULL);
-
- pthread_join(Client, NULL);
- pthread_join(tcpserver, NULL);
-
- pthread_join(tcpclient, NULL);
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_setsockopt.c
-/// @brief Test Case Example for setsockopt() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-
-/**
-* @fn :tc_net_setsockopt_multicast_ttl_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_multicast_ttl_p(int s)
-{
- int ret = -1;
- u8_t optval = 1;
- ret = setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &optval, sizeof(optval));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_multicast_ttl_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_ttl_p: PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_multicast_ttl_loop_own_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_multicast_ttl_loop_own_p(int s)
-{
- int ret = -1;
- u8_t loop = 1;
- ret = setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_multicast_ttl_loop_own_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_ttl_loop_own_p: PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_multicast_ttl_loop_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_multicast_ttl_loop_p(int s)
-{
- int ret = -1;
- u8_t loop = 250;
- ret = setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_multicast_ttl_loop_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_ttl_loop_p: PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_multicast_if_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor, ipv4 addr
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_multicast_if_p(int s, const char *my_ipv4addr)
-{
- int ret = -1;
- struct sockaddr_in interface_addr;
- interface_addr.sin_addr.s_addr = inet_addr(my_ipv4addr);
-
- ret = setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &interface_addr, sizeof(interface_addr));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_multicast_if_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_if_p: PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_multicast_add_group_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor, group ipv4 addr
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_multicast_add_group_p(int s,
- const char *group_ipv4addr)
-{
- int ret = -1;
- struct ip_mreq mreq;
-
- mreq.imr_multiaddr.s_addr = inet_addr(group_ipv4addr);
- //mreq.imr_interface.s_addr=htonl(INADDR_ANY);
- ret = setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
-
- if (ret < 0)
- {
- printf("tc_net_setsockopt_multicast_add_group_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_add_group_p: PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_multicast_drop_group_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor, group ipv4 addr
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_multicast_drop_group_p(int s,
- const char *group_ipv4addr)
-{
- int ret = -1;
- struct ip_mreq mreq;
-
- mreq.imr_multiaddr.s_addr = inet_addr(group_ipv4addr);
- mreq.imr_interface.s_addr = htonl(INADDR_ANY);
- ret = setsockopt(s, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
-
- if (ret < 0)
- {
- printf("tc_net_setsockopt_multicast_add_group_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_add_group_p: PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_multicast_tcp_nodelay_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_multicast_tcp_nodelay_p(int s)
-{
- int ret = -1;
- int option = 1;
-
- ret = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(option));
-
- if (ret < 0) {
- printf("tc_net_setsockopt_multicast_tcp_nodelay_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_tcp_nodelay_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_multicast_tcp_keepalive_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_multicast_tcp_keepalive_p(int s)
-{
- int ret = -1;
- int option = 1;
-
- ret = setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE, &option, sizeof(option));
-
- if (ret < 0) {
- printf("tc_net_setsockopt_multicast_tcp_keepalive_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_tcp_keepalive_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_multicast_tcp_keepidle_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_multicast_tcp_keepidle_p(int s)
-{
- int ret = -1;
- int keepidle = 30;
-
- ret = setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE, &keepidle, sizeof(keepidle));
-
- if (ret < 0) {
- printf("tc_net_setsockopt_multicast_tcp_keepidle_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_tcp_keepidle_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_multicast_tcp_keepintvl_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_multicast_tcp_keepintvl_p(int s)
-{
- int ret = -1;
- int keepintvl = 120;
-
- ret = setsockopt(s, IPPROTO_TCP, TCP_KEEPINTVL, &keepintvl, sizeof(keepintvl));
-
- if (ret < 0) {
- printf("tc_net_setsockopt_multicast_tcp_keepintvl_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_tcp_keepintvl_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_multicast_tcp_keepcnt_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_multicast_tcp_keepcnt_p(int s)
-{
- int ret = -1;
- int keepcnt = 5;
-
- ret = setsockopt(s, IPPROTO_TCP, TCP_KEEPCNT, &keepcnt, sizeof(keepcnt));
-
- if (ret < 0) {
- printf("tc_net_setsockopt_multicast_tcp_keepcnt_p: SETSOCKOPT Multicast failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_multicast_tcp_keepcnt_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_ip_tos_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_ip_tos_p(int s)
-{
- int ret = -1;
- int optval = 1;
-
- ret = setsockopt(s, IPPROTO_IP, IP_TOS, &optval, sizeof(optval));
- if (ret < 0) {
- printf("tc_net_setsockopt_ip_tos_p FAIL: setopt IP_TOS failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_ip_tos_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_ip_ttl_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_ip_ttl_p(int s)
-{
- int ret = -1;
- int optval = 1;
-
- ret = setsockopt(s, IPPROTO_IP, IP_TTL, &optval, sizeof(optval));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_ip_ttl_p FAIL: setopt SO_IP_TTL failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_ip_ttl_p PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_no_check_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_no_check_p(int s)
-{
- int ret = -1;
- int optval = 1;
-
- ret = setsockopt(s, SOL_SOCKET, SO_NO_CHECK, &optval, sizeof(optval));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_no_check_p FAIL: setopt SO_NO_CHECK failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_no_check_p PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_broadcast_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_broadcast_p(int s)
-{
- int ret = 0;
- int optval = 1; //broadcast value
-
- ret = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof optval);
- if (ret < 0) {
- printf("tc_net_setsockopt_broadcast_p FAIL: Data BROADCASTING failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- printf("tc_net_setsockopt_broadcast_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_sndtimo_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_sndtimo_p(int s)
-{
- int ret = -1;
- struct timeval timeout;
- timeout.tv_sec = 10;
- timeout.tv_usec = 0;
-
- ret = setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
- if (ret < 0)
- {
- printf("tc_net_setsockopt_sndtimo_p FAIL: setopt SO_SNDTIMO failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_sndtimo_p PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_rcvtimo_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_rcvtimo_p(int s)
-{
- int ret = -1;
- struct timeval tv;
- tv.tv_sec = 1;
- tv.tv_usec = 0;
-
- ret = setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&tv, sizeof(struct timeval));
- if (ret < 0) {
- printf("tc_net_setsockopt_rcvtimo_p FAIL: setopt SO_RCVTIMO failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_rcvtimo_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_reuseaddr_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_reuseaddr_p(int s)
-{
- int ret = -1;
- int option = 1;
-
- ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&option, sizeof option);
- if (ret < 0) {
- printf("tc_net_setsockopt_reuseaddr_p FAIL: setopt SO_REUSEADDR failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_reuseaddr_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_reuseport_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_reuseport_p(int s)
-{
- int ret = -1;
- int option = 1;
-
- ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, (char *)&option, sizeof option);
- if (ret < 0) {
- printf("tc_net_setsockopt_reuseport_p FAIL: setopt SO_REUSEPORT failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_reuseport_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_rcvbuf_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-/*
-static void tc_net_setsockopt_rcvbuf_p(int s)
-{
- int ret = -1;
- int size = 1000;
-
- ret = setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, size);
- if (ret < 0)
- {
- printf("tc_net_setsockopt_rcvbuf_p FAIL: setopt SO_RCVBUF failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_rcvbuf_p PASS\n");
- nw_total_pass++;
-}
-*/
-/**
-* @fn :tc_net_setsockopt_keepalive_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_keepalive_p(int s)
-{
- int ret = -1;
- int optval = 1;
-
- ret = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof optval);
- if (ret < 0) {
- printf("tc_net_setsockopt_keepalive_p FAIL: setopt KEEPALIVE failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_keepalive_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_ipproto_ip_ip_pktinfo_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-
-static void tc_net_setsockopt_ipproto_ip_ip_pktinfo_p(int s)
-{
- int ret = -1;
- int optval=1;
-
- ret = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &optval, sizeof(optval));;
- if(ret < 0) {
- printf("tc_net_setsockopt_ipproto_ip_ip_pktinfo_p FAIL: setopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_ipproto_ip_ip_pktinfo_p PASS\n");
- nw_total_pass++;
-}*/
-
-/**
-* @fn :tc_net_setsockopt_sol_socket_timestamping_p
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-
-static void tc_net_setsockopt_sol_socket_timestamping_p(fd)
-{
- int ret = -1;
- int optval=1;
-
- ret = setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &optval, sizeof(optval));
- if(ret < 0) {
- printf("tc_net_setsockopt_sol_socket_timestamping_p FAIL: setopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_sol_socket_timestamping_p PASS\n");
- nw_total_pass++;
-}*/
-
-/**
-* @fn :tc_net_setsockopt_bad_filedesc_n
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_bad_filedesc_n(void)
-{
- int ret = -1;
- // int optval=1;
-
- ret = setsockopt(-1, SOL_SOCKET, 0, 0, 0);
- if (ret != -1) {
- printf("tc_net_setsockopt_bad_filedesc_n FAIL: setopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_bad_filedesc_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_invalid_filedesc_n
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_invalid_filedesc_n(void)
-{
- int ret = -1;
- // int optval=1;
-
- ret = setsockopt(0, SOL_SOCKET, 0, 0, 0);
- if (ret != -1) {
- printf("tc_net_setsockopt_invalid_filedesc_n FAIL: setopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_invalid_filedesc_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_invalid_level_n
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-*/
-static void tc_net_setsockopt_invalid_level_n(int s)
-{
- int ret = -1;
- //int optval=1;
-
- ret = setsockopt(s, -1, 0, 0, 0);
- if (ret != -1) {
- printf("tc_net_setsockopt_invalid_level_n FAIL: setopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_invalid_level_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_setsockopt_invalid_opt_name_n
-* @brief :
-* @Scenario :
-* @API's covered :setsockopt()
-* Preconditions :socket file descriptor
-* Postconditions :
-* @return :void
-
-static void tc_net_setsockopt_invalid_opt_name_n(int s)
-{
- int ret = -1;
- //int optval=1;
-
- ret = setsockopt(s, SOL_SOCKET, SCTP_AUTOCLOSE, 0, 0);
- if(ret != -1) {
- printf("tc_net_setsockopt_invalid_opt_name_n FAIL: setopt KEEPALIVE failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf("tc_net_setsockopt_invalid_opt_name_n PASS\n");
- nw_total_pass++;
-}*/
-
-/****************************************************************************
- * Name: setsockopt()
- ****************************************************************************/
-
-int net_setsockopt_main(void)
-{
- int fd = -1;
- //char *mip = "239.255.255.255";
- //char *ip = "192.168.1.100";
-
- fd = socket(AF_INET, SOCK_STREAM, 0);
-
- //tc_net_setsockopt_invalid_opt_name_n(fd);
- tc_net_setsockopt_invalid_level_n(fd);
- tc_net_setsockopt_invalid_filedesc_n();
- tc_net_setsockopt_bad_filedesc_n();
- //tc_net_setsockopt_sol_socket_timestamping_p(fd);
- //tc_net_setsockopt_ipproto_ip_ip_pktinfo_p(fd);
- tc_net_setsockopt_keepalive_p(fd);
- //tc_net_setsockopt_rcvbuf_p(fd);
- tc_net_setsockopt_reuseport_p(fd);
- tc_net_setsockopt_reuseaddr_p(fd);
- tc_net_setsockopt_rcvtimo_p(fd);
- //tc_net_setsockopt_sndtimo_p(fd);
- tc_net_setsockopt_broadcast_p(fd);
- //tc_net_setsockopt_no_check_p(fd);
- //tc_net_setsockopt_ip_ttl_p(fd);
- tc_net_setsockopt_ip_tos_p(fd);
- tc_net_setsockopt_multicast_tcp_keepcnt_p(fd);
- tc_net_setsockopt_multicast_tcp_keepintvl_p(fd);
- tc_net_setsockopt_multicast_tcp_keepidle_p(fd);
- tc_net_setsockopt_multicast_tcp_keepalive_p(fd);
- tc_net_setsockopt_multicast_tcp_nodelay_p(fd);
- //tc_net_setsockopt_multicast_drop_group_p(fd,mip);
- //tc_net_setsockopt_multicast_add_group_p(fd,mip);
- //tc_net_setsockopt_multicast_if_p(fd,ip);
- //tc_net_setsockopt_multicast_ttl_loop_p(fd);
- //tc_net_setsockopt_multicast_ttl_loop_own_p(fd);
- //tc_net_setsockopt_multicast_ttl_p(fd);
-
- close(fd);
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-// @file tc_net_shutdown.c
-// @brief Test Case Example for shutdown() API
-#include <tinyara/config.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <net/if.h>
-#include <apps/netutils/netlib.h>
-#include "tc_internal.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include<pthread.h>
-
-#define PORTNUM 1112
-#define MAXRCVLEN 20
-int mut = 0;
-/**
- * @fn :shutdown_wait
- * @brief :function to wait on semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void shutdown_wait(void)
-{
- while (mut <= 0) {
-
- printf("");
- }
- mut--;
-}
-
-/**
- * @fn :shutdown_signal
- * @brief :function to signal semaphore
- * @scenario :
- * API's covered :
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void shutdown_signal(void)
-{
- mut++;
-}
-
-/**
- * @fn :tc_net_shutdown_recv_p
- * @brief :
- * @scenario :
- * API's covered :shutdown()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_shutdown_recv_p(int fd)
-{
- int ret = shutdown(fd, SHUT_RD);
- if (ret == -1) {
-
- printf(" \ntc_net_shutdown_recv_p:FAIL %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_shutdown_recv_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_shutdown_send_p
- * @brief :
- * @scenario :
- * API's covered :shutdown()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_shutdown_send_p(int fd)
-{
- char *msg = "Hello World !\n";
- int ret = shutdown(fd, SHUT_WR);
-
- if (ret == -1) {
-
- printf(" \ntc_net_shutdown_send_p:FAIL %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- printf(" \ntc_net_shutdown_send_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_shutdown_sendrecv_p
- * @brief :
- * @scenario :
- * API's covered :shutdown()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_shutdown_sendrecv_p(int fd)
-{
- int ret = shutdown(fd, SHUT_RDWR);
- if (ret == -1) {
-
- printf(" \ntc_net_shutdown_sendrecv_p:FAIL %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_shutdown_sendrecv_p:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_shutdown_n
- * @brief :
- * @scenario :
- * API's covered :shutdown()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_shutdown_n(void)
-{
- int ret = shutdown(-1, SHUT_RDWR);
- if (ret != -1) {
-
- printf(" \ntc_net_shutdown_n:FAIL %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_shutdown_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :tc_net_shutdown_sock_n
- * @brief :
- * @scenario :
- * API's covered :shutdown()
- * Preconditions :
- * Postconditions :
- * @return :void
- */
-void tc_net_shutdown_sock_n(int fd)
-{
- int ret = shutdown(fd, SHUT_RD);
- if (ret != -1) {
-
- printf(" \ntc_net_shutdown_sock_n:FAIL %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- printf(" \ntc_net_shutdown_sock_n:PASS\n");
- nw_total_pass++;
-
-}
-
-/**
- * @fn :shutdown_server
- * @brief :
- * @scenario :
- * API's covered :socket,bind,listen,send,accept,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *shutdown_server(void *args)
-{
- char *msg = "Hello World !\n";
- struct sockaddr_in sa;
- int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&sa, 0, sizeof(sa));
-
- sa.sin_family = PF_INET;
- sa.sin_port = htons(PORTNUM);
- sa.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- bind(SocketFD, (struct sockaddr *)&sa, sizeof(sa));
-
- listen(SocketFD, 1);
-
- shutdown_signal();
-
- int ConnectFD = accept(SocketFD, NULL, NULL);
- tc_net_shutdown_send_p(ConnectFD);
- int val = send(ConnectFD, msg, strlen(msg), 0);
- if (val == -1)
- printf("\nShutdown send successful %d\n", errno);
- tc_net_shutdown_recv_p(ConnectFD);
- val = recv(ConnectFD, msg, 1024, 0);
- if (val == -1)
- printf("\nShutdown recv successful %d\n", errno);
- tc_net_shutdown_n();
- tc_net_shutdown_sock_n(SocketFD);
- close(ConnectFD);
- close(SocketFD);
-
- return 0;
-
-}
-
-/**
- * @fn :shut_client
- * @brief :
- * @scenario :
- * API's covered :socket,connect,recvfrom,close
- * Preconditions :
- * Postconditions :
- * @return :void *
- */
-void *shutdown_client(void *args)
-{
- char buffer[MAXRCVLEN];
- int len, mysocket;
- struct sockaddr_in dest;
-
- mysocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- memset(&dest, 0, sizeof(dest));
- dest.sin_family = PF_INET;
- dest.sin_addr.s_addr = inet_addr("127.0.0.1");
- dest.sin_port = htons(PORTNUM);
-
- shutdown_wait();
-
- connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
- len = recv(mysocket, buffer, MAXRCVLEN, 0);
- buffer[len] = '\0';
- tc_net_shutdown_recv_p(mysocket);
- int val = recv(mysocket, buffer, MAXRCVLEN, 0);
- if (val == -1)
- printf("\nShutdown recv successful %d\n", errno);
- tc_net_shutdown_sendrecv_p(mysocket);
- val = recv(mysocket, buffer, MAXRCVLEN, 0);
- if (val == -1)
- printf("\nShutdown recv successful %d\n", errno);
- val = send(mysocket, buffer, strlen(buffer), 0);
- if (val == -1)
- printf("\nShutdown recv successful %d\n", errno);
- tc_net_shutdown_n();
- close(mysocket);
- return 0;
-
-}
-
-/****************************************************************************
- * Name: shutdown()
- ****************************************************************************/
-int net_shutdown_main(void)
-{
-
- pthread_t Server, Client;
-
- pthread_create(&Server, NULL, shutdown_server, NULL);
- pthread_create(&Client, NULL, shutdown_client, NULL);
-
- pthread_join(Server, NULL);
-
- pthread_join(Client, NULL);
-
- return 0;
-}
+++ /dev/null
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ****************************************************************************/
-
-/// @file tc_net_socket.c
-/// @brief Test Case Example for socket() API
-#include <tinyara/config.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-//#include <arch/board/board.h>
-#include <apps/netutils/netlib.h>
-
-#include <sys/socket.h>
-
-#include "tc_internal.h"
-
-/**
-* @fn :tc_net_socket_pf_inet_sock_raw_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_pf_inet_sock_raw_p(void)
-{
- int fd = -1;
- fd = socket(PF_INET, SOCK_RAW, 0);
- if (fd < 0) {
- printf("tc_net_socket_pf_inet_sock_raw_p FAIL: TCP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_pf_inet_sock_raw_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_dgram_p FAIL: TCP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_pf_inet_sock_dgram_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_pf_inet_sock_dgram_p(void)
-{
- int fd = -1;
- fd = socket(PF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_pf_inet_sock_dgram_p FAIL: TCP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_pf_inet_sock_dgram_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_pf_inet_sock_stream_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_pf_inet_sock_stream_p(void)
-{
-
- int fd = -1;
- fd = socket(PF_INET, SOCK_STREAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_pf_inet_sock_stream_p FAIL: TCP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_pf_inet_sock_stream_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_tcp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_tcp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_TCP);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_dgram_tcp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_tcp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_udp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_udp_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_dgram_udp_p FAIL: UDP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_udp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_soc_dgram_icmp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_soc_dgram_icmp_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_soc_dgram_icmp_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_soc_dgram_icmp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_igmp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_igmp_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IGMP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_dgram_igmp_p: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_igmp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_ipv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_ipv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_dgram_ipv6_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_ipv6_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_routing_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_routing_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ROUTING);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_dgram_routing_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_routing_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_fragment_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_fragment_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_FRAGMENT);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_dgram_fragment_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_fragment_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_dgram_icmpv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_dgram_icmpv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_dgram_icmpv6_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_dgram_icmpv6_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_tcp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_tcp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_TCP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_dgram_tcp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_tcp_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_udp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_udp_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_UDP);
- if (fd < 0) {
- printf("tc_net_socket_af_unix_sock_dgram_udp_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_udp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_icmp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_icmp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_ICMP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_dgram_icmp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_icmp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_igmp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_igmp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_IGMP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_dgram_igmp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_igmp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_x25_sock_stream_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_x25_sock_stream_n(void)
-{
- int fd = -1;
- fd = socket(AF_X25, SOCK_STREAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_x25_sock_stream_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_x25_sock_stream_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_ax25_sock_stream_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_ax25_sock_stream_n(void)
-{
- int fd = -1;
- fd = socket(AF_AX25, SOCK_STREAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_ax25_sock_stream_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_ax25_sock_stream_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_packet_sock_stream_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_packet_sock_stream_n(void)
-{
- int fd = -1;
- fd = socket(AF_PACKET, SOCK_STREAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_packet_sock_stream_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_packet_sock_stream_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_p(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_unix_sock_stream_p: TCP socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_tcp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_tcp_p(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_TCP);
- if (fd < 0) {
- printf("tc_net_socket_af_unix_sock_stream_tcp_p: TCP socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_tcp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_udp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_udp_n(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_UDP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_stream_udp_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_udp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_icmp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_icmp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_ICMP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_stream_icmp_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_icmp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_igmp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_igmp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_IGMP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_stream_igmp_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_igmp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_ipv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_ipv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_IPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_stream_ipv6_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_ipv6_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unixsock_stream_routing_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unixsock_stream_routing_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_ROUTING);
- if (fd != -1) {
- printf("tc_net_socket_af_unixsock_stream_routing_n: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unixsock_stream_routing_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_stream_icmpv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_stream_icmpv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, IPPROTO_ICMPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_stream_icmpv6_n: \n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_stream_icmpv6_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_netlink_sock_stream_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_netlink_sock_stream_n(void)
-{
- int fd = -1;
- fd = socket(AF_NETLINK, SOCK_STREAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_netlink_sock_stream_n: failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_netlink_sock_stream_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unspec_sock_stream_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unspec_sock_stream_p(void)
-{
- int fd = -1;
- fd = socket(AF_UNSPEC, SOCK_STREAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_unspec_sock_stream_p: socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unspec_sock_stream_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_tcp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_tcp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_stream_tcp_p: TCP IPPROTO_TCP failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_tcp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_protocol_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_protocol_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 256);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_protocol_n: TCP socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_protocol_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_domain_sock_stream_protocol_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_domain_sock_stream_protocol_n(void)
-{
-
- int fd = -1;
- fd = socket(30, SOCK_STREAM, 256);
- if (fd != -1) {
- printf("tc_net_socket_domain_sock_stream_protocol_n: TCP socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_domain_sock_stream_protocol_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_type_protocol_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_type_protocol_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, 7, 256);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_type_protocol_n: TCP socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_type_protocol_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_domain_type_protocol_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_domain_type_protocol_n(void)
-{
- int fd = -1;
- fd = socket(13, 6, 256);
- if (fd != -1) {
- printf("tc_net_socket_domain_type_protocol_n: TCP socket failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_domain_type_protocol_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_domain_sock_stream_tcp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_domain_sock_stream_tcp_n(void)
-{
- int fd = -1;
- fd = socket(40, SOCK_STREAM, IPPROTO_TCP);
- if (fd != -1) {
- printf("tc_net_socket_domain_sock_stream_tcp_n: IPPROTO_TCP failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_domain_sock_stream_tcp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_udp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_udp_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_UDP);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_udp_n: IPPROTO_UDP failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_udp_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_icmp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_icmp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_ICMP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_stream_icmp_p: TCP IPPROTO_ICMP failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_icmp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_igmp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_igmp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IGMP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_stream_igmp_p: TCP IPPROTO_IGMP failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_igmp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_protoipv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_protoipv6_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_protoipv6_n: TCP IPPROTO_IPV6 failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_protoipv6_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_routing_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_routing_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_ROUTING);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_stream_routing_p: TCP IPPROTO_ROUTING failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_routing_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_fragment_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_fragment_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_FRAGMENT);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_stream_fragment_p: TCP IPPROTO_FRAGMENT failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_fragment_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_icmpv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_icmpv6_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_ICMPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_icmpv6_n: TCP IPPROTO_ICMPV6 failure fd = %d err=%d\n", fd, errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_icmpv6_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet6_sock_stream_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet6_sock_stream_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET6, SOCK_STREAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_inet6_sock_stream_p: TCP AF_INET6\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet6_sock_stream_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_type_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_type_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, 5, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_type_n: TCP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_type_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_domain_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_domain_n(void)
-{
- int fd = -1;
- fd = socket(12, SOCK_STREAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_domain_n: TCP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_domain_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_domain_protocol_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_domain_protocol_n(void)
-{
- int fd = -1;
- fd = socket(15, SOCK_STREAM, 289);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_domain_protocol_n: TCP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_domain_protocol_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_type_protocol_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_type_protocol_n(void)
-{
- int fd = -1;
- fd = socket(AF_INET, 7, 300);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_stream_type_protocol_n: TCP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_type_protocol_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_stream_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_stream_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_stream_p: TCP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_stream_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_invalid_domain_sock_stream_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_invalid_domain_sock_stream_n(void)
-{
- int fd = -1;
- fd = socket(-1, SOCK_STREAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_invalid_domain_sock_stream_n: TCP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_invalid_domain_sock_stream_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_ipv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_ipv6_n(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_IPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_dgram_ipv6_n: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_ipv6_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_routing_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_routing_n(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_ROUTING);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_dgram_routing_n FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_routing_n: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_fragment_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_fragment_p(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_FRAGMENT);
- if (fd < 0) {
- printf("tc_net_socket_af_unix_sock_dgram_fragment_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_fragment_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_dgram_icmpv6
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_dgram_icmpv6_n(void)
-{
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_ICMPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_dgram_icmpv6_n FAIL: UDP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_unix_sock_dgram_icmpv6_n : PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_netlink_sock_dgram_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_netlink_sock_dgram_p(void)
-{
- int fd = -1;
- fd = socket(AF_NETLINK, SOCK_DGRAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_netlink_sock_dgram_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_netlink_sock_dgram_p:PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unspec_sock_dgram_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unspec_sock_dgram_p(void)
-{
- int fd = -1;
- fd = socket(AF_UNSPEC, SOCK_DGRAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_unspec_sock_dgram_p FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_unspec_sock_dgram_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_local_sock_dgram_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_local_sock_dgram_p(void)
-{
- int fd = -1;
- fd = socket(AF_LOCAL, SOCK_DGRAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_local_sock_dgram_p: UDP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_local_sock_dgram_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_x25_sock_dgram_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_x25_sock_dgram_n(void)
-{
- int fd = -1;
- fd = socket(AF_X25, SOCK_DGRAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_x25_sock_dgram_n FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_x25_sock_dgram_n:PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_ax25_sock_dgram_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_ax25_sock_dgram_n(void)
-{
- int fd = -1;
- fd = socket(AF_AX25, SOCK_DGRAM, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_ax25_sock_dgram_n FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_ax25_sock_dgram_n:PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_packet_sock_dgram_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_packet_sock_dgram_p(void)
-{
- int fd = -1;
- fd = socket(AF_PACKET, SOCK_DGRAM, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_packet_sock_dgram_p FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_packet_sock_dgram_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, 0);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_p FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_p:PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_tcp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_tcp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_tcp_p FAIL: UDP socket create failure %d\n", errno);
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_tcp_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_udp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-
-static void tc_net_socket_af_inet_sock_raw_udp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_udp_p FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_udp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_icmp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_icmp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_icmp_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_icmp_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_igmp_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_igmp_p(void)
-{
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_igmp_p FAIL: UDP socket create failure \n");
- nw_total_fail++;
- RETURN_ERR;
- }
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_igmp_p: PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_ipv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_ipv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_IPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_raw_ipv6_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_ipv6_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_routing_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_routing_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_ROUTING);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_routing_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_routing_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_fragment_p
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_fragment_p(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_FRAGMENT);
- if (fd < 0) {
- printf("tc_net_socket_af_inet_sock_raw_fragment_p FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_fragment_p PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_inet_sock_raw_icmpv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_inet_sock_raw_icmpv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_inet_sock_raw_icmpv6_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_inet_sock_raw_icmpv6_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, 0);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_tcp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_tcp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_TCP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_tcp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_tcp_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_udp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_udp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_UDP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_udp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_udp_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_icmp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_icmp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_ICMP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_icmp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_icmp_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_igmp_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_igmp_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_IGMP);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_igmp_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_igmp_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_ipv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_ipv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_IPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_ipv6_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_ipv6_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_routing_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_routing_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_ROUTING);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_routing_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_routing_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_frag_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_fragment_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_FRAGMENT);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_frag_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_frag_n PASS\n");
- nw_total_pass++;
-}
-
-/**
-* @fn :tc_net_socket_af_unix_sock_raw_icmpv6_n
-* @brief :
-* @scenario :
-* API's covered :socket()
-* Preconditions :
-* Postconditions :
-* @return :void
-*/
-static void tc_net_socket_af_unix_sock_raw_icmpv6_n(void)
-{
-
- int fd = -1;
- fd = socket(AF_UNIX, SOCK_RAW, IPPROTO_ICMPV6);
- if (fd != -1) {
- printf("tc_net_socket_af_unix_sock_raw_icmpv6_n FAIL: UDP socket create failure\n");
- nw_total_fail++;
- RETURN_ERR;
- }
-
- close(fd);
- printf("tc_net_socket_af_unix_sock_raw_icmpv6_n PASS\n");
- nw_total_pass++;
-}
-
-/****************************************************************************
- * Name: socket()
- ****************************************************************************/
-
-int net_socket_main(void)
-{
- tc_net_socket_af_inet_sock_stream_p();
- tc_net_socket_pf_inet_sock_stream_p();
- tc_net_socket_af_inet_sock_dgram_p();
- tc_net_socket_pf_inet_sock_dgram_p();
- tc_net_socket_pf_inet_sock_raw_p();
- tc_net_socket_af_inet_sock_dgram_tcp_n();
- tc_net_socket_af_inet_sock_dgram_udp_p();
- tc_net_socket_af_inet_soc_dgram_icmp_p();
- tc_net_socket_af_inet_sock_dgram_igmp_p();
- tc_net_socket_af_inet_sock_dgram_ipv6_n();
- tc_net_socket_af_inet_sock_dgram_routing_p();
- tc_net_socket_af_inet_sock_dgram_fragment_p();
- tc_net_socket_invalid_domain_sock_stream_n();
- tc_net_socket_af_inet_sock_dgram_icmpv6_n();
- tc_net_socket_af_unix_sock_dgram_tcp_n();
- tc_net_socket_af_unix_sock_dgram_udp_p();
- tc_net_socket_af_unix_sock_dgram_icmp_n();
- tc_net_socket_af_unix_sock_dgram_igmp_n();
- tc_net_socket_af_x25_sock_stream_n();
- tc_net_socket_af_ax25_sock_stream_n();
- tc_net_socket_af_packet_sock_stream_n();
- tc_net_socket_af_unix_sock_stream_p();
- tc_net_socket_af_unix_sock_stream_udp_n();
- tc_net_socket_af_unix_sock_stream_icmp_n();
- tc_net_socket_af_unix_sock_stream_igmp_n();
- tc_net_socket_af_unix_sock_stream_ipv6_n();
- tc_net_socket_af_unixsock_stream_routing_n();
- tc_net_socket_af_unix_sock_stream_icmpv6_n();
- tc_net_socket_af_netlink_sock_stream_n();
- tc_net_socket_af_unspec_sock_stream_p();
- tc_net_socket_af_unix_sock_stream_tcp_p();
- tc_net_socket_af_inet_sock_stream_protocol_n();
- tc_net_socket_domain_sock_stream_protocol_n();
- tc_net_socket_af_inet_sock_stream_tcp_p();
- tc_net_socket_af_inet_type_protocol_n();
- tc_net_socket_domain_type_protocol_n();
- tc_net_socket_domain_sock_stream_tcp_n();
- tc_net_socket_af_inet_sock_stream_udp_n();
- tc_net_socket_af_inet_sock_stream_icmp_p();
- tc_net_socket_af_inet_sock_stream_igmp_p();
- tc_net_socket_af_inet_sock_stream_protoipv6_n();
- tc_net_socket_af_inet_sock_stream_routing_p();
- tc_net_socket_af_inet_sock_stream_fragment_p();
- tc_net_socket_af_inet_sock_stream_icmpv6_n();
- tc_net_socket_af_inet6_sock_stream_p();
- tc_net_socket_af_inet_sock_stream_type_n();
- tc_net_socket_af_inet_sock_stream_domain_n();
- tc_net_socket_af_inet_sock_stream_domain_protocol_n();
- tc_net_socket_af_inet_sock_stream_type_protocol_n();
- tc_net_socket_af_unix_sock_dgram_ipv6_n();
- tc_net_socket_af_unix_sock_dgram_routing_n();
- tc_net_socket_af_unix_sock_dgram_fragment_p();
- tc_net_socket_af_unix_sock_dgram_icmpv6_n();
- tc_net_socket_af_netlink_sock_dgram_p();
- tc_net_socket_af_unspec_sock_dgram_p();
- tc_net_socket_af_local_sock_dgram_p();
- tc_net_socket_af_x25_sock_dgram_n();
- tc_net_socket_af_ax25_sock_dgram_n();
- tc_net_socket_af_packet_sock_dgram_p();
- tc_net_socket_af_inet_sock_raw_p();
- tc_net_socket_af_inet_sock_raw_tcp_p();
- tc_net_socket_af_inet_sock_raw_udp_p();
- tc_net_socket_af_inet_sock_raw_icmp_p();
- tc_net_socket_af_inet_sock_raw_igmp_p();
- tc_net_socket_af_inet_sock_raw_ipv6_n();
- tc_net_socket_af_inet_sock_raw_routing_p();
- tc_net_socket_af_inet_sock_raw_fragment_p();
- tc_net_socket_af_inet_sock_raw_icmpv6_n();
- tc_net_socket_af_unix_sock_raw_n();
- tc_net_socket_af_unix_sock_raw_tcp_n();
- tc_net_socket_af_unix_sock_raw_udp_n();
- tc_net_socket_af_unix_sock_raw_icmp_n();
- tc_net_socket_af_unix_sock_raw_igmp_n();
- tc_net_socket_af_unix_sock_raw_ipv6_n();
- tc_net_socket_af_unix_sock_raw_routing_n();
- tc_net_socket_af_unix_sock_raw_fragment_n();
- tc_net_socket_af_unix_sock_raw_icmpv6_n();
-
- return 0;
-}