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

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

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