| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 LOG(ERROR) << filename << ": couldn't read file."; | 57 LOG(ERROR) << filename << ": couldn't read file."; |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 scoped_ptr<Value> value(base::JSONReader::Read(json)); | 61 scoped_ptr<Value> value(base::JSONReader::Read(json)); |
| 62 if (!value.get()) { | 62 if (!value.get()) { |
| 63 LOG(ERROR) << filename << ": couldn't parse JSON."; | 63 LOG(ERROR) << filename << ": couldn't parse JSON."; |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| 67 DictionaryValue* dict; | 67 base::DictionaryValue* dict; |
| 68 if (!value->GetAsDictionary(&dict)) { | 68 if (!value->GetAsDictionary(&dict)) { |
| 69 LOG(ERROR) << filename << ": test case is not a dictionary."; | 69 LOG(ERROR) << filename << ": test case is not a dictionary."; |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 *crash_test = dict->HasKey("crash_test"); | 73 *crash_test = dict->HasKey("crash_test"); |
| 74 if (*crash_test) { | 74 if (*crash_test) { |
| 75 LOG(INFO) << filename << ": crash_test is set!"; | 75 LOG(INFO) << filename << ": crash_test is set!"; |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 if (!dict->GetInteger("qtype", &qtype_int)) { | 96 if (!dict->GetInteger("qtype", &qtype_int)) { |
| 97 LOG(ERROR) << filename << ": qtype is missing or not an integer."; | 97 LOG(ERROR) << filename << ": qtype is missing or not an integer."; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 if (!FitsUint16(qtype_int)) { | 100 if (!FitsUint16(qtype_int)) { |
| 101 LOG(ERROR) << filename << ": qtype is out of range."; | 101 LOG(ERROR) << filename << ": qtype is out of range."; |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 *qtype = static_cast<uint16>(qtype_int); | 104 *qtype = static_cast<uint16>(qtype_int); |
| 105 | 105 |
| 106 ListValue* resp_list; | 106 base::ListValue* resp_list; |
| 107 if (!dict->GetList("response", &resp_list)) { | 107 if (!dict->GetList("response", &resp_list)) { |
| 108 LOG(ERROR) << filename << ": response is missing or not a list."; | 108 LOG(ERROR) << filename << ": response is missing or not a list."; |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 size_t resp_size = resp_list->GetSize(); | 112 size_t resp_size = resp_list->GetSize(); |
| 113 resp_buf->clear(); | 113 resp_buf->clear(); |
| 114 resp_buf->reserve(resp_size); | 114 resp_buf->reserve(resp_size); |
| 115 for (size_t i = 0; i < resp_size; i++) { | 115 for (size_t i = 0; i < resp_size; i++) { |
| 116 int resp_byte_int; | 116 int resp_byte_int; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 if (!ReadAndRunTestCase(argv[i])) | 206 if (!ReadAndRunTestCase(argv[i])) |
| 207 ret = 2; | 207 ret = 2; |
| 208 | 208 |
| 209 // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish | 209 // Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish |
| 210 // successful runs from crashes. | 210 // successful runs from crashes. |
| 211 printf("#EOF\n"); | 211 printf("#EOF\n"); |
| 212 | 212 |
| 213 return ret; | 213 return ret; |
| 214 } | 214 } |
| 215 | 215 |
| OLD | NEW |