Commit Graph

240 Commits

Author SHA1 Message Date
Simon Goldschmidt
b406a54389 Fix mqtt unit test broken after 684adaca
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:18:39 +02:00
Dirk Ziegelmeier
d9c9b55766 CMake: add an include guard since files are intended to be included in other projects 2018-10-05 08:02:34 +02:00
Simon Goldschmidt
eeee2b1c55 dhcp: adapt unit test to ignoring packets without END 2018-07-03 20:47:49 +02:00
Simon Goldschmidt
824ebbe0e9 tcp: fix RTO timer not working if link is down
... and added some test cases for this situation
See bug #54139

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-06-19 22:48:06 +02:00
Simon Goldschmidt
e61b925709 try to fix compiling with gcc & clang 2018-06-14 15:01:57 +02:00
Simon Goldschmidt
39faa8f61d added tests for ip6addr_ntoa_r 2018-06-14 12:30:14 +02:00
Simon Goldschmidt
b0e5eeb7d2 udp: prefer correctly bound pcbs when receiving broadcast
See bug #53301

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-06-13 22:01:18 +02:00
Simon Goldschmidt
38614e4f3e unit tests: remove dummy netif input function
This partly reverts a26a2e13 after removing that NULL check again.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-06-13 10:46:44 +02:00
Simon Goldschmidt
392c676ef5 fix bug #53273: IPv6 link-local address generation for non-ethernet type netif does not convert byte order 2018-06-13 08:57:17 +02:00
Simon Goldschmidt
0c5133d7cf fix ip6addr_aton for non-shortened ipv4 mapped addresses 2018-06-12 21:48:32 +02:00
Simon Goldschmidt
a26a2e1340 adapt unit tests to additional NULL checks 2018-06-12 13:47:13 +02:00
Simon Goldschmidt
2837bb310c fix ip6addr_aton handling IPv4-mapped addresses
... and added a unit test for it

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-06-11 22:21:31 +02:00
Simon Goldschmidt
f8e7cccf21 add new ip6 tests to (c)make list files 2018-06-10 19:23:02 +02:00
Simon Goldschmidt
fd050b8a97 fix bug #53971 Lwip sends Router Solicitation on address changes
... and add a unit test for it.

Moved resetting netif->rs_count from all reports to link-up and netif-up only.
While at it, clean up the interface a bit so that netif->rs_count is touched
from nd6.c only.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-06-08 22:18:50 +02:00
Simon Goldschmidt
d4845abac6 test_etharp: fix compiler warning 2018-06-08 20:03:51 +02:00
Dirk Ziegelmeier
f116bc37d1 Cleanups in CMake files 2018-04-30 22:29:07 +02:00
Dirk Ziegelmeier
ab5bc1e766 Work on CMake build system - add Filelists.cmake for unit tests 2018-04-27 23:58:36 +02:00
Joel Cunningham
b28e979739 unit: write out XML file
This writes out the results of the unit tests in an XML file called
lwip_unittests.xml in the same directory as the unittests executable.

See https://libcheck.github.io/check/doc/check_html/check_4.html#XML-Logging
for an example of the ouput. Of particular use is the duration field, for
each test and for the entire test run.
2018-03-04 10:42:54 -06:00
Joel Cunningham
b1258bf8e6 unit: speed up test_pbuf_queueing_bigger_than_64k
Speed up test_pbuf_queueing_bigger_than_64k by using memcmp rather than
a byte by byte comparision. This allows using word aligned compares
within the memcmp implementation

This fixes a unit test timeout on my Windows 10 box with WSL which was
taking longer than 4 seconds for the unix port unit test to complete

See failure details in https://savannah.nongnu.org/patch/index.php?9579
2018-03-03 17:43:23 -06:00
goldsimon
7b6d2870ca test: add a unit test for TCP_CHECKSUM_ON_COPY with retransmissions
This triggers bug #50914 (TCP_CHECKSUM_ON_COPY when adding data to
retransmission) when data is added to an already transmitted segment
with an uneven length of tcp data.
2018-02-12 12:34:45 +01:00
goldsimon
cff31ba5de test: enable LWIP_CHECKSUM_ON_COPY and TCP_CHECKSUM_ON_COPY_SANITY_CHECK
To find and verify bug #50914 (TCP_CHECKSUM_ON_COPY when adding data to
retransmission), enable checksum-on-copy for the unit tests.
2018-02-12 12:32:40 +01:00
goldsimon
b1b6275110 socket/netconn recv: FIN should only be reported once
FIN should only be reported once (as '0' for sockets, as 'ERR_CLSD' for
netconns). Before this change, ERR_CLSD was returned forever...

