summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authormbarbella <mbarbella@chromium.org>2015-02-17 09:12:57 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-17 17:13:33 +0000
commit66c7eff8184adfdcd58e2d381956382635b17ecf (patch)
tree7a25def9cacd62f8bce9df9df642f6d62991df2b /tools
parent74126f4a63e94878ce3aeda6160ffe7b6d8a9d63 (diff)
downloadchromium_src-66c7eff8184adfdcd58e2d381956382635b17ecf.zip
chromium_src-66c7eff8184adfdcd58e2d381956382635b17ecf.tar.gz
chromium_src-66c7eff8184adfdcd58e2d381956382635b17ecf.tar.bz2
Add an --in switch to ipc_message_util to support minimization in CF.
BUG=450268 R=inferno@chromium.org,tsepez@chromium.org Review URL: https://codereview.chromium.org/931153003 Cr-Commit-Position: refs/heads/master@{#316593}
Diffstat (limited to 'tools')
-rw-r--r--tools/ipc_fuzzer/mutate/message_util.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/ipc_fuzzer/mutate/message_util.cc b/tools/ipc_fuzzer/mutate/message_util.cc
index 21430c4..85ce14b 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.";
+
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);
+ std::vector<bool> indices;
+
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);