| author | |
| committer | |
| log | e747d2ba172a086e6df831c854ebe7f92bf07cd0 |
| tree | c9ba665dd60bc3a5e2e293139acb526339de4119 |
| parent | 25f666330480a2391d1c06e1beab8d517a096e99 |
2 files changed, 25 insertions(+), 0 deletions(-)
lib/std/c.zig+5| ... | @@ -330,3 +330,8 @@ pub const FILE = @Type(.Opaque); | ... | @@ -330,3 +330,8 @@ pub const FILE = @Type(.Opaque); |
| 330 | pub extern "c" fn dlopen(path: [*:0]const u8, mode: c_int) ?*c_void; | 330 | pub extern "c" fn dlopen(path: [*:0]const u8, mode: c_int) ?*c_void; |
| 331 | pub extern "c" fn dlclose(handle: *c_void) c_int; | 331 | pub extern "c" fn dlclose(handle: *c_void) c_int; |
| 332 | pub extern "c" fn dlsym(handle: ?*c_void, symbol: [*:0]const u8) ?*c_void; | 332 | pub extern "c" fn dlsym(handle: ?*c_void, symbol: [*:0]const u8) ?*c_void; |
| 333 | |||
| 334 | pub extern "c" fn sync() void; | ||
| 335 | pub extern "c" fn syncfs(fd: c_int) c_int; | ||
| 336 | pub extern "c" fn fsync(fd: c_int) c_int; | ||
| 337 | pub extern "c" fn fdatasync(fd: c_int) c_int; |
lib/std/os/test.zig+20| ... | @@ -555,3 +555,23 @@ test "signalfd" { | ... | @@ -555,3 +555,23 @@ test "signalfd" { |
| 555 | return error.SkipZigTest; | 555 | return error.SkipZigTest; |
| 556 | _ = std.os.signalfd; | 556 | _ = std.os.signalfd; |
| 557 | } | 557 | } |
| 558 | |||
| 559 | test "sync" { | ||
| 560 | if (builtin.os.tag != .linux and builtin.os.tag != .windows) | ||
| 561 | return error.SkipZigTest; | ||
| 562 | |||
| 563 | var tmp = tmpDir(.{}); | ||
| 564 | defer tmp.cleanup(); | ||
| 565 | |||
| 566 | const test_out_file = "os_tmp_test"; | ||
| 567 | const file = try tmp.dir.createFile(test_out_file, .{}); | ||
| 568 | defer { | ||
| 569 | file.close(); | ||
| 570 | tmp.dir.deleteFile(test_out_file) catch {}; | ||
| 571 | } | ||
| 572 | |||
| 573 | try os.syncfs(file.handle); | ||
| 574 | try os.fsync(file.handle); | ||
| 575 | try os.fdatasync(file.handle); | ||
| 576 | os.sync(); | ||
| 577 | } |