Commit Graph

259 Commits

Author SHA1 Message Date
Florian La Roche
7c3aab2ea2 gcc warning for sign conversion
See patch #10143
2021-12-30 22:48:18 +01:00
Wouter van Gulik
5ab46f82f9 Fix failing fuzzer if compiling with ubsan
See patch #10163

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-12-30 22:04:23 +01:00
Simon Goldschmidt
bb5ee3783a fix compiling/running tests on win32
- new files
- different warning settings
- all tests run in a single process (no fork)
2021-05-21 22:00:49 +02:00
Erik Ekman
988ce1e80e netif: Add test for netif_find 2021-02-27 12:28:14 +01:00
Erik Ekman
74231d6873 netif: Add test for netif_is_flag_set() 2021-02-08 19:29:33 +01:00
Erik Ekman
c825eb3604 tcp: Check tcp_output return values in tests
Found with clang-analyzer
2021-01-19 20:19:02 +01:00
Erik Ekman
21fba21054 test/unit: Update convenience makefile
Allow cleaning - useful when switching compiler between GCC/clang.
2021-01-19 20:19:02 +01:00
Erik Ekman
7b77378ed8 test/unit: Fix compilation of ip4 test
../../../../src/../test/unit/ip4/test_ip4.c: In function ‘test_ip4_icmp_replylen_short’:
../../../../src/../test/unit/ip4/test_ip4.c:291:35: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
   fail_unless(linkoutput_byte_ctr == icmp_len + sizeof(unknown_proto));

Plus minor cleanup in second icmp reply test
2021-01-13 21:31:19 +01:00
Erik Ekman
d0c214feff test/unit: Add convenience Makefile
To allow running them easily on *nix without changing directory.
2021-01-13 20:57:23 +01:00
Erik Ekman
35550eeab3 icmp: Fix copied length in response packets
Fixes bug #59364, reported by Yi Guai
2021-01-13 20:31:55 +01:00
Erik Ekman
d6a37b1ad6 fuzz: Improve Makefile
Similar to recent change to ports/unix/check:
- Split depfile into three different files
- Fix make dep
- Skip depfile generation for 'make clean'
2020-12-04 10:51:11 +01:00
Erik Ekman
264a5a3e97 Rename IP and Ethernet equality checkers from _cmp to _eq
Functions ending in cmp are expected to return 0 on equality but these
return non-zero.

eth_addr_cmp -> eth_addr_eq

ip_addr_cmp -> ip_addr_eq
ip4_addr_cmp -> ip4_addr_eq
ip6_addr_cmp -> ip6_addr_eq

ip_addr_netcmp -> ip_addr_net_eq
ip4_addr_netcmp -> ip4_addr_net_eq
ip6_addr_netcmp -> ip6_addr_net_eq

ip_addr_cmp_zoneless -> ip_addr_zoneless_eq
ip6_addr_cmp_zoneless -> ip6_addr_zoneless_eq

ip6_addr_cmp_zone -> ip6_addr_zone_eq
ip6_addr_netcmp_zoneless -> ip6_addr_net_zoneless_eq
ip6_addr_nethostcmp -> ip6_addr_nethost_eq
ip6_addr_cmp_packed -> ip6_addr_packed_eq
ip6_addr_cmp_solicitednode -> ip6_addr_solicitednode_eq

All call sites have been changed, and fallback macros have been added to not
break external users.
2020-07-07 18:51:45 +02:00
Erik Ekman
047f3b3306 dns: Verify setting/getting servers in unit test 2020-07-04 18:57:41 +02:00
Erik Ekman
5b7524e10e unit: Enable DNS
Avoid allocating in dns_init by enabling random source port.
2020-07-04 14:24:40 +02:00
Erik Ekman
2bf8fcd7c2 pbuf: Add pbuf_copy_partial_pbuf library function
Like pbuf_copy, but can copy part of a pbuf to an offset in another.
pbuf_copy now uses this function internally.

