Skip to content

Commit

Permalink
ci: Add simple CI test
Browse files Browse the repository at this point in the history
with relaxed criteria on the lingering test, as the fix is not added yet
  • Loading branch information
david-cermak committed Sep 10, 2024
1 parent 531e799 commit f49974d
Show file tree
Hide file tree
Showing 22 changed files with 999 additions and 21 deletions.
54 changes: 38 additions & 16 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
name: CI

on:
push:
branches: [master]
on: [push, pull_request]

jobs:
build:
build-and-test:
strategy:
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
LSAN_OPTIONS: verbosity=1:log_threads=1
WGET_CHECK2JUNIT_PY: https://raw.githubusercontent.com/gsauthof/utility/42792030/check2junit.py
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install deps
run: sudo apt-get install check ninja-build doxygen
run: |
sudo apt-get install check ninja-build doxygen
python -m pip install lxml junit-xml
wget --no-verbose ${WGET_CHECK2JUNIT_PY}
- name: Build and Run unit tests with make and cmake
run: ./test/ci/unit_tests.sh

- name: Copy lwipcfg.h for example app
run: cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h

- name: Build unit tests with make
run: make -C contrib/ports/unix/check
- name: Run unit tests
run: make -C contrib/ports/unix/check check

- name: Run cmake
run: mkdir build && cd build && cmake .. -G Ninja
- name: Build with cmake
Expand All @@ -35,9 +34,32 @@ jobs:
run: cd build && cmake --build . --target lwipdocs

- name: Validate combinations of options
run: cd contrib/ports/unix/example_app && ./iteropts.sh
run: ./test/ci/validate_opts.sh

- name: Build the default example app
run: |
cp contrib/examples/example_app/lwipcfg.h.example contrib/examples/example_app/lwipcfg.h
make -C contrib/ports/unix/example_app TESTFLAGS="-Wno-documentation" -j 4
- name: Build and run test apps
run: ./test/ci/test_apps.sh

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Test Results ${{ matrix.compiler }}
path: "*.xml"

publish-test-results:
name: "Publish Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
checks: write
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "artifacts/**/*.xml"
75 changes: 75 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
stages:
- host_test
- deploy

image: ${CI_DOCKER_REGISTRY}/esp-env-v5.0:2

variables:
CMAKE_SH: cmake-3.22.3-linux-x86_64.sh
CC: cc

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

run_unittests:
stage: host_test
tags:
- host_test
dependencies: []
script:
- ./test/ci/unit_tests.sh

build_all:
stage: host_test
tags:
- host_test
script:
- cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
- mkdir build && cd build && cmake .. -G Ninja
- cmake --build .
- cmake --build . --target lwipdocs

validate_opts:
stage: host_test
tags:
- host_test
script:
- ./test/ci/validate_opts.sh

run_test_apps:
stage: host_test
tags:
- host_test
script:
- *get_cmake
- ./test/ci/test_apps.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
- 2.1.3-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}"

2 changes: 2 additions & 0 deletions contrib/ports/CMakeCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND LWIP_COMPILER_FLAGS_GNU_CLANG
-Wlogical-op
-Wtrampolines
-fno-stack-clash-protection
-Wno-error=format-extra-args
)

if (NOT LWIP_HAVE_MBEDTLS)
Expand Down
2 changes: 1 addition & 1 deletion contrib/ports/unix/check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include(${LWIP_DIR}/contrib/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)
list(APPEND LWIP_COMPILER_FLAGS -Wno-gnu-zero-variadic-macro-arguments)
endif()

set (LWIP_DEFINITIONS -DLWIP_DEBUG -DLWIP_NOASSERT_ON_ERROR)
Expand Down
1 change: 0 additions & 1 deletion contrib/ports/unix/port/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* leaking messages.
*/
#define _GNU_SOURCE /* pull in pthread_setname_np() on Linux */

#include "lwip/debug.h"

