mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-06-05 21:04:45 +00:00
ci: Add github/lab build/run unit tests on linux
Co-Authored-By: Erik Ekman <erik@kryo.se> (lwip-tcpip/lwip@853258ff) Co-Authored-By: xueyunfei <xueyunfei@espressif.com> (espressif/esp-lwip@74e2fa32) Ref IDF-4797
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
compiler: [gcc, clang]
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
LSAN_OPTIONS: verbosity=1:log_threads=1
|
||||
WGET_PATH: http://download.savannah.nongnu.org/releases/lwip
|
||||
CONTRIB: contrib-2.1.0
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install check ninja-build doxygen
|
||||
wget --no-verbose ${WGET_PATH}/${CONTRIB}.zip
|
||||
unzip -oq ${CONTRIB}.zip
|
||||
patch -s -p0 < test/${CONTRIB}.patch
|
||||
|
||||
- name: Build unit tests with make
|
||||
run: LWIPDIR=../../../../src make -C ${CONTRIB}/ports/unix/check
|
||||
- name: Run unit tests
|
||||
run: LWIPDIR=../../../../src make -C ${CONTRIB}/ports/unix/check check
|
||||
|
||||
- name: Run cmake
|
||||
run: mkdir build && cd build && cmake .. -G Ninja
|
||||
- name: Build with cmake
|
||||
run: cd build && cmake --build .
|
||||
- name: Build docs with cmake
|
||||
run: cd build && cmake --build . --target lwipdocs
|
||||
|
||||
- name: Validate combinations of options
|
||||
run: |
|
||||
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"
|
||||
export LWIPDIR=../../../../src/
|
||||
chmod +x iteropts.sh && ./iteropts.sh
|
||||
|
||||
- name: Build and run unit tests with cmake
|
||||
run: |
|
||||
cd ${CONTRIB}/ports/unix/check
|
||||
mkdir build && cd build && cmake -DLWIP_DIR=`pwd`/../../../../.. .. -G Ninja
|
||||
cmake --build . && ./lwip_unittests
|
||||
@@ -0,0 +1,98 @@
|
||||
stages:
|
||||
- host_test
|
||||
- deploy
|
||||
|
||||
image: ${CI_DOCKER_REGISTRY}/esp-env-v5.0:2
|
||||
|
||||
variables:
|
||||
# tag in lwip-contrib repo, which supports our esp-lwip branch (and it's cherry-picked commits from release branches)
|
||||
LWIP_CONTRIB_TAG: STABLE-2_1_0_RELEASE
|
||||
# test timeout is seconds
|
||||
TEST_TIMEOUT: 200
|
||||
CONTRIB: contrib-2.1.0
|
||||
CMAKE_SH: cmake-3.22.3-linux-x86_64.sh
|
||||
|
||||
before_script:
|
||||
# Use CI Tools
|
||||
- curl -sSL ${CIT_LOADER_URL} | sh
|
||||
- source citools/import_functions
|
||||
|
||||
.get_cmake: &get_cmake |
|
||||
wget -q https://github.com/Kitware/CMake/releases/download/v3.22.3/${CMAKE_SH}
|
||||
mkdir -p /opt/cmake && sh ${CMAKE_SH} --prefix=/opt/cmake --skip-license
|
||||
export PATH=/opt/cmake/bin:$PATH
|
||||
|
||||
.get_contrib: &get_contrib |
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
||||
base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
echo -e "Host ${GITLAB_HOSTNAME}\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
git clone "${LWIP_CONTRIB_MIRROR}" ${CONTRIB} && cd ${CONTRIB} && git checkout tags/${LWIP_CONTRIB_TAG}
|
||||
cd .. && sed -i $'s/\r$//' test/contrib-2.1.0.patch && patch -s -p0 < test/${CONTRIB}.patch
|
||||
|
||||
run_unittests:
|
||||
stage: host_test
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
script:
|
||||
- *get_contrib
|
||||
- LWIPDIR=../../../../src make -C ${CONTRIB}/ports/unix/check 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:
|
||||
stage: host_test
|
||||
tags:
|
||||
- host_test
|
||||
script:
|
||||
- *get_cmake
|
||||
- mkdir build && cd build && cmake .. -G Ninja
|
||||
- cmake --build .
|
||||
- cmake --build . --target lwipdocs
|
||||
|
||||
validate_opts:
|
||||
stage: host_test
|
||||
tags:
|
||||
- host_test
|
||||
script:
|
||||
- *get_contrib
|
||||
- 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"
|
||||
- export LWIPDIR=../../../../src/
|
||||
- chmod +x iteropts.sh && ./iteropts.sh
|
||||
|
||||
|
||||
.add_gh_key_remote: &add_gh_key_remote |
|
||||
command -v ssh-agent >/dev/null || exit 1
|
||||
eval $(ssh-agent -s)
|
||||
printf '%s\n' "${GH_PUSH_KEY}" | tr -d '\r' | ssh-add - > /dev/null
|
||||
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config || ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
|
||||
git remote remove github || true
|
||||
git remote add github ${GH_PUSH_REPO}
|
||||
|
||||
push_master_to_github:
|
||||
stage: deploy
|
||||
only:
|
||||
- 2.1.2-esp
|
||||
when: on_success
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
script:
|
||||
- *add_gh_key_remote
|
||||
- "[ -n \"${CI_COMMIT_TAG:-}\" ] && git push github ${CI_COMMIT_TAG}"
|
||||
- "[ -z \"${CI_COMMIT_TAG:-}\" ] && git push github ${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}"
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
diff -ruN contrib-2.1.0/examples/example_app/test_configs/opt_no_tcp_dualstack.h contrib-2.1.0-P/examples/example_app/test_configs/opt_no_tcp_dualstack.h
|
||||
--- contrib-2.1.0/examples/example_app/test_configs/opt_no_tcp_dualstack.h 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/examples/example_app/test_configs/opt_no_tcp_dualstack.h 2022-03-19 15:07:57.455415829 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_configs/opt_dualstack.h"
|
||||
|
||||
#undef LWIP_TCP
|
||||
-#define LWIP_TCP 0
|
||||
\ No newline at end of file
|
||||
+#define LWIP_TCP 0
|
||||
diff -ruN contrib-2.1.0/examples/example_app/test_configs/opt_no_tcp_ipv4only.h contrib-2.1.0-P/examples/example_app/test_configs/opt_no_tcp_ipv4only.h
|
||||
--- contrib-2.1.0/examples/example_app/test_configs/opt_no_tcp_ipv4only.h 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/examples/example_app/test_configs/opt_no_tcp_ipv4only.h 2022-03-19 15:08:27.446964821 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_configs/opt_ipv4only.h"
|
||||
|
||||
#undef LWIP_TCP
|
||||
-#define LWIP_TCP 0
|
||||
\ No newline at end of file
|
||||
+#define LWIP_TCP 0
|
||||
diff -ruN contrib-2.1.0/examples/example_app/test_configs/opt_no_tcp_ipv6only.h contrib-2.1.0-P/examples/example_app/test_configs/opt_no_tcp_ipv6only.h
|
||||
--- contrib-2.1.0/examples/example_app/test_configs/opt_no_tcp_ipv6only.h 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/examples/example_app/test_configs/opt_no_tcp_ipv6only.h 2022-03-19 15:08:36.622826844 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_configs/opt_ipv6only.h"
|
||||
|
||||
#undef LWIP_TCP
|
||||
-#define LWIP_TCP 0
|
||||
\ No newline at end of file
|
||||
+#define LWIP_TCP 0
|
||||
diff -ruN contrib-2.1.0/examples/example_app/test_configs/opt_no_udp_dualstack.h contrib-2.1.0-P/examples/example_app/test_configs/opt_no_udp_dualstack.h
|
||||
--- contrib-2.1.0/examples/example_app/test_configs/opt_no_udp_dualstack.h 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/examples/example_app/test_configs/opt_no_udp_dualstack.h 2022-03-19 15:08:43.974716296 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_configs/opt_dualstack.h"
|
||||
|
||||
#undef LWIP_UDP
|
||||
-#define LWIP_UDP 0
|
||||
\ No newline at end of file
|
||||
+#define LWIP_UDP 0
|
||||
diff -ruN contrib-2.1.0/examples/example_app/test_configs/opt_no_udp_ipv4only.h contrib-2.1.0-P/examples/example_app/test_configs/opt_no_udp_ipv4only.h
|
||||
--- contrib-2.1.0/examples/example_app/test_configs/opt_no_udp_ipv4only.h 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/examples/example_app/test_configs/opt_no_udp_ipv4only.h 2022-03-19 15:08:48.590646888 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_configs/opt_ipv4only.h"
|
||||
|
||||
#undef LWIP_UDP
|
||||
-#define LWIP_UDP 0
|
||||
\ No newline at end of file
|
||||
+#define LWIP_UDP 0
|
||||
diff -ruN contrib-2.1.0/examples/example_app/test_configs/opt_no_udp_ipv6only.h contrib-2.1.0-P/examples/example_app/test_configs/opt_no_udp_ipv6only.h
|
||||
--- contrib-2.1.0/examples/example_app/test_configs/opt_no_udp_ipv6only.h 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/examples/example_app/test_configs/opt_no_udp_ipv6only.h 2022-03-19 15:08:52.490588248 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_configs/opt_ipv6only.h"
|
||||
|
||||
#undef LWIP_UDP
|
||||
-#define LWIP_UDP 0
|
||||
\ No newline at end of file
|
||||
+#define LWIP_UDP 0
|
||||
diff -ruN contrib-2.1.0/ports/CMakeCommon.cmake contrib-2.1.0-P/ports/CMakeCommon.cmake
|
||||
--- contrib-2.1.0/ports/CMakeCommon.cmake 2018-09-04 22:54:08.000000000 +0200
|
||||
+++ contrib-2.1.0-P/ports/CMakeCommon.cmake 2022-03-19 15:03:40.651279436 +0100
|
||||
@@ -73,7 +73,6 @@
|
||||
-fsanitize=undefined
|
||||
-fno-sanitize=alignment
|
||||
-fstack-protector
|
||||
- -fstack-check
|
||||
)
|
||||
set(LWIP_SANITIZER_LIBS asan ubsan)
|
||||
endif()
|
||||
diff -ruN contrib-2.1.0/ports/unix/check/CMakeLists.txt contrib-2.1.0-P/ports/unix/check/CMakeLists.txt
|
||||
--- contrib-2.1.0/ports/unix/check/CMakeLists.txt 2018-09-04 22:54:08.000000000 +0200
|
||||
+++ contrib-2.1.0-P/ports/unix/check/CMakeLists.txt 2022-03-19 15:03:40.651279436 +0100
|
||||
@@ -7,14 +7,12 @@
|
||||
endif()
|
||||
|
||||
set(LWIP_CONTRIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||
-set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../lwip)
|
||||
|
||||
set(LWIP_USE_SANITIZERS true)
|
||||
include(${LWIP_CONTRIB_DIR}/ports/CMakeCommon.cmake)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
|
||||
# check.h causes 'error: token pasting of ',' and __VA_ARGS__ is a GNU extension' with clang 9.0.0
|
||||
- list(LWIP_COMPILER_FLAGS APPEND -Wno-gnu-zero-variadic-macro-arguments)
|
||||
endif()
|
||||
|
||||
set (LWIP_DEFINITIONS -DLWIP_DEBUG -DLWIP_NOASSERT_ON_ERROR)
|
||||
diff -ruN contrib-2.1.0/ports/unix/example_app/iteropts.sh contrib-2.1.0-P/ports/unix/example_app/iteropts.sh
|
||||
--- contrib-2.1.0/ports/unix/example_app/iteropts.sh 2018-09-12 22:16:02.000000000 +0200
|
||||
+++ contrib-2.1.0-P/ports/unix/example_app/iteropts.sh 2022-03-19 15:03:40.651279436 +0100
|
||||
@@ -1,24 +1,34 @@
|
||||
-#!/bin/bash
|
||||
-
|
||||
-LOGFILE=iteropts.log
|
||||
-EXAPPDIR=../../../examples/example_app
|
||||
-
|
||||
-pushd `dirname "$0"`
|
||||
-pwd
|
||||
-echo Starting Iteropts run >> $LOGFILE
|
||||
-for f in $EXAPPDIR/test_configs/*.h
|
||||
-do
|
||||
- echo Cleaning...
|
||||
- make clean
|
||||
- BUILDLOG=$(basename "$f" ".h").log
|
||||
- echo testing $f
|
||||
- echo testing $f >> $LOGFILE
|
||||
- rm $EXAPPDIR/lwipopts_test.h
|
||||
- # cat the file to update its timestamp
|
||||
- cat $f > $EXAPPDIR/lwipopts_test.h
|
||||
- make TESTFLAGS=-DLWIP_OPTTEST_FILE -j 8 &> $BUILDLOG 2>&1 || echo file $f failed >> $LOGFILE
|
||||
- echo test $f done >> $LOGFILE
|
||||
-done
|
||||
-echo done, cleaning
|
||||
-make clean
|
||||
-popd
|
||||
+#!/bin/bash
|
||||
+
|
||||
+LOGFILE=iteropts.log
|
||||
+EXAPPDIR=../../../examples/example_app
|
||||
+RETVAL=0
|
||||
+
|
||||
+pushd `dirname "$0"`
|
||||
+pwd
|
||||
+echo Starting Iteropts run >> $LOGFILE
|
||||
+for f in $EXAPPDIR/test_configs/*.h
|
||||
+do
|
||||
+ echo Cleaning...
|
||||
+ make clean > /dev/null
|
||||
+ BUILDLOG=$(basename "$f" ".h").log
|
||||
+ echo testing $f
|
||||
+ echo testing $f >> $LOGFILE
|
||||
+ rm -f $EXAPPDIR/lwipopts_test.h
|
||||
+ # cat the file to update its timestamp
|
||||
+ cat $f > $EXAPPDIR/lwipopts_test.h
|
||||
+ make TESTFLAGS="-DLWIP_OPTTEST_FILE -Wno-documentation" -j 4 1> $BUILDLOG 2>&1
|
||||
+ ERR=$?
|
||||
+ if [ $ERR != 0 ]; then
|
||||
+ cat $BUILDLOG
|
||||
+ echo file $f failed with $ERR >> $LOGFILE
|
||||
+ echo ++++++++ $f FAILED +++++++
|
||||
+ RETVAL=1
|
||||
+ fi
|
||||
+ echo test $f done >> $LOGFILE
|
||||
+done
|
||||
+echo done, cleaning
|
||||
+make clean > /dev/null
|
||||
+popd
|
||||
+echo Exit value: $RETVAL
|
||||
+exit $RETVAL
|
||||
diff -ruN contrib-2.1.0/ports/unix/port/include/arch/sys_arch.h contrib-2.1.0-P/ports/unix/port/include/arch/sys_arch.h
|
||||
--- contrib-2.1.0/ports/unix/port/include/arch/sys_arch.h 2018-07-12 21:24:16.000000000 +0200
|
||||
+++ contrib-2.1.0-P/ports/unix/port/include/arch/sys_arch.h 2022-03-19 15:05:59.193194629 +0100
|
||||
@@ -59,5 +59,8 @@
|
||||
struct sys_thread;
|
||||
typedef struct sys_thread * sys_thread_t;
|
||||
|
||||
+#define LWIP_EXAMPLE_APP_ABORT() lwip_unix_keypressed()
|
||||
+int lwip_unix_keypressed(void);
|
||||
+
|
||||
#endif /* LWIP_ARCH_SYS_ARCH_H */
|
||||
|
||||
diff -ruN contrib-2.1.0/ports/unix/port/sys_arch.c contrib-2.1.0-P/ports/unix/port/sys_arch.c
|
||||
--- contrib-2.1.0/ports/unix/port/sys_arch.c 2018-09-04 22:02:58.000000000 +0200
|
||||
+++ contrib-2.1.0-P/ports/unix/port/sys_arch.c 2022-03-19 15:07:13.416078142 +0100
|
||||
@@ -717,3 +717,14 @@
|
||||
}
|
||||
}
|
||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
||||
+
|
||||
+/* get keyboard state to terminate the debug app by using select */
|
||||
+int
|
||||
+lwip_unix_keypressed(void)
|
||||
+{
|
||||
+ struct timeval tv = { 0L, 0L };
|
||||
+ fd_set fds;
|
||||
+ FD_ZERO(&fds);
|
||||
+ FD_SET(0, &fds);
|
||||
+ return select(1, &fds, NULL, NULL, &tv);
|
||||
+}
|
||||
Reference in New Issue
Block a user