Commit graph

47 commits

Author SHA1 Message Date
Pistonight
ca6d0eda3d hashsum: Windows: check in binary mode by default and allow --binary/--text whcn checking 2024-10-22 11:55:49 -07:00
Dorian Péron
b34730dda3 test(hashsum): add tests for comment in checksum files 2024-10-18 11:58:03 +02:00
Daniel Hofstetter
79d7158aac
Merge pull request #6584 from howjmay/checksum-no-check
hashsum: Return err when only --strict or --quiet is given
2024-07-23 15:20:35 +02:00
Yang Hau
e5d765f46c hashsum: Return err when only --strict or --quiet is given 2024-07-19 16:05:30 +08:00
Ben Wiederhake
471f047a64 clippy: simplify code according to nightly 'byte_char_slices' lint
https://rust-lang.github.io/rust-clippy/master/index.html#/byte_char_slices
2024-07-18 15:59:36 +02:00
Sylvestre Ledru
0ecc18fb5b hashsum/b2sum: when the checksum file is untagged, detect the size
Should fix tests/cksum/b2sum.sh
2024-06-28 10:15:27 +02:00
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
1cf6700023 cksum/hashsum: manage the '*' start correctly 2024-05-29 09:08:04 +02:00
Sylvestre Ledru
84d90fcbdf cksum/hashsum: try to detect the format faster the first line 2024-05-29 09:08:04 +02:00
Sylvestre Ledru
2c83b28d18 hashsum: improve the file verification algo.
We have 3 different kinds of input:
* "algo (filename) = checksum"
  example: `BLAKE2 (a) = bedfbb90d858c2d67b7ee8f7523be3d3b54004ef9e4f02f2ad79a1d05bfdfe49b81e3c92ebf99b504102b6bf003fa342587f5b3124c205f55204e8c4b4ce7d7c`
* "checksum  filename"
  example: `60b725f10c9c85c70d97880dfe8191b3  a`
* "checksum filename"
  example: `60b725f10c9c85c70d97880dfe8191b3 a`

