diff --git a/src/c++/perf_analyzer/command_line_parser.cc b/src/c++/perf_analyzer/command_line_parser.cc index 356033794..d02a96ed5 100644 --- a/src/c++/perf_analyzer/command_line_parser.cc +++ b/src/c++/perf_analyzer/command_line_parser.cc @@ -964,37 +964,23 @@ CLParser::ParseCommandLine(int argc, char** argv) case 7: { params_->using_concurrency_range = true; std::string arg = optarg; - size_t pos = 0; - int index = 0; - while (pos != std::string::npos) { - size_t colon_pos = arg.find(":", pos); - if (index > 2) { - Usage( - "Failed to parse --concurrency-range. The value does not " - "match ."); - } - int64_t val; - if (colon_pos == std::string::npos) { - val = std::stoull(arg.substr(pos, colon_pos)); - pos = colon_pos; - } else { - val = std::stoull(arg.substr(pos, colon_pos - pos)); - pos = colon_pos + 1; - } - switch (index) { - case 0: - params_->concurrency_range.start = val; - break; - case 1: - params_->concurrency_range.end = val; - break; - case 2: - params_->concurrency_range.step = val; - break; - } - index++; + std::vector values{SplitString(arg)}; + if (values.size() > 3) { + Usage( + "Failed to parse --concurrency-range. The value does not match " + "."); } + for (size_t i = 0; i < values.size(); ++i) { + uint64_t val = std::stoull(values[i]); + if (i == 0) { + params_->concurrency_range.start = val; + } else if (i == 1) { + params_->concurrency_range.end = val; + } else if (i == 2) { + params_->concurrency_range.step = val; + } + } break; } case 8: diff --git a/src/c++/perf_analyzer/test_command_line_parser.cc b/src/c++/perf_analyzer/test_command_line_parser.cc index 794f775c8..ef0375de8 100644 --- a/src/c++/perf_analyzer/test_command_line_parser.cc +++ b/src/c++/perf_analyzer/test_command_line_parser.cc @@ -493,26 +493,6 @@ CheckInvalidRange( check_params = false; } - - SUBCASE("wrong separator") - { - args.push_back(option_name); - args.push_back("100,400,10"); - - int argc = args.size(); - char* argv[argc]; - std::copy(args.begin(), args.end(), argv); - - REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); - CHECK(parser.UsageCalled()); - - // BUG (TMA-1307): Should detect this and through an error. User will - // enter this and have no clue why the end and step sizes are not used - // correctly. - // - - check_params = false; - } } @@ -1167,6 +1147,26 @@ TEST_CASE("Testing Command Line Parser") CheckInvalidRange(args, option_name, parser, act, check_params); + SUBCASE("wrong separator") + { + args.push_back(option_name); + args.push_back("100,400,10"); + + int argc = args.size(); + char* argv[argc]; + std::copy(args.begin(), args.end(), argv); + + REQUIRE_NOTHROW(act = parser.Parse(argc, argv)); + CHECK(!parser.UsageCalled()); + + // BUG (TMA-1307): Should detect this and through an error. User will + // enter this and have no clue why the end and step sizes are not used + // correctly. + // + + check_params = false; + } + SUBCASE("invalid condition - end and latency threshold are 0") { args.push_back(option_name);