aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorJens Goldberg <jens.goldberg@gmail.com>2020-09-03 09:52:26 +0000
committerJens Goldberg <jens.goldberg@gmail.com>2020-09-03 09:52:26 +0000
commit68818983aef0d44f43f9575d8207053d5b7250ba (patch)
treeedf7903aed514e9e0d277a977801195f6f217612 /lib/std
parente747d2ba172a086e6df831c854ebe7f92bf07cd0 (diff)
downloadzig-68818983aef0d44f43f9575d8207053d5b7250ba.tar.gz
zig-68818983aef0d44f43f9575d8207053d5b7250ba.zip
Split the sync tests into sync and fsync
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/os/test.zig20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig
index 0d8d2cc0db..0a453d8b2e 100644
--- a/lib/std/os/test.zig
+++ b/lib/std/os/test.zig
@@ -557,7 +557,7 @@ test "signalfd" {
}
test "sync" {
- if (builtin.os.tag != .linux and builtin.os.tag != .windows)
+ if (builtin.os.tag != .linux)
return error.SkipZigTest;
var tmp = tmpDir(.{});
@@ -570,8 +570,24 @@ test "sync" {
tmp.dir.deleteFile(test_out_file) catch {};
}
+ os.sync();
try os.syncfs(file.handle);
+}
+
+test "fsync" {
+ if (builtin.os.tag != .linux and builtin.os.tag != .windows)
+ return error.SkipZigTest;
+
+ var tmp = tmpDir(.{});
+ defer tmp.cleanup();
+
+ const test_out_file = "os_tmp_test";
+ const file = try tmp.dir.createFile(test_out_file, .{});
+ defer {
+ file.close();
+ tmp.dir.deleteFile(test_out_file) catch {};
+ }
+
try os.fsync(file.handle);
try os.fdatasync(file.handle);
- os.sync();
}