Commit Graph

573 Commits

Author SHA1 Message Date
Wildan M fc2937b648 Correct out strcpy expected output 2025-12-19 17:15:28 +07:00
Wildan M f6fa58bbbc Fix NATIVE_RELIBC=0 2025-12-18 12:26:34 +07:00
Wildan M 42d5369d41 Make test runner hang proof 2025-12-18 10:16:08 +07:00
Wildan M fb01e89508 Adjust test sleeps 2025-12-18 10:13:40 +07:00
Wildan M d902941b14 Use dynamic link for tests 2025-12-18 07:52:26 +07:00
auronandace c2da2a8e47 fix expected output of strcpy test 2025-12-15 08:28:25 +00:00
Wildan M 31797971bc Write unified test script and make test readable 2025-12-10 23:28:57 +07:00
Anhad Singh 843f3f89ff fix(tests/Makefile): use correct dynamic linker path depending on target 2025-12-09 15:02:34 +11:00
Anhad Singh 396a0d20bf fix(build): target specific sysroot directory 2025-12-09 14:13:09 +11:00
Anhad Singh 2575639212 fix(tests/time): explictly set timezone instead of assuming 2025-12-09 01:18:32 +11:00
Josh Megnauth 4538fdb0c9 Implement timespec_get and timespec_getres
`timespec_get` and `timespec_getres` are both C23 functions. They're
similar to the POSIX functions `clock_gettime` and `clock_getres`, but
both sets of functions define extra, exclusive features. I didn't
implement the extra features yet, partially because Redox doesn't seem
to support them yet either.
2025-12-04 20:38:35 +00:00
Anhad Singh a7d08aa37e fix(tests/getopt_long): c should be an int not a char
`getopt_long` returns an `int` not a `char`. On aarch64 `char` is
unsigned but on x86 is signed. This is why it had worked so far without
any issues.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-01 14:55:00 +11:00
Jeremy Soller 8ad1d3c110 Merge branch 'fix-netdb-test' into 'master'
Move netdb to varied output test

See merge request redox-os/relibc!766
2025-11-29 06:44:56 -07:00
Wildan M 7e48f2d2fc Move netdb to varied output test 2025-11-28 19:08:32 -08:00
Josh Megnauth 8e5937ca25 Implement posix_fallocate
`posix_fallocate` ensures that a byte range in a file is allocated so
that subsequent writes don't fail. Unlike ftruncate, posix_fallocate
does not shrink files.

The Linux syscall fallocate is similar to posix_fallocate except with
far more control over how byte ranges are allocated (e.g. it supports
file holes and other features). This MR doesn't implement fallocate as
it requires syscall and redoxfs support.

Finally, I changed the flags for flock from usize to c_int. That matches
what we have in libc and also avoids some silly, needless type casting.
2025-11-28 19:49:21 -05:00
Wildan M 8e16c9c80c Fix getsubopt and add test 2025-11-28 06:59:51 -08:00
Josh Megnauth f5d432644f Implement renameat, renameat2
Like the other "at" functions, renameat renames files with respect with
a directory descriptor. "renameat2" is Linux specific but really nice -
it adds a flag which supports atomically swapping two files or failing
if the target already exists. The latter is easily supported in relibc.
The former requires redoxfs support.

Besides the impl itself, I refactored "cap_path_at" into what it really
is: a mini openat2-like function.
2025-10-21 14:47:39 -04:00
Wildan M 1712290deb Define posix_dent for posix_getdents 2025-10-12 20:25:37 +07:00
Wildan M a118d5659b Implement reading memory 2025-10-09 13:15:05 +07:00
Jeremy Soller 82084440ad Support nightly-2025-10-03 2025-10-03 21:51:10 -06:00
Wildan Mubarok 7416ba6ff3 Implement posix_getdents 2025-09-23 10:57:13 -06:00
Josh Megnauth 85c5e889fb Implement fchmodat
Capability based `fchmod`. I also implemented unit tests for chmod,
fchmod, and fchmodat.

The unit tests check Redox-specific behavior, so some of the tests are
disabled for Linux.
2025-09-21 10:04:11 -04:00
Josh Megnauth c555503a35 Implement readlinkat
Like readlink except capability based. Most of this patch is refactoring
fstatat into a reusable, openat-like private function.
2025-09-18 01:27:55 +00:00
Josh Megnauth c6a9a165ec Implement fdopendir and fdclosedir
`fdopendir` takes ownership of a directory file descriptor instead of
opening one with a path. `fdclosedir` is a FreeBSD extension that
transfers ownership of the file descriptor in DIR to the user.
2025-09-17 08:24:48 -04:00
Wildan Mubarok 94fbdd5159 Fix grp implementation 2025-09-15 21:14:53 +00:00
Jeremy Soller fdb7532a67 Merge branch 'null_getaddrinfo' into 'master'
Implement getaddrinfo NULL nodename, AI_PASSIVE, AI_NUMERICHOST

Closes #223

See merge request redox-os/relibc!710
2025-09-15 06:47:27 -06:00
Wildan M 726a0fb1a8 Implement getaddrinfo NULL nodename, AI_PASSIVE, AI_NUMERICHOST 2025-09-15 15:10:50 +07:00
Josh Megnauth 28901b1b62 Impl AT_SYMLINK_NOFOLLOW and AT_EMPTY_PATH
AT_SYMLINK_NOFOLLOW acts on the symlink itself rather than following it.

AT_EMPTY_PATH acts on the directory if path is empty.

