-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lwip-tests: create port enabling run of lwip tests
JIRA: CI-329
- Loading branch information
Showing
7 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Lwip tests require check test framework | ||
CHECK_VER="0.10.0" # This version of check works fine with lwip tests, latest is incompatible | ||
CHECK="check-$CHECK_VER" | ||
CHECK_COMMIT="ad83496d1aea4d1d700d6acbec526fa2a2271968" | ||
CHECK_PKG_URL="https://github.com/libcheck/check/archive/${CHECK_COMMIT}.tar.gz" | ||
CHECK_PKG_MIRROR_URL="https://files.phoesys.com/ports/${CHECK}.tar.gz" | ||
|
||
b_log "Building check test framework" | ||
|
||
# Download check to lwip-tests directory (only lwip-tests use it) | ||
PREFIX_LWIP_TEST="${PREFIX_PROJECT}/phoenix-rtos-ports/lwip-tests" | ||
PREFIX_LWIP_TEST_BUILD="${PREFIX_BUILD}/lwip-test" | ||
PREFIX_CHECK_BUILD="${PREFIX_LWIP_TEST_BUILD}/check" | ||
PREFIX_CHECK_SRC="${PREFIX_CHECK_BUILD}/$CHECK" | ||
|
||
# | ||
# Download and unpack | ||
# | ||
if [ ! -f "${PREFIX_LWIP_TEST}/${CHECK}.tar.gz" ]; then | ||
if ! wget "$CHECK_PKG_URL" -O "${PREFIX_LWIP_TEST}/${CHECK}.tar.gz" --no-check-certificate; then | ||
wget "$CHECK_PKG_MIRROR_URL" -P "$PREFIX_LWIP_TEST" --no-check-certificate | ||
fi | ||
fi | ||
|
||
mkdir -p "$PREFIX_CHECK_BUILD" | ||
if [ ! -d "$PREFIX_CHECK_SRC" ]; then | ||
tar xzf "${PREFIX_LWIP_TEST}/${CHECK}.tar.gz" -C "$PREFIX_CHECK_BUILD" && \ | ||
mv "${PREFIX_CHECK_BUILD}/check-$CHECK_COMMIT" "${PREFIX_CHECK_SRC}" | ||
fi | ||
|
||
# | ||
# Configure | ||
# | ||
mkdir -p "${PREFIX_CHECK_BUILD}/include" | ||
if [ ! -f "{$PREFIX_CHECK_BUILD}/config.h" ]; then | ||
CHECK_CFLAGS="-std=gnu99 -I${PREFIX_CHECK_BUILD}/include" | ||
(cd "$PREFIX_CHECK_SRC" && autoreconf -i -v -f && \ | ||
PKG_CONFIG="" ./configure CC="$CC" LD="$LD" AR="$AR" STRIP="${CROSS}strip" CFLAGS="$CFLAGS $CHECK_CFLAGS" \ | ||
LDFLAGS="$LDFLAGS" --host="${HOST}" --build="x86_64-linux-gnu" --disable-subunit \ | ||
--disable-shared --disable-doc --enable-static --libdir="$PREFIX_A" \ | ||
--includedir="${PREFIX_CHECK_BUILD}/include") | ||
fi | ||
|
||
# | ||
# Make | ||
# | ||
SUBDIRS="lib src . tests" # Run makefiles from this directories | ||
make -C "$PREFIX_CHECK_SRC" | ||
make SUBDIRS="$SUBDIRS" doc_DATA="" m4data_DATA="" -C "$PREFIX_CHECK_SRC" install | ||
|
||
b_log "Building lwip-test" | ||
|
||
LWIP_CONTRIB_COMMIT="35b011d4cf4c4b480f8859c456587a884ec9d287" | ||
LWIP_CONTRIB_PKG_URL="https://github.com/particle-iot/lwip-contrib/archive/${LWIP_CONTRIB_COMMIT}.tar.gz" | ||
LWIP_CONTRIB_PKG_MIRROR_URL="https://files.phoesys.com/ports/lwip-contrib.tar.gz" | ||
PREFIX_LWIP_CONTRIB="${PREFIX_LWIP_TEST_BUILD}/contrib-lwip" | ||
PREFIX_LWIP_CHECK="${PREFIX_LWIP_CONTRIB}/ports/unix/check" | ||
PREFIX_LWIP_TEST_MARKERS="${PREFIX_LWIP_TEST_BUILD}/markers" | ||
|
||
# | ||
# Download and unpack lwip-contrib | ||
# | ||
if [ ! -f "${PREFIX_LWIP_TEST}/lwip-contrib.tar.gz" ]; then | ||
if ! wget "$LWIP_CONTRIB_PKG_URL" -O "${PREFIX_LWIP_TEST}/lwip-contrib.tar.gz" --no-check-certificate; then | ||
wget "$LWIP_CONTRIB_PKG_MIRROR_URL" -P "$PREFIX_LWIP_TEST" --no-check-certificate | ||
fi | ||
fi | ||
|
||
if [ ! -d "$PREFIX_LWIP_CONTRIB" ]; then | ||
tar xzf "${PREFIX_LWIP_TEST}/lwip-contrib.tar.gz" -C "$PREFIX_LWIP_TEST_BUILD" && \ | ||
mv "${PREFIX_LWIP_TEST_BUILD}/lwip-contrib-$LWIP_CONTRIB_COMMIT" "${PREFIX_LWIP_TEST_BUILD}/contrib-lwip" | ||
fi | ||
|
||
# | ||
# Apply patches | ||
# | ||
mkdir -p "$PREFIX_LWIP_TEST_MARKERS" | ||
for patchfile in "$PREFIX_LWIP_TEST"/patch/*; do | ||
if [ ! -f "${PREFIX_LWIP_TEST_MARKERS}/$(basename "$patchfile").applied" ]; then | ||
echo "applying patch: $patchfile" | ||
patch -d "${PREFIX_LWIP_CONTRIB}/" -p1 < "$patchfile" | ||
touch "${PREFIX_LWIP_TEST_MARKERS}/$(basename "$patchfile").applied" | ||
fi | ||
done | ||
|
||
make clean check -C "$PREFIX_LWIP_CHECK" | ||
"${CROSS}strip" -s "${PREFIX_LWIP_CHECK}/lwip_unittests" -o "${PREFIX_PROG_STRIPPED}/lwip_unittests" | ||
cp -a "${PREFIX_LWIP_CHECK}/lwip_unittests" "${PREFIX_PROG}/lwip_unittests" | ||
|
||
b_install "${PREFIX_PROG_STRIPPED}/lwip_unittests" /bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- contrib_orginal/ports/Common.allports.mk 2024-01-09 16:16:39.398560526 +0100 | ||
+++ contrib/ports/Common.allports.mk 2024-01-10 16:38:01.764990843 +0100 | ||
@@ -29,11 +29,10 @@ | ||
# Author: Adam Dunkels <adam@sics.se> | ||
# | ||
|
||
-#CC=gcc | ||
-#CC=clang | ||
+CC=$(CROSS)gcc | ||
CCDEP?=$(CC) | ||
|
||
-CFLAGS+=-g -DLWIP_DEBUG -Wall -pedantic -Werror \ | ||
+CFLAGS+=-g -DLWIP_DEBUG -Wall -pedantic \ | ||
-Wparentheses -Wsequence-point -Wswitch-default \ | ||
-Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual \ | ||
-Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align \ | ||
@@ -48,15 +47,15 @@ | ||
#CFLAGS:=$(CFLAGS) -fsanitize=address -fstack-protector -fstack-check -fsanitize=undefined -fno-sanitize=alignment | ||
else | ||
# we cannot sanitize alignment on x86-64 targets because clang wants 64 bit alignment | ||
-CFLAGS+= -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -Wdocumentation -Wno-documentation-deprecated-sync | ||
+# CFLAGS+= -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -Wdocumentation -Wno-documentation-deprecated-sync | ||
endif | ||
|
||
-CONTRIBDIR?=../../.. | ||
+CONTRIBDIR?=$(PREFIX_BUILD)/lwip-test/contrib-lwip | ||
ARFLAGS?=rs | ||
|
||
#Set this to where you have the lwip core module checked out from git | ||
#default assumes it's a dir named lwip at the same level as the contrib module | ||
-LWIPDIR?=$(CONTRIBDIR)/../lwip/src | ||
+LWIPDIR?=$(PREFIX_PROJECT)/phoenix-rtos-lwip/lib-lwip/src | ||
|
||
CFLAGS+=-I. \ | ||
-I$(CONTRIBDIR) \ | ||
@@ -64,7 +63,7 @@ | ||
-I$(LWIPARCH)/include | ||
|
||
# Add include path and link to mbedTLS lib if available | ||
-MBEDTLSDIR?=$(CONTRIBDIR)/../mbedtls | ||
+MBEDTLSDIR?=$(PREFIX_BUILD)/mbedtls/mbedtls-2.28.0 | ||
ifneq (,$(wildcard $(MBEDTLSDIR)/include/mbedtls/*.h)) | ||
LDFLAGS+=-L$(MBEDTLSDIR)/library -lmbedtls -lmbedcrypto -lmbedx509 | ||
CFLAGS+=-I$(MBEDTLSDIR)/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -Wno-c90-c99-compat | ||
@@ -77,6 +76,7 @@ | ||
LWIPFILES=$(LWIPNOAPPSFILES) $(ARCHFILES) | ||
LWIPOBJS=$(notdir $(LWIPFILES:.c=.o)) | ||
|
||
+AR=$(CROSS)ar | ||
LWIPLIBCOMMON=liblwipcommon.a | ||
$(LWIPLIBCOMMON): $(LWIPOBJS) | ||
$(AR) $(ARFLAGS) $(LWIPLIBCOMMON) $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- contrib_orginal/ports/unix/Common.mk 2024-01-09 16:16:39.402560579 +0100 | ||
+++ contrib/ports/unix/Common.mk 2024-01-10 20:01:40.592109932 +0100 | ||
@@ -42,10 +42,12 @@ | ||
UNIX_COMMON_MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
include $(UNIX_COMMON_MK_DIR)../Common.allports.mk | ||
|
||
-LDFLAGS+=-lutil | ||
+# Util lib not necessary | ||
+# LDFLAGS+=-lutil | ||
|
||
UNAME_S:= $(shell uname -s) | ||
ifneq ($(UNAME_S),Darwin) | ||
# Darwin doesn't have pthreads or POSIX real-time extensions libs | ||
-LDFLAGS+=-pthread -lrt | ||
+# Phoenix do not need real-time extensions libs and -pthread linker flag | ||
+# LDFLAGS+=-pthread -lrt | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- contrib_orginal/ports/unix/check/Makefile 2024-01-09 16:16:39.402560579 +0100 | ||
+++ contrib/ports/unix/check/Makefile 2024-01-10 20:30:23.731142432 +0100 | ||
@@ -33,7 +33,7 @@ | ||
.PHONY: all clean check | ||
|
||
# The include path to sys_arch.h and lwipopts.h must be first, so this must be before Common.mk | ||
-CFLAGS=-DLWIP_NOASSERT_ON_ERROR -I/usr/include/check -I$(LWIPDIR)/../test/unit | ||
+CFLAGS+=-DLWIP_NOASSERT_ON_ERROR -I$(LWIPDIR)/../../include/arch -I$(LWIPDIR)/../../include/default-opts/testsuite -I$(CONTRIBDIR)/../check/include | ||
|
||
# Ignore 'too many arguments for format' warnings which happen with GCCs | ||
# from check 0.15.2 on fail_if/fail_unless macros with text. | ||
@@ -46,18 +46,21 @@ | ||
endif | ||
|
||
# Prevent compiling sys_arch.c of unix port because unit test provide their own port | ||
-SYSARCH?= | ||
+PORTDIR = $(LWIPDIR)/../../port | ||
+SYSARCH?=$(wildcard $(PORTDIR)/*.c) | ||
include ../Common.mk | ||
|
||
-LDFLAGS:=-lcheck -lm $(LDFLAGS) | ||
+LDFLAGS+= -L$(PREFIX_A) -lcheck --static | ||
|
||
ifneq ($(UNAME_S),Darwin) | ||
# check installed via brew on Darwin doesn't have a separate subunit library (must be statically linked) | ||
-LDFLAGS+=-lsubunit | ||
+# Subunit not ported, tests can work without it | ||
+# LDFLAGS+=-lsubunit | ||
endif | ||
|
||
TESTDIR=$(LWIPDIR)/../test/unit | ||
include $(TESTDIR)/Filelists.mk | ||
+include $(LWIPDIR)/../test/unit/Filelists.mk | ||
TESTOBJS=$(notdir $(TESTFILES:.c=.o)) | ||
|
||
clean: | ||
@@ -83,4 +86,3 @@ | ||
endif | ||
|
||
check: lwip_unittests | ||
- @./lwip_unittests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- contrib_orginal/ports/unix/check/config.h 2024-01-09 16:16:39.402560579 +0100 | ||
+++ contrib/ports/unix/check/config.h 2024-01-11 12:56:06.185539301 +0100 | ||
@@ -1,2 +1,2 @@ | ||
/* Enable this to simplify debugging */ | ||
-/* #define LWIP_UNITTESTS_NOFORK */ | ||
+#define LWIP_UNITTESTS_NOFORK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- contrib_orginal/ports/unix/port/netif/sio.c 2024-01-09 16:16:39.406560629 +0100 | ||
+++ contrib/ports/unix/port/netif/sio.c 2024-01-10 19:53:25.386132460 +0100 | ||
@@ -44,7 +44,7 @@ | ||
#include <fcntl.h> | ||
#include <signal.h> | ||
#include <string.h> | ||
-#include <sys/signal.h> | ||
+#include <signal.h> | ||
#include <sys/types.h> | ||
|
||
#ifndef LWIP_HAVE_SLIPIF | ||
@@ -161,11 +161,20 @@ | ||
} | ||
/* Make the file descriptor asynchronous (the manual page says only | ||
O_APPEND and O_NONBLOCK, will work with F_SETFL...) */ | ||
- if ( fcntl( fd, F_SETFL, FASYNC ) != 0) | ||
+ | ||
+ | ||
+/* | ||
+ * FASYNC is not standarized by OPEN GROUP and not supported by Phoenix-RTOS | ||
+ * Comment out this code to make it compile, this code is excluded anyway since PPP_SUPPORT is defined | ||
+ */ | ||
+ | ||
+/* | ||
+ if ( fcntl( fd, F_SETFL, FASYNC ) != 0) | ||
{ | ||
perror( device ); | ||
exit( -1 ); | ||
} | ||
+*/ | ||
#else | ||
if ( fcntl( fd, F_SETFL, 0 ) != 0) | ||
{ | ||
@@ -175,6 +184,19 @@ | ||
|
||
#endif /* ! (PPP_SUPPORT || LWIP_HAVE_SLIPIF) */ | ||
|
||
+ | ||
+/* | ||
+ * Phoenix-RTOS patch | ||
+ * | ||
+ * CRTSCTS termios cflag is BSD specific, | ||
+ * This compilation is for Phoenix-RTOS which does not support this flag. | ||
+ * This macro has a chance to be forward compatible if Phoenix-RTOS will support it in the future. | ||
+ */ | ||
+#ifndef CRTSCTS | ||
+#define CRTSCTS 0 | ||
+#endif | ||
+ | ||
+ | ||
tcgetattr( fd,&oldtio ); /* save current port settings */ | ||
/* set new port settings */ | ||
/* see 'man termios' for further settings */ |