aboutsummaryrefslogtreecommitdiff
path: root/lib/std/posix/test.zig
AgeCommit message (Collapse)Author
2025-10-29std: make signal numbers into an enumAndrew Kelley
fixes start logic for checking whether IO/POLL exist
2025-10-29std.Io.Threaded: implement netListen for WindowsAndrew Kelley
2025-10-29std: fix compilation errors on WindowsAndrew Kelley
2025-10-29std.Io.Threaded: implement dirMake for WASIAndrew Kelley
2025-10-29fix miscellaneous compilation errorsAndrew Kelley
- ILSEQ -> error.BadPathName - implement dirStatPath for WASI
2025-10-29std: updating to std.Io interfaceAndrew Kelley
got the build runner compiling
2025-10-29WIP: hack at std.Io on a planeAndrew Kelley
2025-10-29std.Io.net: implement receiving connectionless messagesAndrew Kelley
2025-10-27remove all Oracle Solaris supportAlex Rønne Petersen
There is no straightforward way for the Zig team to access the Solaris system headers; to do this, one has to create an Oracle account, accept their EULA to download the installer ISO, and finally install it on a machine or VM. We do not have to jump through hoops like this for any other OS that we support, and no one on the team has expressed willingness to do it. As a result, we cannot audit any Solaris contributions to std.c or other similarly sensitive parts of the standard library. The best we would be able to do is assume that Solaris and illumos are 100% compatible with no way to verify that assumption. But at that point, the solaris and illumos OS tags would be functionally identical anyway. For Solaris especially, any contributions that involve APIs introduced after the OS was made closed-source would also be inherently more risky than equivalent contributions for other proprietary OSs due to the case of Google LLC v. Oracle America, Inc., wherein Oracle clearly demonstrated its willingness to pursue legal action against entities that merely copy API declarations. Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in maintenance mode since, presumably to be retired completely sometime in the 2030s. For these reasons, this commit removes all Oracle Solaris support. Anyone who still wishes to use Zig on Solaris can try their luck by simply using illumos instead of solaris in target triples - chances are it'll work. But there will be no effort from the Zig team to support this use case; we recommend that people move to illumos instead.
2025-10-21std.{c,posix}: add getgid and getegidWim de With
2025-10-18tweak tests to avoid timeoutsmlugg
2025-10-16std: disable a few failing tests on hexagonAlex Rønne Petersen
2025-09-22std.posix: remove bogus assert that SIGRTMAX < NSIGalexrp
2025-09-09standalone posix tests for sigactionPat Tullmann
Fixes #24380
2025-09-09standalone posix tests for relative path linkingPat Tullmann
2025-09-09standalone posix test for env varsPat Tullmann
2025-09-09standalone posix test for current working directoryPat Tullmann
2025-09-09posix/test.zig: "sigset_t bits" test fixesPat Tullmann
Re-enable the test. Will trigger #24380 as-is, but follow-on change moes this code over to test/standalone. Make the test a bit easier to debug by stashing the "seen" signal number in the shared `seen_sig` (instead of just incrementing a counter for each hit). And only doing so if the `seen_sig` is zero.
2025-09-09Move some Thread tests out of posix/test.zig into Thread.zigPat Tullmann
These tests aren't (directly) using Posix APIs, so they don't need to be in posix/test.zig. Put them over with the code and tests in Thread.zig. Since the spawn/join test in the posix code was redundant, just dropped that one.
2025-08-30Merge pull request #25077 from ziglang/GenericReaderAndrew Kelley
std.Io: delete GenericReader, AnyReader, FixedBufferStream; and related API breakage
2025-08-30std.posix.test: fix mmap() test to use actual page size instead of 4096Alex Rønne Petersen
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-28std: delete most remaining uses of GenericWriterAndrew Kelley
2025-08-06lib/std/posix/test.zig: don't compare blksize in "fstatat"Pat Tullmann
In trying to reproduce the race in #24380, my system tripped over the stat "blocks" field changing in this test. The value was almost always 8 (effectively 4k) or very infrequently 0 (I saw the 0 from both `fstat` and `fstatat`). I believe the underlying filesystem is free to asynchronously change this value. For example, if it migrates a file between some "inline" or maybe journal storage, and actual on-disk blocks. So it seems plausible that its allowed to change between stat calls. Breaking up the struct comparison this way means we also don't compare any of the padding or "reserved" fields, too. And we can narrow down the s390x-linux work-around.
2025-07-14std.posix: skip flaky testAndrew Kelley
tracked by #24380
2025-07-11Remove numerous things deprecated during the 0.14 release cycleLinus Groh
Basically everything that has a direct replacement or no uses left. Notable omissions: - std.ArrayHashMap: Too much fallout, needs a separate cleanup. - std.debug.runtime_safety: Too much fallout. - std.heap.GeneralPurposeAllocator: Lots of references to it remain, not a simple find and replace as "debug allocator" is not equivalent to "general purpose allocator". - std.io.Reader: Is being reworked at the moment. - std.unicode.utf8Decode(): No replacement, needs a new API first. - Manifest backwards compat options: Removal would break test data used by TestFetchBuilder. - panic handler needs to be a namespace: Many tests still rely on it being a function, needs a separate cleanup.
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-05-29std.posix.test: Fix reserved_signo() for NetBSD.Alex Rønne Petersen
2025-05-11Merge pull request #23810 from alexrp/more-test-targetsAlex Rønne Petersen
2025-05-09std.posix: Add sigrtmin() and sigrtmax()Pat Tullmann
For C code the macros SIGRTMIN and SIGRTMAX provide these values. In practice what looks like a constant is actually provided by a libc call. So the Zig implementations are explicitly function calls. glibc (and Musl) export a run-time minimum "real-time" signal number, based on how many signals are reserved for internal implementation details (generally threading). In practice, on Linux, sigrtmin() is 35 on glibc with the older LinuxThread and 34 with the newer NPTL-based implementation. Musl always returns 35. The maximum "real-time" signal number is NSIG - 1 (64 on most Linux kernels, but 128 on MIPS). When not linking a C Library, Zig can report the full range of "rt" signals (none are reserved by Zig). Fixes #21189
2025-05-08std: Disable `posix.test.test.fchmodat smoke test` on MIPS N32.Alex Rønne Petersen
https://github.com/ziglang/zig/issues/23808
2025-04-30sigset_t: sigemptyset() and sigfillset() are functions that return sigset_tPat Tullmann
By returning an initialized sigset (instead of taking the set as an output parameter), these functions can be used to directly initialize the `mask` parameter of a `Sigaction` instance.
2025-04-30posix: remove empty_sigsetPat Tullmann
When linking a libc, Zig should defer to the C library for sigset operations. The pre-filled constants signal sets (empty_sigset, filled_sigset) are not compatible with C library initialization, so remove them and use the runtime `sigemptyset` and `sigfillset` methods to initialize any sigset.
2025-04-30posix.zig: export sigset_t and matching operations from systemPat Tullmann
Unify the C library sigset_t and Linux native sigset_t and the accessor operations. Add tests that the various sigset_t operations are working. And clean up existing tests a bit.
2025-04-11std.posix.getenv: early-return comparison (#23265)g-logunov
Fixes std.posix.getenv() being slower than musl getenv() even when linking libc
2025-04-07std: Disable usage of fstat() and friends on loongarch.Alex Rønne Petersen
Like riscv32, loongarch exclusively uses statx().
2025-04-04std: Disable `link with relative paths` and `linkat with different ↵Alex Rønne Petersen
directories` tests for mips64(el). These started failing with LLVM 20 for unclear reasons: test-std └─ run test std-mips64-linux.4.19...6.13.4-gnuabi64.2.28-mips64r2-Debug-libc 2798/2878 passed, 2 failed, 78 skipped error: 'posix.test.test.link with relative paths' failed: expected 2, found 0 /home/alexrp/Source/ziglang/zig-llvm20/lib/std/testing.zig:103:17: 0x1d9e5bf in expectEqualInner__anon_47031 (test) return error.TestExpectedEqual; ^ /home/alexrp/Source/ziglang/zig-llvm20/lib/std/posix/test.zig:311:9: 0x3650f57 in test.link with relative paths (test) try testing.expectEqual(@as(@TypeOf(nstat.nlink), 2), nstat.nlink); ^ error: 'posix.test.test.linkat with different directories' failed: expected 2, found 0 /home/alexrp/Source/ziglang/zig-llvm20/lib/std/testing.zig:103:17: 0x1d9e5bf in expectEqualInner__anon_47031 (test) return error.TestExpectedEqual; ^ /home/alexrp/Source/ziglang/zig-llvm20/lib/std/posix/test.zig:355:9: 0x3653377 in test.linkat with different directories (test) try testing.expectEqual(@as(@TypeOf(nstat.nlink), 2), nstat.nlink); ^ error: while executing test 'zig.system.darwin.macos.test.detect', the following test command failed: qemu-mips64 -L /opt/glibc/mips64-linux-gnu-n64 /home/alexrp/Source/ziglang/zig-llvm20/.zig-cache/o/22a8c3762ea56ae3a674fa9ad15f6657/test --seed=0xa1dbb43c --cache-dir=/home/alexrp/Source/ziglang/zig-llvm20/.zig-cache --listen=- test-std └─ run test std-mips64-linux.4.19...6.13.4-gnuabi64.2.28-mips64r2-Debug-libc 2798/2878 passed, 1 failed, 79 skipped error: 'posix.test.test.linkat with different directories' failed: expected 2, found 0 /home/alexrp/Source/ziglang/zig-llvm20/lib/std/testing.zig:103:17: 0x1d9e22f in expectEqualInner__anon_47031 (test) return error.TestExpectedEqual; ^ /home/alexrp/Source/ziglang/zig-llvm20/lib/std/posix/test.zig:356:9: 0x3650b47 in test.linkat with different directories (test) try testing.expectEqual(@as(@TypeOf(nstat.nlink), 2), nstat.nlink); ^ error: while executing test 'zig.system.darwin.macos.test.detect', the following test command failed: qemu-mips64 -L /opt/glibc/mips64-linux-gnu-n64 /home/alexrp/Source/ziglang/zig-llvm20/.zig-cache/o/22a8c3762ea56ae3a674fa9ad15f6657/test --seed=0xa1dbb43c --cache-dir=/home/alexrp/Source/ziglang/zig-llvm20/.zig-cache --listen=- Unfortunately, neither GDB nor LLDB want to play nice with qemu-mips64(el) at the moment, so I can't easily debug these failures.
2025-03-27std.posix: add getuid()/geteuid()blurrycat
2025-03-09std/lib: {fs,io,posix} test clean upPat Tullmann
* use `tmp.dir.realpathAlloc()` to get full path into tmpDir instances * use `testing.allocator` where that simplifies things (vs. manual ArenaAllocator for 1 or 2 allocs) * Trust `TmpDir.cleanup()` to clean up contained files and sub-trees * Remove some unnecessary absolute paths (enabling WASI to run the tests) * Drop some no-longer necessary `[_][]const u8` casts * Add scopes to reduce `var` usage in favor of `const`
2025-02-20lib/std/posix/test.zig: enable disabled tests using CWDPat Tullmann
Four tests in lib/std/posix/test.zig were disabled because they created fixed-name files in the current working directory, and this caused problems if tests were running in parallel with other build's tests. This PR fixes those tests to all use `std.testing.tmpDir` to create unique temporary names and directories. Also clean the tests up to more consistently use `defer` to clean up, or to just rely on tmpDir cleanup to remove individual files. Working on these tests revealed a bunch of stale WASI code paths in posix.zig, fixed by replacing stale `wast.AT.FDCWD` references with just `AT.FDCWD`. Fixes #14968.
2025-02-09wasi: fix wasm-wasi-musl constantsPat Tullmann
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was wrong, as were the `IFIFO` and `IFSOCK` file type flags. Fix these up, and add comments pointing to exactly where they come from (as the wasi-musl source has lots of unused, different definitions of these constants). Add tests for the Zig convention that WASM preopen 3 is the current working directory. This is true for WASM with or without libc. Enable several fs and posix tests that are now passing (not necessarily because of this change) on wasm targets. Fixes #20890.
2025-01-16x86_64: implement switch jump tablesJacob Young
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
2024-10-04std.posix: Skip Stat struct comparison in fstatat test for s390x-linux.Alex Rønne Petersen
On s390x-linux, fstat() does not have nanosecond precision, but fstatat() does. As a result, comparing Stat structs returned from these syscalls is doomed to fail.
2024-09-06std.posix: Skip a couple of tests that use fstat()/fstatat() on riscv32.Alex Rønne Petersen
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-07POSIX link() syscall only takes two arguments (no flags)Pat Tullmann
The signature is documented as: int link(const char *, const char *); (see https://man7.org/linux/man-pages/man2/link.2.html or https://man.netbsd.org/link.2) And its not some Linux extension, the [syscall implementation](https://github.com/torvalds/linux/blob/21b136cc63d2a9ddd60d4699552b69c214b32964/fs/namei.c#L4794-L4797) only expects two arguments too. It probably *should* have a flags parameter, but its too late now. I am a bit surprised that linking glibc or musl against code that invokes a 'link' with three parameters doesn't fail (at least, I couldn't get any local test cases to trigger a compile or link error). The test case in std/posix/test.zig is currently disabled, but if I manually enable it, it works with this change.
2024-07-29std: Stop supporting Linux/glibc versions older than declared in std.Target.Alex Rønne Petersen
2024-07-28Merge pull request #20297 from sno2/wtf8-conversion-buffer-overflowsAndrew Kelley
std: fix buffer overflows from improper WTF encoding
2024-07-21std.posix: Consider invalid signal numbers to sigaction() to be programmer ↵Alex Rønne Petersen
error. The set of signals that cannot have their action changed is documented in POSIX, and any additional, non-standard signals are documented by the specific OS. I see no valid reason why EINVAL should be considered an unpredictable error here.