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

Side by Side Diff: tests/lib/mirrors/invocation_fuzz_test.dart

Issue 590703003: Revert "Add _Bigint._mulAdd to the invisible list. Strengthen the mirror invocation fuzzer." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | « tests/lib/lib.status ('k') | 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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This test reflectively enumerates all the methods in the system and tries to 5 // This test reflectively enumerates all the methods in the system and tries to
6 // invoke them will various basic values (nulls, ints, etc). This may result in 6 // invoke them will all nulls. This may result in Dart exceptions or hangs, but
7 // Dart exceptions or hangs, but should never result in crashes or JavaScript 7 // should never result in crashes or JavaScript exceptions.
8 // exceptions.
9 8
10 library test.invoke_natives; 9 library test.invoke_natives;
11 10
12 import 'dart:mirrors'; 11 import 'dart:mirrors';
13 import 'dart:async'; 12 import 'dart:async';
13 import 'package:expect/expect.dart';
14 14
15 // Methods to be skipped, by qualified name. 15 // Methods to be skipped, by qualified name.
16 var blacklist = [ 16 var blacklist = [
17 // Don't recurse on this test. 17 // Don't recurse on this test.
18 'test.invoke_natives', 18 'test.invoke_natives',
19 19
20 // Don't exit the test pre-maturely. 20 // Don't exit the test pre-maturely.
21 'dart.io.exit', 21 'dart.io.exit',
22 22
23 // Don't run blocking io calls. 23 // Don't run blocking io calls.
24 new RegExp(r".*Sync$"), 24 new RegExp(r".*Sync$"),
25 25
26 // These prevent the test from exiting. 26 // These prevent the test from exiting.
27 'dart.async._scheduleAsyncCallback', 27 'dart.async._scheduleAsyncCallback',
28 'dart.async._setTimerFactoryClosure', 28 'dart.async._setTimerFactoryClosure',
29
29 'dart.isolate._startMainIsolate', 30 'dart.isolate._startMainIsolate',
30 'dart.isolate._startIsolate', 31 'dart.isolate._startIsolate',
31 'dart.io.sleep', 32 'dart.io.sleep',
32 'dart.io.HttpServer.HttpServer.listenOn', 33 'dart.io.HttpServer.HttpServer.listenOn',
33 new RegExp(r'dart.io.*'), /// smi: ok
34
35 // Runtime exceptions we can't catch.
36 'dart.isolate._isolateScheduleImmediate',
37 'dart.io._Timer._createTimer', /// smi: ok
38 34
39 // These either cause the VM to segfault or throw uncatchable API errors. 35 // These either cause the VM to segfault or throw uncatchable API errors.
40 // TODO(15274): Fix them and remove from blacklist. 36 // TODO(15274): Fix them and remove from blacklist.
41 'dart.io._IOService.dispatch', 37 'dart.io._IOService.dispatch',
42 new RegExp(r'.*_RandomAccessFile.*'), 38 new RegExp(r'.*_RandomAccessFile.*'),
43 'dart.io._StdIOUtils._socketType', 39 'dart.io._StdIOUtils._socketType',
44 'dart.io._StdIOUtils._getStdioOutputStream', 40 'dart.io._StdIOUtils._getStdioOutputStream',
45 'dart.io._Filter.newZLibInflateFilter', 41 'dart.io._Filter.newZLibInflateFilter',
46 'dart.io._Filter.newZLibDeflateFilter', 42 'dart.io._Filter.newZLibDeflateFilter',
47 'dart.io._FileSystemWatcher._listenOnSocket', 43 'dart.io._FileSystemWatcher._listenOnSocket',
48 'dart.io.SystemEncoding.decode', 44 'dart.io.SystemEncoding.decode',
49 'dart.io.SystemEncoding.encode', 45 'dart.io.SystemEncoding.encode',
50 'dart.core.StringBuffer.toString', /// emptyarray: ok 46 'dart.core._Bigint._mulAdd', // TODO(regis): Is this an intrinsic issue?
51 ]; 47 ];
52 48
53 bool isBlacklisted(Symbol qualifiedSymbol) { 49 bool isBlacklisted(Symbol qualifiedSymbol) {
54 var qualifiedString = MirrorSystem.getName(qualifiedSymbol); 50 var qualifiedString = MirrorSystem.getName(qualifiedSymbol);
55 for (var pattern in blacklist) { 51 for (var pattern in blacklist) {
56 if (qualifiedString.contains(pattern)) return true; 52 if (qualifiedString.contains(pattern)) return true;
57 } 53 }
58 return false; 54 return false;
59 } 55 }
60 56
61 class Task { 57 class Task {
62 var name; 58 var name;
63 var action; 59 var action;
64 } 60 }
65 var queue = new List(); 61 var queue = new List();
66 62
67 checkMethod(MethodMirror m, ObjectMirror target, [origin]) { 63 checkMethod(MethodMirror m, ObjectMirror target, [origin]) {
68 if (isBlacklisted(m.qualifiedName)) return; 64 if (isBlacklisted(m.qualifiedName)) return;
69 65
70 var task = new Task(); 66 var task = new Task();
71 task.name = '${MirrorSystem.getName(m.qualifiedName)} from $origin'; 67 task.name = '${MirrorSystem.getName(m.qualifiedName)} from $origin';
72 68
73 if (m.isRegularMethod) { 69 if (m.isRegularMethod) {
74 task.action = 70 task.action =
75 () => target.invoke(m.simpleName, 71 () => target.invoke(m.simpleName, new List(m.parameters.length));
76 new List.filled(m.parameters.length, fuzzArgument));
77 } else if (m.isGetter) { 72 } else if (m.isGetter) {
78 task.action = 73 task.action =
79 () => target.getField(m.simpleName); 74 () => target.getField(m.simpleName);
80 } else if (m.isSetter) { 75 } else if (m.isSetter) {
81 task.action = 76 task.action =
82 () => target.setField(m.simpleName, null); 77 () => target.setField(m.simpleName, null);
83 } else if (m.isConstructor) { 78 } else if (m.isConstructor) {
84 return; 79 return;
85 } else { 80 } else {
86 throw "Unexpected method kind"; 81 throw "Unexpected method kind";
(...skipping 18 matching lines...) Expand all
105 .forEach((m) => checkMethod(m, classMirror)); 100 .forEach((m) => checkMethod(m, classMirror));
106 101
107 classMirror.declarations.values 102 classMirror.declarations.values
108 .where((d) => d is MethodMirror && d.isConstructor) 103 .where((d) => d is MethodMirror && d.isConstructor)
109 .forEach((m) { 104 .forEach((m) {
110 if (isBlacklisted(m.qualifiedName)) return; 105 if (isBlacklisted(m.qualifiedName)) return;
111 var task = new Task(); 106 var task = new Task();
112 task.name = MirrorSystem.getName(m.qualifiedName); 107 task.name = MirrorSystem.getName(m.qualifiedName);
113 108
114 task.action = () { 109 task.action = () {
115 var instance = classMirror.newInstance( 110 var instance = classMirror.newInstance(m.constructorName,
116 m.constructorName, 111 new List(m.parameters.length));
117 new List.filled(m.parameters.length, fuzzArgument));
118 checkInstance(instance, task.name); 112 checkInstance(instance, task.name);
119 }; 113 };
120 queue.add(task); 114 queue.add(task);
121 }); 115 });
122 } 116 }
123 117
124 checkLibrary(libraryMirror) { 118 checkLibrary(libraryMirror) {
125 print(libraryMirror.simpleName); 119 print(libraryMirror.simpleName);
126 if (isBlacklisted(libraryMirror.qualifiedName)) return; 120 if (isBlacklisted(libraryMirror.qualifiedName)) return;
127 121
(...skipping 20 matching lines...) Expand all
148 task.action(); 142 task.action();
149 } catch(e) {} 143 } catch(e) {}
150 144
151 // Register the next task in a timer callback so as to yield to async code 145 // Register the next task in a timer callback so as to yield to async code
152 // scheduled in the current task. This isn't necessary for the test itself, 146 // scheduled in the current task. This isn't necessary for the test itself,
153 // but is helpful when trying to figure out which function is responsible for 147 // but is helpful when trying to figure out which function is responsible for
154 // a crash. 148 // a crash.
155 testZone.createTimer(Duration.ZERO, doOneTask); 149 testZone.createTimer(Duration.ZERO, doOneTask);
156 } 150 }
157 151
158 var fuzzArgument;
159
160 main([args]) { 152 main([args]) {
161 fuzzArgument = null;
162 fuzzArgument = 1; /// smi: ok
163 fuzzArgument = false; /// false: ok
164 fuzzArgument = 'string'; /// string: ok
165 fuzzArgument = new List(0); /// emptyarray: ok
166
167 currentMirrorSystem().libraries.values.forEach(checkLibrary); 153 currentMirrorSystem().libraries.values.forEach(checkLibrary);
168 154
169 var valueObjects = 155 var valueObjects =
170 [true, false, null, 156 [true, false, null,
171 0, 0xEFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 157 0, 0xEFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
172 "foo", 'blåbærgrød', 'Îñţérñåţîöñåļîžåţîờñ', "𝄞", #symbol]; 158 "foo", 'blåbærgrød', 'Îñţérñåţîöñåļîžåţîờñ'];
173 valueObjects.forEach((v) => checkInstance(reflect(v), 'value object')); 159 valueObjects.forEach((v) => checkInstance(reflect(v), 'value object'));
174 160
175 uncaughtErrorHandler(self, parent, zone, error, stack) {}; 161 uncaughtErrorHandler(self, parent, zone, error, stack) {};
176 var zoneSpec = 162 var zoneSpec =
177 new ZoneSpecification(handleUncaughtError: uncaughtErrorHandler); 163 new ZoneSpecification(handleUncaughtError: uncaughtErrorHandler);
178 testZone = Zone.current.fork(specification: zoneSpec); 164 testZone = Zone.current.fork(specification: zoneSpec);
179 testZone.createTimer(Duration.ZERO, doOneTask); 165 testZone.createTimer(Duration.ZERO, doOneTask);
180 } 166 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698