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

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

Issue 590513003: 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, 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.
36 'dart.isolate._isolateScheduleImmediate',
37 'dart.io._Timer._createTimer', /// smi: ok
34 38
35 // These either cause the VM to segfault or throw uncatchable API errors. 39 // These either cause the VM to segfault or throw uncatchable API errors.
36 // TODO(15274): Fix them and remove from blacklist. 40 // TODO(15274): Fix them and remove from blacklist.
37 'dart.io._IOService.dispatch', 41 'dart.io._IOService.dispatch',
38 new RegExp(r'.*_RandomAccessFile.*'), 42 new RegExp(r'.*_RandomAccessFile.*'),
39 'dart.io._StdIOUtils._socketType', 43 'dart.io._StdIOUtils._socketType',
40 'dart.io._StdIOUtils._getStdioOutputStream', 44 'dart.io._StdIOUtils._getStdioOutputStream',
41 'dart.io._Filter.newZLibInflateFilter', 45 'dart.io._Filter.newZLibInflateFilter',
42 'dart.io._Filter.newZLibDeflateFilter', 46 'dart.io._Filter.newZLibDeflateFilter',
43 'dart.io._FileSystemWatcher._listenOnSocket', 47 'dart.io._FileSystemWatcher._listenOnSocket',
44 'dart.io.SystemEncoding.decode', 48 'dart.io.SystemEncoding.decode',
45 'dart.io.SystemEncoding.encode', 49 'dart.io.SystemEncoding.encode',
46 'dart.core._Bigint._mulAdd', // TODO(regis): Is this an intrinsic issue? 50 'dart.core.StringBuffer.toString', /// emptyarray: ok
47 ]; 51 ];
48 52
49 bool isBlacklisted(Symbol qualifiedSymbol) { 53 bool isBlacklisted(Symbol qualifiedSymbol) {
50 var qualifiedString = MirrorSystem.getName(qualifiedSymbol); 54 var qualifiedString = MirrorSystem.getName(qualifiedSymbol);
51 for (var pattern in blacklist) { 55 for (var pattern in blacklist) {
52 if (qualifiedString.contains(pattern)) return true; 56 if (qualifiedString.contains(pattern)) return true;
53 } 57 }
54 return false; 58 return false;
55 } 59 }
56 60
57 class Task { 61 class Task {
58 var name; 62 var name;
59 var action; 63 var action;
60 } 64 }
61 var queue = new List(); 65 var queue = new List();
62 66
63 checkMethod(MethodMirror m, ObjectMirror target, [origin]) { 67 checkMethod(MethodMirror m, ObjectMirror target, [origin]) {
64 if (isBlacklisted(m.qualifiedName)) return; 68 if (isBlacklisted(m.qualifiedName)) return;
65 69
66 var task = new Task(); 70 var task = new Task();
67 task.name = '${MirrorSystem.getName(m.qualifiedName)} from $origin'; 71 task.name = '${MirrorSystem.getName(m.qualifiedName)} from $origin';
68 72
69 if (m.isRegularMethod) { 73 if (m.isRegularMethod) {
70 task.action = 74 task.action =
71 () => target.invoke(m.simpleName, new List(m.parameters.length)); 75 () => target.invoke(m.simpleName,
76 new List.filled(m.parameters.length, fuzzArgument));
72 } else if (m.isGetter) { 77 } else if (m.isGetter) {
73 task.action = 78 task.action =
74 () => target.getField(m.simpleName); 79 () => target.getField(m.simpleName);
75 } else if (m.isSetter) { 80 } else if (m.isSetter) {
76 task.action = 81 task.action =
77 () => target.setField(m.simpleName, null); 82 () => target.setField(m.simpleName, null);
78 } else if (m.isConstructor) { 83 } else if (m.isConstructor) {
79 return; 84 return;
80 } else { 85 } else {
81 throw "Unexpected method kind"; 86 throw "Unexpected method kind";
(...skipping 18 matching lines...) Expand all
100 .forEach((m) => checkMethod(m, classMirror)); 105 .forEach((m) => checkMethod(m, classMirror));
101 106
102 classMirror.declarations.values 107 classMirror.declarations.values
103 .where((d) => d is MethodMirror && d.isConstructor) 108 .where((d) => d is MethodMirror && d.isConstructor)
104 .forEach((m) { 109 .forEach((m) {
105 if (isBlacklisted(m.qualifiedName)) return; 110 if (isBlacklisted(m.qualifiedName)) return;
106 var task = new Task(); 111 var task = new Task();
107 task.name = MirrorSystem.getName(m.qualifiedName); 112 task.name = MirrorSystem.getName(m.qualifiedName);
108 113
109 task.action = () { 114 task.action = () {
110 var instance = classMirror.newInstance(m.constructorName, 115 var instance = classMirror.newInstance(
111 new List(m.parameters.length)); 116 m.constructorName,
117 new List.filled(m.parameters.length, fuzzArgument));
112 checkInstance(instance, task.name); 118 checkInstance(instance, task.name);
113 }; 119 };
114 queue.add(task); 120 queue.add(task);
115 }); 121 });
116 } 122 }
117 123
118 checkLibrary(libraryMirror) { 124 checkLibrary(libraryMirror) {
119 print(libraryMirror.simpleName); 125 print(libraryMirror.simpleName);
120 if (isBlacklisted(libraryMirror.qualifiedName)) return; 126 if (isBlacklisted(libraryMirror.qualifiedName)) return;
121 127
(...skipping 20 matching lines...) Expand all
142 task.action(); 148 task.action();
143 } catch(e) {} 149 } catch(e) {}
144 150
145 // Register the next task in a timer callback so as to yield to async code 151 // 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, 152 // 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 153 // but is helpful when trying to figure out which function is responsible for
148 // a crash. 154 // a crash.
149 testZone.createTimer(Duration.ZERO, doOneTask); 155 testZone.createTimer(Duration.ZERO, doOneTask);
150 } 156 }
151 157
158 var fuzzArgument;
159
152 main([args]) { 160 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
153 currentMirrorSystem().libraries.values.forEach(checkLibrary); 167 currentMirrorSystem().libraries.values.forEach(checkLibrary);
154 168
155 var valueObjects = 169 var valueObjects =
156 [true, false, null, 170 [true, false, null,
157 0, 0xEFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 171 0, 0xEFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
158 "foo", 'blåbærgrød', 'Îñţérñåţîöñåļîžåţîờñ']; 172 "foo", 'blåbærgrød', 'Îñţérñåţîöñåļîžåţîờñ', "𝄞", #symbol];
159 valueObjects.forEach((v) => checkInstance(reflect(v), 'value object')); 173 valueObjects.forEach((v) => checkInstance(reflect(v), 'value object'));
160 174
161 uncaughtErrorHandler(self, parent, zone, error, stack) {}; 175 uncaughtErrorHandler(self, parent, zone, error, stack) {};
162 var zoneSpec = 176 var zoneSpec =
163 new ZoneSpecification(handleUncaughtError: uncaughtErrorHandler); 177 new ZoneSpecification(handleUncaughtError: uncaughtErrorHandler);
164 testZone = Zone.current.fork(specification: zoneSpec); 178 testZone = Zone.current.fork(specification: zoneSpec);
165 testZone.createTimer(Duration.ZERO, doOneTask); 179 testZone.createTimer(Duration.ZERO, doOneTask);
166 } 180 }
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