From e76c5c08d31115f7a5a00099045c152b6cca6ab2 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 20 Mar 2025 22:14:46 -0400 Subject: [PATCH 1/2] Enhance scenario validation in AQM evaluation runner. Added checks for valid scenario numbers and names, providing error messages for invalid inputs. Improved scenario execution logic for clarity. --- .../examples/aqm-eval-suite-runner.cc | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc b/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc index 3cd2daada48..85115ed4a60 100644 --- a/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc +++ b/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc @@ -204,25 +204,65 @@ int main (int argc, char *argv[]) if (scenarioName == "") { - scenarioName = ScenarioNumberMapping[scenarioNumber]; + auto it = ScenarioNumberMapping.find (scenarioNumber); + + if (it != ScenarioNumberMapping.end ()) + { + scenarioName = it->second; + } + else if (!scenarioNumber.empty ()) + { + std::cout << "Error: Invalid scenario number \"" << scenarioNumber << "\"" << std::endl; + std::cout << "Valid scenario numbers are:"; + for (const auto& mapping : ScenarioNumberMapping) + { + std::cout << " \"" << mapping.first << "\""; + } + std::cout << std::endl; + exit (-1); + } } - + + // Check if scenarioName is valid (if it's not "All" or "RttFairness") if (scenarioName != "All" && scenarioName != "RttFairness") { + bool validScenarioName = false; + + for (const auto& mapping : ScenarioNumberMapping) + { + if (mapping.second == scenarioName) + { + validScenarioName = true; + break; + } + } + + if (!validScenarioName) + { + std::cout << "Error: Invalid scenario name \"" << scenarioName << "\"" << std::endl; + std::cout << "Valid scenario names are: \"All\", \"RttFairness\""; + for (const auto& mapping : ScenarioNumberMapping) + { + std::cout << ", \"" << mapping.second << "\""; + } + std::cout << std::endl; + exit (-1); + } + RunOneScenario (scenarioName); } - else if (scenarioName != "All" && scenarioName == "RttFairness") + else if (scenarioName == "RttFairness") { RunRttFairness (scenarioName); } else { RunRttFairness (scenarioName); - for (std::map::iterator it = ScenarioNumberMapping.begin (); it != ScenarioNumberMapping.end (); ++it) + for (const auto& mapping : ScenarioNumberMapping) { - if (it->second != "RttFairness") + if (mapping.second != "RttFairness") { - RunOneScenario (it->second); + RunOneScenario (mapping.second); } } } From 31e0ae56e0aaf41dfa6d4e5aed61f4a1a0e3c632 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 20 Mar 2025 23:26:15 -0400 Subject: [PATCH 2/2] Update valid scenario names in error message for AQM evaluation runner --- src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc b/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc index 85115ed4a60..519b0c89e72 100644 --- a/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc +++ b/src/aqm-eval-suite/examples/aqm-eval-suite-runner.cc @@ -240,7 +240,7 @@ int main (int argc, char *argv[]) if (!validScenarioName) { std::cout << "Error: Invalid scenario name \"" << scenarioName << "\"" << std::endl; - std::cout << "Valid scenario names are: \"All\", \"RttFairness\""; + std::cout << "Valid scenario names are: \"All\""; for (const auto& mapping : ScenarioNumberMapping) { std::cout << ", \"" << mapping.second << "\"";