#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion doc/doxygen/lwip.Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "lwIP"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = "2.2.0.esp"
PROJECT_NUMBER = "2.2.0.dev"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion src/api/api_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ lwip_netconn_do_close_internal(struct netconn *conn WRITE_DELAYED_PARAM)
err = ERR_OK;
/* linger enabled/required at all? (i.e. is there untransmitted data left?) */
if ((conn->linger >= 0) && (conn->pcb.tcp->unsent || conn->pcb.tcp->unacked)) {
if ((conn->linger == 0)) {
if (conn->linger == 0) {
/* data left but linger prevents waiting */
tcp_abort(tpcb);
tpcb = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/include/lwip/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern "C" {
#if LWIP_VERSION_IS_RELEASE
#define LWIP_VERSION_STRING_SUFFIX ""
#elif LWIP_VERSION_IS_DEVELOPMENT
#define LWIP_VERSION_STRING_SUFFIX "esp"
#define LWIP_VERSION_STRING_SUFFIX "d"
#else
#define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC)
#endif
Expand Down
66 changes: 66 additions & 0 deletions test/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.8)

project(lwip_test_apps C)

if (NOT CMAKE_SYSTEM_NAME STREQUAL Linux AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
message(FATAL_ERROR "Unit test are currently only working on Linux or Darwin")
endif()

if (NOT LWIP_DIR OR NOT LWIP_CONTRIB_DIR)
set(LWIP_DIR "$ENV{LWIP_DIR}")
set(LWIP_CONTRIB_DIR "$ENV{LWIP_CONTRIB_DIR}")
endif()

if (NOT CI_BUILD)
set(LWIP_USE_SANITIZERS true)
endif()

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
endif()

set (LWIP_DEFINITIONS -DLWIP_DEBUG -DLWIP_NOASSERT_ON_ERROR -DLWIP_OPTTEST_FILE)
set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/test/apps"
"${LWIP_DIR}/test/unix"
"${LWIP_CONTRIB_DIR}/ports/unix/port/include"
"${LWIP_DIR}/test/unit"
"${LWIP_DIR}/src/include"
"${LWIP_CONTRIB_DIR}/"
"${CMAKE_CURRENT_SOURCE_DIR}/"
"${CMAKE_CURRENT_SOURCE_DIR}/${TEST_CONFIG}"
)

include(${LWIP_CONTRIB_DIR}/ports/unix/Filelists.cmake)
include(${LWIP_DIR}/src/Filelists.cmake)
include(${LWIP_DIR}/test/apps/Filelists.cmake)

add_executable(lwip_test_apps ${LWIP_TESTFILES})
target_include_directories(lwip_test_apps PRIVATE ${LWIP_INCLUDE_DIRS})
target_compile_options(lwip_test_apps PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(lwip_test_apps PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})

find_library(LIBCHECK check)
find_library(LIBM m)
target_link_libraries(lwip_test_apps ${LWIP_SANITIZER_LIBS} lwipallapps lwipcore ${LIBCHECK} ${LIBM})

if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# check installed via brew on Darwin doesn't have a separate subunit library (must be statically linked)
find_library(LIBSUBUNIT subunit)
target_link_libraries(lwip_test_apps ${LIBSUBUNIT})
endif()

if (CMAKE_SYSTEM_NAME STREQUAL Linux)
find_library(LIBUTIL util)
find_library(LIBPTHREAD pthread)
find_library(LIBRT rt)
target_link_libraries(lwip_test_apps ${LIBUTIL} ${LIBPTHREAD} ${LIBRT})
endif()

if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Darwin doesn't have pthreads or POSIX real-time extensions libs
find_library(LIBUTIL util)
target_link_libraries(lwip_test_apps ${LIBUTIL})
endif()
16 changes: 16 additions & 0 deletions test/apps/Filelists.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is indended to be included in end-user CMakeLists.txt
# include(/path/to/Filelists.cmake)
# It assumes the variable LWIP_DIR is defined pointing to the
# root path of lwIP sources.
#
# This file is NOT designed (on purpose) to be used as cmake
# subdir via add_subdirectory()
# The intention is to provide greater flexibility to users to
# create their own targets using the *_SRCS variables.

set(LWIP_TESTDIR ${LWIP_DIR}/test/apps)
set(LWIP_TESTFILES
${LWIP_TESTDIR}/test_apps.c
${LWIP_TESTDIR}/test_sockets.c
${LWIP_CONTRIB_DIR}/ports/unix/port/sys_arch.c
)
4 changes: 4 additions & 0 deletions test/apps/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef LWIP_HDR_LWIP_CHECK_CONFIG_H
#define LWIP_HDR_LWIP_CHECK_CONFIG_H

#endif /* LWIP_TEST_APPS_CONFIG_H */
37 changes: 37 additions & 0 deletions test/apps/config_linger/lwipopts_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H
#define LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H

#define LWIP_SO_LINGER 1

#ifdef LWIP_DEBUG

#define LWIP_DBG_MIN_LEVEL 0
#define PPP_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#endif

#endif /* LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H */
7 changes: 7 additions & 0 deletions test/apps/config_linger_reuse/lwipopts_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H
#define LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H

#define LWIP_SO_LINGER 1
#define SO_REUSE 1

#endif /* LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H */
37 changes: 37 additions & 0 deletions test/apps/config_no_linger/lwipopts_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H
#define LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H

#define LWIP_SO_LINGER 0

#ifdef LWIP_DEBUG

#define LWIP_DBG_MIN_LEVEL 0
#define PPP_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#endif

#endif /* LWIP_HDR_TEST_APPS_LWIPOPTS_TEST_H */
Loading

0 comments on commit f49974d

Please sign in to comment.