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

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

Issue 10383179: Start 'fuzzing' of dart:io APIs and fix first issue found. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_message.cc ('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
new file mode 100644
index 0000000000000000000000000000000000000000..47a6519654d62b3c6a1dba656c1a129f43e129c6
--- /dev/null
+++ b/tests/standalone/io/file_fuzz_test.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// 'fuzz' test the file APIs by providing unexpected type arguments. The test
+// passes if the VM does not crash.
+
+#import('dart:io');
+
+final typeMapping = const {
+ 'int': 0,
+ 'String': 'a',
+ 'FileMode': FileMode.READ,
+ 'num': 0.50,
+ 'List<int>': const [1, 2, 3]
+};
+
+doItSync(Function f) {
+ // Ignore all exceptions.
+ try { f(); } catch (var e) {}
+}
+
+fuzzSyncMethods() {
+ typeMapping.forEach((k, v) {
+ doItSync(() {
+ var f = new File(v);
+ doItSync(f.existsSync);
+ doItSync(f.createSync);
+ doItSync(f.deleteSync);
+ doItSync(f.directorySync);
+ doItSync(f.lengthSync);
+ doItSync(f.fullPathSync);
+ doItSync(() => f.openInputStream().onError = (e) => null);
+ doItSync(f.readAsBytesSync);
+ typeMapping.forEach((k2, v2) {
+ doItSync(() => f.openSync(v2));
+ doItSync(() => f.openOutputStream(v2).onError = (e) => null);
+ doItSync(() => f.readAsTextSync(v2));
+ doItSync(() => f.readAsLinesSync(v2));
+ });
+ });
+ });
+}
+
+main() {
+ fuzzSyncMethods();
+}
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698