From b3749e38f9a37d6df456bd61b723dc92e42e1b07 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 16 Apr 2020 07:50:32 +0200 Subject: [PATCH] ppp-test: check if ppp interface is active and IP address correct before starting the test Addressing stability of pppos test: * listing active network interfaces for presence of "ppp0" interface * fixed IPv6 address regex to prevent ttfw accept partial address only (less than 8 octets) * workaround crash after exiting app_main() --- tools/test_apps/protocols/pppos/app_test.py | 9 ++++++++- tools/test_apps/protocols/pppos/main/pppos_client_main.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/test_apps/protocols/pppos/app_test.py b/tools/test_apps/protocols/pppos/app_test.py index 9111868e05..818fe17f5e 100644 --- a/tools/test_apps/protocols/pppos/app_test.py +++ b/tools/test_apps/protocols/pppos/app_test.py @@ -5,6 +5,7 @@ import socket import subprocess import ttfw_idf import time +import netifaces from threading import Thread, Event @@ -58,7 +59,13 @@ def test_examples_protocol_pppos_connect(env, extra_data): t = Thread(target=run_server, args=(server_stop, port, server_ip, client_ip)) t.start() try: - ip6_addr = dut1.expect(re.compile(r"Got IPv6 address ([0-9a-f\:]+)"), timeout=30)[0] + ppp_server_timeout = time.time() + 30 + while "ppp0" not in netifaces.interfaces(): + print("PPP server haven't yet setup its netif, list of active netifs:{}".format(netifaces.interfaces())) + time.sleep(0.5) + if time.time() > ppp_server_timeout: + raise ValueError("ENV_TEST_FAILURE: PPP server failed to setup ppp0 interface within timeout") + ip6_addr = dut1.expect(re.compile(r"Got IPv6 address (\w{4}\:\w{4}\:\w{4}\:\w{4}\:\w{4}\:\w{4}\:\w{4}\:\w{4})"), timeout=30)[0] print("IPv6 address of ESP: {}".format(ip6_addr)) dut1.expect(re.compile(r"Socket listening")) diff --git a/tools/test_apps/protocols/pppos/main/pppos_client_main.c b/tools/test_apps/protocols/pppos/main/pppos_client_main.c index 058257125d..568486df85 100644 --- a/tools/test_apps/protocols/pppos/main/pppos_client_main.c +++ b/tools/test_apps/protocols/pppos/main/pppos_client_main.c @@ -247,6 +247,8 @@ void app_main(void) ESP_LOGE(TAG, "IPv6 test failed!"); } + /* Wait for the PPP server to stop */ + vTaskDelay(30000 / portTICK_PERIOD_MS); ESP_ERROR_CHECK(esp_modem_stop_ppp(dte)); /* Destroy the netif adapter withe events, which internally frees also the esp-netif instance */ esp_modem_netif_clear_default_handlers(modem_netif_adapter);