samples: net: sockets: Allow to build and test with POSIX subsys

With CONFIG_POSIX_API enabled, these samples now build under Zephyr
with exactly the same source as e.g. Linux (or in general, other POSIX
systems). However, building without CONFIG_POSIX_API (i.e. with
CONFIG_NET_SOCKETS_POSIX_NAMES aux option) is retained for now.

Add testcase definitions to build these samples with CONFIG_POSIX_API
in CI.

Fixes: #17353

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2019-08-28 13:49:15 +03:00 committed by Ioannis Glaropoulos
commit 5eb974d8e7
9 changed files with 60 additions and 23 deletions

View file

@ -1,10 +1,18 @@
sample:
description: BSD Sockets big HTTP download example
name: big_http_download
tests:
sample.net.sockets.big_http_download:
common:
filter: TOOLCHAIN_HAS_NEWLIB == 1
harness: net
min_ram: 32
min_flash: 128
tags: net socket
tests:
sample.net.sockets.big_http_download:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.big_http_download.posix:
filter: and not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y

View file

@ -11,7 +11,7 @@
#include "mbedtls/md.h"
#ifndef __ZEPHYR__
#if !defined(__ZEPHYR__) || defined(CONFIG_POSIX_API)
#include <netinet/in.h>
#include <sys/socket.h>

View file

@ -1,10 +1,18 @@
sample:
description: BSD Sockets API dumb HTTP server example
name: socket_dumb_http_server
tests:
sample.net.sockets.dumb_http_server:
common:
filter: TOOLCHAIN_HAS_NEWLIB == 1
harness: net
min_ram: 32
min_flash: 96
tags: net socket
tests:
sample.net.sockets.dumb_http_server:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.dumb_http_server.posix:
filter: and not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y

View file

@ -8,7 +8,7 @@
#include <stdlib.h>
#include <errno.h>
#ifndef __ZEPHYR__
#if !defined(__ZEPHYR__) || defined(CONFIG_POSIX_API)
#include <netinet/in.h>
#include <sys/socket.h>

View file

@ -2,8 +2,17 @@ sample:
description: BSD Sockets API TCP echo server sample
using non-blocking sockets
name: socket_echo_async
tests:
sample.net.sockets.echo_async:
common:
filter: TOOLCHAIN_HAS_NEWLIB == 1
harness: net
platform_whitelist: qemu_x86
tags: net socket
tests:
sample.net.sockets.echo_async:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
sample.net.sockets.echo_async.posix:
filter: and not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y

View file

@ -9,7 +9,7 @@
#include <errno.h>
#include <stdlib.h>
#ifndef __ZEPHYR__
#if !defined(__ZEPHYR__) || defined(CONFIG_POSIX_API)
#include <netinet/in.h>
#include <sys/socket.h>

View file

@ -9,10 +9,11 @@
#include <errno.h>
#include <stdlib.h>
#ifndef __ZEPHYR__
#if !defined(__ZEPHYR__) || defined(CONFIG_POSIX_API)
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>

View file

@ -1,10 +1,21 @@
sample:
description: BSD Sockets API HTTP GET example
name: socket_http_get
tests:
sample.net.sockets.http_get:
common:
filter: TOOLCHAIN_HAS_NEWLIB == 1
harness: net
min_ram: 32
min_flash: 80
tags: net socket
tests:
sample.net.sockets.http_get:
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=y
# Forcibly defines CONFIG_POSIX_API, which is incompatible with
# CONFIG_NET_SOCKETS_POSIX_NAMES.
platform_exclude: cc3220sf_launchxl
sample.net.sockets.http_get.posix:
filter: and not CONFIG_NET_SOCKETS_OFFLOAD
extra_configs:
- CONFIG_NET_SOCKETS_POSIX_NAMES=n
- CONFIG_POSIX_API=y

View file

@ -7,7 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef __ZEPHYR__
#if !defined(__ZEPHYR__) || defined(CONFIG_POSIX_API)
#include <netinet/in.h>
#include <sys/socket.h>