Parse --cpu-set as ParseIntList
An argument of --cpu-set=1,2,3 is currently parsed into a
vector<int32_t>. This causes two problems:
1. With the type CmdlineType<std::vector<int32_t>> that internally does
the comma spliting, it prevents us from adding another type of int
vector (e.g. multiple --dex-fd $FD). This is inconsistent to existing
string and vector<string> parsing.
2. A delimiter-separated argument like "-Xbootclasspath:" is parsed with
ParseStringList, which keeps the types of "string vector" seperated
(depending on whether it comes from a single argument, like
"-Xbootclasspath:", or multiple arguments, like --dex-file).
This change replaces the parser of vector<int32_t> with the new
ParseIntList, which solves the two problems above.
Bug: 187327262
Test: atest art_cmdline_tests
Test: TH
Change-Id: I2f225ec2c9f47f1bf1df76507ccb67b23bb51861
diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc
index 398c929..779e3e0 100644
--- a/cmdline/cmdline_parser_test.cc
+++ b/cmdline/cmdline_parser_test.cc
@@ -574,11 +574,13 @@
} // TEST_F
TEST_F(CmdlineParserTest, TypesNotInRuntime) {
- CmdlineType<std::vector<int32_t>> ct;
+ using ParseCommaSeparatedIntList = ParseIntList<','>;
+ CmdlineType<ParseCommaSeparatedIntList> ct;
auto success0 =
- CmdlineParseResult<std::vector<int32_t>>::Success(std::vector<int32_t>({1, 2, 3, 4}));
+ CmdlineParseResult<ParseCommaSeparatedIntList>::Success(ParseCommaSeparatedIntList({1, 2, 3, 4}));
EXPECT_EQ(success0, ct.Parse("1,2,3,4"));
- auto success1 = CmdlineParseResult<std::vector<int32_t>>::Success(std::vector<int32_t>({0}));
+ auto success1 =
+ CmdlineParseResult<ParseCommaSeparatedIntList>::Success(ParseCommaSeparatedIntList({0}));
EXPECT_EQ(success1, ct.Parse("1"));
EXPECT_FALSE(ct.Parse("").IsSuccess());