From 71c9b87abc0da28f805313ec2236ac75ef8b726c Mon Sep 17 00:00:00 2001
From: Oleg Hahm <oleg@riot-os.org>
Date: Wed, 13 Dec 2023 21:13:13 +0100
Subject: [PATCH] examples: tests: update native TERMFLAGS

Updating the Makefiles for example and test applications to set the
TERMFLAGS correctly for native.
---
 examples/gcoap/Makefile                                 | 4 ++--
 examples/gcoap_dtls/Makefile                            | 4 ++--
 examples/gnrc_border_router/Makefile.native.conf        | 2 +-
 examples/gnrc_networking/Makefile                       | 4 ++--
 tests/net/emcute/Makefile                               | 2 +-
 tests/net/gcoap_fileserver/Makefile                     | 2 +-
 tests/net/gnrc_dhcpv6_client_6lbr/Makefile              | 2 +-
 tests/net/gnrc_dhcpv6_relay/Makefile                    | 2 +-
 tests/net/gnrc_ipv6_ext/Makefile                        | 2 +-
 tests/net/gnrc_ipv6_ext_frag/Makefile                   | 2 +-
 tests/net/gnrc_ipv6_ext_opt/Makefile                    | 2 +-
 tests/net/gnrc_ipv6_nib_dns/Makefile                    | 2 +-
 tests/net/gnrc_netif_ieee802154/Makefile                | 2 +-
 tests/net/gnrc_rpl/Makefile                             | 2 +-
 tests/net/gnrc_rpl_srh/Makefile                         | 2 +-
 tests/net/gnrc_sixlowpan_frag_sfr_congure_impl/Makefile | 2 +-
 tests/net/gnrc_sock_dns/Makefile                        | 2 +-
 tests/net/gnrc_sock_dodtls/Makefile                     | 2 +-
 tests/net/gnrc_sock_tcp/Makefile                        | 2 +-
 tests/net/gnrc_tcp/Makefile                             | 2 +-
 tests/net/ieee802154_hal/Makefile                       | 2 +-
 tests/net/ieee802154_submac/Makefile                    | 2 +-
 tests/net/socket_zep/Makefile                           | 2 +-
 tests/net/socket_zep/tests/01-run.py                    | 6 +++---
 24 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/examples/gcoap/Makefile b/examples/gcoap/Makefile
index 5a203246819c7..b6b8f4fc19c39 100644
--- a/examples/gcoap/Makefile
+++ b/examples/gcoap/Makefile
@@ -70,11 +70,11 @@ USE_ZEP ?= 0
 # set the ZEP port for native
 ZEP_PORT_BASE ?= 17754
 ifeq (1,$(USE_ZEP))
-  TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE)
+  TERMFLAGS += --native-args '-z [::1]:$(ZEP_PORT_BASE)'
   USEMODULE += socket_zep
 
   ifneq (,$(ZEP_MAC))
-    TERMFLAGS += --eui64=$(ZEP_MAC)
+    TERMFLAGS += --native-args '\-\-eui64=$(ZEP_MAC)'
   endif
 endif
 
diff --git a/examples/gcoap_dtls/Makefile b/examples/gcoap_dtls/Makefile
index 08d94fd248278..647be9722a238 100644
--- a/examples/gcoap_dtls/Makefile
+++ b/examples/gcoap_dtls/Makefile
@@ -82,11 +82,11 @@ USE_ZEP ?= 0
 # set the ZEP port for native
 ZEP_PORT_BASE ?= 17754
 ifeq (1,$(USE_ZEP))
-  TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE)
+  TERMFLAGS += --native-args '-z [::1]:$(ZEP_PORT_BASE)'
   USEMODULE += socket_zep
 
   ifneq (,$(ZEP_MAC))
-    TERMFLAGS += --eui64=$(ZEP_MAC)
+    TERMFLAGS += --native-args '\-\-eui64=$(ZEP_MAC)'
   endif
 endif
 
