Commit Graph

276 Commits

Author SHA1 Message Date
Simon Goldschmidt
a9052caf10 fuzz: add debug output to help debugging fuzz crashes 2020-03-05 20:49:41 +01:00
Simon Goldschmidt
d05be56a50 fuzz: add more fuzz tests
From: Hiromasa Ito <v3hertz@gmail.com>

See bugs #57374-#57380 found by this new test mode.
2020-02-20 21:55:13 +01:00
Simon Goldschmidt
a07e0a82c9 test: split fuzz into different files and binaries
This is in preparation to add more fuzzing code...
2020-02-17 22:05:46 +01:00
Simon Goldschmidt
1ffcc5079c Fix-more-typos-using-codespell
Committing nearly all changes done by 'codespell_check.sh -w'

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:53 +01:00
jona
d6a6b661d9 Fix typos using codespell
Conservative strategy was used, maybe other typos remain.

Rebased: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:41 +01:00
Gao Qingshui
a9ac18aebb ip6: enable ip6_autoconfig_enabled by default
See bug #56135

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-04 22:23:58 +01:00
Simon Goldschmidt
dae8eb8d6e adapt unit test to new netif ext callback reason 2020-01-13 19:37:59 +01:00
Simon Goldschmidt
f857260e29 fix compiling fuzz test under Linux after merging contrib to main repo 2019-12-11 22:20:14 +01:00
Simon Goldschmidt
cb3f0a9b17 fuzz: adapt to changes in mdns
mdns_resp_add_netif() takes only 3 arguments
2019-12-11 19:50:50 +01:00
Joan Lledó
785b7aba3c Sockets: Unit tests and apps corrections
* Include lwip/inet.h in some unit tests and apps
  * Since they use htons() and pals.
* test/unit/api/test_sockets.c:
  * write() could be declared by external socket headers
    * Call lwip_write() instead.
  * Code expects fcntl() to return 6
    * But O_RDWR could have another value if external
      socket headers are present
    * Replace 6 by O_RDWR.
* apps/tftp/tftp.c:
  * recv() could be declared by external socket headers
    * Rename it to tftp_recv()
2019-08-11 20:12:47 +02:00
Joan Lledó
f92d6702bc Sockets: declare msghdr->msg_iovlen as msg_iovlen_t
* Lwip declares msghdr->msg_iovlen as int, but when
  using external socket headers, some systems declare
  msg_iovlen as size_t or others.
* This patch creates a new type msg_iovlen_t and
  expects users to typedef it to the type they need
  for their system.
2019-08-11 20:12:02 +02:00
Simon Goldschmidt
2ebebe7287 fix compiling unit tests after adding compile-time check for LWIP_NETCONN_FULLDUPLEX 2019-07-10 21:29:13 +02:00
Simon Goldschmidt
752cdb1a53 udp: fix udp_bind for IPADDR_TYPE_ANY
See bug #55171

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-02-26 14:48:44 +01:00
Simon Goldschmidt
2037ec371c test: fix compiling unit test on win32 2019-01-30 14:53:41 +01:00
Jacob Kroon
2f098c42a7 Fix compile of UDP unit test
Fix building unit tests via contrib/ports/unix/check on Debian 9, gcc 6.3.0.

Fixes:
  <snip>/ip_addr.h:105:58: error: the comparison will always evaluate as ‘true’ for the address of ‘ip1’ will never be NULL [-Werror=address]
   #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr),iptype); }}while(0)

Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
2019-01-03 07:09:51 +01:00
Dirk Ziegelmeier
91037b4c28 Add testcase for bug #55171: Binding UDP PCB with different IP type PCBs does not work 2018-12-06 14:40:20 +01:00
Jasper Verschueren
3043d9d023 mDNS: move domain related functions and output related funtions
mDNS.c needed to become cleaner. Domain related functions are
moved to the mdns_domain.c util module. The output related
functions are split off (clear separation between defining the
packet and generating the packet). The output functions can
now be found in mdns_out.c.

mDNS move probe question packet generation to mdns_send_outpacket

The probe any questions were added to the pbuf in the send_probe
routine. It is better if we move all pbuf generation to the output
function so later on packets can be delayed etc. keep it all in
one place.

mDNS: move legacy question generation to mdns_send_outpacket

It's better to do the pbuf generation in one place.
Especially important for message delaying etc.

mDNS take out domain related functionality and put in other file.

The mDNS file is getting very big and a lot still needs to be added.
For clarity reasons it's better to split these domain functions
from the main mDNS file.

mDNS split off output related functionality and put in other file

A lot of functions are only needed for the generation of the pbuf,
by separating them into another file we clean up the mdns file.
We only need the mdns_send_outpacket function as interface.
Packet definition is now completely separated from packet
generation.
2018-11-13 12:17:36 +01:00
Dirk Ziegelmeier
48c2056d5b Implement unit test for bug #54670: 127.0.0.1 sent out to netif_default? 2018-11-01 21:35:46 +01:00
Simon Goldschmidt
eeef3f65b8 Add a unit test for bug #54833 (tcp_abort with wrong ports)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 22:57:24 +02:00
Dirk Ziegelmeier
6826130d6f CMake: Use include_guard only when CMake >= 3.10.0 2018-10-12 22:01:25 +02:00
Simon Goldschmidt
0528f68c6d Fixed the remaining dhcp unit tests after adding ACD
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:37:17 +02:00
Simon Goldschmidt
8d05e22f9a Fix some dhcp unit tests after adding ACD, disable the rest
I disabled the yet unfixed tests to test if the new travis
integration works. Still working on them...

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-10-12 21:20:23 +02:00
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
goldsimon
4a22d6d5a2 sockets_stresstest: fix typo (&1, not %1) 2018-04-20 07:52:35 +02:00
goldsimon
71c13c6079 Improve the socket stress test to better test fullduplex 2018-04-18 22:03:11 +02:00
goldsimon
61a1b98cc9 various IPv6-only compile fixes 2018-03-07 20:55:00 +01: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
ca0a356221 sockets_stresstest: don't compile when LWIP_SOCKET is disabled 2018-02-18 08:56:57 +01:00
goldsimon
e6f0700c81 fuzz: fix compile error, ignore 0 length pbufs 2018-02-18 08:56:23 +01:00
goldsimon
58de2af5f2 test/fuzz: add some applications, add an experimental multi-packet mode
The experimental multi-packet mode splits input bytes depending on a length
decoded from the first 2 bytes and does that until the end of input.
To use this mode, compile with "make D=-DLWIP_FUZZ_MULTI_PACKET"

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-15 14:35:08 +01: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
a7a8d9273c sockets_stresstest: replace printf with LWIP_DEBUGF, fix unused arg 2018-01-17 19:46:32 +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
goldsimon
f8f31218d1 sockets_stresstest.c: some compile and runtime fixes 2017-11-23 09:19:01 +01:00
goldsimon
6e624f8035 multithreading socket test: implement more code paths 2017-11-22 23:08:57 +01:00
goldsimon
0397ff9ba4 Added initial version of multithreading socket test 2017-11-22 22:03:33 +01: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