aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os
diff options
context:
space:
mode:
authorJens Goldberg <jens.goldberg@gmail.com>2020-09-03 07:49:18 +0000
committerJens Goldberg <jens.goldberg@gmail.com>2020-09-03 07:49:18 +0000
commite747d2ba172a086e6df831c854ebe7f92bf07cd0 (patch)
treec9ba665dd60bc3a5e2e293139acb526339de4119 /lib/std/os
parent25f666330480a2391d1c06e1beab8d517a096e99 (diff)
downloadzig-e747d2ba172a086e6df831c854ebe7f92bf07cd0.tar.gz
zig-e747d2ba172a086e6df831c854ebe7f92bf07cd0.zip
Add C declarations and tests for the sync functions
Diffstat (limited to 'lib/std/os')
-rw-r--r--lib/std/os/test.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig
index 576125e2a3..0d8d2cc0db 100644
--- a/lib/std/os/test.zig
+++ b/lib/std/os/test.zig
@@ -555,3 +555,23 @@ test "signalfd" {
return error.SkipZigTest;
_ = std.os.signalfd;
}
+
+test "sync" {
+ 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.syncfs(file.handle);
+ try os.fsync(file.handle);
+ try os.fdatasync(file.handle);
+ os.sync();
+}