diff options
author | ttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-08 20:33:31 +0000 |
---|---|---|
committer | ttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-08 20:33:31 +0000 |
commit | 7a94dd9e3881201a89848b2a21a8d6a7af0852df (patch) | |
tree | a28c84fb74f3278b05e1841b28001acaaa7884e7 /net/tools/dns_fuzz_stub | |
parent | 7a5c8de35f036a7530104de526ee13f4c5cdd493 (diff) | |
download | chromium_src-7a94dd9e3881201a89848b2a21a8d6a7af0852df.zip chromium_src-7a94dd9e3881201a89848b2a21a8d6a7af0852df.tar.gz chromium_src-7a94dd9e3881201a89848b2a21a8d6a7af0852df.tar.bz2 |
Print #EOF when DNS fuzz stub finishes successfully
BUG=130751
TEST=manual, prints #EOF on success but not failure
Review URL: https://chromiumcodereview.appspot.com/10538063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/dns_fuzz_stub')
-rw-r--r-- | net/tools/dns_fuzz_stub/dns_fuzz_stub.cc | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc b/net/tools/dns_fuzz_stub/dns_fuzz_stub.cc index 4b88218..4dcae72 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; } |