Skip to content

Conversation

@naoNao89
Copy link
Contributor

This PR implements the --debug flag for cksum, split from the original PR #8948.

What's included:

  • --debug CLI argument with help text
  • Localization for English and French
  • Tests covering single file, multiple files, and algorithm combinations

Implements the --debug flag for the cksum utility. This flag indicates
which implementation is being used for the checksum calculation.

Changes:
- Add DEBUG constant to options module
- Add --debug argument to CLI with help text
- Add help text translations (en-US and fr-FR)
- Add comprehensive tests for --debug flag with various scenarios

The flag is currently a no-op but provides the foundation for future
implementation of debug output functionality.
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 30, 2025

CodSpeed Performance Report

Merging #9088 will not alter performance

Comparing naoNao89:fix-cksum-debug-flag (6328c51) with main (95b266f)

Summary

✅ 125 untouched

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cksum/cksum is no longer failing!

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.

Can you please add a hint to the help text that the debug functionality is not yet implemented? To make it visible to the user that it is a no-op. Otherwise the PR looks good.

Address maintainer feedback to make it clear to users that the --debug
flag is a placeholder and does not currently produce any output.

Changes:
- Update en-US help text to include '(not yet implemented)'
- Update fr-FR help text to include '(pas encore implémenté)'

This follows the pattern used by other utilities (cp, mkdir, split)
for indicating unimplemented features in help text.
@naoNao89
Copy link
Contributor Author

@cakebaker Updated! ✅

Added the clarification to the help text as requested:

English:

--debug    indicate which implementation used (not yet implemented)

French:

--debug    indiquer quelle implémentation est utilisée (pas encore implémenté)

This follows the same pattern used by other utilities in the codebase (cp, mkdir, split) for indicating unimplemented features.

The test still passes:

test test_cksum::test_debug_flag ... ok

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cksum/cksum is no longer failing!

@sylvestre
Copy link
Contributor

Why not implementing it?

@naoNao89 naoNao89 marked this pull request as draft October 30, 2025 11:25
Fully implement the --debug flag for cksum utility to display which
hash algorithm is being used for each file processed.

Changes:
- Add debug field to Options struct
- Create print_debug_info() function to output algorithm information
- Integrate debug output into checksum processing flow
- Update localization strings (en-US and fr-FR) for debug messages
- Remove '(not yet implemented)' disclaimer from help text
- Add comprehensive test coverage for debug flag with various algorithms

The implementation outputs debug information to stderr (matching GNU
cksum behavior) in the format: 'filename: ALGORITHM' or 'standard input:
ALGORITHM' for stdin.

Tests verify debug output works correctly with:
- Default CRC algorithm
- MD5, SHA1, SHA256, BLAKE2b algorithms
- Single files, multiple files, and stdin input
- Custom BLAKE2b lengths

All 135 cksum tests pass with no clippy warnings.
@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)
Congrats! The gnu test tests/cksum/cksum is no longer failing!

@naoNao89 naoNao89 marked this pull request as ready for review October 30, 2025 18:09
Copy link
Contributor

@cakebaker cakebaker Oct 31, 2025

Choose a reason for hiding this comment

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

It looks like you implemented something else, but not the --debug functionality from GNU cksum :|

Here is the output I get on my machine when I manually run the first three tests with GNU cksum 9.8:

$ cksum --debug README.md 
cksum: avx512 support not detected
cksum: avx2 support not detected
cksum: using pclmul hardware support
3970598914 9068 README.md
$ cksum --debug -a md5 README.md 
MD5 (README.md) = 15af838487236a3900e77e6b70e4d2a7
$ printf "test" | cksum --debug
cksum: avx512 support not detected
cksum: avx2 support not detected
cksum: using pclmul hardware support
3076352578 4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean hardware capability detection :v

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.

3 participants