OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Random-walk fuzzer for the Dart VM. | 5 // Random-walk fuzzer for the Dart VM. |
6 // | 6 // |
7 // Start with all the classes and libraries and various interesting values. | 7 // Start with all the classes and libraries and various interesting values. |
8 // Repeatedly choose one as a receiver, construct a message it is likely to | 8 // Repeatedly choose one as a receiver, construct a message it is likely to |
9 // understand, send the message, and add the result. | 9 // understand, send the message, and add the result. |
10 // | 10 // |
(...skipping 15 matching lines...) Expand all Loading... |
26 ]; | 26 ]; |
27 | 27 |
28 final bool trace = false; | 28 final bool trace = false; |
29 | 29 |
30 void main(List<String> args) { | 30 void main(List<String> args) { |
31 int seed; | 31 int seed; |
32 if (args.length == 1) { | 32 if (args.length == 1) { |
33 seed = int.parse(args[0]); | 33 seed = int.parse(args[0]); |
34 } else { | 34 } else { |
35 // Dart's built-in random number generator doesn't provide access to the | 35 // Dart's built-in random number generator doesn't provide access to the |
36 // seed when it is choosen by the implementation. We need to be able to | 36 // seed when it is chosen by the implementation. We need to be able to |
37 // report this seed to make runs of the fuzzer reproducible, so we create | 37 // report this seed to make runs of the fuzzer reproducible, so we create |
38 // the seed ourselves. | 38 // the seed ourselves. |
39 | 39 |
40 // When running on many machines in parallel, the current time alone | 40 // When running on many machines in parallel, the current time alone |
41 // is a poor choice of seed. | 41 // is a poor choice of seed. |
42 seed = 0; | 42 seed = 0; |
43 try { | 43 try { |
44 var f = new File("/dev/urandom").openSync(); | 44 var f = new File("/dev/urandom").openSync(); |
45 seed = (seed << 8) | f.readByteSync(); | 45 seed = (seed << 8) | f.readByteSync(); |
46 seed = (seed << 8) | f.readByteSync(); | 46 seed = (seed << 8) | f.readByteSync(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 addInstance(double.NEGATIVE_INFINITY); | 169 addInstance(double.NEGATIVE_INFINITY); |
170 addInstance(double.MIN_POSITIVE); | 170 addInstance(double.MIN_POSITIVE); |
171 addInstance(double.MAX_FINITE); | 171 addInstance(double.MAX_FINITE); |
172 | 172 |
173 addInstance("foo"); // ASCII string | 173 addInstance("foo"); // ASCII string |
174 addInstance("blåbærgrød"); // Latin1 string | 174 addInstance("blåbærgrød"); // Latin1 string |
175 addInstance("Îñţérñåţîöñåļîžåţîờñ"); // Unicode string | 175 addInstance("Îñţérñåţîöñåļîžåţîờñ"); // Unicode string |
176 addInstance("𝄞"); // Surrogate pairs | 176 addInstance("𝄞"); // Surrogate pairs |
177 addInstance("𝄞"[0]); // Surrogate pairs | 177 addInstance("𝄞"[0]); // Surrogate pairs |
178 addInstance("𝄞"[1]); // Surrogate pairs | 178 addInstance("𝄞"[1]); // Surrogate pairs |
179 addInstance("\u{0}"); // Non-printing charater | 179 addInstance("\u{0}"); // Non-printing character |
180 addInstance("\u{1}"); // Non-printing charater | 180 addInstance("\u{1}"); // Non-printing character |
181 addInstance("f\u{0}oo"); // Internal NUL | 181 addInstance("f\u{0}oo"); // Internal NUL |
182 addInstance("blåbæ\u{0}rgrød"); // Internal NUL | 182 addInstance("blåbæ\u{0}rgrød"); // Internal NUL |
183 addInstance("Îñţérñåţîö\u{0}ñåļîžåţîờñ"); // Internal NUL | 183 addInstance("Îñţérñåţîö\u{0}ñåļîžåţîờñ"); // Internal NUL |
184 addInstance("\u{0}𝄞"); // Internal NUL | 184 addInstance("\u{0}𝄞"); // Internal NUL |
185 | 185 |
186 for (int len = 0; len < 8; len++) { | 186 for (int len = 0; len < 8; len++) { |
187 addInstance(fillInt(new Int8List(len))); | 187 addInstance(fillInt(new Int8List(len))); |
188 addInstance(fillInt(new Int16List(len))); | 188 addInstance(fillInt(new Int16List(len))); |
189 addInstance(fillInt(new Int32List(len))); | 189 addInstance(fillInt(new Int32List(len))); |
190 addInstance(fillInt(new Int64List(len))); | 190 addInstance(fillInt(new Int64List(len))); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // Chain a bunch of moderately sized arrays, then let go of them. Using a | 343 // Chain a bunch of moderately sized arrays, then let go of them. Using a |
344 // moderate size avoids our allocations going directly to a large object | 344 // moderate size avoids our allocations going directly to a large object |
345 // page in old space. | 345 // page in old space. |
346 var n; | 346 var n; |
347 for (int i = 0; i < 2048; i++) { | 347 for (int i = 0; i < 2048; i++) { |
348 var m = new List(512); | 348 var m = new List(512); |
349 m[0] = n; | 349 m[0] = n; |
350 n = m; | 350 n = m; |
351 } | 351 } |
352 } | 352 } |
OLD | NEW |