@@ -798,68 +798,69 @@ def verify_repository_installed(self, node: Node) -> None: # noqa: C901
798
798
799
799
@TestCaseMetadata (
800
800
description = """
801
- This test will check the serial console is enabled from kernel command line
802
- in dmesg.
801
+ This test will check the serial console is enabled from kernel command line.
803
802
804
803
Steps:
805
- 1. Get the kernel command line from /var/log/messages or
806
- /var/log/syslog output.
804
+ 1. Get the kernel command line from /var/log/messages, /var/log/syslog,
805
+ dmesg, or journalctl output.
807
806
2. Check expected setting from kernel command line.
808
807
2.1. Expected to see 'console=ttyAMA0' for aarch64.
809
808
2.2. Expected to see 'console=ttyS0' for x86_64.
809
+ 2.3. Expected to see 'uart0: console 115200,n,8,1 for FreeBSD.
810
810
""" ,
811
811
priority = 1 ,
812
812
requirement = simple_requirement (supported_platform_type = [AZURE , READY ]),
813
813
)
814
814
def verify_serial_console_is_enabled (self , node : Node ) -> None :
815
- console_device = {
816
- CpuArchitecture .X64 : "ttyS0" ,
817
- CpuArchitecture .ARM64 : "ttyAMA0" ,
818
- }
819
815
if isinstance (node .os , CBLMariner ):
820
816
if node .os .information .version < "2.0.0" :
821
817
raise SkippedException (
822
818
"CBLMariner 1.0 has a known 'wont fix' issue with this test"
823
819
)
824
- if isinstance (node .os , CBLMariner ) or (
825
- isinstance (node .os , Ubuntu ) and node .os .information .version >= "22.10.0"
826
- ):
827
- log_output = node .tools [Dmesg ].get_output ()
828
- log_file = "dmesg"
829
- else :
830
- cat = node .tools [Cat ]
831
- if node .shell .exists (node .get_pure_path ("/var/log/messages" )):
832
- log_file = "/var/log/messages"
833
- log_output = cat .read (log_file , force_run = True , sudo = True )
834
- elif node .shell .exists (node .get_pure_path ("/var/log/syslog" )):
835
- log_file = "/var/log/syslog"
836
- log_output = cat .read (log_file , force_run = True , sudo = True )
837
- else :
838
- log_file = "journalctl"
839
- journalctl = node .tools [Journalctl ]
840
- log_output = journalctl .first_n_logs_from_boot ()
841
- if not log_output :
842
- raise LisaException (
843
- "Neither /var/log/messages nor /var/log/syslog found."
844
- "and journal ctl log is empty."
845
- )
846
-
820
+ console_device = {
821
+ CpuArchitecture .X64 : "ttyS0" ,
822
+ CpuArchitecture .ARM64 : "ttyAMA0" ,
823
+ }
847
824
lscpu = node .tools [Lscpu ]
848
825
arch = lscpu .get_architecture ()
849
826
current_console_device = console_device [arch ]
850
827
console_enabled_pattern = re .compile (
851
828
rf"^(.*console \[{ current_console_device } \] enabled.*)$" , re .M
852
829
)
853
830
freebsd_pattern = re .compile (r"^(.*uart0: console \(115200,n,8,1\).*)$" , re .M )
854
- result = find_patterns_in_lines (
855
- log_output , [console_enabled_pattern , freebsd_pattern ]
856
- )
857
- if not (result [0 ] or result [1 ]):
831
+ patterns = [console_enabled_pattern , freebsd_pattern ]
832
+ pattern_found = False
833
+
834
+ if isinstance (node .os , CBLMariner ) or (
835
+ isinstance (node .os , Ubuntu ) and node .os .information .version >= "22.10.0"
836
+ ):
837
+ log_output = node .tools [Dmesg ].get_output ()
838
+ if any (find_patterns_in_lines (log_output , patterns )):
839
+ pattern_found = True
840
+ else :
841
+ log_sources = [
842
+ ("/var/log/syslog" , node .tools [Cat ]),
843
+ ("/var/log/messages" , node .tools [Cat ]),
844
+ ]
845
+ journalctl_tool = node .tools [Journalctl ]
846
+ for log_file , tool in log_sources :
847
+ if node .shell .exists (node .get_pure_path (log_file )):
848
+ current_log_output = tool .read (log_file , force_run = True , sudo = True )
849
+ if current_log_output :
850
+ if any (find_patterns_in_lines (current_log_output , patterns )):
851
+ pattern_found = True
852
+ break
853
+ if not pattern_found and journalctl_tool ._check_exists ():
854
+ current_log_output = journalctl_tool .first_n_logs_from_boot ()
855
+ if current_log_output :
856
+ if any (find_patterns_in_lines (current_log_output , patterns )):
857
+ pattern_found = True
858
+ if not pattern_found :
858
859
raise LisaException (
859
860
"Fail to find console enabled line "
860
861
f"'console [{ current_console_device } ] enabled' "
861
862
"or 'uart0: console (115200,n,8,1)' "
862
- f "from { log_file } output",
863
+ "from any log output"
863
864
)
864
865
865
866
@TestCaseMetadata (
0 commit comments