Skip to content

Conversation

@Alonely0
Copy link
Contributor

This PR fixes #9071, #9072, as well as a few bugs found along the way.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 29, 2025

CodSpeed Performance Report

Merging #9078 will not alter performance

Comparing Alonely0:stat_fix (07ade8b) with main (1eea517)

Summary

✅ 136 untouched
⏩ 24 skipped1

Footnotes

  1. 24 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Alonely0
Copy link
Contributor Author

I mean, that's not my fault lol.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@rlee287
Copy link

rlee287 commented Oct 29, 2025

I think it'd be better to add tests for the device number and the percent escape issues as well.

For the percent escape issue, I propose the following addition to test_stat.rs:

#[test]
fn test_double_percent() {
    let ts = TestScenario::new(util_name!());
    let result = ts.ucmd().args(&["-c", "%%m", "/"]).succeeds();
    let output = result.stdout_str().trim();
    assert!(!output.is_empty(), "Escaped percent should be present");
    assert_eq!(output, "%m");
}

For the device number format issue, I'd add %Hd %Ld %r %R %Hr %Lr to one of NORMAL_FORMAT_STR, DEV_FORMAT_STR, or FS_FORMAT_STR in test_stat.rs, but I'm not familiar enough with the purpose of each of those to suggest which one(s) they should be added to.

@Alonely0
Copy link
Contributor Author

Yeah I agree, I'll add a few tests :). Ngl, I was trying to cut that corner cuz tomorrow I got an exam, but it should be quick enough.

@Alonely0
Copy link
Contributor Author

Testing the value of these flags (%Hd %Ld %r %R %Hr %Lr) is actually correct is quite difficult without bringing in the machine's stat as a reference, because their output is not trivial. Rn, in CI it's probably either GNU or busybox, but knowing Ubuntu's switched to uutils we might as well be testing against an older version of uutils in the future. This is why I'm choosing against including that test, and only one about percent escaping. Maintainers, lmk if you would like me to include it nevertheless (it's already written lol).

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@Alonely0
Copy link
Contributor Author

Alonely0 commented Oct 30, 2025

Those CI fails are still not my fault :) Also, I'll probably be opening a few PRs with perf improvements, passes of clippy nightly, and I'll probably refactor stat's format parser so it's less spaghetti-y; iirc stat is not the only coreutil that does use percent escaping (ls, date, du and printf come to my mind) so I feel strongly like adding a general impl to uu_core or common and refactoring these other coreutils. If you approve, I'll have it done by the end of next week (I'm done w/ my exams on Wednesday :) )

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cksum/b2sum is no longer failing!

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cksum/b2sum is no longer failing!

@sylvestre
Copy link
Contributor

a bunch of jobs are still failing

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cp/cp-mv-enotsup-xattr. tests/cp/cp-mv-enotsup-xattr is passing on 'main'. Maybe you have to rebase?
Note: The gnu test tests/csplit/csplit-io-err was skipped on 'main' but is now failing.

@Alonely0
Copy link
Contributor Author

a bunch of jobs are still failing

Correct me if I'm wrong, but it doesn't seem like any of the CI failures are related to the PR. Previously it was a bunch of cancelled jobs and a couple of network failures on rustup, and now it seems to be just a few unrelated failures? It's weird, because this does not touch uucore or anything that's shared across utils.

@Alonely0
Copy link
Contributor Author

@sylvestre You menace, CI is gonna be busy for hours LOL... (4h and still counting...) /jk

@sylvestre
Copy link
Contributor

@sylvestre You menace, CI is gonna be busy for hours LOL... (4h and still counting...) /jk

Yeah, I rebased almost all pr

@sylvestre
Copy link
Contributor

@sylvestre
Copy link
Contributor

please update mknod.rs also

@Alonely0
Copy link
Contributor Author

please update mknod.rs also

There is also a makedev libc function, so it seems we can just use that.

@Alonely0
Copy link
Contributor Author

I'll get to the FreeBSD shenanigans in a minute, after I'm done writing the extra tests.

@Alonely0 Alonely0 force-pushed the stat_fix branch 2 times, most recently from c8064eb to fca942a Compare December 31, 2025 00:28
@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tty/tty-eof is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/tty/tty-eof is no longer failing!

@Alonely0
Copy link
Contributor Author

Alonely0 commented Dec 31, 2025

It appears that macOS CI has been down for a while lol. There are multiple PRs (including this one) which have stalled jobs for anywhere in between 4 and 15 hours because of this. Is CI self-hosted (and fixable) or are we hostage to GitHub? GitHub Status reports it's all fine... For what it's worth, last time I pushed, macOS ran successfully, and this last push was about Redox support (with conditional compilation for it), so this should be fine to merge.
EDIT: it appears there's a load-bearing macOS runner bearing the weight of the universe on its usb-c dongle.

Fixes issue uutils#9072, where some AppArmor profiles designed for GNU coreutils would break under uutils because we would fetch this info unnecessarily.
Fixes issue uutils#9071, where the default options for the `Device` field where incorrect, as well as several format flags that were not working as intended: %R, %Hr, %Lr, %Hd, %Ld, %t.
Previosuly, stat would ignore the next char after escaping it; e.g., "%%m" would become "%" instead of literally "%m".
Now uucore::fs reexports libc's major(), minor() and makedev() directives.
@Alonely0
Copy link
Contributor Author

It appears we ran into a filesystem race condition with atime and stime on the last runner of all the 11-hour-long CI lol (cries inside)... To avoid this in the future, I've just removed time checks and added a comment; it was naive of us to expect consistent filesystem timing anyway.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?

@Alonely0
Copy link
Contributor Author

Should we add those two failing GNU tests (shuf-reservoir and sort-stale-thread-mem) to the intermittent list? It's not the first time I've seen them spuriously fail here, and it's not like we have touched them on this PR. The sort one smells a lot like a data race or stable sorting shenanigans, and shuf uses rng so it's a whole can of worms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default output format of stat uses incorrect format for Device field

3 participants