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

Unified Diff: net/tools/dns_fuzz_stub/dns_fuzz_stub.cc

Issue 10538063: Print #EOF when DNS fuzz stub finishes successfully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize id and qtype Created 8 years, 6 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: net/tools/dns_fuzz_stub/dns_fuzz_stub.cc
diff --git a/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc b/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc
index 4b882181f2127115e85b6c485185849a13d1c915..4dcae720f85de3e23f00feef4454e530a0a637db 100644
--- a/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc
+++ b/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <algorithm>
+#include <iostream>
#include <string>
#include <vector>
@@ -107,6 +108,33 @@ bool ReadTestCase(const char* filename,
return true;
}
+void RunTestCase(uint16 id, std::string& qname, uint16 qtype,
+ std::vector<char>& resp_buf) {
+ net::DnsQuery query(id, qname, qtype);
+ net::DnsResponse response;
+ std::copy(resp_buf.begin(), resp_buf.end(), response.io_buffer()->data());
+
+ if (!response.InitParse(resp_buf.size(), query)) {
+ LOG(INFO) << "InitParse failed.";
+ return;
+ }
+
+ net::AddressList address_list;
+ base::TimeDelta ttl;
+ net::DnsResponse::Result result = response.ParseToAddressList(
+ &address_list, &ttl);
+ if (result != net::DnsResponse::DNS_SUCCESS) {
+ LOG(INFO) << "ParseToAddressList failed: " << result;
+ return;
+ }
+
+ LOG(INFO) << "Address List:";
+ for (unsigned int i = 0; i < address_list.size(); i++) {
+ LOG(INFO) << "\t" << address_list[i].ToString();
+ }
+ LOG(INFO) << "TTL: " << ttl.InSeconds() << " seconds";
+}
+
}
int main(int argc, char** argv) {
@@ -119,9 +147,9 @@ int main(int argc, char** argv) {
LOG(INFO) << "Test case: " << filename;
- uint16 id;
+ uint16 id = 0;
std::string qname_dotted;
- uint16 qtype;
+ uint16 qtype = 0;
std::vector<char> resp_buf;
if (!ReadTestCase(filename, &id, &qname_dotted, &qtype, &resp_buf)) {
@@ -140,29 +168,9 @@ int main(int argc, char** argv) {
return 3;
}
- net::DnsQuery query(id, qname, qtype);
- net::DnsResponse response;
- std::copy(resp_buf.begin(), resp_buf.end(), response.io_buffer()->data());
+ RunTestCase(id, qname, qtype, resp_buf);
- if (!response.InitParse(resp_buf.size(), query)) {
- LOG(INFO) << "InitParse failed.";
- return 0;
- }
-
- net::AddressList address_list;
- base::TimeDelta ttl;
- net::DnsResponse::Result result = response.ParseToAddressList(
- &address_list, &ttl);
- if (result != net::DnsResponse::DNS_SUCCESS) {
- LOG(INFO) << "ParseToAddressList failed: " << result;
- return 0;
- }
-
- LOG(INFO) << "Address List:";
- for (unsigned int i = 0; i < address_list.size(); i++) {
- LOG(INFO) << "\t" << address_list[i].ToString();
- }
- LOG(INFO) << "TTL: " << ttl.InSeconds() << " seconds";
+ std::cout << "#EOF" << std::endl;
return 0;
}
« 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