This is the 2nd try. First try (commit ebcae98ae6)
was buggy in that it could drop the FIN if it was read together with data
(reverted in commit ebcae98ae6).

This version fixes this by adding an apiflag and a netconn flag to keep
track of this.
2018-02-04 20:16:53 +01:00
goldsimon
fe828634ac socket unit test: check receiving FIN together with data works 2018-02-04 20:14:02 +01:00
goldsimon
f343a67b40 netif unit test: add some more tests for ext callbacks 2018-01-13 15:22:09 +01:00
goldsimon
e645d00484 netif unit test: fix -Werror=c++-compat 2018-01-13 15:16:12 +01:00
goldsimon
734b6ab57a netif: ensure netif_set_addr() only results in one "ext_status_callback"
This can be used e.g. in mdns to create one, not multiple "changed" triggers
if IP address and netmask change at the same time.
2018-01-12 23:11:38 +01:00
goldsimon
fa75ffed9d unit tests: added test_netif (checking ext_callbacks only, for now) 2018-01-12 22:27:15 +01:00
Dirk Ziegelmeier
990c25d4f3 Add unit test for a long running timer 2018-01-12 12:37:16 +01:00
Dirk Ziegelmeier
b6b14438b7 Rename lwip_sys_timers_get_next_timout() to sys_timeouts_get_next_timeout() 2018-01-11 09:53:07 +01:00
goldsimon
1affbb4bd5 unit tests: fixed testing itoa with too small buffer 2018-01-08 21:38:16 +01:00
Dirk Ziegelmeier
d7566216c9 Remove Simon's compile fix in test_timers.c, it is not needed any more. The function is now used. 2018-01-08 13:02:58 +01:00
Dirk Ziegelmeier
b4768f1711 Once again: Fix build warnings in test_timers.c 2018-01-08 08:34:17 +01:00
Dirk Ziegelmeier
3f30bfae28 lwipopts.h for unit tests: Increase number of timeouts 2018-01-08 07:34:38 +01:00
Dirk Ziegelmeier
eaca067c7d Make _cyclic_ timers interval more deterministic - next timeout is calculated from last due time instead of relative to current time
This eliminates the cyclic timer jitter
2018-01-08 07:16:49 +01:00
Dirk Ziegelmeier
dd3861720f Fix bug #52748: the bug in timeouts.c by reimplementing timer logic to use absolute instead of relative timeout values 2018-01-08 07:16:47 +01:00
goldsimon
e415151cf2 minor style change: fixed indentation 2018-01-05 21:30:32 +01:00
goldsimon
40c0f21b9e Added dummy sys_mbox_trypost to unit test port 2018-01-05 21:30:07 +01:00
goldsimon
c4867b878c Try to silence unused function warning in travis 2018-01-05 21:12:31 +01:00
Dirk Ziegelmeier
1623c3e2cc Add test for bug 52748
Disabled :-) -> travis doesn't complain
2018-01-05 08:20:36 +01:00
Dirk Ziegelmeier
8de4900641 Work on timer unit tests 2018-01-05 07:49:39 +01:00
Dirk Ziegelmeier
8542556a03 Fix build warning in test_def.c 2018-01-04 13:37:29 +01:00
Dirk Ziegelmeier
756b7431a7 Start implementing unit tests for timers 2018-01-04 13:37:05 +01:00
Joel Cunningham
a98d3a4efb Add test_def.c to Filelists.mk 2017-12-27 09:13:31 -06:00
goldsimon
c6887522fe Fixed lwip_itoa (bug #51729) and added unit tests for it 2017-12-23 20:35:18 +01:00
Joel Cunningham
50a5d85f45 tcp: handle segmentation oversize during segment split (bug #52676)
This fixes a bug in tcp_split_unsent_seg where oversized segments were not
handled during the split, leading to pcb->unsent_oversized and
useg->oversize_left getting out of sync with the split segment

This would result in over-writing the pbuf if another call to tcp_write()
happened after the split, but before the remainder of the split was sent in
tcp_output

Now pcb->unsent_oversized is explicitly cleared (because the remainder at
the tail is never oversized) and useg->oversized_left is cleared after it is
trimmed

This also updates the test_tcp_persist_split unit test to explicitly check for
this case
2017-12-18 11:42:13 -06:00
Joel Cunningham
cdabdcb00d test_sockets: disable test for calling recv() after remote closure
Re-enable these when calling recv() multiple times after remote closure
returns an error
2017-11-20 14:17:59 -06:00
goldsimon
f5c37c8cbb Fix broken MSG_PEEK on TCP sockets (post-2.0.3 bug)
MSG_PEEK on TCP sockets was broken since commit b71d4477ea
from 06.03.2017: recv hung in an endless loop and tcp_recved() was called for peeked data
(which would result in a too large window advertised).

Aded TCP MSG_PEEK to socket unit tests
2017-11-18 13:34:20 +01:00
goldsimon
2b309bd1ae socket unit tests: improve basic tests a bit 2017-11-17 21:22:00 +01:00
goldsimon
926805bcf1 tcp unit test: fix some endless loops for TCP_WND == 0xFFFF 2017-11-17 21:04:33 +01:00
Joel Cunningham
1147b9ce38 test_dhcp: set link up on net_test netif
DHCP test code didn't set link up on net_test netif (exposed by changes
in 637bce91b4)

Then during the test_dhcp function, a Gratuitous ARP was not sent during
the call to dhcp_bind() because the link was still down

The sets the link state for all DHCP test functions
2017-11-08 14:42:28 -06:00
Axel Lin
a8acca5902 Trivial typo fix
s/chekc/check/g

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-11-07 13:44:43 +01:00
Joel Cunningham
de531131c5 Fix compiler warnings seen with clang 8.1.0 on MacOS
This fixes the following warnings:

test_tcp.c:266:5: error: code will never be executed [-Werror,-Wunreachable-code]
    pbuf_free(p);
    ^~~~~~~~~
 - The check API 'fail' aborts the test, thus pbuf_free(p) will never be executed

pbuf.c:783:111: error: format specifies type 'unsigned short' but the argument has type 'u8_t' (aka 'unsigned char') [-Werror,-Wformat]
      LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref));
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
 - LWIP_PBUF_REF_T is u8_t by default and doesn't match U16_F, so cast to u16_t. The cast and formatter will need to be changed
   if ref is larger than 16 bits

