@@ -939,3 +939,71 @@ fn test_check_b2sum_strict_check() {
939
939
. succeeds ( )
940
940
. stdout_only ( & output) ;
941
941
}
942
+
943
+ #[ test]
944
+ fn test_check_md5_comment_line ( ) {
945
+ // A comment in a checksum file shall be discarded unnoticed.
946
+
947
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
948
+ let at = & scene. fixtures ;
949
+
950
+ at. write ( "foo" , "foo-content\n " ) ;
951
+ at. write (
952
+ "MD5SUM" ,
953
+ "\
954
+ # This is a comment\n \
955
+ 8411029f3f5b781026a93db636aca721 foo\n \
956
+ # next comment is empty\n #",
957
+ ) ;
958
+
959
+ scene
960
+ . ccmd ( "md5sum" )
961
+ . arg ( "--check" )
962
+ . arg ( "MD5SUM" )
963
+ . succeeds ( )
964
+ . stdout_contains ( "foo: OK" )
965
+ . no_stderr ( ) ;
966
+ }
967
+
968
+ #[ test]
969
+ fn test_check_md5_comment_only ( ) {
970
+ // A file only filled with comments is equivalent to an empty file,
971
+ // and therefore produces an error.
972
+
973
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
974
+ let at = & scene. fixtures ;
975
+
976
+ at. write ( "foo" , "foo-content\n " ) ;
977
+ at. write ( "MD5SUM" , "# This is a comment\n " ) ;
978
+
979
+ scene
980
+ . ccmd ( "md5sum" )
981
+ . arg ( "--check" )
982
+ . arg ( "MD5SUM" )
983
+ . fails ( )
984
+ . stderr_contains ( "no properly formatted checksum lines found" ) ;
985
+ }
986
+
987
+ #[ test]
988
+ fn test_check_md5_comment_leading_space ( ) {
989
+ // A file only filled with comments is equivalent to an empty file,
990
+ // and therefore produces an error.
991
+
992
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
993
+ let at = & scene. fixtures ;
994
+
995
+ at. write ( "foo" , "foo-content\n " ) ;
996
+ at. write (
997
+ "MD5SUM" ,
998
+ " # This is a comment\n \
999
+ 8411029f3f5b781026a93db636aca721 foo\n ",
1000
+ ) ;
1001
+
1002
+ scene
1003
+ . ccmd ( "md5sum" )
1004
+ . arg ( "--check" )
1005
+ . arg ( "MD5SUM" )
1006
+ . succeeds ( )
1007
+ . stdout_contains ( "foo: OK" )
1008
+ . stderr_contains ( "WARNING: 1 line is improperly formatted" ) ;
1009
+ }
0 commit comments