aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux/test.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrewrk@noreply.codeberg.org>2025-12-27 14:10:46 +0100
committerAndrew Kelley <andrewrk@noreply.codeberg.org>2025-12-27 14:10:46 +0100
commite55e6b5528bb2f01de242fcf32b172e244e98e74 (patch)
tree3a5eb3193d3d192c54ab0c2b7295a7f21861c27e /lib/std/os/linux/test.zig
parentc3f2de5e519926eb0029062fe8e782a6f9df9c05 (diff)
parent60a1ba0a8f3517356fa2941462f002a7f580545b (diff)
downloadzig-e55e6b5528bb2f01de242fcf32b172e244e98e74.tar.gz
zig-e55e6b5528bb2f01de242fcf32b172e244e98e74.zip
Merge pull request 'std: migrate all `fs` APIs to `Io`' (#30232) from std.Io-fs into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30232
Diffstat (limited to 'lib/std/os/linux/test.zig')
-rw-r--r--lib/std/os/linux/test.zig32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig
index 500c3f0bae..974ce0a25c 100644
--- a/lib/std/os/linux/test.zig
+++ b/lib/std/os/linux/test.zig
@@ -12,14 +12,16 @@ const fs = std.fs;
test "fallocate" {
if (builtin.cpu.arch.isMIPS64() and (builtin.abi == .gnuabin32 or builtin.abi == .muslabin32)) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30220
+ const io = std.testing.io;
+
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
const path = "test_fallocate";
- const file = try tmp.dir.createFile(path, .{ .truncate = true, .mode = 0o666 });
- defer file.close();
+ const file = try tmp.dir.createFile(io, path, .{ .truncate = true, .permissions = .fromMode(0o666) });
+ defer file.close(io);
- try expect((try file.stat()).size == 0);
+ try expect((try file.stat(io)).size == 0);
const len: i64 = 65536;
switch (linux.errno(linux.fallocate(file.handle, 0, 0, len))) {
@@ -29,7 +31,7 @@ test "fallocate" {
else => |errno| std.debug.panic("unhandled errno: {}", .{errno}),
}
- try expect((try file.stat()).size == len);
+ try expect((try file.stat(io)).size == len);
}
test "getpid" {
@@ -77,12 +79,14 @@ test "timer" {
}
test "statx" {
+ const io = std.testing.io;
+
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
const tmp_file_name = "just_a_temporary_file.txt";
- var file = try tmp.dir.createFile(tmp_file_name, .{});
- defer file.close();
+ var file = try tmp.dir.createFile(io, tmp_file_name, .{});
+ defer file.close(io);
var buf: linux.Statx = undefined;
switch (linux.errno(linux.statx(file.handle, "", linux.AT.EMPTY_PATH, .BASIC_STATS, &buf))) {
@@ -111,15 +115,17 @@ test "user and group ids" {
}
test "fadvise" {
+ const io = std.testing.io;
+
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
const tmp_file_name = "temp_posix_fadvise.txt";
- var file = try tmp.dir.createFile(tmp_file_name, .{});
- defer file.close();
+ var file = try tmp.dir.createFile(io, tmp_file_name, .{});
+ defer file.close(io);
var buf: [2048]u8 = undefined;
- try file.writeAll(&buf);
+ try file.writeStreamingAll(io, &buf);
const ret = linux.fadvise(file.handle, 0, 0, linux.POSIX_FADV.SEQUENTIAL);
try expectEqual(@as(usize, 0), ret);
@@ -401,14 +407,6 @@ test "futex2_requeue" {
try expectEqual(0, rc);
}
-test "copy_file_range error" {
- const fds = try std.posix.pipe();
- defer std.posix.close(fds[0]);
- defer std.posix.close(fds[1]);
-
- try std.testing.expectError(error.InvalidArguments, linux.wrapped.copy_file_range(fds[0], null, fds[1], null, 1, 0));
-}
-
test {
_ = linux.IoUring;
}