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

Unified Diff: tests/standalone/io/file_fuzz_test.dart

Issue 10411053: Finish file 'fuzzer' and fix issues. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_fuzz_test.dart
diff --git a/tests/standalone/io/file_fuzz_test.dart b/tests/standalone/io/file_fuzz_test.dart
index efee40a6934098663797000dc848207d6c9275c0..f13529925b51db2d9769c3250d76c03ed484e1b6 100644
--- a/tests/standalone/io/file_fuzz_test.dart
+++ b/tests/standalone/io/file_fuzz_test.dart
@@ -110,7 +110,6 @@ fuzzAsyncMethods() {
}
-// TODO(ager): Finish implementation.
fuzzSyncRandomAccessMethods() {
var d = new Directory('');
var temp = d.createTempSync();
@@ -121,6 +120,7 @@ fuzzSyncRandomAccessMethods() {
var opened = file.openSync(m);
typeMapping.forEach((k, v) {
doItSync(() => opened.setPositionSync(v));
+ doItSync(() => opened.truncateSync(v));
doItSync(() => opened.writeByteSync(v));
});
for (var p in typePermutations(2)) {
@@ -128,15 +128,48 @@ fuzzSyncRandomAccessMethods() {
}
for (var p in typePermutations(3)) {
doItSync(() => opened.readListSync(p[0], p[1], p[2]));
- doItSync(() => opened.writeList(p[0], p[1], p[2]));
+ doItSync(() => opened.writeListSync(p[0], p[1], p[2]));
}
opened.closeSync();
}
temp.deleteRecursivelySync();
}
+fuzzAsyncRandomAccessMethods() {
+ var d = new Directory('');
+ var temp = d.createTempSync();
+ var file = new File('${temp.path}/x');
+ file.createSync();
+ var modes = [ FileMode.READ, FileMode.WRITE, FileMode.APPEND ];
+ var futures = [];
+ var openedFiles = [];
+ for (var m in modes) {
+ var opened = file.openSync(m);
+ openedFiles.add(opened);
+ typeMapping.forEach((k, v) {
+ futures.add(doItAsync(() => opened.setPosition(v)));
+ futures.add(doItAsync(() => opened.truncate(v)));
+ futures.add(doItAsync(() => opened.writeByte(v)));
+ });
+ for (var p in typePermutations(2)) {
+ futures.add(doItAsync(() => opened.writeString(p[0], p[1])));
+ }
+ for (var p in typePermutations(3)) {
+ futures.add(doItAsync(() => opened.readList(p[0], p[1], p[2])));
+ futures.add(doItAsync(() => opened.writeList(p[0], p[1], p[2])));
+ }
+ }
+ Futures.wait(futures).then((ignore) {
+ for (var opened in openedFiles) {
+ opened.closeSync();
+ }
+ temp.deleteRecursivelySync();
+ });
+}
+
main() {
fuzzSyncMethods();
fuzzAsyncMethods();
fuzzSyncRandomAccessMethods();
+ fuzzAsyncRandomAccessMethods();
}
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698