Commit 68818983ae

Jens Goldberg <jens.goldberg@gmail.com>
2020-09-03 11:52:26
Split the sync tests into sync and fsync
1 parent e747d2b
Changed files (1)
lib
std
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();
 }