Commit 5eb974d8 authored by Paul Sokolovsky's avatar Paul Sokolovsky Committed by Ioannis Glaropoulos
Browse files

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: default avatarPaul Sokolovsky <paul.sokolovsky@linaro.org>
parent a358248a
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
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
+1 −1
Original line number Diff line number Diff line
@@ -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>
+13 −5
Original line number Diff line number Diff line
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
+1 −1
Original line number Diff line number Diff line
@@ -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>
+12 −3
Original line number Diff line number Diff line
@@ -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
Loading