From a5bd08a6b65362c21c137bb9e457a3956f6e8d17 Mon Sep 17 00:00:00 2001 From: Anurag Kar Date: Wed, 3 Apr 2019 19:01:40 +0530 Subject: [PATCH] esp_http_server : Test added to check limit on max_open_sockets config option --- .../esp_http_server/test/test_http_server.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/components/esp_http_server/test/test_http_server.c b/components/esp_http_server/test/test_http_server.c index e343c99ca..d7a8542aa 100644 --- a/components/esp_http_server/test/test_http_server.c +++ b/components/esp_http_server/test/test_http_server.c @@ -167,3 +167,22 @@ TEST_CASE("Basic Functionality Tests", "[HTTP SERVER]") test_handler_limit(hd); TEST_ASSERT(httpd_stop(hd) == ESP_OK); } + +TEST_CASE("Max Allowed Sockets Test", "[HTTP SERVER]") +{ + test_case_uses_tcpip(); + + httpd_handle_t hd; + httpd_config_t config = HTTPD_DEFAULT_CONFIG(); + + /* Starting server with default config options should pass */ + TEST_ASSERT(httpd_start(&hd, &config) == ESP_OK); + TEST_ASSERT(httpd_stop(hd) == ESP_OK); + + /* Default value of max_open_sockets is already set as per + * maximum limit imposed by LWIP. Increasing this beyond the + * maximum allowed value, without increasing LWIP limit, + * should fail */ + config.max_open_sockets += 1; + TEST_ASSERT(httpd_start(&hd, &config) != ESP_OK); +}