1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00
Commit graph

31 commits

Author SHA1 Message Date
Etienne Cordonnier
35634b46a0 stdbuf: fix cross-compilation
Summary:

Partial fix for https://github.com/uutils/coreutils/issues/6591

The current code declare libstdbuf as a build-dependency of stdbuf as a
workaround to enforce that libstdbuf is compiled before stdbuf. This breaks
cross-compilation, because build-dependencies were compiled for the host
architecture, and not for the target architecture.

The reason this workaround is necessary is that bindeps is available only in nightly at the moment:
https://rust-lang.github.io/rfcs/3028-cargo-binary-dependencies.html

This commit replaces the "build-dependency" workaround with another workaround:
calling cargo manually to build libstdbuf in the build.rs of stdbuf, in order to ensure that libstdbuf is built before stdbuf.

Changes:

- Removed cpp/cpp_build dependencies:

The cpp, cpp_build, and related dependencies were removed because they made cross-compilation in a build.rs file very complex, since you need
to pass proper CXX env variables for cross-compilation, whereas cross-compiling rust code using cargo is quite simple.
Provided Rust implementations for getting stdin, stdout, and stderr pointers.
Switched from C++/cpp macro-based initialization to using the Rust ctor crate for library initialization.

- Remove "feat_require_crate_cpp" which is not needed any more, since stdbuf was the only utility using the cpp crate.

Tests:

This commit fixes e.g. this test:
cross test --target aarch64-unknown-linux-gnu --features stdbuf test_stdbuf::test_libstdbuf_preload -- --nocapture

- The "i686" build of stdbuf was also broken (stdbuf 32 bits, but libstdbuf 64 bits) and test_stdbuf::test_libstdbuf_preload of the i686 builds in github CI serves as regression
test for this issue, no need to add a cross-rs test for aarch64.
- The x86_64 musl build of stdbuf was also broken and was passing tests in CI only because it was compiled with the wrong libc (glibc instead of musl)

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2025-06-02 10:55:57 +02:00
Etienne Cordonnier
2e8b6fabcc stdbuf: add test_libstdbuf_preload
This test verifies that libstdbuf correctly gets preloaded, and that there are no architecture mismatch errors.
At the moment the test passes when compiled normally, but fails when compiled with cross-rs, due to https://github.com/uutils/coreutils/issues/6591

This passes:
```
cargo test --features stdbuf test_stdbuf::test_libstdbuf_preload -- --nocapture
```

This fails:
```
cross test --target aarch64-unknown-linux-gnu --features stdbuf test_stdbuf::test_libstdbuf_preload -- --nocapture
```

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
2025-06-02 10:52:32 +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
Sylvestre Ledru
04d4c9e1ef stdbuf: better handling when non existing files
Should fix tests/misc/stdbuf
2025-01-08 00:13:31 +01:00
Sylvestre Ledru
79645d45ce stdbuf: better handling of the error message when no perm
Tested in tests/misc/stdbuf
2025-01-08 00:13:31 +01:00
Sylvestre Ledru
001b97f445 adjust error for runcon & stdbuf to make tests/misc/invalid-opt.pl pass 2024-08-20 22:28:16 +02:00
Laurent Cheylus
c96e639f2f
tests: disable failed tests for stdbuf on OpenBSD
Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-07-06 22:29:19 +02:00
Daniel Hofstetter
a816960c33 tests: remove 'target_pointer_width = "128"' 2024-05-20 23:27:53 +02:00
clara swanson
58087df02a
stdbuf: remove crash macro (#5549)
* stdbuf: remove crash! macro

* stdbuf: change target_vendor back to apple

* tests/stdbuf: change stderr_only to usage_error in test_stdbuf_invalid_mode_fails

* stdbuf: add exit code to check_option

* stdbuf: remove set_exit_code line from error
2023-11-20 10:16:18 +01:00
zhitkoff
7038657a44 implement R and Q prefixes 2023-10-17 10:50:50 -04:00
Sylvestre Ledru
bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Daniel Hofstetter
3eeb5dda30 tests: adapt to clap's modified error messages 2023-03-09 10:06:20 +01:00
Joining7943
1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00
Terts Diepraam
b6a4f32889 stdbuf: update to clap 4 2022-10-13 17:50:40 +02:00
Omer Tuchfeld
0ce22f3a08 Improve coverage / error messages from parse_size PR
https://github.com/uutils/coreutils/pull/3084 (2a333ab391) had some
missing coverage and was merged before I had a chance to fix it.

This PR adds some coverage / improved error messages that were missing
from that previous PR.
2022-02-22 22:09:45 +01:00
Terts Diepraam
0fca4460de stdbuf: clap 3 2022-01-11 19:16:48 +01:00
Thomas Queiroz
c9624725ab
tests: use CmdResult::usage_error 2021-11-09 17:37:05 -03:00
Michael Debertol
5f2335829a refactor ~ revert to single quotes for "Try '{0 --help'"
This is a test expectation for gnu.
2021-08-14 17:22:09 +02:00
Roy Ivy III
4da46d93c7 tests ~ fix tests for new execution_phrase!() and usage phrasing 2021-08-14 14:01:34 +02:00
Jan Scheer
c0be979611 fix some issues with locale (replace "LANGUAGE" with "LC_ALL")
`LANGUAGE=C` is not enough, `LC_ALL=C` is needed as the environment
variable that overrides all the other localization settings.

e.g.
```bash
$ LANGUAGE=C id foobar
id: ‘foobar’: no such user

$ LC_ALL=C id foobar
id: 'foobar': no such user
```

* replace `LANGUAGE` with `LC_ALL` as environment variable in the tests
* fix the the date string of affected uutils
* replace `‘` and `’` with `'`
2021-06-23 11:30:28 +02:00
Jan Scheer
db3ee61742 du/sort/od/stdbuf: make error handling of SIZE/BYTES/MODE arguments more consistent
* od: add stderr info for not yet implemented '--strings' flag
2021-06-03 21:00:03 +02:00
Jan Scheer
1c41efd732 stdbuf: use "parse_size" from uucore 2021-05-31 09:35:46 +02:00
Yağız can Değirmenci
8fe34c72d2 test: fix tests 2021-05-26 03:07:49 +03:00
Yağız can Değirmenci
071899d24d tests: delete 'error:' prefix from the tests 2021-05-26 02:45:53 +03:00
Sylvestre Ledru
4aaeede3d8 rustfmt the recent change 2021-05-23 00:13:53 +02:00
joppich
f33320e581
do not pipe data into failure tests (#2072)
Co-authored-by: joppich <joppich@bricknet.de>
2021-04-17 10:07:45 +02:00
joppich
c54b5f2d82 stdbuf: move from getopts to clap 2021-04-10 00:39:12 +02:00
Roy Ivy III
de0375f909 tests ~ reorganize tests 2020-06-01 18:30:04 -05:00
Renamed from tests/test_stdbuf.rs (Browse further)