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

Side by Side Diff: tests/standalone/io/directory_fuzz_test.dart

Issue 10408060: Fuzzing of dart:io Directory API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | « runtime/bin/directory_impl.dart ('k') | tests/standalone/io/file_fuzz_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 // 'fuzz' test the directory APIs by providing unexpected type
6 // arguments. The test passes if the VM does not crash.
7
8 #import('dart:io');
9 #import('dart:isolate');
10
11 #import('fuzz_support.dart');
12
13 fuzzSyncMethods() {
14 typeMapping.forEach((k, v) {
15 doItSync(() {
16 var d = new Directory(v);
17 doItSync(d.existsSync);
18 doItSync(d.createSync);
19 doItSync(d.deleteSync);
20 doItSync(() {
21 d.createTempSync().deleteSync();
22 });
23 doItSync(() {
24 // Let's be a little careful. If the directory exists we don't
25 // want to delete it and all its contents.
26 if (!d.existsSync()) d.deleteRecursivelySync();
27 });
28 typeMapping.forEach((k2, v2) {
29 doItSync(() => d.renameSync(v2));
30 doItSync(() => d.list(v2).onError = (e) => null);
31 });
32 });
33 });
34 }
35
36 fuzzAsyncMethods() {
37 var port = new ReceivePort();
38 var futures = [];
39 typeMapping.forEach((k, v) {
40 var d = new Directory(v);
41 futures.add(doItAsync(d.exists));
42 futures.add(doItAsync(d.create));
43 futures.add(doItAsync(d.delete));
44 futures.add(doItAsync(() {
45 return d.createTemp().chain((temp) {
46 return temp.delete();
47 });
48 }));
49 futures.add(doItAsync(() {
50 return d.exists().chain((res) {
51 if (!res) return d.deleteRecursively();
52 return new Future.immediate(true);
53 });
54 }));
55 typeMapping.forEach((k2, v2) {
56 futures.add(doItAsync(() => d.rename(v2)));
57 });
58 });
59 Futures.wait(futures).then((ignore) => port.close());
60 }
61
62 main() {
63 fuzzSyncMethods();
64 fuzzAsyncMethods();
65 }
OLDNEW
« no previous file with comments | « runtime/bin/directory_impl.dart ('k') | tests/standalone/io/file_fuzz_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698