Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checksum: prepare further behavior fix with a rework #6822

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RenjiSann
Copy link
Contributor

Now that #6782, #6793 and #6815 have landed, it is time to achieve the rework of checksum.rs started in #6654.

This will allow us to fix #6572, #6614 and #6653.

This PR mainly tries to split the massive perform_checksum_verification in smaller functions, and to get rid of the &mut ChecksumResult that is passed everywhere, which makes it very difficult to understand where the global state of the program is modified.

Also, it adds ignored tests for future features (it will prevent too many conflicts when rebasing future PRs on each other).

Next PRs will focus on reworking the algorithm detection behavior, in particular for blake2b size guessing,
Regex detection behavior which for now prevents us from encountering both hexa and base64 digits in the same file.

@RenjiSann
Copy link
Contributor Author

Depending on the feedback on this discussion, I might split the checksum.rs file into several files (a bit like the initial PR #6654).
I'd like to move Error structs to checksum/error.rs, everything that's Algorithm-related to checksum/algo.rs, etc...

What do you think ?

@cakebaker
Copy link
Contributor

I'd like to move Error structs to checksum/error.rs, everything that's Algorithm-related to checksum/algo.rs, etc...

What do you think ?

It sounds good to me.

@RenjiSann RenjiSann force-pushed the cksum-big-rework branch 2 times, most recently from 7898120 to aa5f0c0 Compare October 25, 2024 12:48
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@RenjiSann RenjiSann force-pushed the cksum-big-rework branch 2 times, most recently from 734dd51 to 9854090 Compare October 25, 2024 15:17
@RenjiSann
Copy link
Contributor Author

I've finally decided to keep the splitting in several files for later, because it's a nightmare to mix changes and file architecture when you have to rebase to keep a sound change history.

@RenjiSann RenjiSann force-pushed the cksum-big-rework branch 2 times, most recently from b33e635 to 0d02461 Compare October 25, 2024 15:38
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@RenjiSann
Copy link
Contributor Author

I'm not sure why the macos test failed. Is it just flakey or have I touched something ?

@sylvestre
Copy link
Contributor

flaky:

---- test_stat::test_stdin_pipe_fifo1 stdout ----
run: /Users/runner/work/coreutils/coreutils/target/aarch64-apple-darwin/debug/coreutils stat -
run: /Users/runner/work/coreutils/coreutils/target/aarch64-apple-darwin/debug/coreutils stat -L -
thread 'test_stat::test_stdin_pipe_fifo1' panicked at ''  File: -
  Size: 0         	Blocks: 0          IO Block: 512    weird file
Device: 4ef1bb9ch/1324465052d	Inode: 500453238   Links: 0
Access: (0660/?rw-rw----)  Uid: (  501/  runner)   Gid: (   20/   staff)
Access: 2024-10-25 15:48:53.191317902 +0000
Modify: 2024-10-25 15:48:53.191317902 +0000
Change: 2024-10-25 15:48:53.191317902 +0000
 Birth: 1970-01-01 00:00:00.000000000 +0000
' does not contain 'fifo'', tests/by-util/test_stat.rs:288:10

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@RenjiSann
Copy link
Contributor Author

@cakebaker Both of your comments address the details of implementation I came to when working on it.
If you come up with better alternatives, I'll gladly hear them ^^

res: &mut ChecksumResult,
cli_algo_name: Option<&str>,
cli_algo_length: Option<usize>,
properly_formatted: &mut bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this argument necessary? There's already LineCheckError::ImproperlyFormatted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the way the program currently works, it is complicated to completely get rid of it.
I plan to get rid of it with the following PRs that will be in charge of fixing the tests that are added but ignored by this PR.

You can take a look at my previous, now deprecated, PR #6654, which fixed everything at once, but which was a pain to review.

Copy link
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

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

Overall good job with this refactoring :)

…, LineCheckError>

- Treat digest mismatch as an error
test(cksum): add test for blake length gessing
test(cksum): add test for hexa/base64 confusion
test(cksum): add test for error handling on incorrectly formatted checksum
test(cksum): add test for trailing spaces making a line improperly formatted
test(cksum): Re-implement GNU test 'cksum-base64' in the testsuite
Copy link

github-actions bot commented Nov 3, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

Copy link

github-actions bot commented Nov 3, 2024

GNU testsuite comparison:

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

@RenjiSann RenjiSann mentioned this pull request Nov 6, 2024
@RenjiSann
Copy link
Contributor Author

Up @cakebaker
Once this is done, I will move on and fix the tests I added :)

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.

cksum: gets confused by base64 that happens to consist entirely of hexadecimal digits
3 participants