Index: tools/ipc_fuzzer/mutate/message_util.cc |
diff --git a/tools/ipc_fuzzer/mutate/message_util.cc b/tools/ipc_fuzzer/mutate/message_util.cc |
index 21430c480ef3600976e28fade61622e78aff5ba8..85ce14b7492c7da31c45d33f3b42f9197bb3aeb7 100644 |
--- a/tools/ipc_fuzzer/mutate/message_util.cc |
+++ b/tools/ipc_fuzzer/mutate/message_util.cc |
@@ -28,6 +28,10 @@ const char kHelpSwitch[] = "help"; |
const char kHelpSwitchHelp[] = |
"display this message."; |
+const char kInSwitch[] = "in"; |
+const char kInSwitchHelp[] = |
+ "output only the messages in the specified list."; |
Tom Sepez
2015/02/17 18:50:47
nit: is this a list of message IDs or a list of or
|
+ |
const char kInvertSwitch[] = "invert"; |
const char kInvertSwitchHelp[] = |
"output messages NOT meeting above criteria."; |
@@ -48,6 +52,7 @@ void usage() { |
<< " ipc_message_util" |
<< " [--" << kStartSwitch << "=n]" |
<< " [--" << kEndSwitch << "=m]" |
+ << " [--" << kInSwitch << "=i,j,...]]" |
<< " [--" << kRegexpSwitch << "=x]" |
<< " [--" << kInvertSwitch << "]" |
<< " [--" << kDumpSwitch << "]" |
@@ -56,6 +61,7 @@ void usage() { |
std::cerr << " --" << kStartSwitch << " - " << kStartSwitchHelp << "\n" |
<< " --" << kEndSwitch << " - " << kEndSwitchHelp << "\n" |
+ << " --" << kInSwitch << " - " << kInSwitchHelp << "\n" |
<< " --" << kRegexpSwitch << " - " << kRegexpSwitchHelp << "\n" |
<< " --" << kInvertSwitch << " - " << kInvertSwitchHelp << "\n" |
<< " --" << kDumpSwitch << " - " << kDumpSwitchHelp << "\n" |
@@ -85,7 +91,7 @@ int main(int argc, char** argv) { |
size_t start_index = 0; |
if (cmd->HasSwitch(kStartSwitch)) { |
int temp = atoi(cmd->GetSwitchValueASCII(kStartSwitch).c_str()); |
- if (temp > 0 ) |
+ if (temp > 0) |
start_index = static_cast<size_t>(temp); |
} |
@@ -96,6 +102,9 @@ int main(int argc, char** argv) { |
end_index = static_cast<size_t>(temp); |
} |
+ bool has_indices = cmd->HasSwitch(kInSwitch); |
Tom Sepez
2015/02/17 18:50:47
nit: You can move these down to line 137 or so sin
|
+ std::vector<bool> indices; |
Tom Sepez
2015/02/17 18:50:47
nit: you probably want std::set<int> here. If I'm
|
+ |
bool has_regexp = cmd->HasSwitch(kRegexpSwitch); |
RE2 filter_pattern(cmd->GetSwitchValueASCII(kRegexpSwitch)); |
@@ -125,6 +134,18 @@ int main(int argc, char** argv) { |
message_vector.weak_clear(); |
} |
+ if (has_indices) { |
+ indices.resize(input_message_vector.size(), false); |
+ std::vector<std::string> index_strings; |
+ base::SplitString(cmd->GetSwitchValueASCII(kInSwitch), ',', &index_strings); |
+ for (std::vector<std::string>::iterator it = index_strings.begin(); |
+ it != index_strings.end(); ++it) { |
+ int index = atoi(it->c_str()); |
+ if (index >= 0 && static_cast<size_t>(index) < indices.size()) |
+ indices[index] = true; |
+ } |
+ } |
+ |
ipc_fuzzer::MessageVector output_message_vector; |
std::vector<size_t> remap_vector; |
@@ -133,6 +154,9 @@ int main(int argc, char** argv) { |
if (valid && has_regexp) { |
valid = MessageMatches(input_message_vector[i], filter_pattern); |
} |
+ if (valid && has_indices) { |
+ valid = indices[i]; |
+ } |
if (valid != invert) { |
output_message_vector.push_back(input_message_vector[i]); |
remap_vector.push_back(i); |