diff --git a/examples/gnrc_border_router/Makefile.native.conf b/examples/gnrc_border_router/Makefile.native.conf
index 947424b8bf487..5234b0f0aaf33 100644
--- a/examples/gnrc_border_router/Makefile.native.conf
+++ b/examples/gnrc_border_router/Makefile.native.conf
@@ -41,7 +41,7 @@ TERMFLAGS ?= $(patsubst %,-z [::1]:%, $(shell seq $(ZEP_PORT_BASE) $(ZEP_PORT_MA
 
 # set optional ZEP l2 address
 ifneq (,$(ZEP_MAC))
-  TERMFLAGS += --eui64=$(ZEP_MAC)
+  TERMFLAGS += --native-args '\-\-eui64=$(ZEP_MAC)'
 endif
 
 # native uses $PORT to specify the TAP interface
diff --git a/examples/gnrc_networking/Makefile b/examples/gnrc_networking/Makefile
index b4f919eddf213..4eb45bdb514eb 100644
--- a/examples/gnrc_networking/Makefile
+++ b/examples/gnrc_networking/Makefile
@@ -47,11 +47,11 @@ USE_ZEP ?= 0
 # set the ZEP port for native
 ZEP_PORT_BASE ?= 17754
 ifeq (1,$(USE_ZEP))
-  TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE)
+  TERMFLAGS += --native-args '-z [::1]:$(ZEP_PORT_BASE)'
   USEMODULE += socket_zep
 
   ifneq (,$(ZEP_MAC))
-    TERMFLAGS += --eui64=$(ZEP_MAC)
+    TERMFLAGS += --native-args '\-\-eui64=$(ZEP_MAC)'
   endif
 endif
 
diff --git a/tests/net/emcute/Makefile b/tests/net/emcute/Makefile
index 441c524ae6dea..c37c5160720ba 100644
--- a/tests/net/emcute/Makefile
+++ b/tests/net/emcute/Makefile
@@ -6,7 +6,7 @@ export TAP ?= tap0
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT += $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gcoap_fileserver/Makefile b/tests/net/gcoap_fileserver/Makefile
index 2bd00ed769684..e3bcdbb10d93b 100644
--- a/tests/net/gcoap_fileserver/Makefile
+++ b/tests/net/gcoap_fileserver/Makefile
@@ -37,7 +37,7 @@ ifeq (native, $(BOARD))
   USEMODULE += socket_zep
   USEMODULE += socket_zep_hello
   USEMODULE += netdev
-  TERMFLAGS += -z 127.0.0.1:17754 # Murdock has no IPv6 support
+  TERMFLAGS += --native-args '-z 127.0.0.1:17754' # Murdock has no IPv6 support
   # make sure each instance gets their own fs
   CFLAGS += -DCONFIG_NATIVE_ISOLATE_FS=1
 else
diff --git a/tests/net/gnrc_dhcpv6_client_6lbr/Makefile b/tests/net/gnrc_dhcpv6_client_6lbr/Makefile
index 6fbf4da34f3e0..bb1f054892cda 100644
--- a/tests/net/gnrc_dhcpv6_client_6lbr/Makefile
+++ b/tests/net/gnrc_dhcpv6_client_6lbr/Makefile
@@ -15,7 +15,7 @@ USEMODULE += shell_cmds_default
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS += -z [::1]:17754
+  TERMFLAGS += --native-args '-z [::1]:17754'
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_dhcpv6_relay/Makefile b/tests/net/gnrc_dhcpv6_relay/Makefile
index 66334905a0347..4376191ab6c1e 100644
--- a/tests/net/gnrc_dhcpv6_relay/Makefile
+++ b/tests/net/gnrc_dhcpv6_relay/Makefile
@@ -12,7 +12,7 @@ USEMODULE += gnrc_netif_single          # Only one interface used and it makes
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_ipv6_ext/Makefile b/tests/net/gnrc_ipv6_ext/Makefile
index 9e802876cf752..6e53ff607bdb0 100644
--- a/tests/net/gnrc_ipv6_ext/Makefile
+++ b/tests/net/gnrc_ipv6_ext/Makefile
@@ -6,7 +6,7 @@ export TAP ?= tap0
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_ipv6_ext_frag/Makefile b/tests/net/gnrc_ipv6_ext_frag/Makefile
index 771ab061c5f4e..7a7a22491addf 100644
--- a/tests/net/gnrc_ipv6_ext_frag/Makefile
+++ b/tests/net/gnrc_ipv6_ext_frag/Makefile
@@ -8,7 +8,7 @@ CFLAGS += -DOUTPUT=TEXT
 CFLAGS += -DTEST_SUITES="gnrc_ipv6_ext_frag"
 
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_ipv6_ext_opt/Makefile b/tests/net/gnrc_ipv6_ext_opt/Makefile
index af95d8bbf321d..e6c4bb403ed6a 100644
--- a/tests/net/gnrc_ipv6_ext_opt/Makefile
+++ b/tests/net/gnrc_ipv6_ext_opt/Makefile
@@ -6,7 +6,7 @@ export TAP ?= tap0
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_ipv6_nib_dns/Makefile b/tests/net/gnrc_ipv6_nib_dns/Makefile
index 172e3cefb61d9..fe5e3792f1d99 100644
--- a/tests/net/gnrc_ipv6_nib_dns/Makefile
+++ b/tests/net/gnrc_ipv6_nib_dns/Makefile
@@ -10,7 +10,7 @@ USEMODULE += gnrc_ipv6_default
 USEMODULE += gnrc_ipv6_nib_dns
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_netif_ieee802154/Makefile b/tests/net/gnrc_netif_ieee802154/Makefile
index 6e8e0f3226666..84b8d763efcea 100644
--- a/tests/net/gnrc_netif_ieee802154/Makefile
+++ b/tests/net/gnrc_netif_ieee802154/Makefile
@@ -4,7 +4,7 @@ include ../Makefile.net_common
 
 ifeq (native, $(BOARD))
   USEMODULE += socket_zep
-  TERMFLAGS ?= -z "0.0.0.0:17755,localhost:17754"
+  TERMFLAGS ?= --native-args '-z "0.0.0.0:17755,localhost:17754"'
   USEMODULE += netdev
   # somehow this breaks the test
   DISABLE_MODULE += test_utils_print_stack_usage
diff --git a/tests/net/gnrc_rpl/Makefile b/tests/net/gnrc_rpl/Makefile
index c548be23f426a..d8778e5a8a1ec 100644
--- a/tests/net/gnrc_rpl/Makefile
+++ b/tests/net/gnrc_rpl/Makefile
@@ -13,7 +13,7 @@ ifeq (native, $(BOARD))
   USEMODULE += socket_zep
   USEMODULE += socket_zep_hello
   USEMODULE += netdev
-  TERMFLAGS += -z 127.0.0.1:17754 # Murdock has no IPv6 support
+  TERMFLAGS += --native-args '-z 127.0.0.1:17754' # Murdock has no IPv6 support
 else
   USEMODULE += netdev_default
   # automated test only works on native
diff --git a/tests/net/gnrc_rpl_srh/Makefile b/tests/net/gnrc_rpl_srh/Makefile
index 8222db51c2667..f00a1df1852af 100644
--- a/tests/net/gnrc_rpl_srh/Makefile
+++ b/tests/net/gnrc_rpl_srh/Makefile
@@ -8,7 +8,7 @@ CFLAGS += -DOUTPUT=TEXT
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_sixlowpan_frag_sfr_congure_impl/Makefile b/tests/net/gnrc_sixlowpan_frag_sfr_congure_impl/Makefile
index 22765e6245f82..10e868266ac56 100644
--- a/tests/net/gnrc_sixlowpan_frag_sfr_congure_impl/Makefile
+++ b/tests/net/gnrc_sixlowpan_frag_sfr_congure_impl/Makefile
@@ -28,7 +28,7 @@ ifeq (native, $(BOARD))
   USEMODULE += socket_zep
   USEMODULE += socket_zep_hello
   USEMODULE += netdev
-  TERMFLAGS = -z 127.0.0.1:17754 # Murdock has no IPv6 support
+  TERMFLAGS = --native-args '-z 127.0.0.1:17754' # Murdock has no IPv6 support
 else
   USEMODULE += netdev_default
   # automated test only works on native
diff --git a/tests/net/gnrc_sock_dns/Makefile b/tests/net/gnrc_sock_dns/Makefile
index d4be69f3f7395..9a14321d8c8a3 100644
--- a/tests/net/gnrc_sock_dns/Makefile
+++ b/tests/net/gnrc_sock_dns/Makefile
@@ -11,7 +11,7 @@ USEMODULE += gnrc_netif_single          # Only one interface used and it makes
                                         # shell commands easier
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_sock_dodtls/Makefile b/tests/net/gnrc_sock_dodtls/Makefile
index ced402a5942aa..be677aa52914e 100644
--- a/tests/net/gnrc_sock_dodtls/Makefile
+++ b/tests/net/gnrc_sock_dodtls/Makefile
@@ -21,7 +21,7 @@ USEPKG += tinydtls
 
 # use Ethernet as link-layer protocol
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_sock_tcp/Makefile b/tests/net/gnrc_sock_tcp/Makefile
index 17ecf9d095424..0230b56c2f32e 100644
--- a/tests/net/gnrc_sock_tcp/Makefile
+++ b/tests/net/gnrc_sock_tcp/Makefile
@@ -13,7 +13,7 @@ TIMEOUT_MS ?= 3000
 TEST_ON_CI_BLACKLIST += all
 
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/gnrc_tcp/Makefile b/tests/net/gnrc_tcp/Makefile
index fff4172cf8c89..989c0603a7b9a 100644
--- a/tests/net/gnrc_tcp/Makefile
+++ b/tests/net/gnrc_tcp/Makefile
@@ -18,7 +18,7 @@ CUSTOM_GNRC_TCP_NO_TIMEOUT ?= 1
 TEST_ON_CI_BLACKLIST += all
 
 ifeq (native,$(BOARD))
-  TERMFLAGS ?= $(TAP)
+  PORT ?= $(TAP)
 else
   ETHOS_BAUDRATE ?= 115200
   CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE)
diff --git a/tests/net/ieee802154_hal/Makefile b/tests/net/ieee802154_hal/Makefile
index c684e36a220fc..4233ca6a96d05 100644
--- a/tests/net/ieee802154_hal/Makefile
+++ b/tests/net/ieee802154_hal/Makefile
@@ -27,7 +27,7 @@ BOARD_WHITELIST += adafruit-clue \
 
 ifeq ($(BOARD), native)
   ZEP_PORT_BASE ?= 17754
-  TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE)
+  TERMFLAGS += --native-args '-z [::1]:$(ZEP_PORT_BASE)'
   USEMODULE += socket_zep
   # the same for Kconfig
   ifeq (1,$(TEST_KCONFIG))
