Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: test/mjsunit/fuzz-natives.js

Issue 598011: Changed fuzzer to randomly remove half of the arguments when running... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --allow-natives-syntax 28 // Flags: --allow-natives-syntax
29 29
30 var RUN_WITH_ALL_ARGUMENT_ENTRIES = false;
31 var kOnManyArgumentsRemove = 5;
32
30 function makeArguments() { 33 function makeArguments() {
31 var result = [ ]; 34 var result = [ ];
32 result.push(17); 35 result.push(17);
33 result.push(-31); 36 result.push(-31);
34 result.push(new Array(100)); 37 result.push(new Array(100));
35 result.push(new Array(100003)); 38 result.push(new Array(100003));
36 result.push(Number.MIN_VALUE); 39 result.push(Number.MIN_VALUE);
37 result.push("whoops"); 40 result.push("whoops");
38 result.push("x"); 41 result.push("x");
39 result.push({"x": 1, "y": 2}); 42 result.push({"x": 1, "y": 2});
(...skipping 27 matching lines...) Expand all
67 } 70 }
68 } 71 }
69 } 72 }
70 73
71 function testArgumentTypes(name, argc) { 74 function testArgumentTypes(name, argc) {
72 var type = 0; 75 var type = 0;
73 var hasMore = true; 76 var hasMore = true;
74 var func = makeFunction(name, argc); 77 var func = makeFunction(name, argc);
75 while (hasMore) { 78 while (hasMore) {
76 var argPool = makeArguments(); 79 var argPool = makeArguments();
80 // When we have 5 or more arguments we lower the amount of tests cases
81 // by randomly removing kOnManyArgumentsRemove entries
82 var numArguments = RUN_WITH_ALL_ARGUMENT_ENTRIES ?
83 kArgObjects : kArgObjects-kOnManyArgumentsRemove;
84 if (argc >= 5 && !RUN_WITH_ALL_ARGUMENT_ENTRIES) {
85 for (var i = 0; i < kOnManyArgumentsRemove; i++) {
86 var rand = Math.floor(Math.random() * (kArgObjects - i));
87 argPool.splice(rand,1);
Mads Ager (chromium) 2010/02/09 12:04:14 nit: add a space after the comma.
88 }
89 }
77 var current = type; 90 var current = type;
78 var hasMore = false; 91 var hasMore = false;
79 var argList = [ ]; 92 var argList = [ ];
80 for (var i = 0; i < argc; i++) { 93 for (var i = 0; i < argc; i++) {
81 var index = current % kArgObjects; 94 var index = current % numArguments;
82 current = (current / kArgObjects) << 0; 95 current = (current / numArguments) << 0;
83 if (index != (kArgObjects - 1)) 96 if (index != (numArguments - 1))
84 hasMore = true; 97 hasMore = true;
85 argList.push(argPool[index]); 98 argList.push(argPool[index]);
86 } 99 }
87 try { 100 try {
88 func.apply(void 0, argList); 101 func.apply(void 0, argList);
89 } catch (e) { 102 } catch (e) {
90 // we don't care what happens as long as we don't crash 103 // we don't care what happens as long as we don't crash
91 } 104 }
92 type++; 105 type++;
93 } 106 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (name in knownProblems || name in currentlyUncallable) 163 if (name in knownProblems || name in currentlyUncallable)
151 continue; 164 continue;
152 print(name); 165 print(name);
153 var argc = nativeInfo[1]; 166 var argc = nativeInfo[1];
154 testArgumentCount(name); 167 testArgumentCount(name);
155 testArgumentTypes(name, argc); 168 testArgumentTypes(name, argc);
156 } 169 }
157 } 170 }
158 171
159 testNatives(); 172 testNatives();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698