| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 for (size_t i = 0; i < length; ++i) | 97 for (size_t i = 0; i < length; ++i) |
| 98 temp_string += RandInRange(256); | 98 temp_string += RandInRange(256); |
| 99 *value = temp_string; | 99 *value = temp_string; |
| 100 } | 100 } |
| 101 | 101 |
| 102 class GeneratorImpl : public Generator { | 102 class GeneratorImpl : public Generator { |
| 103 public: | 103 public: |
| 104 GeneratorImpl() {} | 104 GeneratorImpl() {} |
| 105 virtual ~GeneratorImpl() {} | 105 virtual ~GeneratorImpl() {} |
| 106 | 106 |
| 107 virtual void GenerateBool(bool* value) OVERRIDE { | 107 virtual void GenerateBool(bool* value) override { |
| 108 *value = RandInRange(2); | 108 *value = RandInRange(2); |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual void GenerateInt(int* value) OVERRIDE { | 111 virtual void GenerateInt(int* value) override { |
| 112 GenerateIntegralType<int>(value); | 112 GenerateIntegralType<int>(value); |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual void GenerateLong(long* value) OVERRIDE { | 115 virtual void GenerateLong(long* value) override { |
| 116 GenerateIntegralType<long>(value); | 116 GenerateIntegralType<long>(value); |
| 117 } | 117 } |
| 118 | 118 |
| 119 virtual void GenerateSize(size_t* value) OVERRIDE { | 119 virtual void GenerateSize(size_t* value) override { |
| 120 GenerateIntegralType<size_t>(value); | 120 GenerateIntegralType<size_t>(value); |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual void GenerateUChar(unsigned char* value) OVERRIDE { | 123 virtual void GenerateUChar(unsigned char* value) override { |
| 124 GenerateIntegralType<unsigned char>(value); | 124 GenerateIntegralType<unsigned char>(value); |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual void GenerateUInt16(uint16* value) OVERRIDE { | 127 virtual void GenerateUInt16(uint16* value) override { |
| 128 GenerateIntegralType<uint16>(value); | 128 GenerateIntegralType<uint16>(value); |
| 129 } | 129 } |
| 130 | 130 |
| 131 virtual void GenerateUInt32(uint32* value) OVERRIDE { | 131 virtual void GenerateUInt32(uint32* value) override { |
| 132 GenerateIntegralType<uint32>(value); | 132 GenerateIntegralType<uint32>(value); |
| 133 } | 133 } |
| 134 | 134 |
| 135 virtual void GenerateInt64(int64* value) OVERRIDE { | 135 virtual void GenerateInt64(int64* value) override { |
| 136 GenerateIntegralType<int64>(value); | 136 GenerateIntegralType<int64>(value); |
| 137 } | 137 } |
| 138 | 138 |
| 139 virtual void GenerateUInt64(uint64* value) OVERRIDE { | 139 virtual void GenerateUInt64(uint64* value) override { |
| 140 GenerateIntegralType<uint64>(value); | 140 GenerateIntegralType<uint64>(value); |
| 141 } | 141 } |
| 142 | 142 |
| 143 virtual void GenerateFloat(float* value) OVERRIDE { | 143 virtual void GenerateFloat(float* value) override { |
| 144 GenerateFloatingType<float>(value); | 144 GenerateFloatingType<float>(value); |
| 145 } | 145 } |
| 146 | 146 |
| 147 virtual void GenerateDouble(double* value) OVERRIDE { | 147 virtual void GenerateDouble(double* value) override { |
| 148 GenerateFloatingType<double>(value); | 148 GenerateFloatingType<double>(value); |
| 149 } | 149 } |
| 150 | 150 |
| 151 virtual void GenerateString(std::string* value) OVERRIDE { | 151 virtual void GenerateString(std::string* value) override { |
| 152 GenerateStringType<std::string>(value); | 152 GenerateStringType<std::string>(value); |
| 153 } | 153 } |
| 154 | 154 |
| 155 virtual void GenerateString16(base::string16* value) OVERRIDE { | 155 virtual void GenerateString16(base::string16* value) override { |
| 156 GenerateStringType<base::string16>(value); | 156 GenerateStringType<base::string16>(value); |
| 157 } | 157 } |
| 158 | 158 |
| 159 virtual void GenerateData(char* data, int length) OVERRIDE { | 159 virtual void GenerateData(char* data, int length) override { |
| 160 for (int i = 0; i < length; ++i) { | 160 for (int i = 0; i < length; ++i) { |
| 161 GenerateIntegralType<char>(&data[i]); | 161 GenerateIntegralType<char>(&data[i]); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 virtual void GenerateBytes(void* data, int data_len) OVERRIDE { | 165 virtual void GenerateBytes(void* data, int data_len) override { |
| 166 GenerateData(static_cast<char*>(data), data_len); | 166 GenerateData(static_cast<char*>(data), data_len); |
| 167 } | 167 } |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 // Partially-specialized class that knows how to generate a given type. | 170 // Partially-specialized class that knows how to generate a given type. |
| 171 template <class P> | 171 template <class P> |
| 172 struct GenerateTraits { | 172 struct GenerateTraits { |
| 173 static bool Generate(P* p, Generator *generator) { | 173 static bool Generate(P* p, Generator *generator) { |
| 174 // This is the catch-all for types we don't have enough information | 174 // This is the catch-all for types we don't have enough information |
| 175 // to generate. | 175 // to generate. |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 return EXIT_FAILURE; | 1335 return EXIT_FAILURE; |
| 1336 | 1336 |
| 1337 return EXIT_SUCCESS; | 1337 return EXIT_SUCCESS; |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 } // namespace ipc_fuzzer | 1340 } // namespace ipc_fuzzer |
| 1341 | 1341 |
| 1342 int main(int argc, char** argv) { | 1342 int main(int argc, char** argv) { |
| 1343 return ipc_fuzzer::GenerateMain(argc, argv); | 1343 return ipc_fuzzer::GenerateMain(argc, argv); |
| 1344 } | 1344 } |
| OLD | NEW |