@@ -386,6 +386,63 @@ def test_verify_messages_no_errors(self, dmesg):
386386 )
387387 assert dmesg .verify_messages ()["successful" ]
388388
389+ def test_verify_messages_ignores_empty_lines (self , dmesg ):
390+ output = (
391+ "[ 4.923735] SELinux: Runtime disable is not supported\n "
392+ "\n "
393+ "[ 321.327775] CIFS: VFS: unaligned rsize, making it a multiple of 4096 bytes"
394+ )
395+ custom_allowlist = ["SELinux" , "unaligned rsize" ]
396+ dmesg ._connection .execute_command .return_value = ConnectionCompletedProcess (
397+ return_code = 0 , args = "command" , stdout = output , stderr = "stderr"
398+ )
399+ result = dmesg .verify_messages (custom_allowlist = custom_allowlist )
400+ assert result ["successful" ]
401+ assert result ["error" ] == ""
402+
403+ @pytest .mark .parametrize (
404+ "custom_allowlist,expected_successful,expected_error_contains" ,
405+ [
406+ pytest .param (
407+ ["Couldn't get size" , "MODSIGN" , "unexpected notification" ],
408+ True ,
409+ [],
410+ id = "all_errors_allowlisted" ,
411+ ),
412+ pytest .param (
413+ ["Couldn't get size" ],
414+ False ,
415+ ["MODSIGN" , "unexpected notification" ],
416+ id = "partial_match" ,
417+ ),
418+ pytest .param (
419+ [],
420+ False ,
421+ ["Couldn't get size" ],
422+ id = "empty_allowlist" ,
423+ ),
424+ ],
425+ )
426+ def test_verify_messages_with_custom_allowlist (
427+ self , dmesg , custom_allowlist , expected_successful , expected_error_contains
428+ ):
429+ output = dedent (
430+ """
431+ [ 4.660616] Couldn't get size: 0x800000000000000e
432+ [ 4.694322] MODSIGN: Couldn't get UEFI db list
433+ [ 33.580364] cdc_ether 1-1.1.2:1.0 enp0s29u1u1u2: CDC: unexpected notification 20!"""
434+ )
435+ dmesg ._connection .execute_command .return_value = ConnectionCompletedProcess (
436+ return_code = 0 , args = "command" , stdout = output , stderr = "stderr"
437+ )
438+ result = dmesg .verify_messages (custom_allowlist = custom_allowlist )
439+ assert result ["successful" ] == expected_successful
440+ if expected_successful :
441+ assert result ["error" ] == ""
442+ else :
443+ for fragment in expected_error_contains :
444+ assert fragment in result ["error" ]
445+
389446 def test_check_errors (self , dmesg ):
390447 output = dedent (
391448 """
@@ -841,6 +898,43 @@ def test_verify_messages_no_errors(self, dmesg):
841898 )
842899 assert dmesg .verify_messages ()["successful" ]
843900
901+ @pytest .mark .parametrize (
902+ "custom_allowlist,expected_successful,expected_error_contains" ,
903+ [
904+ pytest .param (
905+ ["Couldn't get size" , "MODSIGN" ],
906+ True ,
907+ [],
908+ id = "all_errors_allowlisted" ,
909+ ),
910+ pytest .param (
911+ ["Couldn't get size" ],
912+ False ,
913+ ["MODSIGN ERROR" ],
914+ id = "partial_match" ,
915+ ),
916+ ],
917+ )
918+ def test_verify_messages_with_custom_allowlist (
919+ self , dmesg , custom_allowlist , expected_successful , expected_error_contains
920+ ):
921+ output = dedent (
922+ """
923+ [ 4.660616] Couldn't get size error: 0x800000000000000e
924+ [ 4.694322] MODSIGN ERROR: Couldn't get UEFI db list
925+ [ 4.728454] Couldn't get size ERROR: 0x800000000000000e"""
926+ )
927+ dmesg ._connection .execute_command .return_value = ConnectionCompletedProcess (
928+ return_code = 0 , args = "command" , stdout = output , stderr = "stderr"
929+ )
930+ result = dmesg .verify_messages (custom_allowlist = custom_allowlist )
931+ assert result ["successful" ] == expected_successful
932+ if expected_successful :
933+ assert result ["error" ] == ""
934+ else :
935+ for fragment in expected_error_contains :
936+ assert fragment in result ["error" ]
937+
844938 def test_check_errors (self , dmesg ):
845939 output = dedent (
846940 """
0 commit comments