Lines Matching +full:re +full:- +full:started

1 # SPDX-License-Identifier: GPL-2.0
4 # results with reader-friendly format. Stores and returns test results in a
14 import re
29 status : TestStatus - status of the test
30 name : str - name of the test
31 expected_count : int - expected number of subtests (0 if single
33 subtests : List[Test] - list of subtests
34 log : List[str] - log of KTAP lines that correspond to the test
35 counts : TestCounts - counts of the test statuses and errors of
39 def __init__(self) -> None:
48 def __str__(self) -> str:
53 def __repr__(self) -> str:
57 def add_error(self, printer: Printer, error_message: str) -> None:
62 def ok_status(self) -> bool:
87 def __str__(self) -> str:
95 def total(self) -> int:
102 def add_subtest_counts(self, counts: TestCounts) -> None:
109 counts - a different TestCounts object whose counts
118 def get_status(self) -> TestStatus:
135 def add_status(self, status: TestStatus) -> None:
164 def _get_next(self) -> None:
175 def peek(self) -> str:
181 def pop(self) -> str:
191 def __bool__(self) -> bool:
197 def __iter__(self) -> Iterator[str]:
204 def line_number(self) -> int:
211 KTAP_START = re.compile(r'\s*KTAP version ([0-9]+)$')
212 TAP_START = re.compile(r'\s*TAP version ([0-9]+)$')
213 KTAP_END = re.compile(r'\s*(List of all partitions:|'
214 'Kernel panic - not syncing: VFS:|reboot: System halted)')
215 EXECUTOR_ERROR = re.compile(r'\s*kunit executor: (.*)$')
217 def extract_tap_lines(kernel_output: Iterable[str]) -> LineStream:
220 -> Iterator[Tuple[int, str]]:
222 started = False
226 if not started and KTAP_START.search(line):
231 started = True
233 elif not started and TAP_START.search(line):
237 started = True
239 elif started and KTAP_END.search(line):
242 elif started:
254 version_type: str, test: Test, printer: Printer) -> None:
260 version_num - The inputted version number from the parsed KTAP or TAP
262 accepted_version - List of accepted KTAP or TAP versions
263 version_type - 'KTAP' or 'TAP' depending on the type of
265 test - Test object for current test being parsed
266 printer - Printer object to output error
273 def parse_ktap_header(lines: LineStream, test: Test, printer: Printer) -> bool:
279 - 'KTAP version [version number]'
280 - 'TAP version [version number]'
283 lines - LineStream of KTAP output to parse
284 test - Test object for current test being parsed
285 printer - Printer object to output results
303 TEST_HEADER = re.compile(r'^\s*# Subtest: (.*)$')
305 def parse_test_header(lines: LineStream, test: Test) -> bool:
311 - '# Subtest: [test name]'
314 lines - LineStream of KTAP output to parse
315 test - Test object for current test being parsed
327 TEST_PLAN = re.compile(r'^\s*1\.\.([0-9]+)')
329 def parse_test_plan(lines: LineStream, test: Test) -> bool:
337 - '1..[number of subtests]'
340 lines - LineStream of KTAP output to parse
341 test - Test object for current test being parsed
355 TEST_RESULT = re.compile(r'^\s*(ok|not ok) ([0-9]+) (- )?([^#]*)( # .*)?$')
357 TEST_RESULT_SKIP = re.compile(r'^\s*(ok|not ok) ([0-9]+) (- )?(.*) # SKIP(.*)$')
359 def peek_test_name_match(lines: LineStream, test: Test) -> bool:
366 - '[ok|not ok] [test number] [-] [test name] [optional skip
370 lines - LineStream of KTAP output to parse
371 test - Test object for current test being parsed
385 expected_num: int, printer: Printer) -> bool:
396 - '[ok|not ok] [test number] [-] [test name] [optional skip
400 lines - LineStream of KTAP output to parse
401 test - Test object for current test being parsed
402 expected_num - expected test number for current test
403 printer - Printer object to output results
438 def parse_diagnostic(lines: LineStream) -> List[str]:
444 - '# Subtest: [test name]'
445 - '[ok|not ok] [test number] [-] [test name] [optional skip
447 - 'KTAP version [version number]'
450 lines - LineStream of KTAP output to parse
457 while lines and not any(re.match(lines.peek())
458 for re in non_diagnostic_lines):
467 def format_test_divider(message: str, len_message: int) -> str:
475 message - message to be centered in divider line
476 len_message - length of the message to be printed such that
485 difference = len(DIVIDER) - len_message - 2 # 2 spaces added
489 len_2 = difference - len_1
492 def print_test_header(test: Test, printer: Printer) -> None:
501 test - Test object representing current test being printed
502 printer - Printer object to output results
516 def print_log(log: Iterable[str], printer: Printer) -> None:
522 def format_test_result(test: Test, printer: Printer) -> str:
531 test - Test object representing current test being printed
532 printer - Printer object to output results
549 def print_test_result(test: Test, printer: Printer) -> None:
557 test - Test object representing current test being printed
558 printer - Printer object
562 def print_test_footer(test: Test, printer: Printer) -> None:
570 test - Test object representing current test being printed
571 printer - Printer object to output results
575 len(message) - printer.color_len()))
577 def print_test(test: Test, failed_only: bool, printer: Printer) -> None:
585 test - Test object to print
586 failed_only - True if only failed/crashed tests should be printed.
587 printer - Printer object to output results
604 def _summarize_failed_tests(test: Test) -> str:
607 def failed_names(test: Test, parent_name: str) -> List[str]:
608 # Note: we use 'main' internally for the top-level test.
618 # Don't summarize it down "the top-level test failed", though.
636 def print_summary_line(test: Test, printer: Printer) -> None:
648 test - Test object representing current test being printed
649 printer - Printer object to output results
659 # Summarize failures that might have gone off-screen since we had a lot
670 def bubble_up_test_results(test: Test) -> None:
678 test - Test object for current test being parsed
690 …(lines: LineStream, expected_num: int, log: List[str], is_subtest: bool, printer: Printer) -> Test:
700 - Main KTAP/TAP header
708 - Subtest header (must include either the KTAP version line or
734 - Test result line
738 ok 1 - test
741 lines - LineStream of KTAP output to parse
742 expected_num - expected test number for test to be parsed
743 log - list of strings containing any preceding diagnostic lines
745 is_subtest - boolean indicating whether test is a subtest
746 printer - Printer object to output results
759 # If parsing the main/top-level test, parse KTAP version line and
835 def parse_run_tests(kernel_output: Iterable[str], printer: Printer) -> Test:
841 kernel_output - Iterable object contains lines of kernel output
842 printer - Printer object to output results
845 Test - the main test object with all subtests.