diff --git a/tests/net/ieee802154_submac/Makefile b/tests/net/ieee802154_submac/Makefile
index 2dec0b082d01b..688294937d97c 100644
--- a/tests/net/ieee802154_submac/Makefile
+++ b/tests/net/ieee802154_submac/Makefile
@@ -40,7 +40,7 @@ USEMODULE += ztimer_usec
 
 ifeq ($(BOARD), native)
   ZEP_PORT_BASE ?= 17754
-  TERMFLAGS += -z [::1]:$(ZEP_PORT_BASE)
+  TERMFLAGS += --native-args '-z [::1]:$(ZEP_PORT_BASE)'
   USEMODULE += socket_zep
 endif
 
diff --git a/tests/net/socket_zep/Makefile b/tests/net/socket_zep/Makefile
index 18ec781596860..7bb9d945f989f 100644
--- a/tests/net/socket_zep/Makefile
+++ b/tests/net/socket_zep/Makefile
@@ -6,6 +6,6 @@ USEMODULE += od
 USEMODULE += socket_zep
 USEMODULE += netdev
 
-TERMFLAGS ?= -z [::1]:17754
+TERMFLAGS ?= --native-args '-z [::1]:17754'
 
 include $(RIOTBASE)/Makefile.include
diff --git a/tests/net/socket_zep/tests/01-run.py b/tests/net/socket_zep/tests/01-run.py
index b72f66137b0e4..1d4e4ca8fefff 100755
--- a/tests/net/socket_zep/tests/01-run.py
+++ b/tests/net/socket_zep/tests/01-run.py
@@ -51,9 +51,9 @@ def testfunc(child):
 
 
 if __name__ == "__main__":
-    os.environ['TERMFLAGS'] = "--eui64=00:5a:45:50:0a:00:30:38 -z [%s]:%d,[%s]:%d" % (
-            zep_params['local_addr'], zep_params['local_port'],
-            zep_params['remote_addr'], zep_params['remote_port'])
+    os.environ['TERMFLAGS'] = "--native-args '\\-\\-eui64=00:5a:45:50:0a:00:30:38' --native-args '-z [%s]:%d,[%s]:%d'"\
+            % (zep_params['local_addr'], zep_params['local_port'],
+               zep_params['remote_addr'], zep_params['remote_port'])
     s = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
     s.bind(("127.0.0.1", zep_params['remote_port']))
     res = run(testfunc, timeout=1, echo=True, traceback=True)