ethernet.c:105:16: error: format specifies type 'unsigned char' but the argument has type 'unsigned int' [-Werror,-Wformat]
               (unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2],
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 - addr[] is type u8_t, formatter is X8_F which should be 8 bits. 'unsigned' is an int, so cast to unsighed char instead
2017-10-13 07:52:34 -05:00
goldsimon
1710fc1a89 Fix a corner case of double-free in the heap 2017-09-25 22:29:02 +02:00
goldsimon
f058364d7f Added two simple unit tests for illegal calls to mem_free() 2017-09-25 21:38:00 +02:00
goldsimon
630c4a3de3 try to fix building unit test on gcc/clang 2017-09-11 11:10:42 +02:00
goldsimon
48c687ea84 tcp_remove_all() (used in tcp test setup/teardown): handle tcp_bound_pcbs, too 2017-09-05 22:20:44 +02:00
goldsimon
cf651e7e0f add test case that shows what's wrong for bug #51937 (Leaking tcp_pcbs on passive close with unacked data) 2017-09-05 22:19:38 +02:00
goldsimon
fca38fda1a remove unnecessary lines from last added test case 2017-09-05 22:18:52 +02:00
goldsimon
8c04009357 add unit test case for passive open & (invalid) bug #51941 2017-09-05 21:47:06 +02:00
Joel Cunningham
f582c88339 tcp: persist timer re-work (bug #50837)
This re-works the persist timer to have the following behavior:

  1) Only start persist timer when a buffered segment doesn't fit within
     the current window and there is no in-fligh data.  Previously, the
     persist timer was always started when the window went to zero even
     if there was no buffered data (since timer was managed in receive
     pathway rather than transmit pathway)
  2) Upon first fire of persist timer, fill the remaining window if
     non-zero by splitting the unsent segment.  If split segment is sent,
     persist timer is stopped, RTO timer is now ensuring reliable window
     updates
  3) If window is already zero when persist timer fires, send 1 byte probe
  4) Persist timer and zero window probe should only be active when the
     following are true:
       * no in-flight data (pcb->unacked == NULL)
       * when there is buffered data (pcb->unsent != NULL)
       * when pcb->unsent->len > pcb->snd_wnd
