Commit graph

56 commits

Author SHA1 Message Date
Sylvestre Ledru
1cbb4d9752 cksum/hashsum: improve the tests and wording 2024-06-03 19:43:20 +02:00
Sylvestre Ledru
773d8cfbc6 cksum/hashsum: fix the windows tests + improve some 2024-06-02 15:46:55 +02:00
Sylvestre Ledru
89b7a1a8fb hashsum: handle the case when md5sum is used but the file contains a different algo 2024-05-29 09:08:04 +02:00
Sylvestre Ledru
0882eea07c cksum/hashsum: factor the error structure and use it more 2024-05-29 09:08:04 +02:00
Sylvestre Ledru
dbe7a20e08 cksum/hashsum: refactor the common code.
Summary of the change:
* Move the common code into checksum
* Create a structure HashAlgorithm to handle the algorithm (instead of the 3 variables)
* Use the same function for cksum & hashsum for --check (perform_checksum_validation)
* Use the same for function for the hash generation (digest_reader)
* Add unit tests
* Add integration tests
* Fix some incorrect tests
2024-05-29 09:08:00 +02:00
Sylvestre Ledru
514d810371 cksum: improve the blake2b detection algo corner case 2024-05-17 22:09:41 +02:00
Sylvestre Ledru
db58d2b6b5 cksum: when length/bits can't be divided by 8, generate an error 2024-05-17 22:08:53 +02:00
Sylvestre Ledru
1b78102a6b cksum: fails in case of unknown algo 2024-05-17 20:21:14 +02:00
Sylvestre Ledru
9c52ca8d55 cksum: also handle the case when the line start with ' \' 2024-05-15 11:46:58 +02:00
Sylvestre Ledru
58c2b5d421 cksum: add failing tests - to be fixed 2024-05-14 23:27:50 +02:00
Sylvestre Ledru
115b203b22 cksum: also show the error on stdout 2024-05-14 23:27:50 +02:00
Sylvestre Ledru
07d579c40a cksum: handle the empty lines (and just spaces) 2024-05-14 23:27:50 +02:00
Sylvestre Ledru
bbd80e4061 cksum: various improvements/fixes 2024-05-14 23:27:47 +02:00
Sylvestre Ledru
843275a136 cksum/blake2b: improve the error management 2024-05-14 23:21:56 +02:00
Sylvestre Ledru
8ddb2131df cksum/blake2b, when length=512, don't add it in the line 2024-05-14 23:21:56 +02:00
Sylvestre Ledru
1aec8b407d chksum: add support of --check --algorithm=xxx 2024-05-14 23:21:56 +02:00
Sylvestre Ledru
81500ae3b8 cksum: implement check & strict 2024-05-12 21:20:58 +02:00
Sylvestre Ledru
eb6f1df3bc cksum: add an ignored test for issue 6375 2024-05-07 20:24:25 +02:00
Sylvestre Ledru
ee2772925a cksum: --tag & --untagged - the order of usage matters. manage it 2024-05-07 20:24:25 +02:00
Sylvestre Ledru
9e080a3684 cksum: handle a corner case 2024-05-07 20:24:25 +02:00
Sylvestre Ledru
234f2f9508 cksum: handle an error like GNU 2024-05-07 20:24:25 +02:00
Sylvestre Ledru
10d8fd6f98 cksum: add binary and prepare the rest 2024-05-07 20:24:25 +02:00
Jadi
4312f3c43e cksum: adding -b as the short form for --base64
closes #5706
2024-04-04 15:09:17 +03:30
Krysztal112233
fd3640482b
lint: fix clippy::unnecessary_to_owned in test_cksum.rs 2024-03-21 23:56:40 +08:00
Krysztal112233
ee09f276a4
lint: fix clippy::useless_format in test_cksum.rs 2024-03-21 23:55:36 +08:00
Ben Wiederhake
133cdde885 cksum: implement and test --base64 output method 2024-03-18 20:59:59 +01:00
Ben Wiederhake
7b219aee63 cksum: implement trivial --tag flag 2024-03-18 20:59:59 +01:00
Ben Wiederhake
edb1eb0a76 cksum: allow repeated flags and arguments 2024-03-18 20:59:59 +01:00
Biplab Mochan Gartia
076b905513
cksum: stops when one of given files doesn't exist #5809 (#5820)
* cksum: stops when one of given files doesn't exist #5809

