@@ -1569,35 +1569,68 @@ fn test_check_mix_hex_base64() {
15691569 . stdout_only ( "foo1.dat: OK\n foo2.dat: OK\n " ) ;
15701570}
15711571
1572- #[ ignore = "not yet implemented" ]
1572+ /// This test ensures that an improperly formatted base64 checksum in a file
1573+ /// does not interrupt the processing of next lines.
15731574#[ test]
1574- fn test_check_incorrectly_formatted_checksum_does_not_stop_processing ( ) {
1575- // The first line contains an incorrectly formatted checksum that can't be
1576- // correctly decoded. This must not prevent the program from looking at the
1577- // rest of the file.
1578- let lines = [
1579- "BLAKE2b-56 (foo1) = GFYEQ7HhAw=" , // Should be 2 '=' at the end
1580- "BLAKE2b-56 (foo2) = 18560443b1e103" , // OK
1581- ] ;
1575+ fn test_check_incorrectly_formatted_checksum_keeps_processing_b64 ( ) {
1576+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
1577+ let at = & scene. fixtures ;
1578+ at. touch ( "f" ) ;
1579+
1580+ let good_ck = "MD5 (f) = 1B2M2Y8AsgTpgAmY7PhCfg==" ; // OK
1581+ let bad_ck = "MD5 (f) = 1B2M2Y8AsgTpgAmY7PhCfg=" ; // Missing last '='
1582+
1583+ // Good then Bad
1584+ scene
1585+ . ucmd ( )
1586+ . arg ( "--check" )
1587+ . pipe_in ( [ good_ck, bad_ck] . join ( "\n " ) . as_bytes ( ) . to_vec ( ) )
1588+ . succeeds ( )
1589+ . stdout_contains ( "f: OK" )
1590+ . stderr_contains ( "cksum: WARNING: 1 line is improperly formatted" ) ;
1591+
1592+ // Bad then Good
1593+ scene
1594+ . ucmd ( )
1595+ . arg ( "--check" )
1596+ . pipe_in ( [ bad_ck, good_ck] . join ( "\n " ) . as_bytes ( ) . to_vec ( ) )
1597+ . succeeds ( )
1598+ . stdout_contains ( "f: OK" )
1599+ . stderr_contains ( "cksum: WARNING: 1 line is improperly formatted" ) ;
1600+ }
15821601
1602+ /// This test ensures that an improperly formatted hexadecimal checksum in a
1603+ /// file does not interrupt the processing of next lines.
1604+ #[ test]
1605+ fn test_check_incorrectly_formatted_checksum_keeps_processing_hex ( ) {
15831606 let scene = TestScenario :: new ( util_name ! ( ) ) ;
15841607 let at = & scene. fixtures ;
1608+ at. touch ( "f" ) ;
1609+
1610+ let good_ck = "MD5 (f) = d41d8cd98f00b204e9800998ecf8427e" ; // OK
1611+ let bad_ck = "MD5 (f) = d41d8cd98f00b204e9800998ecf8427" ; // Missing last
15851612
1586- at. write ( "foo1" , "foo" ) ;
1587- at. write ( "foo2" , "foo" ) ;
1588- at. write ( "sum" , & lines. join ( "\n " ) ) ;
1613+ // Good then Bad
1614+ scene
1615+ . ucmd ( )
1616+ . arg ( "--check" )
1617+ . pipe_in ( [ good_ck, bad_ck] . join ( "\n " ) . as_bytes ( ) . to_vec ( ) )
1618+ . succeeds ( )
1619+ . stdout_contains ( "f: OK" )
1620+ . stderr_contains ( "cksum: WARNING: 1 line is improperly formatted" ) ;
15891621
1622+ // Bad then Good
15901623 scene
15911624 . ucmd ( )
15921625 . arg ( "--check" )
1593- . arg ( at . subdir . join ( "sum" ) )
1626+ . pipe_in ( [ bad_ck , good_ck ] . join ( "\n " ) . as_bytes ( ) . to_vec ( ) )
15941627 . succeeds ( )
1595- . stderr_contains ( "1 line is improperly formatted ")
1596- . stdout_contains ( "foo2: OK ") ;
1628+ . stdout_contains ( "f: OK ")
1629+ . stderr_contains ( "cksum: WARNING: 1 line is improperly formatted ") ;
15971630}
15981631
15991632/// This module reimplements the cksum-base64.pl GNU test.
1600- mod cksum_base64 {
1633+ mod gnu_cksum_base64 {
16011634 use super :: * ;
16021635 use crate :: common:: util:: log_info;
16031636
0 commit comments