-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Running the std tests on Ubuntu Linux 18.04.5, for recent master (12ce6eb) using matching precompiled zig-linux-x86_64-0.6.0+12ce6eb8f.tar.xz fails:
$ zig --override-lib-dir $PWD/lib --main-pkg-path $PWD/lib test $PWD/lib/std/std.zig
Test [224/1523] std.progress.test "basic functionality"...SKIP
Test [605/1523] std.event.loop.test "std.event.Loop - basic"...SKIP
Test [631/1523] std.io.c_writer.test ""...SKIP
Test [648/1523] std.fs.test.test "file operations on directories"...expected error.IsDir, found
/home/marnix/projects/zig/lib/std/testing.zig:27:24: 0x9f4e05 in std.testing.expectError (test)
std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
^
/home/marnix/projects/zig/lib/std/fs/test.zig:258:28: 0x40eb40 in std.fs.test.test "file operations on directories" (test)
testing.expectError(error.IsDir, tmp_dir.dir.readFileAlloc(testing.allocator, test_dir_name, std.math.maxInt(usize)));
^
/home/marnix/projects/zig/lib/std/special/test_runner.zig:61:28: 0x4872a1 in std.special.main (test)
} else test_fn.func();
^
/home/marnix/projects/zig/lib/std/start.zig:257:37: 0x450e4d in std.start.posixCallMainAndExit (test)
const result = root.main() catch |err| {
^
/home/marnix/projects/zig/lib/std/start.zig:128:5: 0x450b8f in std.start._start (test)
@call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
^
Tests failed. Use the following command to reproduce the failure:
/media/marnux3data/data/projects/zig/zig-cache/o/VM696BU7V7eI0ftno9RVM7Y3OPoU2itihaW2KO0QnNOI0brEapB_8hJP-FZnUkif/test
(The line where things fail is
Line 258 in 12ce6eb
| testing.expectError(error.IsDir, tmp_dir.dir.readFileAlloc(testing.allocator, test_dir_name, std.math.maxInt(usize))); |
-target x86_64-linux-none or -target x86_64-linux-gnu or -target x86_64-linux-musl doesn't change the behavior.)
From what gdb debugging I could manage, the issue seems to be that Linux openat() on a directory only returns EISDIR if a write action is requested, not for read-only. (See https://man7.org/linux/man-pages/man2/openat.2.html, which says that EISDIR is returned if "pathname refers to a directory and the access requested involved writing (that is, O_WRONLY or O_RDWR is set).") And reading that directory file descriptor then results in a zero-length 'file'. So this test seems wrong?
However, on the other hand, I see the Linux pull request builds having nice success output lines like
2020-09-02T01:21:53.0021801Z 631/1506 fs.test.test "std-x86_64-linux-none-Debug-bare-multi file operations on directories"...OK