Browse Source

Merge branch 'bugfix/example_test_socket_issue_4.1' into 'release/v4.1'

CI: example test socket issue (4.1)

See merge request espressif/esp-idf!13906
He Yin Ling 4 years ago
parent
commit
5438706922

+ 1 - 0
examples/protocols/asio/chat_server/asio_chat_server_test.py

@@ -26,6 +26,7 @@ def test_examples_protocol_asio_chat_server(env, extra_data):
     # 2. get the server IP address
     data = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30)
     # 3. create tcp client and connect to server
+    dut1.expect('ASIO engine is up and running', timeout=1)
     cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     cli.settimeout(30)
     cli.connect((data[0], 2222))

+ 2 - 0
examples/protocols/asio/chat_server/main/chat_server.cpp

@@ -225,5 +225,7 @@ extern "C" void app_main(void)
       servers.emplace_back(io_context, endpoint);
     }
 
+    std::cout << "ASIO engine is up and running" << std::endl;
+
     io_context.run();
 }

+ 1 - 0
examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py

@@ -27,6 +27,7 @@ def test_examples_protocol_asio_tcp_server(env, extra_data):
     # 2. get the server IP address
     data = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30)
     # 3. create tcp client and connect to server
+    dut1.expect('ASIO engine is up and running', timeout=1)
     cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     cli.settimeout(30)
     cli.connect((data[0], 2222))

+ 2 - 0
examples/protocols/asio/tcp_echo_server/main/echo_server.cpp

@@ -102,5 +102,7 @@ extern "C" void app_main(void)
 
     server s(io_context, std::atoi(CONFIG_EXAMPLE_PORT));
 
+    std::cout << "ASIO engine is up and running" << std::endl;
+
     io_context.run();
 }

+ 1 - 0
examples/protocols/asio/udp_echo_server/asio_udp_server_test.py

@@ -27,6 +27,7 @@ def test_examples_protocol_asio_udp_server(env, extra_data):
     # 2. get the server IP address
     data = dut1.expect(re.compile(r" IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)"), timeout=30)
     # 3. create tcp client and connect to server
+    dut1.expect('ASIO engine is up and running', timeout=1)
     cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     cli.settimeout(30)
     cli.connect((data[0], 2222))

+ 2 - 0
examples/protocols/asio/udp_echo_server/main/udp_echo_server.cpp

@@ -84,5 +84,7 @@ extern "C" void app_main(void)
 
     server s(io_context, std::atoi(CONFIG_EXAMPLE_PORT));
 
+    std::cout << "ASIO engine is up and running" << std::endl;
+
     io_context.run();
 }

+ 1 - 0
examples/wifi/iperf/components/iperf/iperf.c

@@ -149,6 +149,7 @@ static esp_err_t IRAM_ATTR iperf_run_tcp_server(void)
         return ESP_FAIL;
     }
 
+    printf("iperf tcp server create successfully\n");
     buffer = s_iperf_ctrl.buffer;
     want_recv = s_iperf_ctrl.buffer_len;
     while (!s_iperf_ctrl.finish) {

+ 13 - 7
examples/wifi/iperf/iperf_test.py

@@ -182,7 +182,7 @@ class TestResult(object):
 
     @staticmethod
     def _convert_to_draw_format(data, label):
-        keys = data.keys()
+        keys = list(data.keys())
         keys.sort()
         return {
             "x-axis": keys,
@@ -216,8 +216,8 @@ class TestResult(object):
 
         LineChart.draw_line_chart(os.path.join(path, file_name),
                                   "Throughput Vs {} ({} {})".format(type_name, self.proto, self.direction),
-                                  "Throughput (Mbps)",
                                   "{} (dbm)".format(type_name),
+                                  "Throughput (Mbps)",
                                   data_list)
         return file_name
 
@@ -305,7 +305,7 @@ class IperfTestUtility(object):
         except subprocess.CalledProcessError:
             pass
         self.dut.write("restart")
-        self.dut.expect("esp32>")
+        self.dut.expect_any("iperf>", "esp32>")
         self.dut.write("scan {}".format(self.ap_ssid))
         for _ in range(SCAN_RETRY_COUNT):
             try:
@@ -358,6 +358,12 @@ class IperfTestUtility(object):
             with open(PC_IPERF_TEMP_LOG_FILE, "w") as f:
                 if proto == "tcp":
                     self.dut.write("iperf -s -i 1 -t {}".format(TEST_TIME))
+                    # wait until DUT TCP server created
+                    try:
+                        self.dut.expect("iperf tcp server create successfully", timeout=1)
+                    except DUT.ExpectTimeout:
+                        # compatible with old iperf example binary
+                        pass
                     process = subprocess.Popen(["iperf", "-c", dut_ip,
                                                 "-t", str(TEST_TIME), "-f", "m"],
                                                stdout=f, stderr=f)
@@ -431,7 +437,7 @@ class IperfTestUtility(object):
         :return: True or False
         """
         self.dut.write("restart")
-        self.dut.expect("esp32>")
+        self.dut.expect_any("iperf>", "esp32>")
         for _ in range(WAIT_AP_POWER_ON_TIMEOUT // SCAN_TIMEOUT):
             try:
                 self.dut.write("scan {}".format(self.ap_ssid))
@@ -477,7 +483,7 @@ def test_wifi_throughput_with_different_configs(env, extra_data):
         dut = env.get_dut("iperf", "examples/wifi/iperf", dut_class=ttfw_idf.ESP32DUT,
                           app_config_name=config_name)
         dut.start_app()
-        dut.expect("esp32>")
+        dut.expect_any("iperf>", "esp32>")
 
         # 3. run test for each required att value
         test_result[config_name] = {
@@ -533,7 +539,7 @@ def test_wifi_throughput_vs_rssi(env, extra_data):
     dut = env.get_dut("iperf", "examples/wifi/iperf", dut_class=ttfw_idf.ESP32DUT,
                       app_config_name=BEST_PERFORMANCE_CONFIG)
     dut.start_app()
-    dut.expect("esp32>")
+    dut.expect_any("iperf>", "esp32>")
 
     # 2. run test for each required att value
     for ap_info in ap_list:
@@ -580,7 +586,7 @@ def test_wifi_throughput_basic(env, extra_data):
     dut = env.get_dut("iperf", "examples/wifi/iperf", dut_class=ttfw_idf.ESP32DUT,
                       app_config_name=BEST_PERFORMANCE_CONFIG)
     dut.start_app()
-    dut.expect("esp32>")
+    dut.expect_any("iperf>", "esp32>")
 
     # 2. preparing
     test_result = {

+ 2 - 2
tools/ci/python_packages/idf_iperf_test_util/TestReport.py

@@ -36,7 +36,7 @@ class ThroughputForConfigsReport(object):
             self.sdkconfigs[config_name] = self._parse_config_file(sdkconfig_files[config_name])
         if not os.path.exists(output_path):
             os.makedirs(output_path)
-        self.sort_order = self.sdkconfigs.keys()
+        self.sort_order = list(self.sdkconfigs.keys())
         self.sort_order.sort()
 
     @staticmethod
@@ -162,7 +162,7 @@ class ThroughputVsRssiReport(object):
         self.output_path = output_path
         self.raw_data_path = os.path.join(output_path, "raw_data")
         self.results = throughput_results
-        self.throughput_types = self.results.keys()
+        self.throughput_types = list(self.results.keys())
         self.throughput_types.sort()
         if not os.path.exists(self.raw_data_path):
             os.makedirs(self.raw_data_path)