From ef13cb8bd3f8ec0ad9f01bda42f894f5b83772d3 Mon Sep 17 00:00:00 2001 From: Nhi Pham Date: Thu, 30 Mar 2023 23:22:57 -0600 Subject: [PATCH 1/3] Parser: Workaround .ekl log string quirks The EKL has a couple quirks where a newline is inserted into the results string. This cause a problem for the parser. We have a workaround for two cases: Sometimes the EKL has a '\n ' in the log string Sometimes the EKL has a '\n/' in the log string In each case, append the line to the previous log string for reporting. Signed-off-by: Nhi Pham --- parser.py | 12 ++++++++---- sample/sample.ekl | Bin 45468 -> 48748 bytes tests/test-parser | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/parser.py b/parser.py index 4282c4e..f5a53f1 100755 --- a/parser.py +++ b/parser.py @@ -170,10 +170,14 @@ def ekl_parser(file): 'descr': split_line[11], 'device path': '|'.join(split_line[13:]), } - - # FIXME:? EKL file has an inconsistent line structure, - # sometime we see a line that consits ' dump of GOP->I\n' - # easiest way to skip is check for blank space in the first char + # Sometimes the EKL has a '\n ' in the log string, so if we see that, + # we need to append the line to the previous log entry. + elif split_line[0] != '' and split_line[0][0] == " " and n >= 1: + temp_list[n-1]['log'] = temp_list[n-1]['log'] + line + # Sometimes the EKL has a '\n/' in the log string, so if we see that, + # we need to append the line to the previous log entry. + elif split_line[0] != '' and split_line[0][0] == "/" and n >= 1: + temp_list[n-1]['log'] = temp_list[n-1]['log'] + line elif split_line[0] != '' and split_line[0][0] != " ": try: # deliminiate on ':' for tests diff --git a/sample/sample.ekl b/sample/sample.ekl index 8679b6f2493a36ff3bdb59e345975a9a7094a10b..e3dd276d77f5e12e17ce8b8ec7918898df330148 100644 GIT binary patch delta 2363 zcmeH}OKTHR6vt1Cpa_BpMQRYooyC?sX7WUZq$aUQF>S0aOVXsanr3Qdtd$mmTM$k6)u-cK3s?JJ*8t z2P?Sn`KOzZluSuXl8gzy39)6HZ(MTFSw@F(TQX8WmgRNOrm;>-UWzge<)97ym*k+I`T#nem$Gx%ZWtm4(kq4wV z4Frp%v_Oaz9fSS7NVgA&g-`1bkZ#EYve$s&1BoRYB-?^(K(CRm0-2L2Iv2hPrSLtM zXYg-KNu%Lq?(1#KTXin|85CJ4*#AsVF)O)9pE zOs)MOe>E9g-ncS;B&@-w+c%B{edPVbf+DtyE$jcCAnx`r`L}~<|6cA+n_;Gnz#i3%Zx7v5LqT!555HiIaWjyNsf{!U@J7TwnmQis;f|C zPX;pGv_e^h7T(0NMVZ%(pSVnRF`lOe9$gIAPI*#_Gy3lc{^X#OU=TflGbEu=J~k%)y|; PtBnTb7)uQ{ZH|lI*XNT$ delta 9 RcmaF!hiT4ZrVVp80stIa1!({P diff --git a/tests/test-parser b/tests/test-parser index ca8005f..17f98e8 100755 --- a/tests/test-parser +++ b/tests/test-parser @@ -34,6 +34,7 @@ args=(--config sample/sample.yaml sample/sample.ekl sample/sample.seq) parser.py "${args[@]}" |& tee "$out" grep -q 'Identified.* as "Test sample' "$out" grep -q 'Updated 1 test.* after applying 1 rule' "$out" +if grep -q 'ERROR' "$out"; then false; fi grep -q 'Meta-data' result.md echo -n 'null config, ' >&3 -- GitLab From d4968a5994332d44a1b8d85b0f42220737dd607a Mon Sep 17 00:00:00 2001 From: Nhi Pham Date: Thu, 30 Mar 2023 23:28:58 -0600 Subject: [PATCH 2/3] Parser: Fix special markdown characters in tables A '|' indicates a cell in the table, but it is also a character in the device string. ex: Acpi(PNP0A08,0)/Pci(1|0)/Pci(0|0). Escape the '|' to print markdown tables correctly. Signed-off-by: Nhi Pham --- parser.py | 2 ++ tests/test-parser | 2 ++ 2 files changed, 4 insertions(+) diff --git a/parser.py b/parser.py index f5a53f1..ffa6015 100755 --- a/parser.py +++ b/parser.py @@ -278,6 +278,8 @@ def dict_2_md(input_list, file): test_string = "|" for y in k: v = x[y] if y in x else '' + # Escape any | in the string for proper markup table formatting + v = v.replace("|", r"\|") test_string += v + "|" file.write(test_string + '\n') # seprate table from other items in MD diff --git a/tests/test-parser b/tests/test-parser index 17f98e8..273e822 100755 --- a/tests/test-parser +++ b/tests/test-parser @@ -37,6 +37,8 @@ grep -q 'Updated 1 test.* after applying 1 rule' "$out" if grep -q 'ERROR' "$out"; then false; fi grep -q 'Meta-data' result.md +if grep -q 'Pci(0|0)' result.md; then false; fi + echo -n 'null config, ' >&3 parser.py "${args[@]}" --config /dev/null |& tee "$out" -- GitLab From bc6c5c816e2ee89087f5ffa1470d54412f3a4980 Mon Sep 17 00:00:00 2001 From: Nhi Pham Date: Thu, 30 Mar 2023 23:32:47 -0600 Subject: [PATCH 3/3] Parser: Add test result key Add a key to explain the results summary for Pass, Fail, Warning, Dropped, Ignored, Skipped tests. Signed-off-by: Nhi Pham --- parser.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/parser.py b/parser.py index ffa6015..45e7c4a 100755 --- a/parser.py +++ b/parser.py @@ -812,7 +812,24 @@ def gen_md(md, res_keys, bins, meta): resultfile.write( "|{}:|{}|\n".format(k.title(), len(bins[k]))) - resultfile.write("\n\n") + resultfile.write("\n") + resultfile.write("- Dropped: " + "The test is in the .seq file, " + "but there is no test sub-set or " + "results in the .ekl.\n") + resultfile.write("- Failure: " + "The test has a failed result in the .ekl.\n") + resultfile.write("- Ignored: " + "The test result is ignored by the .yaml rules.\n") + resultfile.write("- Pass: " + "The test has a passed result in the .ekl. " + "(Not printed in this results.md)\n") + resultfile.write("- Skipped: " + "The test sub-set is present in the .ekl, " + "but no test results are in the .ekl.\n") + resultfile.write("- Warning: " + "The test has a warning result in the .ekl.\n") + resultfile.write("\n---\n\n") # Loop on all the result values we found (except PASS) for the sections # listing the tests by group -- GitLab