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

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

Issue 2501803002: Simplifies the blocking file lock test (Closed)
Patch Set: Address comments Created 4 years, 1 month 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 | « no previous file | tests/standalone/io/file_blocking_lock_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_blocking_lock_script.dart
diff --git a/tests/standalone/io/file_blocking_lock_script.dart b/tests/standalone/io/file_blocking_lock_script.dart
index 5c955c49e70959ae3ad42a74c77fa1c51421b22b..9ba2feb4b8a675e00ee1373ef4633b7493c3f1c2 100644
--- a/tests/standalone/io/file_blocking_lock_script.dart
+++ b/tests/standalone/io/file_blocking_lock_script.dart
@@ -11,32 +11,15 @@ Future<int> testLockWholeFile(File file, int len) async {
var raf = await file.open(mode: APPEND);
await raf.setPosition(0);
int nextToWrite = 1;
- while (nextToWrite <= len) {
- await raf.lock(FileLock.BLOCKING_EXCLUSIVE, 0, len);
+ await raf.lock(FileLock.BLOCKING_EXCLUSIVE, 0, len);
- int at;
- int p;
- while (true) {
- p = await raf.position();
- at = await raf.readByte();
- if (at == 0 || at == -1) break;
- nextToWrite++;
- }
- await raf.setPosition(p);
- await raf.writeByte(nextToWrite);
- await raf.flush();
- nextToWrite++;
- await raf.unlock(0, len);
- }
+ // Make sure the peer fails a non-blocking lock at some point.
+ await new Future.delayed(const Duration(seconds: 1));
- await raf.lock(FileLock.BLOCKING_EXCLUSIVE, 0, len);
- await raf.setPosition(0);
- for (int i = 1; i <= len; i++) {
- if ((await raf.readByte()) != i) {
- await raf.unlock(0, len);
- await raf.close();
- return 1;
- }
+ int p = 0;
+ while (p < len) {
+ await raf.writeByte(1);
+ p++;
}
await raf.unlock(0, len);
await raf.close();
« no previous file with comments | « no previous file | tests/standalone/io/file_blocking_lock_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698