Commit Graph

259 Commits

Author SHA1 Message Date
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
goldsimon
8313c4d870 tried to add basic socket unit tests (nonsense only for now); made LOCK_TCPIP_CORE()/UNLOCK_TCPIP_CORE() overridable for that 2017-03-16 21:52:30 +01:00
Joel Cunningham
8bf402fd67 Fix unit test with assumed congestion avoidance
test_tcp_fast_rexmit_wraparound correctness relied on the congestion
window being in congestion avoidance so that only a single TCP_MSS
segment is sent upon ACKing the first segment.

It's not known whether the test was relying tcp_alloc() to set ssthresh
to 0 and thus start in congestion avoidance or if the test was working by
accident until changes in b90a54f989

This fixes the test by enforcing the requirement of starting in
congestion avoidance

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-03-10 08:12:17 +01:00
goldsimon
e9e9ec23b8 tcp unit tests: fixed that tcp_teardown() could lead to accessing a netif pointer that is not valid any more (netif added in test function stored on stack) 2017-03-09 20:23:16 +01:00
sg
b198c877db fix compiling TCP unit tests with IPv6 enabled 2017-01-16 14:21:08 +01:00
Erik Ekman
6c9a9b9d99 Remove duplicate netif_dhcp_data() macro
Fix compilation of unit tests
2017-01-05 21:14:43 +01:00
sg
8760fb677f fixed warnings in mdns unit tests 2017-01-04 15:25:52 +01:00
Dirk Ziegelmeier
1884c7e83f Fix TCP unit tests after changes from "Add hook for TCP Initial Sequence Number generation" commit
(pcb->lastack and friends are not initialized during allocation any more, but by connect() / bind() call)
2016-12-31 11:46:27 +01:00
Dirk Ziegelmeier
7f319f5ec5 Fix compile of test_tcp.c unit test after introduction of tcp_next_iss hook 2016-12-18 21:46:49 +01:00
Dirk Ziegelmeier
bb8088d498 Minor cleanup of FUZZ test Makefile 2016-12-17 10:09:15 +01:00
Dirk Ziegelmeier
11780f037b Fixup Makefile of FUZZ test after moving to main lwIP rep 2016-12-17 10:05:49 +01:00
sg
c13a43e5c8 added note about afl-fuzz requiring linux 2016-12-15 21:42:46 +01:00
sg
844c201702 added fuzz tests (moved from contrib/ports/unix/fuzz to get them to a more prominent place, even if afl-fuzz still needs *nix to run) 2016-12-15 21:39:46 +01:00
goldsimon
0e07ed4b13 fixed bug #49676 (Possible endless loop when parsing dhcp options) & added unit test for that 2016-11-25 10:03:43 +01:00
Erik Ekman
b90682dc8b Update email address
I am leaving Verisure at the end of the month.
2016-11-10 11:19:51 +01:00
goldsimon
96c3c48ba7 mdns: moved private things into mdns_priv.h 2016-08-19 09:52:30 +02:00
Dirk Ziegelmeier
e844159f0a Fix warning in test_etharp.c 2016-08-19 09:03:57 +02:00
Dirk Ziegelmeier
11386a26d9 Fix compile of DHCP unit test 2016-08-19 09:00:35 +02:00
Dirk Ziegelmeier
5df88220c4 Fix compile of MDNS unit test with GCC 2016-08-18 20:43:33 +02:00
Dirk Ziegelmeier
a8c8e08984 Minor: cleanups in unit test code 2016-08-18 13:02:59 +02:00
Dirk Ziegelmeier
7f60cb3889 Improve netif client data API for lwIP internal clients - these can use a compile-time constant to access their data now 2016-08-18 12:37:21 +02:00
Dirk Ziegelmeier
fa6a2d48cc Fix DHCP unit test after my last changes 2016-08-18 06:09:02 +02:00
Dirk Ziegelmeier
93b286e508 Also rename LWIP_MDNS to LWIP_MDNS_RESPONDER in unit tests... 2016-08-17 16:03:42 +02:00
Erik Ekman
4919932c49 Apply patch #8755: Multicast DNS responder support from Erik Ekman 2016-08-14 15:07:45 +02:00
Dirk Ziegelmeier
36b9caed23 Fix compile of unit test 2016-08-11 23:54:59 +02:00
sg
a2fd68098e minor: macros should not end with underscore(s) 2016-08-08 21:47:53 +02:00
Dirk Ziegelmeier
6af213787a Fix clang address sanitizer errors in unit tests (buffers too small) 2016-08-07 20:21:27 +02:00
Erik Ekman
28dd0813ab Disable SYS_LIGHTWEIGHT_PROT in unit tests 2016-07-22 09:34:05 +02:00
goldsimon
288fc8ede3 fixed unit tests after changing memp stats 2016-07-08 10:20:04 +02:00
Dirk Ziegelmeier
6af4215f27 Next try to fix test_udp.c (can't compile it at my current machine) 2016-07-08 10:12:22 +02:00
Dirk Ziegelmeier
c483520081 Fix compile of UDP unit test 2016-07-08 08:22:43 +02:00
Erik Ekman
efd3fb8f4e Fix pedantic dhcp test error
../../../../lwip/test/unit/dhcp/test_dhcp.c:121:34: error: comma at end
of enumerator list [-Werror=edantic]
cc1: all warnings being treated as errors
2016-06-24 09:24:15 +02:00
Erik Ekman
94e502fc8a Switch to C-style comments in test lwipopts 2016-06-24 09:16:56 +02:00
Dirk Ziegelmeier
d133999e1d Fix warnings in unit test code when compiling with stricter GCC settings 2016-06-23 22:30:37 +02:00
Dirk Ziegelmeier
8dc77ef558 doxygen updates - include IPv6 in documentation. Exclude include/netif/ppp/polarssl.
Convert TODO -> @todo
2016-06-22 20:18:23 +02:00
Henrik Persson
b9a2ee8aaa [PATCH] Drop instead of ASSERT in tcp_input header parsing
Since allowing input validation to trip the ASSERT handler is bad,
let's just drop the packets instead if validation fails.

Signed-off-by: sg <goldsimon@gmx.de>
2016-06-13 20:08:43 +02:00
Sylvain Rochet
37bb0b89f0 all: trivial include changes related to the new "lwip/priv/" include directory 2015-10-10 22:46:47 +02:00
Sylvain Rochet
ce98bc9437 test: etharp: Fixed const warning 2015-09-27 22:59:15 +02:00
Erik Ekman
e8c0ba2a47 Fix tests after ip4_current_header() made const 2015-09-18 09:52:08 +02:00
sg
851e03966d Fixed more compiler warnings for unit tests 2015-08-05 21:15:41 +02:00
Erik Ekman
38e3299675 test_etharp: Fix warning about braces
../../lwip-trunk/test/unit/etharp/test_etharp.c:16:8: warning: missing
braces around initializer [-Wmissing-braces]
  struct eth_addr test_ethaddr = {1,1,1,1,1,1};
         ^
2015-08-05 21:04:33 +02:00
Erik Ekman
dbdeca3032 test_tcp_oos: Remove last_dropped variable, never read 2015-08-05 21:01:17 +02:00
sg
767d0d9046 Fixed unit tests (compiler errors/warnings, coding style) 2015-08-03 20:41:49 +02:00
Erik Ekman
145efb1a33 Fix edge case in pbuf_take_at()
Writes to offsets pointing to the start of a pbuf in the chain
did nothing and just returned ERR_OK.

Added unit tests to verify the fix, and also
that pbuf_get_at()/pbuf_put_at() handles this case.
2015-08-03 20:34:08 +02:00
Sylvain Rochet
632de523de Fixed PBUF_LINK_ENCAPSULATION_HLEN support
PBUF_LINK_ENCAPSULATION_HLEN support was introduced by 6ef7563f and
missed the fact that header size calculation/reservation using
computation like PBUF_LINK_HLEN + PBUF_IP_HLEN + ... are used all over
the source code. Hopefully fixed all of them.
2015-04-20 23:43:33 +02:00
goldsimon
cf180b651b fixed unit tests after changing ip_addr_t 2015-04-10 08:51:06 +02:00
Clint Sbisa
32f6e7e231 tcp: Fix ooseq processing when seqno is near 2^32
An edge case in out-of-sequence TCP packet processing did not use the
appropriate macro to check if the sender overran the recieve window.

Consequently, this case sometimes evaluated to true when it shouldn't, which
resulted in various bad behavior, including trying to resize a TCP buffer to 4
gigabytes.
2015-03-20 08:32:14 +01:00
goldsimon
94f7bcef67 Fixed tcp unit tests after changing routing to check for link up 2015-03-20 08:31:39 +01:00
goldsimon
df16a7c4f3 Fixed compiler warnings in unit tests 2015-03-06 07:39:06 +01:00
goldsimon
896535fe87 Fixed dhcp unit tests after changing netif up/down handling 2015-03-06 07:38:51 +01:00
goldsimon
0ff98eb2f5 mem: added an MEMP_OVERFLOW_CHECK implementation for MEM_USE_POOLS; added another unit test 2014-12-10 09:48:50 +01:00
Erik Ekman
63038e0305 Restore DHCP relay test packet numbers
These were updated in commit e1225cec5f together with other fixes
without any clear reason, and cause the test to fail.
2014-08-20 21:33:58 +02:00
Simon Goldschmidt
dbd125c714 Fixed bug #35874 reserved identifier violation (removed leading underscores from header include guards) 2014-05-19 21:46:18 +02:00
Simon Goldschmidt
a80c4d147c Unit test patch by Erik Ekman: use macro to store correct testcase name 2014-02-12 21:52:21 +01:00
Erik Ekman
ad66b2bf13 Don't mark arrays as const since they are modified by the test 2014-02-12 21:44:51 +01:00
Simon Goldschmidt
751deac9d1 Another fix to window scaling: support queueing more than 64 KByte in ooseq data 2014-02-12 21:34:19 +01:00
Simon Goldschmidt
d237ec7e78 Changed C++ comments to C style 2013-01-11 21:27:45 +01:00
Henrik Persson
7e9f000d0b Segfault in dhcp_parse_reply if no end marker
If no endmarker is present in a dhcp reply a null pointer is potentially
dereferenced.

Add fix and test case as proof of concept.
2012-09-19 22:11:56 +02:00
goldsimon
d690775ca1 Added unit test that pbuf_copy returns a correct error code for pbuf queues ending with a zero-length pbuf. 2012-05-03 20:11:23 +02:00
goldsimon
84d8760561 dhcp unit test: fixed 2 consts, use udp checksum 0x0000 in handcrafted packets so that CHECKSUM_CHECK_UDP==0 is not necessary 2012-03-25 17:18:58 +02:00
goldsimon
e1225cec5f new dhcp unit test: fix compilation for strict C, made local functions static, made some variables and parameters const 2012-03-25 17:15:56 +02:00
goldsimon
5db6bb02d6 TCP unit tests: fix that ip.rterr stats are increased (some unit tests had no netif set) 2012-03-25 17:12:02 +02:00
Erik Ekman
679d3fd5b3 Add unit tests for DHCP
Three simple tests that test the basic functionality of the DHCP client.
They require that UDP checksums are off for now.
2012-03-25 15:34:31 +02:00
goldsimon
fc7da615fb unit tests lwipopts.h: NO_SYS==1, disable netconn and sockets (not tests) -> lwipopts.h is now usable for unix unit test makefile, too 2012-02-22 21:47:33 +01:00
goldsimon
86766f4e20 Minor: cosmetic source code layout changes 2012-02-22 21:35:04 +01:00
goldsimon
8cb0b7d043 Fixed unit tests: adapted lwipopts.h and fixed test_tcp_new_counters_pcb() after adding snd_wnd_max to struct tcp_pcb. 2012-02-22 21:34:22 +01:00
goldsimon
b6cdeeef8e Added lwipopts.h file for unit tests 2012-02-16 13:11:04 +01:00
Simon Goldschmidt
0333e81616 fixed bug #34517 (persist timer is started although no zero window is received) by starting the persist timer when a zero window is received, not when we have more data queued for sending than fits into the window 2011-10-13 21:18:16 +02:00
Simon Goldschmidt
ab51f3bec0 added unit test cases for seqno wraparound on fast-rexmit and rto-rexmit (unsent/unacked lists must be correctly sorted) 2011-10-11 21:43:27 +02:00
Simon Goldschmidt
ce98df59f1 Added unit test case for persist timer / zero window probes 2011-10-10 21:06:50 +02:00
Simon Goldschmidt
07c610e068 Implemented limiting data on ooseq queue (task #9989) (define TCP_OOSEQ_MAX_BYTES / TCP_OOSEQ_MAX_PBUFS in lwipopts.h), added unit test for this new feature 2011-09-27 22:42:46 +02:00
Simon Goldschmidt
7524f9006e added unit tests for data-after-FIN 2011-09-26 22:10:11 +02:00
Simon Goldschmidt
bcfe3dacc6 fixed unit tests (one TCP test failed, removed comma at the end of array initializers) 2011-09-26 22:09:27 +02:00
Simon Goldschmidt
17a5ba08e4 unit tests: correctly handle small PBUF_POOL_BUFSIZE settings, prevent NULL-pointer-deref. (ooseq test is still not running correctly...) 2011-09-03 21:25:51 +02:00
Simon Goldschmidt
c9e1d6cca8 adapted unit tests to changes after adding IPv6 support 2011-07-26 21:55:32 +02:00
goldsimon
33a587d97e Added a test for fast-rexmit 2011-05-14 15:26:43 +00:00
goldsimon
791505ab6e Fixed tcp unit tests after introducing ip_addr_p_t and letting tcp_input check for broadcasts by using current_iphdr_dest. 2011-03-30 18:50:00 +00:00
goldsimon
88e1719d8e Fixed etharp unit test after changing struct etharp_hdr 2011-03-30 18:47:20 +00:00
goldsimon
da3d84d1dc Fix compilation if ETHARP_SUPPORT_STATIC_ENTRIES==0 2010-03-26 13:40:31 +00:00
goldsimon
cf0b831971 Fixed bug #29080: Correctly handle remote side overrunning our rcv_wnd in ooseq case. 2010-03-25 06:39:01 +00:00
goldsimon
5fd410db4b Added support for static ARP table entries (added option ETHARP_SUPPORT_STATIC_ENTRIES) (+ added test); refactored the etharp code a bit 2010-03-20 11:45:25 +00:00
goldsimon
bcd4b76d31 Moved stack-internal parts of tcp.h to tcp_impl.h, tcp.h now only contains the actual application programmer's API 2010-02-21 11:35:21 +00:00
goldsimon
52970c2459 Renamed mem_realloc() to mem_trim() to prevent confusion with realloc() 2010-02-19 16:23:46 +00:00
goldsimon
3f8e6c423c Fixed unit tests after changing struct ip_addr to ip_addr_t 2010-02-09 16:40:52 +00:00
goldsimon
f5d4f3d83c For wrong configurations, let the test fail instead of the compiler 2010-01-27 20:37:02 +00:00
goldsimon
dbcce3a4be bug #26523: Compiler Warnings 2010-01-23 17:48:36 +00:00
goldsimon
e0c5c4de88 Fixed bug #28679: mem_realloc calculates mem_stats wrong and added test case for it 2010-01-18 17:45:41 +00:00
goldsimon
9a0dac5885 Removed unused test function 2009-12-31 16:50:11 +00:00
goldsimon
c9e0652526 Remove C++-style comments 2009-12-31 16:49:36 +00:00
goldsimon
bf261f4f13 Another fix for bug #28241 (ooseq processing) and adapted corresponding unit test 2009-12-27 11:31:19 +00:00
goldsimon
feca27d69e Slightly modified the out-of-sequence-FIN test: receive packets with FIN & data and with FIN alone 2009-12-11 13:07:47 +00:00
goldsimon
fbef894674 tcp_set_state: fail on unimplemented state 2009-12-11 13:07:06 +00:00
goldsimon
2e4bb8b3b7 Added explicit check for number of segments and seqno/len of each segment on pcb->ooseq 2009-12-10 17:34:11 +00:00
goldsimon
c5d2e536cf Worked on tcp_oos unit tests, nearly all TCP_QUEUE_OOS code is covered now 2009-11-29 13:20:13 +00:00
goldsimon
902ad897b8 Initial check-in of some unit tests 2009-11-27 08:03:53 +00:00