OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | |
8 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
9 #include "tools/ipc_fuzzer/fuzzer/generator.h" | 8 #include "tools/ipc_fuzzer/fuzzer/generator.h" |
10 #include "tools/ipc_fuzzer/fuzzer/rand_util.h" | 9 #include "tools/ipc_fuzzer/fuzzer/rand_util.h" |
11 | 10 |
12 namespace ipc_fuzzer { | 11 namespace ipc_fuzzer { |
13 | 12 |
14 template <typename T> | 13 template <typename T> |
15 void GenerateIntegralType(T* value) { | 14 void GenerateIntegralType(T* value) { |
16 switch (RandInRange(16)) { | 15 switch (RandInRange(16)) { |
17 case 0: | 16 case 0: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 62 } |
64 | 63 |
65 void Generator::FuzzUChar(unsigned char* value) { | 64 void Generator::FuzzUChar(unsigned char* value) { |
66 GenerateIntegralType<unsigned char>(value); | 65 GenerateIntegralType<unsigned char>(value); |
67 } | 66 } |
68 | 67 |
69 void Generator::FuzzWChar(wchar_t* value) { | 68 void Generator::FuzzWChar(wchar_t* value) { |
70 GenerateIntegralType<wchar_t>(value); | 69 GenerateIntegralType<wchar_t>(value); |
71 } | 70 } |
72 | 71 |
73 void Generator::FuzzUInt16(uint16* value) { | 72 void Generator::FuzzUInt16(uint16_t* value) { |
74 GenerateIntegralType<uint16>(value); | 73 GenerateIntegralType<uint16_t>(value); |
75 } | 74 } |
76 | 75 |
77 void Generator::FuzzUInt32(uint32* value) { | 76 void Generator::FuzzUInt32(uint32_t* value) { |
78 GenerateIntegralType<uint32>(value); | 77 GenerateIntegralType<uint32_t>(value); |
79 } | 78 } |
80 | 79 |
81 void Generator::FuzzInt64(int64* value) { | 80 void Generator::FuzzInt64(int64_t* value) { |
82 GenerateIntegralType<int64>(value); | 81 GenerateIntegralType<int64_t>(value); |
83 } | 82 } |
84 | 83 |
85 void Generator::FuzzUInt64(uint64* value) { | 84 void Generator::FuzzUInt64(uint64_t* value) { |
86 GenerateIntegralType<uint64>(value); | 85 GenerateIntegralType<uint64_t>(value); |
87 } | 86 } |
88 | 87 |
89 void Generator::FuzzFloat(float* value) { | 88 void Generator::FuzzFloat(float* value) { |
90 GenerateFloatingType<float>(value); | 89 GenerateFloatingType<float>(value); |
91 } | 90 } |
92 | 91 |
93 void Generator::FuzzDouble(double* value) { | 92 void Generator::FuzzDouble(double* value) { |
94 GenerateFloatingType<double>(value); | 93 GenerateFloatingType<double>(value); |
95 } | 94 } |
96 | 95 |
(...skipping 14 matching lines...) Expand all Loading... |
111 void Generator::FuzzBytes(void* data, int data_len) { | 110 void Generator::FuzzBytes(void* data, int data_len) { |
112 FuzzData(static_cast<char*>(data), data_len); | 111 FuzzData(static_cast<char*>(data), data_len); |
113 } | 112 } |
114 | 113 |
115 bool Generator::ShouldGenerate() { | 114 bool Generator::ShouldGenerate() { |
116 // The generator fuzzer should always generate new values. | 115 // The generator fuzzer should always generate new values. |
117 return true; | 116 return true; |
118 } | 117 } |
119 | 118 |
120 } // namespace ipc_fuzzer | 119 } // namespace ipc_fuzzer |
OLD | NEW |