Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1638)

Unified Diff: tools/ipc_fuzzer/mutate/message_util.cc

Issue 931153003: Add an --in switch to ipc_message_util to support minimization in CF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698