| 294 | } |
| 295 | |
| 296 | fl::json runNetClientTest(const char* host_ip, uint16_t port) { |
| 297 | fl::json response = fl::json::object(); |
| 298 | int tests_passed = 0; |
| 299 | int tests_failed = 0; |
| 300 | fl::json results = fl::json::array(); |
| 301 | |
| 302 | // Build URLs |
| 303 | char url_ping[128]; |
| 304 | char url_data[128]; |
| 305 | snprintf(url_ping, sizeof(url_ping), "http://%s:%u/ping", host_ip, port); |
| 306 | snprintf(url_data, sizeof(url_data), "http://%s:%u/data", host_ip, port); |
| 307 | |
| 308 | // Test 1: GET /ping |
| 309 | { |
| 310 | fl::json r = runHttpGetTest(url_ping, "GET /ping"); |
| 311 | auto passed = r[fl::string("passed")].as_bool(); |
| 312 | if (passed.has_value() && passed.value()) { |
| 313 | tests_passed++; |
| 314 | } else { |
| 315 | tests_failed++; |
| 316 | } |
| 317 | results.push_back(r); |
| 318 | } |
| 319 | |
| 320 | // Test 2: GET /data |
| 321 | { |
| 322 | fl::json r = runHttpGetTest(url_data, "GET /data"); |
| 323 | auto passed = r[fl::string("passed")].as_bool(); |
| 324 | if (passed.has_value() && passed.value()) { |
| 325 | tests_passed++; |
| 326 | } else { |
| 327 | tests_failed++; |
| 328 | } |
| 329 | results.push_back(r); |
| 330 | } |
| 331 | |
| 332 | response.set("success", tests_failed == 0); |
| 333 | response.set("tests_passed", static_cast<int64_t>(tests_passed)); |
| 334 | response.set("tests_failed", static_cast<int64_t>(tests_failed)); |
| 335 | response.set("results", results); |
| 336 | return response; |
| 337 | } |
| 338 | |
| 339 | fl::json runNetLoopback() { |
| 340 | fl::json response = fl::json::object(); |
no test coverage detected