* removed printld  cksum: stops when one of given files doesn't exist #5809

* formatting the code cksum: stops when one of given files doesn't exist #5809

* formatting the code cksum: stops when one of given files doesn't exist #5809

* set exist status cksum: stops when one of given files doesn't exist #5809

* code quality formatting issue cksum: stops when one of given files doesn't exist #5809

* tertsdiepraam idea cksum: stops when one of given files doesn't exist #5809

* one new test case and deleted duplicate show cksum: stops when one of given files doesn't exist #5809

* formatting the test cases cksum: stops when one of given files doesn't exist #5809

* Revert "formatting the test cases cksum: stops when one of given files doesn't exist #5809"

This reverts commit 8c382f1e8f.

* reverting the changes and committing again due to a mistake cksum: stops when one of given files doesn't exist #5809

---------

Co-authored-by: biplab5464 <biplab5464@outlook.com>
2024-01-15 09:37:56 +01:00
Atomei Alexandru
563df4b79d
Made cksum return an error if used on a directory. (#5822)
* Made cksum to return an error if it is used on a directory regardless of the algorithm

* Added one more test for cksum on folders and deleted an old one that expected it to succeed instead of fail

* Made cksum work on more than one item if it fails and added a test for this case
2024-01-13 14:43:36 +01:00
D9nni
96271ffa3c cksum: added tests for --raw with each algorithm, not working for crc, sysv, bsd 2024-01-09 23:12:40 +02:00
D9nni
28b5224725 cksum: fixed test for --raw on single file 2024-01-08 15:50:25 +02:00
Sylvestre Ledru
d72343bc64
Merge branch 'main' into cksum 2024-01-08 09:02:11 +01:00
D9nni
f03ef79bc8 cksum: added tests for --raw and fixed fmt whitespace error 2024-01-08 08:51:06 +02:00
Atomei Alexandru Constantin
0bfd4bbdf7 Added test to validate that it now generates the error for an arbitrary directory 2024-01-08 00:08:24 +02:00
Vardhan Patil
1fc6a760f3 tests/cksum: fix formatting 2023-12-30 20:31:52 +05:30
Vardhan Patil
e1863ac64e tests/cksum: test when the --length argument is 0 or >512 2023-12-30 20:14:30 +05:30
Vardhan Patil
09ef150085 tests/cksum: add tests for the length argument 2023-12-30 16:01:22 +05:30
Sylvestre Ledru
bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00
Daniel Hofstetter
690fff2fc9 cksum: implement --untagged 2023-05-14 16:43:14 +02:00
Daniel Hofstetter
0781ad0a65 cksum: fix output of --algorithm
for the algorithms md5, sha[1,224,256,384,512], blake2b, and sm3 from

<digest> <filesize> <filename>

to

<algo name> (<filename>) = <digest>

to use the same format as GNU cksum
2023-05-11 14:24:43 +02:00
Daniel Hofstetter
ba6eb392aa cksum: split test function into two 2023-05-10 09:48:32 +02:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Yang Hau
678a11dcf2 cksum: Implement option -a
Implement option -a --algorithm.
Move digest to src/uucore/src/lib/features and rename it to hash.

fix lint

fix Cargo.toml
2023-02-18 20:58:53 +08:00
Terts Diepraam
9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00
Terts Diepraam
7ae9e0a7eb cksum: accept directories as empty files 2021-12-26 21:50:13 +01:00
Jan Verbeek
259f18fcab Update message quoting and filename printing 2021-09-07 19:49:01 +02:00
Roy Ivy III
4e20dedf58 tests ~ refactor/polish spelling (comments, names, and exceptions) 2021-05-31 08:23:57 -05:00
Jan Scheer
3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Yağız can Değirmenci
071899d24d tests: delete 'error:' prefix from the tests 2021-05-26 02:45:53 +03:00