2017-08-25 09:35:10 -05:00
goldsimon
22ee33951b TCP: added a unit test for trimming left side of rx segment 2017-08-21 22:34:01 +02:00
Dirk Ziegelmeier
145d6ab5d2 test_etharp.c: IANA_HWTYPE_ETHERNET -> LWIP_IANA_HWTYPE_ETHERNET 2017-08-08 12:22:19 +02:00
Dirk Ziegelmeier
629ec98dd8 Work on task #14587: Create common header for IANA assigned numbers
Create include/lwip/prot/iana.h
Move DHCP and ARP #define in there
2017-08-07 21:06:19 +02:00
goldsimon
1e5870ce85 Fix unit tests under linux 2017-08-04 06:17:21 +02:00
goldsimon
47f55b02bf Finally fix bug #50088 (socket/netconn: data before RST should be readable) and added a unit test for it 2017-08-03 22:28:50 +02:00
goldsimon
4cec20230e Ensure that unit tests leave the stack in a clean state 2017-08-03 22:28:50 +02:00
goldsimon
5ea7f507c3 Fixed bugs #51606 and #51535: IPv4 reassembly could be finished although there are holes 2017-08-02 21:11:53 +02:00
goldsimon
597d5459bb Make sys_arch_sem_wait() & sys_arch_mbox_fetch() a little more robust when waiting (although this should never be a problem...) 2017-07-20 22:02:30 +02:00
goldsimon
5d10e1b6c3 test_pbuf: free pbufs at the end of tests 2017-06-29 20:44:14 +02:00
goldsimon
48213650cd Try to make unit tests work without -Wno-address 2017-06-21 21:55:00 +02:00
goldsimon
35ba3a877d Moved NUM_SOCKETS and struct lwip_sock to sockets_priv.h; added test case for fd_use count with select 2017-06-13 21:07:34 +02:00
Joel Cunningham
c03fef9a3c bug #50837: add zero-window probe timeout
This commit adds a timeout to the zero-window probing (persist timer)
mechanism. LwIP has not historically had a timeout for the persist
timer, leading to unbounded blocking if connection drops during the
zero-window condition

This commit also adds two units test, one to check the RTO timeout
and a second to check the zero-window probe timeout
2017-05-09 09:01:03 -05:00
goldsimon
7617a76b19 added unit test to allocate zero length pbufs 2017-04-26 20:16:27 +02:00
goldsimon
842a235a68 fix test_sockets_msgapi_cmsg unit test (msvc gives me "warning C4706: assignment within conditional expression") 2017-04-25 23:08:53 +02:00
Joel Cunningham
3a01c32e55 test_sockets: fix pointer to integer conversion
This fixes a pointer to integer conversion in test_sockets_msgapi_cmsg()

This was identified by Travis CI: https://travis-ci.org/yarrick/lwip-merged/builds/225640702
2017-04-25 13:48:14 -05:00
Joel Cunningham
2f117add7a sockets: task #14247, add CMSG and IP_PKTINFO
This commit adds CMSG infrastructure (currently used with recvmsg) and
the IP_PKTINFO socket option.

In order to use IP_PKTINFO, set LWIP_NETBUF_RECVINFO to 1

Unit test is added to verify this feature
2017-04-25 09:44:03 -05:00
Joel Cunningham
de90d03e48 tcp: task #14128 - Appropriate Byte Counting support
This commit adds TCP Appropriate Byte Counting (ABC) support based on
RFC 3465

ABC replaces the previous congestion window growth mechanism and has been
configured with limit of 2 SMSS.  See task #14128 for discussion on
defaults, but the goal is to mitigate the performance impact of delayed
ACKs on congestion window growth

This commit also introduces a mechanism to track when the stack is
undergoing a period following an RTO where data is being retransmitted.

Lastly, this adds a unit test to verify RTO period tracking and some
basic ABC cwnd checking
2017-04-20 15:59:24 -05:00
goldsimon
1e02f9e88b add mqtt_test.c to test/unit/Filelists.mk 2017-04-12 22:05:53 +02:00
goldsimon
5cc168c0f1 added unit test for mqtt (that does not really do something useful yet) 2017-04-12 21:54:42 +02:00
goldsimon
7b477b32b8 let unit test sys_arch check that a mutex is not taken recursively 2017-04-11 12:43:33 +02:00
Joel Cunningham
557a11047d Patch #9307: Replace mem_malloc+memset with mem_calloc
Aside from reducing source code, on systems which use MEM_LIBC_MALLOC,
this has the potential to improve performance depending on the underlying
memory allocator