Currently, this is implemented in fstatat itself but the code is general
enough to be refactored once we get the other *at functions. It could
likely just live in openat itself.
2025-09-15 06:12:10 +00:00
Wildan M d527cf455f Implement reading CPU count 2025-09-14 18:45:38 +07:00
Josh Megnauth 55c2e5b8ea Fix renaming broken symbolic link
Closes: #212

The fix is simply to not follow links when opening a file to be renamed.
O_NOFOLLOW, a non-POSIX extension, does exactly that while not needing
renameat or openat.
2025-09-07 07:44:10 -04:00
Josh Megnauth 639e0f2cd7 Add lstat test 2025-09-05 23:59:36 -04:00
Josh Megnauth c899feb774 Implement fstatat
Linux's variant uses the syscall as intended. Redox's variant uses fpath
to build a path to pass to fstat from the file descriptor plus the file
name. Unlike the syscall, this isn't atomic so the liminal space between
fpath/getcwd and fstat is subject to TOCTOU.

Beyond fstatat, I moved the stat test to its correct location and added
an assert since the output of the test is unchecked.

I also added AT_FDCWD which seems to be -100 across Unixes. The other
AT_* constants are unimplemented for now.
2025-08-27 08:21:41 -04:00
Josh Megnauth 9d2f5d95dc Implement confstr (unistd.h)
The implementation for confstr is straightforward. Most of the constants
return 1 on both musl and glibc. The only constant that doesn't is
required for Fish.

I also switched an #[unsafe(no_mangle)] from my last patch back
to a #[no_mangle] because we need to bump cbindgen. #[unsafe(no_mangle)]
is required for Rust 2024.
2025-08-22 22:13:51 -04:00
Josh Megnauth d14ae1c148 Switch resource.h enum to c_int instead of u64
Most platforms use a c_int though glibc uses a u32. GNU defines a type,
__rlimit_resource_t, for the RLIMIT enum that is a u32.

Using a c_int is nicer for a few reasons. The first is that our
(unimplemented) functions receive a c_int for the enum - using a u32 is
technically wrong but doesn't affect anything since the constants are
turned into macros by cbindgen.

The second reason is that a c_int is nicer for libc and nix (the crate)
too since we don't need to pollute the crates with guards for Redox.
2025-08-16 23:52:03 -04:00
Josh Megnauth c3c9e3f619 Add termios constant for VDISABLE
_POSIX_VDISABLE is an extension that disables terminal special
characters.

See:
* redox-os/termios!3
* redox-os/base!27
2025-08-14 01:57:24 -04:00
Jeremy Soller 551c79c526 Merge branch 'redoxer-test' into 'master'
Enable some tests in Redox

See merge request redox-os/relibc!685
2025-08-11 14:11:16 -06:00
Darley Barreto b0aac4e8f6 Enable some tests in Redox 2025-08-11 14:11:15 -06:00
Jeremy Soller a57dbfb13f Merge branch 'test-statvfs' into 'master'
Add basic test for statvfs

See merge request redox-os/relibc!683
2025-08-11 14:10:31 -06:00
Wildan M b3b806cafd Simplify test code 2025-08-07 08:46:54 +07:00
Wildan M c7405e09bd Add statvfs tests to Makefile 2025-08-07 07:35:40 +07:00
Wildan M 0248aab7d4 Add basic test for statvfs 2025-08-07 07:19:56 +07:00
Josh Megnauth 728fb55203 Add %m to printf & fix CI
%m is a format specifier that prints an error string for errno. The
specifier is technically only for syslog, but musl and glibc implement
it for printf itself. Parsing for a single specifier in a single
function is error prone, especially when syslog itself is variadic.
2025-08-06 02:38:47 -04:00
Josh Megnauth 292a4b18a9 Move syslog tests to correct location 2025-08-04 22:20:17 -04:00
Ron Williams b7589a63c5 Fixes to improve signals for openposixtestsuite 2025-08-04 07:37:14 -06:00
Josh Megnauth e677ad55d5 Better priorities & LOG_UPTO for syslog.h
* Fix PERROR to match musl/glibc better
* More unit tests + enabled on Linux
* Pack priority and facility into one i32 and check the bits with
  bitflags
* Add LOG_UPTO (logic is straight from musl)

Not done:
* "%m" - this could just be added to printf
* LOG_CONS
2025-08-01 23:45:26 -04:00
Josh Megnauth 64d9847e37 Linux support for syslog.h
Linux's syslog is a local socket, so this uses the recent UDS work.

* Most of redox.rs is refactored into mod.rs now which has all of the C
  facing functions and consts.
* I wrapped the global logger in a Mutex instead of a RwLock. The logger
  is almost always locked for writing so a Mutex is simpler as RwLock
  provides no benefits.
* I implemented LOG_PERROR which also prints errors to stderr as well as
  the log.
* Syslog should be sys/syslog.h with syslog.h as an alias (the
  original code only had syslog.h).
2025-07-24 21:46:49 -04:00
Bendeguz Pisch 4fc80ea7b0 Implement syslog functionality 2025-07-17 22:49:51 -06:00
Josh Megnauth c7da3c2c6b Add disabled test for rename symlink bug
This test should rename disabled until redox-os/relibc#212 is fixed. The
test works on Linux so it should work on Redox eventually too.

The issue is non-trivial because it involves a syscall, frename, that
may need to be redesigned. frename requires a file descriptor, but
opening a file resolves links which in turn fails with broken symlinks.
2025-07-12 21:33:33 -04:00
Ron Williams 770dc71816 Fix CI, Add signal.h constants 2025-07-11 20:28:45 -06:00
Josh Megnauth 1d5179eb71 Const calculate buffer size for strerror
The current buffer size is hard set to 256. Using const evaluation, the
maximum buf size can be calculated at compile time.
2025-07-10 03:18:17 +00:00