Replace pbuf_take_at loop in icmp6 with pbuf_copy_partial_pbuf().
2020-07-03 18:55:02 +02:00
Erik Ekman
942ca825d0 ip4: Fix missing END_TEST in ip4 test case 2020-07-01 21:09:49 +02:00
Erik Ekman
ec5f3a1563 ip6: Add ipv6 fragmentation test
Seems to work the same as ipv4, and that I was just confused by all the
loops when reading the code.
2020-07-01 20:17:29 +02:00
Erik Ekman
0bda621d3d ip4: Verify ipv4 fragmentation sends all chunks right away
Ahead of investigation how ipv6 code behaves.
2020-07-01 20:16:24 +02:00
Erik Ekman
2faa2d7009 ip6: Rename pbuf in unit test
../../../../src/../test/unit/ip6/test_ip6.c: In function ‘test_ip6_dest_unreachable_chained_pbuf’:
../../../../src/../test/unit/ip6/test_ip6.c:314:16: error: ‘main’ is usually a function [-Werror=main]
   struct pbuf *main = pbuf_alloc(PBUF_RAW, sizeof(udp_hdr), PBUF_ROM);
                ^~~~
cc1: all warnings being treated as errors
2020-07-01 10:46:33 +02:00
Erik Ekman
e2ae25d158 ip6: Add test for fragmenting special packet
Reproduces bug #57374 (Found by Hiromasa Ito).
2020-06-30 01:27:32 +02:00
Erik Ekman
90b3e45c31 pbuf: Add pbuf_copy test operating on chained pbufs
With the payload lengths not matching between source and destination.

Also remove redundant allocation check in other test, it is now done
in the test setup code.
2020-06-29 19:45:18 +02:00
Erik Ekman
bc1da0bddb pbuf: Remove redundant tests that pbufs are freed
Already checked by lwip_check_ensure_no_alloc() in teardown function.
2020-06-24 01:00:12 +02:00
Erik Ekman
dd913250a9 icmp6: add test case for returning copy of chained pbufs
Currently fails due to bug #58553
2020-06-24 01:00:12 +02:00
Erik Ekman
b58e0061e0 unit: Improve message when the mem heap has usage
Show "mem heap still has 216 bytes allocated"
instead of "Assertion 'lwip_stats.mem.used == 0' failed"
2020-06-24 01:00:02 +02:00
Erik Ekman
ff67ce6e07 unit: Improve message when a memp pool has entries
Show "memp pool 'PBUF_REF/ROM' still has 2 entries allocated"
instead of "Assertion 'lwip_stats.memp[i]->used == 0' failed"
2020-06-22 00:51:09 +02:00
Erik Ekman
ea111c511e unit: Support check v0.13.0 and later
Function name no longer needs to be fed separately when adding tests.

Also fix collision of non-static net_test variables in dhcp and netif
tests.
2020-06-19 15:39:15 +02:00
Erik Ekman
9b1056ef0e fuzz: Fix compile error in simulated glibc rand
When using LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC:

fuzz_common.c: In function ‘lwip_fuzz_rand’:
fuzz_common.c:683:11: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
  683 |   if (idx >= sizeof(rand_nrs)/sizeof((rand_nrs)[0])) {
      |           ^~
cc1: all warnings being treated as errors
2020-06-19 13:26:58 +02:00
Simon Goldschmidt
e30d50710d fuzz: allow overriding LWIP_RAND for fuzz tests
Fuzz tests need reproducible code, so we need an "unsafe" version of
LWIP_RAND() in this case...

Also, to reproduce fuzz tests cases from Linux on Windows,
LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC provides the first 20 random numbers that
glibc would have...
2020-03-27 22:42:06 +01:00
Simon Goldschmidt
003f5cc12d fuzz: whitespace fixes 2020-03-09 21:50:50 +01:00
Simon Goldschmidt
b795784832 fuzz: make CC overridable from 'afl-gcc'
e.g. for debugging crashes
2020-03-09 21:40:30 +01:00
Simon Goldschmidt
412c8d1902 fuzz: fix compiler error "missing prototype" 2020-03-08 20:41:53 +01:00
Simon Goldschmidt
74cd9a8644 ip4: add unit test for ip4addr_aton 2020-03-05 21:28:52 +01:00
Simon Goldschmidt
a02f34a193 fuzz: add pcap output to help debugging fuzz crashes 2020-03-05 21:00:00 +01:00
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