@@ -2319,6 +2319,119 @@ mod gnu_cksum_base64 {
23192319 }
23202320}
23212321
2322+ /// This module reimplements the cksum-base64-untagged.sh GNU test.
2323+ mod gnu_cksum_base64_untagged {
2324+ use super :: * ;
2325+
2326+ macro_rules! decl_sha_test {
2327+ ( $id: ident, $algo: literal, $len: expr) => {
2328+ mod $id {
2329+ use super :: * ;
2330+
2331+ #[ test]
2332+ fn check_length_guess( ) {
2333+ let ts = TestScenario :: new( util_name!( ) ) ;
2334+ let at = & ts. fixtures;
2335+
2336+ at. write( "inp" , "test input\n " ) ;
2337+
2338+ let compute = ts
2339+ . ucmd( )
2340+ . arg( "-a" )
2341+ . arg( $algo)
2342+ . arg( "-l" )
2343+ . arg( stringify!( $len) )
2344+ . arg( "--base64" )
2345+ . arg( "--untagged" )
2346+ . arg( "inp" )
2347+ . succeeds( ) ;
2348+
2349+ at. write_bytes( "check" , compute. stdout( ) ) ;
2350+
2351+ ts. ucmd( )
2352+ . arg( "-a" )
2353+ . arg( $algo)
2354+ . arg( "--check" )
2355+ . arg( "check" )
2356+ . succeeds( )
2357+ . stdout_only( "inp: OK\n " ) ;
2358+
2359+ at. write( "check" , " inp" ) ;
2360+
2361+ ts. ucmd( )
2362+ . arg( "-a" )
2363+ . arg( $algo)
2364+ . arg( "check" )
2365+ . fails( )
2366+ . stderr_contains( concat!(
2367+ "--algorithm=" ,
2368+ $algo,
2369+ " requires specifying --length"
2370+ ) ) ;
2371+ }
2372+ }
2373+ } ;
2374+ }
2375+
2376+ decl_sha_test ! ( sha2_224, "sha2" , 224 ) ;
2377+ decl_sha_test ! ( sha2_256, "sha2" , 256 ) ;
2378+ decl_sha_test ! ( sha2_384, "sha2" , 384 ) ;
2379+ decl_sha_test ! ( sha2_512, "sha2" , 512 ) ;
2380+ decl_sha_test ! ( sha3_224, "sha3" , 224 ) ;
2381+ decl_sha_test ! ( sha3_256, "sha3" , 256 ) ;
2382+ decl_sha_test ! ( sha3_384, "sha3" , 384 ) ;
2383+ decl_sha_test ! ( sha3_512, "sha3" , 512 ) ;
2384+
2385+ macro_rules! decl_blake_test {
2386+ ( $id: ident, $len: expr) => {
2387+ mod $id {
2388+ use super :: * ;
2389+
2390+ #[ test]
2391+ fn check_length_guess( ) {
2392+ let ts = TestScenario :: new( util_name!( ) ) ;
2393+ let at = & ts. fixtures;
2394+
2395+ at. write( "inp" , "test input\n " ) ;
2396+
2397+ let compute = ts
2398+ . ucmd( )
2399+ . arg( "-a" )
2400+ . arg( "blake2b" )
2401+ . arg( "-l" )
2402+ . arg( stringify!( $len) )
2403+ . arg( "--base64" )
2404+ . arg( "--untagged" )
2405+ . arg( "inp" )
2406+ . succeeds( ) ;
2407+
2408+ at. write_bytes( "check" , compute. stdout( ) ) ;
2409+
2410+ ts. ucmd( )
2411+ . arg( "-a" )
2412+ . arg( "blake2b" )
2413+ . arg( "--check" )
2414+ . arg( "check" )
2415+ . succeeds( )
2416+ . stdout_only( "inp: OK\n " ) ;
2417+ }
2418+ }
2419+ } ;
2420+ }
2421+
2422+ decl_blake_test ! ( blake2b_8, 8 ) ;
2423+ decl_blake_test ! ( blake2b_216, 216 ) ;
2424+ decl_blake_test ! ( blake2b_224, 224 ) ;
2425+ decl_blake_test ! ( blake2b_232, 232 ) ;
2426+ decl_blake_test ! ( blake2b_248, 248 ) ;
2427+ decl_blake_test ! ( blake2b_256, 256 ) ;
2428+ decl_blake_test ! ( blake2b_264, 264 ) ;
2429+ decl_blake_test ! ( blake2b_376, 376 ) ;
2430+ decl_blake_test ! ( blake2b_384, 384 ) ;
2431+ decl_blake_test ! ( blake2b_392, 392 ) ;
2432+ decl_blake_test ! ( blake2b_504, 504 ) ;
2433+ decl_blake_test ! ( blake2b_512, 512 ) ;
2434+ }
23222435/// This module reimplements the cksum-c.sh GNU test.
23232436mod gnu_cksum_c {
23242437 use super :: * ;
0 commit comments