Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions testing/nettest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,23 @@ if(CONFIG_TESTING_NET_TEST)
${SRCS})
endif()

if(CONFIG_TESTING_NET_TUN)
set(SRCS ${CMAKE_CURRENT_LIST_DIR}/tun/test_tun.c
${CMAKE_CURRENT_LIST_DIR}/tun/test_tun_tcp.c)

nuttx_add_application(
NAME
cmocka_net_tun
PRIORITY
${CONFIG_TESTING_NET_TEST_PRIORITY}
STACKSIZE
${CONFIG_TESTING_NET_TEST_STACKSIZE}
MODULE
${CONFIG_TESTING_NET_TEST}
DEPENDS
cmocka
SRCS
${SRCS})
endif()

endif()
13 changes: 13 additions & 0 deletions testing/nettest/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,17 @@ config TESTING_NET_PKT
lo comes back, and the reassembly timeout of an IPv4 fragment sent
on lo does not stop the kernel (cmocka_net_pkt).

config TESTING_NET_TUN
bool "Enable cmocka net TUN test"
depends on NET_TUN && NET_TCP && NET_IPv4 && NET_TCPBACKLOG
depends on NET_SOCKOPTS && !DISABLE_PTHREAD
default y
---help---
Test TCP against a peer that the program plays on a TUN device
(cmocka_net_tun). The link loses the first transmission of each
segment, and the peer acknowledges each retransmission, so the
connection makes progress at each timeout. The server must send
the whole stream with each byte at its own sequence number, and
must not reset the connection. The case takes about 30 seconds.

endif
6 changes: 6 additions & 0 deletions testing/nettest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,11 @@ PROGNAME += cmocka_net_pkt
CSRCS += pkt/test_pkt_lo.c
endif

ifeq ($(CONFIG_TESTING_NET_TUN),y)
MAINSRC += tun/test_tun.c
PROGNAME += cmocka_net_tun
CSRCS += tun/test_tun_tcp.c
endif

endif
include $(APPDIR)/Application.mk
49 changes: 49 additions & 0 deletions testing/nettest/tun/test_tun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/****************************************************************************
* apps/testing/nettest/tun/test_tun.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <cmocka.h>

#include "test_tun.h"

/****************************************************************************
* Public Functions
****************************************************************************/

int main(int argc, FAR char *argv[])
{
const struct CMUnitTest tun_tests[] =
{
cmocka_unit_test_setup_teardown(test_tun_tcp_lossy,
test_tun_tcp_setup,
test_tun_tcp_teardown),
};

return cmocka_run_group_tests(tun_tests, NULL, NULL);
}
48 changes: 48 additions & 0 deletions testing/nettest/tun/test_tun.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/****************************************************************************
* apps/testing/nettest/tun/test_tun.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/

#ifndef __APPS_TESTING_NETTEST_TUN_TEST_TUN_H
#define __APPS_TESTING_NETTEST_TUN_TEST_TUN_H

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

/****************************************************************************
* Name: test_tun_tcp_setup
****************************************************************************/

int test_tun_tcp_setup(FAR void **state);

/****************************************************************************
* Name: test_tun_tcp_teardown
****************************************************************************/

int test_tun_tcp_teardown(FAR void **state);

/****************************************************************************
* Name: test_tun_tcp_lossy
****************************************************************************/

void test_tun_tcp_lossy(FAR void **state);

#endif /* __APPS_TESTING_NETTEST_TUN_TEST_TUN_H */
Loading
Loading