mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-09-18 07:00:07 +00:00
api_msg: fix tcp_abort thread safety
As this tcp_abort could be directly called by application thread without locking the TCP/TP core. This commit also reworks and fixes CI: 1) Unit tests build with format-f warnings with GCC-11 2) Reworked to use common shell scripts from both GitLab and GitHub CI
This commit is contained in:
@@ -26,19 +26,8 @@ jobs:
|
|||||||
python -m pip install lxml junit-xml
|
python -m pip install lxml junit-xml
|
||||||
wget --no-verbose ${WGET_CHECK2JUNIT_PY}
|
wget --no-verbose ${WGET_CHECK2JUNIT_PY}
|
||||||
|
|
||||||
- name: Build and Run unit tests with make
|
- name: Build and Run unit tests with make and cmake
|
||||||
run: |
|
run: ./test/ci/unit_tests.sh
|
||||||
export LWIPDIR=../../../../src && cd ${CONTRIB}/ports/unix/check
|
|
||||||
make -j 4 check
|
|
||||||
make clean
|
|
||||||
export EXTRA_CFLAGS="-DESP_LWIP=1" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
make -j 4 check
|
|
||||||
make clean
|
|
||||||
export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
make -j 4 check
|
|
||||||
make clean
|
|
||||||
export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1 -DIP_NAPT=1 -DLWIP_ARCH_CC_H -include cc_esp_platform.h" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
make -j 4 check
|
|
||||||
|
|
||||||
- name: Run cmake
|
- name: Run cmake
|
||||||
run: mkdir build && cd build && cmake .. -G Ninja
|
run: mkdir build && cd build && cmake .. -G Ninja
|
||||||
@@ -48,38 +37,10 @@ jobs:
|
|||||||
run: cd build && cmake --build . --target lwipdocs
|
run: cd build && cmake --build . --target lwipdocs
|
||||||
|
|
||||||
- name: Validate combinations of options
|
- name: Validate combinations of options
|
||||||
run: |
|
run: ./test/ci/validate_opts.sh
|
||||||
cp ${CONTRIB}/examples/example_app/lwipcfg.h.example ${CONTRIB}/examples/example_app/lwipcfg.h
|
|
||||||
cd ${CONTRIB}/ports/unix/example_app
|
|
||||||
export CFLAGS="-DESP_LWIP=LWIP_NETCONN_FULLDUPLEX -DESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_DNS_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_IGMP_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_MLD6_TIMERS_ONDEMAND=ESP_LWIP -DESP_DNS=ESP_LWIP -DESP_LWIP_ARP=ESP_LWIP"
|
|
||||||
export LWIPDIR=../../../../src/
|
|
||||||
make TESTFLAGS="-Wno-documentation" -j 4
|
|
||||||
chmod +x iteropts.sh && ./iteropts.sh
|
|
||||||
|
|
||||||
- name: Build and run unit tests with cmake
|
|
||||||
run: |
|
|
||||||
export LWIP_DIR=`pwd`
|
|
||||||
cd ${CONTRIB}/ports/unix/check
|
|
||||||
mkdir build && cd build && cmake -DLWIP_DIR=`pwd`/../../../../.. .. -G Ninja
|
|
||||||
cmake --build . && ./lwip_unittests
|
|
||||||
python ${LWIP_DIR}/check2junit.py lwip_unittests.xml > ${LWIP_DIR}/unit_tests.xml
|
|
||||||
|
|
||||||
- name: Build and run test apps
|
- name: Build and run test apps
|
||||||
run: |
|
run: ./test/ci/test_apps.sh
|
||||||
export LWIP_DIR=`pwd` && export LWIP_CONTRIB_DIR=`pwd`/${CONTRIB}
|
|
||||||
cd test/apps
|
|
||||||
# Prepare a failing report in case we get stuck (check in no-fork mode)
|
|
||||||
python socket_linger_stress_test.py failed > ${LWIP_DIR}/socket_linger_stress_test.xml
|
|
||||||
for cfg in config_no_linger config_linger config_linger_reuse; do
|
|
||||||
cmake -DCI_BUILD=1 -DTEST_CONFIG=${cfg} -B ${cfg} -G Ninja .
|
|
||||||
cmake --build ${cfg}/
|
|
||||||
timeout 10 ./${cfg}/lwip_test_apps
|
|
||||||
python ${LWIP_DIR}/check2junit.py lwip_test_apps.xml > ${LWIP_DIR}/${cfg}.xml
|
|
||||||
done
|
|
||||||
# Run the lingering test multiple times
|
|
||||||
for run in {1..10000}; do ( timeout 10 ./config_linger/lwip_test_apps ) || exit 1 ; done
|
|
||||||
# All good, regenerate the stress test-report, since the test succeeded
|
|
||||||
python socket_linger_stress_test.py > ${LWIP_DIR}/socket_linger_stress_test.xml
|
|
||||||
|
|
||||||
- name: Upload Test Results
|
- name: Upload Test Results
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
+3
-44
@@ -37,36 +37,7 @@ run_unittests:
|
|||||||
dependencies: []
|
dependencies: []
|
||||||
script:
|
script:
|
||||||
- *get_contrib
|
- *get_contrib
|
||||||
- export LWIPDIR=../../../../src && cd ${CONTRIB}/ports/unix/check
|
- ./test/ci/unit_tests.sh
|
||||||
# build and run default lwip tests (ESP_LWIP=0!)
|
|
||||||
- make -j 4 check
|
|
||||||
# retest with ESP_LWIP patches
|
|
||||||
- make clean
|
|
||||||
- export EXTRA_CFLAGS="-DESP_LWIP=1" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
- make -j 4 check
|
|
||||||
# retest with IP_FORWARD enabled
|
|
||||||
- make clean
|
|
||||||
- export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
- make -j 4 check
|
|
||||||
# retest with IP_FORWARD and IP_NAPT enabled
|
|
||||||
- make clean
|
|
||||||
- export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1 -DIP_NAPT=1 -DLWIP_ARCH_CC_H -include cc_esp_platform.h" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
- make -j 4 check
|
|
||||||
# Please uncomment the below to test IP_FORWARD/IP_NAPT tests with debug output (only ip4_route test suite will be executed)
|
|
||||||
#- make clean
|
|
||||||
#- export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1 -DESP_TEST_DEBUG=1 -DIP_NAPT=1 -DLWIP_ARCH_CC_H -include cc_esp_platform.h" && export CC="${CC} $EXTRA_CFLAGS"
|
|
||||||
#- make -j 4 check
|
|
||||||
|
|
||||||
run_unittests_cmake:
|
|
||||||
stage: host_test
|
|
||||||
tags:
|
|
||||||
- host_test
|
|
||||||
script:
|
|
||||||
- *get_contrib
|
|
||||||
- *get_cmake
|
|
||||||
- cd ${CONTRIB}/ports/unix/check
|
|
||||||
- mkdir build && cd build && cmake -DLWIP_DIR=`pwd`/../../../../.. .. -G Ninja
|
|
||||||
- cmake --build . && ./lwip_unittests
|
|
||||||
|
|
||||||
build_all:
|
build_all:
|
||||||
stage: host_test
|
stage: host_test
|
||||||
@@ -84,11 +55,7 @@ validate_opts:
|
|||||||
- host_test
|
- host_test
|
||||||
script:
|
script:
|
||||||
- *get_contrib
|
- *get_contrib
|
||||||
- cp ${CONTRIB}/examples/example_app/lwipcfg.h.example ${CONTRIB}/examples/example_app/lwipcfg.h
|
- ./test/ci/validate_opts.sh
|
||||||
- cd ${CONTRIB}/ports/unix/example_app
|
|
||||||
- export CFLAGS="-DESP_LWIP=LWIP_NETCONN_FULLDUPLEX -DESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_DNS_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_IGMP_TIMERS_ONDEMAND=ESP_LWIP -DESP_LWIP_MLD6_TIMERS_ONDEMAND=ESP_LWIP -DESP_DNS=ESP_LWIP"
|
|
||||||
- export LWIPDIR=../../../../src/
|
|
||||||
- chmod +x iteropts.sh && ./iteropts.sh
|
|
||||||
|
|
||||||
run_test_apps:
|
run_test_apps:
|
||||||
stage: host_test
|
stage: host_test
|
||||||
@@ -97,15 +64,7 @@ run_test_apps:
|
|||||||
script:
|
script:
|
||||||
- *get_contrib
|
- *get_contrib
|
||||||
- *get_cmake
|
- *get_cmake
|
||||||
- export LWIP_DIR=`pwd` && export LWIP_CONTRIB_DIR=`pwd`/${CONTRIB}
|
- ./test/ci/test_apps.sh
|
||||||
- cd test/apps
|
|
||||||
- for cfg in config_no_linger config_linger config_linger_reuse; do
|
|
||||||
- cmake -DCI_BUILD=1 -DTEST_CONFIG=${cfg} -B ${cfg} -G Ninja .
|
|
||||||
- cmake --build ${cfg}/
|
|
||||||
- timeout 10 ./${cfg}/lwip_test_apps
|
|
||||||
- mv lwip_test_apps.xml ${cfg}.xml
|
|
||||||
- done
|
|
||||||
- for run in {1..10000}; do ( timeout 10 ./config_linger/lwip_test_apps ) || exit 1 ; done
|
|
||||||
|
|
||||||
.add_gh_key_remote: &add_gh_key_remote |
|
.add_gh_key_remote: &add_gh_key_remote |
|
||||||
command -v ssh-agent >/dev/null || exit 1
|
command -v ssh-agent >/dev/null || exit 1
|
||||||
|
|||||||
@@ -840,6 +840,20 @@ netconn_free(struct netconn *conn)
|
|||||||
memp_free(MEMP_NETCONN, conn);
|
memp_free(MEMP_NETCONN, conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ESP_LWIP
|
||||||
|
struct tcp_psb_msg {
|
||||||
|
struct tcpip_api_call_data call;
|
||||||
|
struct tcp_pcb *pcb;
|
||||||
|
};
|
||||||
|
|
||||||
|
static err_t tcp_do_abort(struct tcpip_api_call_data *msg)
|
||||||
|
{
|
||||||
|
struct tcp_psb_msg *pcb_msg = __containerof(msg, struct tcp_psb_msg, call);
|
||||||
|
tcp_abort(pcb_msg->pcb);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
#endif /* ESP_LWIP */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete rcvmbox and acceptmbox of a netconn and free the left-over data in
|
* Delete rcvmbox and acceptmbox of a netconn and free the left-over data in
|
||||||
* these mboxes
|
* these mboxes
|
||||||
@@ -902,7 +916,13 @@ netconn_drain(struct netconn *conn)
|
|||||||
#endif /* ESP_LWIP */
|
#endif /* ESP_LWIP */
|
||||||
netconn_drain(newconn);
|
netconn_drain(newconn);
|
||||||
if (newconn->pcb.tcp != NULL) {
|
if (newconn->pcb.tcp != NULL) {
|
||||||
|
#if ESP_LWIP
|
||||||
|
struct tcp_psb_msg pcb_msg = { 0 };
|
||||||
|
pcb_msg.pcb = newconn->pcb.tcp;
|
||||||
|
tcpip_api_call(tcp_do_abort, &pcb_msg.call);
|
||||||
|
#else
|
||||||
tcp_abort(newconn->pcb.tcp);
|
tcp_abort(newconn->pcb.tcp);
|
||||||
|
#endif /* ESP_LWIP */
|
||||||
newconn->pcb.tcp = NULL;
|
newconn->pcb.tcp = NULL;
|
||||||
}
|
}
|
||||||
netconn_free(newconn);
|
netconn_free(newconn);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ endif()
|
|||||||
set (LWIP_DEFINITIONS -DLWIP_DEBUG -DLWIP_NOASSERT_ON_ERROR -DLWIP_OPTTEST_FILE)
|
set (LWIP_DEFINITIONS -DLWIP_DEBUG -DLWIP_NOASSERT_ON_ERROR -DLWIP_OPTTEST_FILE)
|
||||||
set (LWIP_INCLUDE_DIRS
|
set (LWIP_INCLUDE_DIRS
|
||||||
"${LWIP_DIR}/test/apps"
|
"${LWIP_DIR}/test/apps"
|
||||||
|
"${LWIP_DIR}/test/unix"
|
||||||
"${LWIP_CONTRIB_DIR}/ports/unix/port/include"
|
"${LWIP_CONTRIB_DIR}/ports/unix/port/include"
|
||||||
"${LWIP_DIR}/test/unit"
|
"${LWIP_DIR}/test/unit"
|
||||||
"${LWIP_DIR}/src/include"
|
"${LWIP_DIR}/src/include"
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import sys
|
try:
|
||||||
from junit_xml import TestSuite as ts, TestCase as tc
|
import sys
|
||||||
|
from junit_xml import TestSuite as ts, TestCase as tc
|
||||||
|
|
||||||
t=tc("lingering close stress test")
|
t=tc("lingering close stress test")
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "failed":
|
if len(sys.argv) > 1 and sys.argv[1] == "failed":
|
||||||
t.add_failure_info("test got stuck when closing clients socket")
|
t.add_failure_info("test got stuck when closing clients socket")
|
||||||
print(ts.to_xml_string([ts("SOCKET SO_LINGER stress test", [t])]))
|
print(ts.to_xml_string([ts("SOCKET SO_LINGER stress test", [t])]))
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
print()
|
||||||
|
|||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export LWIP_DIR=`pwd`
|
||||||
|
export LWIP_CONTRIB_DIR=`pwd`/${CONTRIB}
|
||||||
|
|
||||||
|
cd test/apps
|
||||||
|
# Prepare a failing report in case we get stuck (check in no-fork mode)
|
||||||
|
python socket_linger_stress_test.py failed > ${LWIP_DIR}/socket_linger_stress_test.xml
|
||||||
|
for cfg in config_no_linger config_linger config_linger_reuse; do
|
||||||
|
cmake -DCI_BUILD=1 -DTEST_CONFIG=${cfg} -B ${cfg} -G Ninja .
|
||||||
|
cmake --build ${cfg}/
|
||||||
|
timeout 10 ./${cfg}/lwip_test_apps
|
||||||
|
[ -f check2junit.py ] &&
|
||||||
|
python ${LWIP_DIR}/check2junit.py lwip_test_apps.xml > ${LWIP_DIR}/${cfg}.xml
|
||||||
|
done
|
||||||
|
# Run the lingering test multiple times
|
||||||
|
for run in {1..10000}; do ( timeout 10 ./config_linger/lwip_test_apps ) || exit 1 ; done
|
||||||
|
# All good, regenerate the stress test-report, since the test succeeded
|
||||||
|
python socket_linger_stress_test.py > ${LWIP_DIR}/socket_linger_stress_test.xml
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export CI_ROOT_DIR=`pwd`
|
||||||
|
export LWIPDIR=../../../../src
|
||||||
|
export ORIG_CC=${CC}
|
||||||
|
pushd `pwd`
|
||||||
|
cd ${CONTRIB}/ports/unix/check
|
||||||
|
|
||||||
|
### with GNU Make
|
||||||
|
|
||||||
|
# build and run default lwip tests (ESP_LWIP=0!)
|
||||||
|
make clean
|
||||||
|
make -j 4 check
|
||||||
|
# retest with ESP_LWIP patches
|
||||||
|
make clean
|
||||||
|
export EXTRA_CFLAGS="-DESP_LWIP=1" && export CC="${ORIG_CC} ${EXTRA_CFLAGS}"
|
||||||
|
make -j 4 check
|
||||||
|
# retest with IP_FORWARD enabled
|
||||||
|
make clean
|
||||||
|
export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1" && export CC="${ORIG_CC} ${EXTRA_CFLAGS}"
|
||||||
|
make -j 4 check
|
||||||
|
# retest with IP_FORWARD and IP_NAPT enabled
|
||||||
|
make clean
|
||||||
|
export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1 -DIP_NAPT=1" && export CC="${ORIG_CC} ${EXTRA_CFLAGS}"
|
||||||
|
make -j 4 check
|
||||||
|
# Please uncomment the below to test IP_FORWARD/IP_NAPT tests with debug output (only ip4_route test suite will be executed)
|
||||||
|
make clean
|
||||||
|
export EXTRA_CFLAGS="-DESP_LWIP=1 -DIP_FORWARD=1 -DESP_TEST_DEBUG=1 -DIP_NAPT=1" && export CC="${ORIG_CC} ${EXTRA_CFLAGS}"
|
||||||
|
make -j 4 check
|
||||||
|
|
||||||
|
|
||||||
|
### with CMake
|
||||||
|
cd ${CI_ROOT_DIR}/${CONTRIB}/ports/unix/check
|
||||||
|
rm -rf build
|
||||||
|
export EXTRA_CFLAGS=""
|
||||||
|
export CC="${ORIG_CC}"
|
||||||
|
mkdir build && cd build && cmake -DLWIP_DIR=`pwd`/../../../../.. .. -G Ninja
|
||||||
|
cmake --build . && ./lwip_unittests
|
||||||
|
[ -f ${CI_ROOT_DIR}/check2junit.py ] &&
|
||||||
|
python ${CI_ROOT_DIR}/check2junit.py lwip_unittests.xml > ${CI_ROOT_DIR}/unit_tests.xml
|
||||||
|
|
||||||
|
popd
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export CFLAGS="-I../../../../test/unix -include esp_lwipopts.h"
|
||||||
|
export LWIPDIR=../../../../src/
|
||||||
|
cp ${CONTRIB}/examples/example_app/lwipcfg.h.example ${CONTRIB}/examples/example_app/lwipcfg.h
|
||||||
|
cd ${CONTRIB}/ports/unix/example_app
|
||||||
|
|
||||||
|
make TESTFLAGS="-Wno-documentation" -j 4
|
||||||
|
chmod +x iteropts.sh
|
||||||
|
./iteropts.sh
|
||||||
@@ -56,10 +56,6 @@
|
|||||||
#define LWIP_ERRNO_STDINCLUDE 1
|
#define LWIP_ERRNO_STDINCLUDE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LWIP_RAND
|
|
||||||
#define LWIP_RAND() ((u32_t)rand())
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* different handling for unit test, normally not needed */
|
/* different handling for unit test, normally not needed */
|
||||||
#ifdef LWIP_NOASSERT_ON_ERROR
|
#ifdef LWIP_NOASSERT_ON_ERROR
|
||||||
#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
|
#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
|
||||||
@@ -85,4 +81,8 @@ typedef struct sio_status_s sio_status_t;
|
|||||||
|
|
||||||
typedef unsigned int sys_prot_t;
|
typedef unsigned int sys_prot_t;
|
||||||
|
|
||||||
|
#ifndef __containerof
|
||||||
|
#define __containerof(ptr, type, member) ((type *)(void *)((char *)ptr - offsetof(type, member)))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_ARCH_CC_ESP_H */
|
#endif /* LWIP_ARCH_CC_ESP_H */
|
||||||
@@ -195,7 +195,7 @@ START_TEST(test_pbuf_take_at_edge)
|
|||||||
|
|
||||||
out = (u8_t*)p->payload;
|
out = (u8_t*)p->payload;
|
||||||
for (i = 0; i < (int)sizeof(testdata); i++) {
|
for (i = 0; i < (int)sizeof(testdata); i++) {
|
||||||
fail_unless(out[i] == testdata[i],
|
ck_assert_msg(out[i] == testdata[i],
|
||||||
"Bad data at pos %d, was %02X, expected %02X", i, out[i], testdata[i]);
|
"Bad data at pos %d, was %02X, expected %02X", i, out[i], testdata[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,11 +204,11 @@ START_TEST(test_pbuf_take_at_edge)
|
|||||||
fail_unless(res == ERR_OK);
|
fail_unless(res == ERR_OK);
|
||||||
|
|
||||||
out = (u8_t*)p->payload;
|
out = (u8_t*)p->payload;
|
||||||
fail_unless(out[p->len - 1] == testdata[0],
|
ck_assert_msg(out[p->len - 1] == testdata[0],
|
||||||
"Bad data at pos %d, was %02X, expected %02X", p->len - 1, out[p->len - 1], testdata[0]);
|
"Bad data at pos %d, was %02X, expected %02X", p->len - 1, out[p->len - 1], testdata[0]);
|
||||||
out = (u8_t*)q->payload;
|
out = (u8_t*)q->payload;
|
||||||
for (i = 1; i < (int)sizeof(testdata); i++) {
|
for (i = 1; i < (int)sizeof(testdata); i++) {
|
||||||
fail_unless(out[i-1] == testdata[i],
|
ck_assert_msg(out[i-1] == testdata[i],
|
||||||
"Bad data at pos %d, was %02X, expected %02X", p->len - 1 + i, out[i-1], testdata[i]);
|
"Bad data at pos %d, was %02X, expected %02X", p->len - 1 + i, out[i-1], testdata[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ START_TEST(test_pbuf_take_at_edge)
|
|||||||
|
|
||||||
out = (u8_t*)p->payload;
|
out = (u8_t*)p->payload;
|
||||||
for (i = 0; i < (int)sizeof(testdata); i++) {
|
for (i = 0; i < (int)sizeof(testdata); i++) {
|
||||||
fail_unless(out[i] == testdata[i],
|
ck_assert_msg(out[i] == testdata[i],
|
||||||
"Bad data at pos %d, was %02X, expected %02X", p->len+i, out[i], testdata[i]);
|
"Bad data at pos %d, was %02X, expected %02X", p->len+i, out[i], testdata[i]);
|
||||||
}
|
}
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
@@ -245,11 +245,11 @@ START_TEST(test_pbuf_get_put_at_edge)
|
|||||||
pbuf_put_at(p, p->len, testdata);
|
pbuf_put_at(p, p->len, testdata);
|
||||||
|
|
||||||
out = (u8_t*)q->payload;
|
out = (u8_t*)q->payload;
|
||||||
fail_unless(*out == testdata,
|
ck_assert_msg(*out == testdata,
|
||||||
"Bad data at pos %d, was %02X, expected %02X", p->len, *out, testdata);
|
"Bad data at pos %d, was %02X, expected %02X", p->len, *out, testdata);
|
||||||
|
|
||||||
getdata = pbuf_get_at(p, p->len);
|
getdata = pbuf_get_at(p, p->len);
|
||||||
fail_unless(*out == getdata,
|
ck_assert_msg(*out == getdata,
|
||||||
"pbuf_get_at() returned bad data at pos %d, was %02X, expected %02X", p->len, getdata, *out);
|
"pbuf_get_at() returned bad data at pos %d, was %02X, expected %02X", p->len, getdata, *out);
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -225,7 +225,7 @@ static void check_pkt(struct pbuf *p, u32_t pos, const u8_t *mem, u32_t len)
|
|||||||
fail_unless(pos + len <= p->len); /* All data we seek within same pbuf */
|
fail_unless(pos + len <= p->len); /* All data we seek within same pbuf */
|
||||||
|
|
||||||
data = (u8_t*)p->payload;
|
data = (u8_t*)p->payload;
|
||||||
fail_if(memcmp(&data[pos], mem, len), "data at pos %d, len %d in packet %d did not match", pos, len, txpacket);
|
ck_assert_msg(!memcmp(&data[pos], mem, len), "data at pos %d, len %d in packet %d did not match", pos, len, txpacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32_t get_opt(u8_t opt, struct pbuf *p, u8_t *mem, u32_t max_len)
|
static u32_t get_opt(u8_t opt, struct pbuf *p, u8_t *mem, u32_t max_len)
|
||||||
@@ -541,17 +541,17 @@ START_TEST(test_dhcp)
|
|||||||
fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
|
fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
|
||||||
fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
|
fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
|
||||||
|
|
||||||
fail_unless(txpacket == 1, "TX %d packets, expected 1", txpacket); /* Nothing more sent */
|
ck_assert_msg(txpacket == 1, "TX %d packets, expected 1", txpacket); /* Nothing more sent */
|
||||||
xid = htonl(netif_dhcp_data(&net_test)->xid);
|
xid = htonl(netif_dhcp_data(&net_test)->xid);
|
||||||
memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */
|
memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */
|
||||||
send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));
|
send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer));
|
||||||
|
|
||||||
fail_unless(txpacket == 2, "TX %d packets, expected 2", txpacket); /* DHCP request sent */
|
ck_assert_msg(txpacket == 2, "TX %d packets, expected 2", txpacket); /* DHCP request sent */
|
||||||
xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */
|
xid = netif_dhcp_data(&net_test)->xid; /* Write bad xid, not using htonl! */
|
||||||
memcpy(&dhcp_ack[46], &xid, 4);
|
memcpy(&dhcp_ack[46], &xid, 4);
|
||||||
send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));
|
send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));
|
||||||
|
|
||||||
fail_unless(txpacket == 2, "TX %d packets, still expected 2", txpacket); /* No more sent */
|
ck_assert_msg(txpacket == 2, "TX %d packets, still expected 2", txpacket); /* No more sent */
|
||||||
xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
|
xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
|
||||||
memcpy(&dhcp_ack[46], &xid, 4); /* insert transaction id */
|
memcpy(&dhcp_ack[46], &xid, 4); /* insert transaction id */
|
||||||
send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));
|
send_pkt(&net_test, dhcp_ack, sizeof(dhcp_ack));
|
||||||
@@ -559,7 +559,7 @@ START_TEST(test_dhcp)
|
|||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
tick_lwip();
|
tick_lwip();
|
||||||
}
|
}
|
||||||
fail_unless(txpacket == 5, "TX %d packets, expected 5", txpacket); /* ARP requests sent */
|
ck_assert_msg(txpacket == 5, "TX %d packets, expected 5", txpacket); /* ARP requests sent */
|
||||||
|
|
||||||
/* Interface up */
|
/* Interface up */
|
||||||
fail_unless(netif_is_up(&net_test));
|
fail_unless(netif_is_up(&net_test));
|
||||||
@@ -839,7 +839,7 @@ START_TEST(test_dhcp_relayed)
|
|||||||
send_pkt(&net_test, relay_offer, sizeof(relay_offer));
|
send_pkt(&net_test, relay_offer, sizeof(relay_offer));
|
||||||
|
|
||||||
/* request sent? */
|
/* request sent? */
|
||||||
fail_unless(txpacket == 2, "txpkt = %d, should be 2", txpacket);
|
ck_assert_msg(txpacket == 2, "txpkt = %d, should be 2", txpacket);
|
||||||
xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
|
xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
|
||||||
memcpy(&relay_ack1[46], &xid, 4); /* insert transaction id */
|
memcpy(&relay_ack1[46], &xid, 4); /* insert transaction id */
|
||||||
send_pkt(&net_test, relay_ack1, sizeof(relay_ack1));
|
send_pkt(&net_test, relay_ack1, sizeof(relay_ack1));
|
||||||
@@ -847,7 +847,7 @@ START_TEST(test_dhcp_relayed)
|
|||||||
for (i = 0; i < 25; i++) {
|
for (i = 0; i < 25; i++) {
|
||||||
tick_lwip();
|
tick_lwip();
|
||||||
}
|
}
|
||||||
fail_unless(txpacket == 5, "txpkt should be 5, is %d", txpacket); /* ARP requests sent */
|
ck_assert_msg(txpacket == 5, "txpkt should be 5, is %d", txpacket); /* ARP requests sent */
|
||||||
|
|
||||||
/* Interface up */
|
/* Interface up */
|
||||||
fail_unless(netif_is_up(&net_test));
|
fail_unless(netif_is_up(&net_test));
|
||||||
@@ -860,20 +860,20 @@ START_TEST(test_dhcp_relayed)
|
|||||||
fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
|
fail_if(memcmp(&netmask, &net_test.netmask, sizeof(ip4_addr_t)));
|
||||||
fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
|
fail_if(memcmp(&gw, &net_test.gw, sizeof(ip4_addr_t)));
|
||||||
|
|
||||||
fail_unless(txpacket == 5, "txpacket = %d", txpacket);
|
ck_assert_msg(txpacket == 5, "txpacket = %d", txpacket);
|
||||||
|
|
||||||
for (i = 0; i < 108000 - 25; i++) {
|
for (i = 0; i < 108000 - 25; i++) {
|
||||||
tick_lwip();
|
tick_lwip();
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless(netif_is_up(&net_test));
|
fail_unless(netif_is_up(&net_test));
|
||||||
fail_unless(txpacket == 6, "txpacket = %d", txpacket);
|
ck_assert_msg(txpacket == 6, "txpacket = %d", txpacket);
|
||||||
|
|
||||||
/* We need to send arp response here.. */
|
/* We need to send arp response here.. */
|
||||||
|
|
||||||
send_pkt(&net_test, arp_resp, sizeof(arp_resp));
|
send_pkt(&net_test, arp_resp, sizeof(arp_resp));
|
||||||
|
|
||||||
fail_unless(txpacket == 7, "txpacket = %d", txpacket);
|
ck_assert_msg(txpacket == 7, "txpacket = %d", txpacket);
|
||||||
fail_unless(netif_is_up(&net_test));
|
fail_unless(netif_is_up(&net_test));
|
||||||
|
|
||||||
xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
|
xid = htonl(netif_dhcp_data(&net_test)->xid); /* xid updated */
|
||||||
@@ -884,7 +884,7 @@ START_TEST(test_dhcp_relayed)
|
|||||||
tick_lwip();
|
tick_lwip();
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless(txpacket == 7, "txpacket = %d", txpacket);
|
ck_assert_msg(txpacket == 7, "txpacket = %d", txpacket);
|
||||||
|
|
||||||
tcase = TEST_NONE;
|
tcase = TEST_NONE;
|
||||||
dhcp_stop(&net_test);
|
dhcp_stop(&net_test);
|
||||||
@@ -1181,7 +1181,7 @@ START_TEST(test_options)
|
|||||||
fail_unless(memcmp(vsi, &vsi_expect, 4) == 0);
|
fail_unless(memcmp(vsi, &vsi_expect, 4) == 0);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
fail_unless(txpacket == 2, "TX %d packets, expected 2", txpacket); /* DHCP request sent */
|
ck_assert_msg(txpacket == 2, "TX %d packets, expected 2", txpacket); /* DHCP request sent */
|
||||||
fail_unless(last_message_type == DHCP_REQUEST);
|
fail_unless(last_message_type == DHCP_REQUEST);
|
||||||
memcpy(dhcp_with_opts, dhcp_ack, sizeof(dhcp_ack));
|
memcpy(dhcp_with_opts, dhcp_ack, sizeof(dhcp_ack));
|
||||||
optptr = &dhcp_with_opts[309]; /* point to the END marker of the original packet */
|
optptr = &dhcp_with_opts[309]; /* point to the END marker of the original packet */
|
||||||
@@ -1211,7 +1211,7 @@ START_TEST(test_options)
|
|||||||
if (last_message_type == DHCP_REQUEST)
|
if (last_message_type == DHCP_REQUEST)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fail_unless(txpacket == 7, "TX %d packets, expected 7", txpacket); /* DHCP renewal */
|
ck_assert_msg(txpacket == 7, "TX %d packets, expected 7", txpacket); /* DHCP renewal */
|
||||||
|
|
||||||
#if ESP_LWIP && LWIP_DHCP_ENABLE_VENDOR_SPEC_IDS
|
#if ESP_LWIP && LWIP_DHCP_ENABLE_VENDOR_SPEC_IDS
|
||||||
dhcp_free_vendor_class_identifier();
|
dhcp_free_vendor_class_identifier();
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ START_TEST(test_etharp_table)
|
|||||||
LWIP_UNUSED_ARG(_i);
|
LWIP_UNUSED_ARG(_i);
|
||||||
|
|
||||||
if (netif_default != &test_netif) {
|
if (netif_default != &test_netif) {
|
||||||
fail("This test needs a default netif");
|
ck_abort_msg("This test needs a default netif");
|
||||||
}
|
}
|
||||||
|
|
||||||
linkoutput_ctr = 0;
|
linkoutput_ctr = 0;
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ void dhcp_free_vendor_class_identifier(void);
|
|||||||
/* NAPT options */
|
/* NAPT options */
|
||||||
#ifdef IP_NAPT
|
#ifdef IP_NAPT
|
||||||
#define IP_NAPT_MAX 16
|
#define IP_NAPT_MAX 16
|
||||||
#undef LWIP_RAND
|
|
||||||
#define LWIP_RAND() (esp_random())
|
#define LWIP_RAND() (esp_random())
|
||||||
#include "lwip/arch.h"
|
#include "lwip/arch.h"
|
||||||
u32_t esp_random(void);
|
u32_t esp_random(void);
|
||||||
@@ -166,6 +165,8 @@ u32_t esp_random(void);
|
|||||||
#define ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND 1
|
#define ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND 1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define LWIP_RAND() ((u32_t)rand())
|
||||||
#define ESP_LWIP 0
|
#define ESP_LWIP 0
|
||||||
#define ESP_DNS 0
|
#define ESP_DNS 0
|
||||||
#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 0
|
#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 0
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#include "../../unit/arch/cc.h"
|
||||||
|
|
||||||
|
#ifndef LWIP_RAND
|
||||||
|
#define LWIP_RAND() ((u32_t)rand())
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#define ESP_LWIP LWIP_NETCONN_FULLDUPLEX
|
||||||
|
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND ESP_LWIP
|
||||||
|
#define ESP_LWIP_IP6_REASSEMBLY_TIMERS_ONDEMAND ESP_LWIP
|
||||||
|
#define ESP_LWIP_DNS_TIMERS_ONDEMAND ESP_LWIP
|
||||||
|
#define ESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND ESP_LWIP
|
||||||
|
#define ESP_LWIP_IGMP_TIMERS_ONDEMAND ESP_LWIP
|
||||||
|
#define ESP_LWIP_MLD6_TIMERS_ONDEMAND ESP_LWIP
|
||||||
|
#define ESP_DNS ESP_LWIP
|
||||||
|
#define ESP_LWIP_ARP ESP_LWIP
|
||||||
Reference in New Issue
Block a user