See http://stackoverflow.com/questions/2688466/why-mallocmemset-is-slower-than-calloc
2017-04-05 14:53:24 -05:00
Joel Cunningham
6fe66771cb test_tcp: de-duplicate test IP addresses, netmask, and ports
This creates a single version of test IP addresses, netmasks, and ports.
All tests were using the same values, but duplicated in each test

This also adds const to some functions so we can use a const version
of addresses
2017-03-31 12:01:43 -05:00
Joel Cunningham
648b2b6f2b test_tcp: remove unnecessary memsets
test_tcp_init_netif() memsets both netif and txcounters, so no need to manually do it
2017-03-31 11:59:12 -05:00
Joel Cunningham
34c9e30225 test_tcp: de-duplicate seqno checking defines
This commit moves common defines and senqo array so they can be
re-used in mulptiple places for sequence number checking rather
than duplicated

Currently they are used in two places, but I'm anticipating needing
them in future TCP unit tests
2017-03-31 11:57:33 -05:00
Joan Lledó
172dab1289 lwip_fcntl() returns access modes 2017-03-29 20:46:30 +02:00
Mikhail Lappo
f7d215043c Possible null-pointer dereference
In unit test if_fail check for nullptr
is always located after dereferencing this
null pointer. This patch introduces correct
order: first check, then use
2017-03-22 22:51:08 +01:00
goldsimon
972b7c2bfd sys_arch unit tests: refine test_sys_arch_waiting_fn a bit 2017-03-18 10:22:44 +01:00
Joel Cunningham
81e4726607 test_socket: conditional compile buffer trailer code
This code is marked as dead when BUF_SZ is a multiple of 4 (current
situation with unit tests)

This hopefully fixes a -Wunreachable-code failure found by Travis CI
2017-03-17 17:12:12 -05:00
Joel Cunningham
0a5a18e703 test_socket: add sendmsg/recvmsg TCP test
This migrates the sendmsg TCP test from socket examples (task #14408)
to socket unit tests

Additionally, this adds support for testing recvmsg, creating a TCP
test for both sendmsg/recvmsg (referred to as msgapi test)

This also makes a small change to msgapi UDP to clear the receive
buffer after verifying the previous datagram
2017-03-17 16:47:44 -05:00
Joel Cunningham
551d76eadd test_sockets: move loopback addr logic to utility function
This moves the loopback address creation logic to a utility function
so it can be shared with forth coming message API TCP test
2017-03-17 14:52:05 -05:00
Joel Cunningham
4c78ec7931 test_socket: replace {0} with memset
Using {0} broke Travis CI even though this should be correct for
initializing struct msghdr (see example in Linxu man pages:
http://man7.org/linux/man-pages/man3/cmsg.3.html)

Just use memset for now which is the common approach in LwIP codebase
2017-03-17 14:44:47 -05:00
Joel Cunningham
02e957de1e test_socket: convert sendmsg test to use recvmsg
This converts the sendmsg test to use recvmsg for receiving, thus
exercising both sendmsg and recvmsg in a single test

This also adjusts the test naming to communicate all message APIs
(sendmsg/recvmsg) are being tested
2017-03-17 14:19:26 -05:00
goldsimon
dffb75c5fa test_sockets: fix warning about unused variable "addr_size" 2017-03-17 11:03:49 +01:00
goldsimon
aa129f35a2 hopefully fix building unit tests on linux/clang 2017-03-17 09:29:06 +01:00
goldsimon
e1d818bb5f sockets unit tests: removed commented-out test code :-/ 2017-03-17 09:26:58 +01:00
goldsimon
b0444a63b0 tried to fix sockets unit tests; fix configuration to run with any NO_SYS setting and with/without IPv6 (IPv4 is required) 2017-03-17 09:05:36 +01:00
goldsimon
a42d1678eb tcp unit tests: don't break later tests relying on loopif 2017-03-17 08:56:03 +01:00
Joel Cunningham
53fcd50870 task #14408: move sendmsg UDP to unit tests
This commit moves the sendmsg UDP test from socket examples to socket
unit tests

The test has been converted to send/receive on the loopback interface
and also test a connected sendmsg with NULL msg_name
2017-03-16 19:27:26 -05:00
goldsimon
d820fb2f8d Try to add a Filelists.mk file for the unit tests (to fix unix build of unit tests) 2017-03-16 22:54:50 +01:00
goldsimon
fc47f846ed Fix and improve sockets unit test and unit test sys_arch (with a little help of tcpip.c) 2017-03-16 22:49:38 +01:00