Commit Graph
36 Commits
Author SHA1 Message Date
07567b1c63 fix: uptime > /dev/full panic fix (#10827)
* fix: uptime > /dev/full panic fix

* style: fmt

* fix: writeln -> write

* uptime: prints replacement

* uptime(test): remove pipe_in from test

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-02-12 02:51:47 -08:00
Chris DrydenandGitHub 2a4573326f Remove wincode and wincode-derive dependencies (#10802) 2026-02-08 11:13:17 +01:00
Daniel Hofstetter f61dd401f0 uptime: fix "unused import" warnings in test file 2026-02-02 11:35:12 +01:00
Ivan-ShamlandGitHub 91edf285b2 uptime: Add -p, --pretty argument (#10143)
* uptime: Add -p, --pretty argument

Rebase of PR https://github.com/uutils/coreutils/pull/7910
All credits go to GitHub User: https://github.com/irbeam256

* Add localization for "up"
2026-01-11 10:20:46 +01:00
Sylvestre Ledru 63d3c9a83b replace bincode by wincode 2026-01-08 23:42:07 +01:00
Cả thế giới là RustandGitHub 3e71f638bc Fix uptime on macOS using sysctl kern.boottime fallback (#8908)
* fix(uucore): use sysctl kern.boottime on macOS as fallback for uptime

If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., #3621).

Context (blame/history):

- 2774274cc2 ("uptime: Support files in uptime (#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs).

- 920d29f703 ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths.

* test: add comprehensive macOS tests for sysctl kern.boottime fallback

Add unit tests for sysctl boottime availability and get_uptime reliability on macOS, verifying the fallback mechanism works correctly when utmpx BOOT_TIME is unavailable.

Add integration tests to ensure uptime command consistently succeeds on macOS with various flags (default, --since) and produces properly formatted output.

Enhance documentation of the sysctl fallback code with detailed comments explaining why it exists, the issue it addresses (#3621), and comprehensive SAFETY comments for the unsafe sysctl call.

All tests are properly gated with #[cfg(target_os = "macos")] to ensure they only run on macOS and don't interfere with other platforms.

* refactor(uucore): replace unsafe sysctl with safe command-line approach for macOS boot time

- Remove unsafe libc::sysctl() system call entirely
- Replace with safe std::process::Command executing 'sysctl -n kern.boottime'
- Parse sysctl output format to extract boot time seconds
- Maintains same API and functionality while eliminating unsafe blocks
- Addresses reviewer feedback to completely remove unsafe code
2025-12-26 01:11:37 +01:00
Laurent CheylusandGitHub ad1bac4c92 Fix build and tests for uptime on OpenBSD (#9158)
* uptime: fix build errors on OpenBSD

Signed-off-by: Laurent Cheylus <foxy@free.fr>

* tests: fix error for uptime on OpenBSD

Signed-off-by: Laurent Cheylus <foxy@free.fr>

---------

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2025-11-07 19:07:15 +01:00
Dorian Peron 6e23d4e979 tests: patch tests to simplify imports 2025-07-01 03:36:46 +02:00
Daniel Hofstetter 3904d5b614 uptime: move imports into test function
to simplify the cfg handling
2025-06-03 16:12:52 +02:00
Daniel Hofstetter b78f78bedf uptime: use clap to handle too many path args 2025-05-06 16:05:23 +02:00
Daniel HofstetterandSylvestre Ledru ed0492a046 uptime: fix "unused import" warnings with musl 2025-05-02 09:09:57 +02:00
Terts DiepraamandGitHub d99b7b31a6 Merge pull request #7740 from Ecordonnier/eco/enable-utmpx-for-musl
enable utmpx feature for musl
2025-04-17 22:46:23 +02:00
Daniel Hofstetter 8590f51f85 uptime: adapt test to API changes in bincode 2025-04-16 11:02:52 +02:00
Etienne Cordonnier 0354f1f84d disable failing uptime test for musl
musl libc only provides stub functions for utmpx, thus this test cannot pass with musl libc.

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2025-04-15 12:51:55 +02:00
Daniel Hofstetter 7b6d05f81d uptime: fix "unused import" warning in test 2025-04-01 09:21:38 +02:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Daniel Hofstetter df4dfea852 tests: replace run() with succeeds() or fails() 2025-03-09 16:53:56 +01:00
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00
Daniel Hofstetter 90208096fd uptime: remove duplicate test 2025-02-04 09:24:32 +01:00
Sylvestre Ledru d66932f593 issues: 7158, 7159 and 7174 - ignore linux arm64 specific test 2025-01-20 08:13:35 +01:00
Ben Wiederhake 6818bbe5d7 uptime: relax error message due to different errno on MacOS
Fixes #6569.
2024-07-15 21:49:42 +02:00
Sylvestre LedruandGitHub 96fa8e9480 Merge pull request #6514 from lcheylus/openbsd-uptime
uptime: add support for OpenBSD using utmp
2024-06-30 21:27:48 +02:00
n4n5 ab67947321 fix clippy tests 2024-06-30 16:27:08 +02:00
Laurent Cheylus c0a3662b63 tests: enable tests for uptime on OpenBSD
Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-06-30 16:17:04 +02:00
Anirban HalderandGitHub 2774274cc2 `uptime`: Support files in uptime (#6400) 2024-06-22 13:06:03 +02:00