These algo/regexp are tricky as files can be called "a, " b", " ", or "*c".
We look at the first time to analyze the kind of input and reuse the same regexp then.
2024-05-29 09:08:04 +02:00
Sylvestre Ledru
6acc8e695f hashsum: Implement the quiet mode 2024-05-29 09:08:04 +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
09e53f3d2d tests: fix some clippy warnings 2024-05-25 09:06:16 +02:00
Sylvestre Ledru
a9a11f486e hashsum: rename the blake2b algo with --tag + manage the different length 2024-05-18 16:16:26 +02:00
Sylvestre Ledru
dc5342d115 hashsum: allow multiple usage of -l and take the last one
tested by gnu/tests/cksum/b2sum.sh
2024-05-07 20:24:25 +02:00
Sylvestre Ledru
13cfe2d8e5 test: replace at.write by at.touch 2024-04-21 13:23:24 +02:00
Sylvestre Ledru
6ef08d7f1c hashsum: improve the error management to match GNU
Should make tests/cksum/md5sum.pl and tests/cksum/sha1sum.pl pass
2024-04-21 09:08:27 +02:00
Sylvestre Ledru
94f5e82dbd hashsum: ignore empty lines in --check 2024-04-21 09:08:27 +02:00
Sylvestre Ledru
f817018f90 hashsum: --ignore-missing needs -c 2024-04-15 22:19:44 +02:00
Sylvestre Ledru
b977d61f67 hashsum: implement the ignore-missing option
Tested by gnu/tests/cksum/md5sum.pl
2024-04-14 20:05:39 +02:00
Sylvestre Ledru
1725479c06
hashsum: also escape/unescape files with checks (#5868)
* hashsum: make tag conflicts with --text and --check

* hashsum: change the case in one of the gnu test

* build-gnu.sh: use symlink instead of copy

Plus: it won't cp new md5

* hashsum: also escape/unescape files with checks

Should fix tests/cksum/md5sum-bsd.sh

* improve the variable name

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

* Improve test

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

* Improve test

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-03-12 14:56:27 +01:00
Sylvestre Ledru
5e29c60b26 hashsum: when the filename contains some special chars, escape them
Should fix tests/cksum/md5sum-newline.pl
2024-01-20 19:27:45 +01:00
Terts Diepraam
93a54f36f3 hashsum: change debug to display format with --tag 2023-08-29 10:15:38 +02:00
Sylvestre Ledru
bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00
Kamil Ogórek
07434647ad
fix: Correctly detect format when using md5sum with check flag (#4645) 2023-05-27 23:56:15 +02:00
Marras Antoine
756293a9c4 b2sum: added tests to handle 0, non multiple of 8 and and more than 512 cases 2023-04-12 21:05:11 +02:00
Marras Antoine
0798cfe155 b2sum: added test for length option 2023-04-10 20:27:49 +02:00
0xMRTT
e7ef9dcd46
hashsum: add --zero option (#4612) (#4632)
* `hashsum`: add `--zero`  option (#4612)
2023-03-28 23:26:11 +02:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Joining7943
1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00
Terts Diepraam
bbc3495896 hashsum: enable testing --no-names
Co-authored-by: Huijeong Kim <herehuijeong@gmail.com>
2022-10-26 11:10:26 +02:00
Sylvestre Ledru
52d82d54a3 Revert "hashsum: test b3sum::test_nonames for real (#4027)"
This reverts commit 02f6fa7b24.
2022-10-25 23:44:05 +02:00
Huijeong Kim
02f6fa7b24
hashsum: test b3sum::test_nonames for real (#4027)
* hashsum: test b3sum::test_nonames for real

Signed-off-by: Huijeong Kim <herehuijeong@gmail.com>

* apply cargo format

Signed-off-by: Huijeong Kim <herehuijeong@gmail.com>
2022-10-22 11:23:39 +02:00
Sylvestre Ledru
49c435a25b
ignore a word 2022-10-20 07:46:38 +02:00
David Matos
d46e5df3d3 hashsum: warn on file not found rather than fail 2022-10-19 22:46:47 +02:00
Terts Diepraam
9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00
Sylvestre Ledru
00f5d91886 sha1sum: fix the -c usage (Closes: #3815) 2022-08-14 23:32:46 +02:00
Kai Lüke
e894e40c56
hashsum: add --no-names option from official b3sum tool (#3361)
* hashsum: add --no-names option from official b3sum tool

The official b3sum tool has a --no-names option for only printing the
hashes, omitting the filenames. This is quite handy when used from
scripts because it spares the postprocessing with "cut" or "awk".
Since the installed b3sum symlink would also serve as a drop-in for the
official tool, the --no-names option is expected to exist for
compatibility.

Add a --no-names option not only for b3sum but for hashsum in general
(and maybe GNU coreutils will also feel inspired to add this option).

Closes https://github.com/uutils/coreutils/issues/3360
2022-04-06 09:09:37 +02:00
Shreyans Jain
30d7a4b167
hashsum: Add BLAKE3 to Hashing Algorithms
Signed-off-by: Shreyans Jain <shreyansthebest2007@gmail.com>
2022-02-10 12:46:44 +05:30
Jeffrey Finkelstein
cd5f676903 hashsum: add tests for Windows text mode 2021-09-17 21:24:43 -04:00
jfinkels
bdc0f4b7c3
hashsum: support --check for algorithms with variable output length (#2583)
* hashsum: support --check for var. length outputs

Add the ability for `hashsum --check` to work with algorithms with
variable output length. Previously, the program would terminate with an
error due to constructing an invalid regular expression.

* fixup! hashsum: support --check for var. length outputs
2021-08-23 18:35:19 +02:00
Gilad Naaman
81d42aa2b3 Fix some tests to not use CmdResult fields 2021-04-10 23:30:50 +03:00
Piyush Jaipuriayar
3ca8ba997c
hashsum: added blake2 as a hashing algorithm (#1651) 2020-12-08 23:32:02 +01:00
Roy Ivy III
de0375f909 tests ~ reorganize tests 2020-06-01 18:30:04 -05:00
Renamed from tests/test_hashsum.rs (Browse further)