@@ -10,9 +10,8 @@ use uutests::util::TestScenario;
1010use uutests:: util:: log_info;
1111use uutests:: util_name;
1212
13- const ALGOS : [ & str ; 12 ] = [
14- "sysv" , "bsd" , "crc" , "crc32b" , "md5" , "sha1" , "sha224" , "sha256" , "sha384" , "sha512" ,
15- "blake2b" , "sm3" ,
13+ const ALGOS : [ & str ; 11 ] = [
14+ "sysv" , "bsd" , "crc" , "md5" , "sha1" , "sha224" , "sha256" , "sha384" , "sha512" , "blake2b" , "sm3" ,
1615] ;
1716const SHA_LENGTHS : [ u32 ; 4 ] = [ 224 , 256 , 384 , 512 ] ;
1817
@@ -2876,3 +2875,102 @@ mod format_mix {
28762875 . stderr_contains ( "cksum: WARNING: 1 line is improperly formatted" ) ;
28772876 }
28782877}
2878+
2879+ #[ cfg( not( target_os = "android" ) ) ]
2880+ mod debug_tests {
2881+ use super :: * ;
2882+
2883+ #[ test]
2884+ fn test_debug_flag ( ) {
2885+ // Test with default CRC algorithm - should output CPU feature detection
2886+ new_ucmd ! ( )
2887+ . arg ( "--debug" )
2888+ . arg ( "lorem_ipsum.txt" )
2889+ . succeeds ( )
2890+ . stdout_is_fixture ( "crc_single_file.expected" )
2891+ . stderr_contains ( "avx512" )
2892+ . stderr_contains ( "avx2" )
2893+ . stderr_contains ( "pclmul" ) ;
2894+
2895+ // Test with MD5 algorithm - CPU detection should be same regardless of algorithm
2896+ new_ucmd ! ( )
2897+ . arg ( "--debug" )
2898+ . arg ( "-a" )
2899+ . arg ( "md5" )
2900+ . arg ( "lorem_ipsum.txt" )
2901+ . succeeds ( )
2902+ . stdout_is_fixture ( "md5_single_file.expected" )
2903+ . stderr_contains ( "avx512" )
2904+ . stderr_contains ( "avx2" )
2905+ . stderr_contains ( "pclmul" ) ;
2906+
2907+ // Test with stdin - CPU detection should appear once
2908+ new_ucmd ! ( )
2909+ . arg ( "--debug" )
2910+ . pipe_in ( "test" )
2911+ . succeeds ( )
2912+ . stderr_contains ( "avx512" )
2913+ . stderr_contains ( "avx2" )
2914+ . stderr_contains ( "pclmul" ) ;
2915+
2916+ // Test with multiple files - CPU detection should appear once, not per file
2917+ new_ucmd ! ( )
2918+ . arg ( "--debug" )
2919+ . arg ( "lorem_ipsum.txt" )
2920+ . arg ( "alice_in_wonderland.txt" )
2921+ . succeeds ( )
2922+ . stdout_is_fixture ( "crc_multiple_files.expected" )
2923+ . stderr_contains ( "avx512" )
2924+ . stderr_contains ( "avx2" )
2925+ . stderr_contains ( "pclmul" ) ;
2926+ }
2927+
2928+ #[ test]
2929+ fn test_debug_with_algorithms ( ) {
2930+ // Test with SHA256 - CPU detection should be same regardless of algorithm
2931+ new_ucmd ! ( )
2932+ . arg ( "--debug" )
2933+ . arg ( "-a" )
2934+ . arg ( "sha256" )
2935+ . arg ( "lorem_ipsum.txt" )
2936+ . succeeds ( )
2937+ . stderr_contains ( "avx512" )
2938+ . stderr_contains ( "avx2" )
2939+ . stderr_contains ( "pclmul" ) ;
2940+
2941+ // Test with BLAKE2b default length
2942+ new_ucmd ! ( )
2943+ . arg ( "--debug" )
2944+ . arg ( "-a" )
2945+ . arg ( "blake2b" )
2946+ . arg ( "lorem_ipsum.txt" )
2947+ . succeeds ( )
2948+ . stderr_contains ( "avx512" )
2949+ . stderr_contains ( "avx2" )
2950+ . stderr_contains ( "pclmul" ) ;
2951+
2952+ // Test with BLAKE2b custom length
2953+ new_ucmd ! ( )
2954+ . arg ( "--debug" )
2955+ . arg ( "-a" )
2956+ . arg ( "blake2b" )
2957+ . arg ( "--length" )
2958+ . arg ( "256" )
2959+ . arg ( "lorem_ipsum.txt" )
2960+ . succeeds ( )
2961+ . stderr_contains ( "avx512" )
2962+ . stderr_contains ( "avx2" )
2963+ . stderr_contains ( "pclmul" ) ;
2964+
2965+ // Test with SHA1
2966+ new_ucmd ! ( )
2967+ . arg ( "--debug" )
2968+ . arg ( "-a" )
2969+ . arg ( "sha1" )
2970+ . arg ( "lorem_ipsum.txt" )
2971+ . succeeds ( )
2972+ . stderr_contains ( "avx512" )
2973+ . stderr_contains ( "avx2" )
2974+ . stderr_contains ( "pclmul" ) ;
2975+ }
2976+ }
0 commit comments