Skip to content

Conversation

@Bluemangoo
Copy link
Collaborator

procps uptime format from procps differs from coreutils'.

for example:

coreutils:

up 00:42

procps v4.0.5:

up 42 min

also see coreutils/7757

ByteSize::b(memory_b).0 as f64 / unit as f64
}

fn format_uptime_procps(up_secs: i64) -> UResult<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for using a procps suffix in the function name (and in get_formated_uptime_procps)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to distinguish it from that of uucore

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I keep it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would keep it. Currently I don't have a better idea. And we can still change it later, if necessary.

}

#[inline]
fn get_formated_uptime_procps() -> UResult<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typo:

Suggested change
fn get_formated_uptime_procps() -> UResult<String> {
fn get_formatted_uptime_procps() -> UResult<String> {

Comment on lines 287 to 299
let test_times = [
1,
10,
60,
100,
200,
3600,
5000,
3600 * 24,
3600 * 24 + 60,
3600 * 24 + 3600,
];
let re = regex::Regex::new(r"(\d+ days?,)?\s*\d+( min|:\d+)").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't use a regex for this test as it also matches invalid results. I think it is simpler to use (input, expected) pairs.

@Bluemangoo
Copy link
Collaborator Author

Bluemangoo commented Apr 26, 2025

Are we planning a common crate for uutils/procps, which is similar to uucore?

I think the uptime formatter are widely used in procps. As the alternative option, I would place it in w, since top requires systemd-dev when build on Linux.

@Bluemangoo Bluemangoo force-pushed the fix/uptime-format branch 2 times, most recently from e7f078e to 377c182 Compare April 26, 2025 15:33
@Bluemangoo Bluemangoo changed the title top: fix uptime format top, w: fix uptime format Apr 26, 2025
@cakebaker
Copy link
Contributor

Are we planning a common crate for uutils/procps, which is similar to uucore?

Yes, I think it would make sense to have such a crate.

@Bluemangoo
Copy link
Collaborator Author

all fixed.

@Bluemangoo Bluemangoo requested a review from cakebaker April 26, 2025 16:20
@cakebaker cakebaker merged commit 6b3a789 into uutils:main Apr 27, 2025
13 checks passed
@cakebaker
Copy link
Contributor

Thanks!

@codecov
Copy link

codecov bot commented Apr 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (389a9f6) to head (f15a629).
Report is 12 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #401   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Bluemangoo Bluemangoo deleted the fix/uptime-format branch July 13, 2025 07:49
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.

2 participants