Unverified Commit c430cc51 authored by Jeffrey Booher-Kaeding's avatar Jeffrey Booher-Kaeding Committed by GitHub
Browse files

Merge pull request #3 from vstehle/for-jeffrey

parents 17f614b9 54a838da
*.pdf
/result.md
# Simple makefile to generate the documentation with pandoc.
.PHONY: all doc help clean
all: doc
help:
@echo 'Targets:'
@echo ' all'
@echo ' clean'
@echo ' doc Generate README.pdf'
@echo ' help Print this help.'
doc: README.pdf
%.pdf: %.md pandoc.yaml
pandoc -o$@ $< pandoc.yaml
clean:
-rm -f README.pdf
#!/usr/bin/env python3
#SCT log parser
import sys
import json
#based loosley on https://stackoverflow.com/a/4391978
# returns a filtered dict of dicts that meet some Key-value pair.
......@@ -18,18 +18,18 @@ def key_value_find(list_1, key, value):
#Were we intrept test logs into test dicts
def test_parser(string,current_group,current_test_set,current_set_guid,current_sub_set):
test_list = {
"name": string[2], #FIXME:Sometimes, SCT has name and Description,
"name": string[2], #FIXME:Sometimes, SCT has name and Description,
"result": string[1],
"group": current_group,
"test set": current_test_set,
"test set": current_test_set,
"sub set": current_sub_set,
"set guid": current_set_guid,
"guid": string[0], #FIXME:GUID's overlap
#"comment": string[-1], #FIXME:need to hash this out, sometime there is no comments
"log": ' '.join(string)
"log": ' '.join(string[3:])
}
return test_list
#Parse the ekl file, and create a map of the tests
def ekl_parser (file):
#create our "database" dict
......@@ -41,11 +41,18 @@ def ekl_parser (file):
current_sub_set = "N/A"
for line in file:
# Strip the line from trailing whitespaces
line = line.rstrip()
# Skip empty line
if line == '':
continue
#strip the line of | & || used for sepration
split_line = [string for string in line.split('|') if string != ""]
#TODO:I can skip TERM, but I feel like "\n" should be able to be handled in the above list comprehension
if split_line[0]=="TERM" or split_line[0]=="\n":
# Skip TERM
if split_line[0] == "TERM":
continue
#The "HEAD" tag is the only indcation we are on a new test set
......@@ -54,7 +61,7 @@ def ekl_parser (file):
try:
current_group, current_set = split_line[8].split('\\')
except:
current_group, current_set =split_line[8],split_line
current_group, current_set = '', split_line[8]
current_set_guid = split_line[4]
current_sub_set = split_line[6]
......@@ -88,7 +95,7 @@ def seq_parser(file):
#(x+3)Name=InstallAcpiTableFunction
#(x+4)Order=0xFFFFFFFF
#(x+5)Iterations=0xFFFFFFFF
#(x+6)(utf-16 char)
#(x+6)(utf-16 char)
#currently only add tests that are supposed to run, should add all?
#0xFFFFFFFF in "Iterations" means the test is NOT supposed to run
if not "0xFFFFFFFF" in lines[x+5]:
......@@ -107,7 +114,7 @@ def seq_parser(file):
#we slowly iterate through the list, group and print groups
def key_tree_2_md(input_list,file,key):
#make a copy so we don't destroy the first list.
temp_list = input_list.copy()
temp_list = input_list.copy()
while temp_list:
test_dict = temp_list.pop()
found, not_found = [test_dict],[]
......@@ -121,7 +128,7 @@ def key_tree_2_md(input_list,file,key):
temp_list = not_found #start over with found items removed
file.write("### " + test_dict[key])
dict_2_md(found,file)
#generic writer, takes a list of dicts and turns the dicts into an MD table.
......@@ -140,7 +147,7 @@ def dict_2_md(input_list,file):
for y in x.keys():
test_string += (x[y] + "|")
file.write(test_string+'\n')
#seprate table from other items in MD
#seprate table from other items in MD
file.write("\n\n")
......@@ -156,7 +163,7 @@ def main():
db2 = dict() #"database 2" all test sets that should run
with open(seq_file,"r",encoding="utf-16") as f: #files are encoded in utf-16
db2 = seq_parser(f)
#cross check is filled only with tests labled as "run" int the seq file
cross_check = list()
#combine a list of test sets that did not run for whatever reason.
......@@ -168,9 +175,9 @@ def main():
else: #if it is empty, this test set was not run.
would_not_run.append(x)
#search for failures and warnings & passes,
failures = key_value_find(cross_check,"result","FAILURE")
warnings = key_value_find(cross_check,"result","WARNING")
passes = key_value_find(cross_check,"result","PASS")
......@@ -178,26 +185,28 @@ def main():
# generate MD summary
with open('result.md', 'w') as resultfile:
resultfile.write("# SCT Summary \n")
resultfile.write("### 1. Dropped: "+str(len(would_not_run))+"\n")
resultfile.write("### 2. Failures: "+str(len(failures))+"\n")
resultfile.write("### 3. Warnings: "+str(len(warnings))+"\n")
resultfile.write("### 4. Passes: "+str(len(passes))+"\n")
resultfile.write("# SCT Summary \n\n")
resultfile.write("| | |\n")
resultfile.write("|--|--|\n")
resultfile.write("|Dropped:|" + str(len(would_not_run)) + "|\n")
resultfile.write("|Failures:|" + str(len(failures)) + "|\n")
resultfile.write("|Warnings:|" + str(len(warnings)) + "|\n")
resultfile.write("|Passes:|" + str(len(passes)) + "|\n")
resultfile.write("\n\n")
resultfile.write("## 1. Silently dropped or missing")
dict_2_md(would_not_run,resultfile)
resultfile.write("## 4. Failure by group")
resultfile.write("\n\n")
resultfile.write("\n\n")
key_tree_2_md(failures,resultfile,"group")
resultfile.write("## 3. Warnings by group")
resultfile.write("\n\n")
key_tree_2_md(warnings,resultfile,"group")
#command line argument 3&4, key are to support a key & value search.
#these will be displayed in CLI
if len(sys.argv) >= 5:
......
......@@ -8,14 +8,14 @@ It will proceed to generate a Markdown file listing number of failures, passes,
## Usage
Usage to generate a "result md" is such. `python3 parser.py <log_file.ekl> <seq_file.seq>`
Usage to generate a "result md" is such. `python3 parser.py <log_file.ekl> <seq_file.seq>`
If you do no provided any command line arguments it will use `sample.ekl` and `sample.seq`.
### Custom search
For a custom Key:value search, the next two arguments *MUST be included together.* The program will search and display files that met that constraint, without the crosscheck, and display the names, guid, and key:value to the command line. `python3 Parser.py <file.ekl> <file.seq> <search key> <search value>`
you can use the `test_dict` below to see available keys.
you can use the `test_dict` below to see available keys.
......@@ -28,8 +28,12 @@ you can use the `test_dict` below to see available keys.
* "comment" is currently not implemented, as formatting is not currently consistent, should reflect the comments from the test.
* some SCT tests have shared GUIDs,
* some lines in ekl file follow Different naming Conventions
* some tests in the sequence file are not strongly Associated with the test spec.
* some tests in the sequence file are not strongly Associated with the test spec.
### Documentation
It is possible to convert this `README.md` into `README.pdf` with pandoc using
`make doc`. See `make help`.
### TODO:
* double check concatenation of all `.ekl` logs, preliminary tests show small Divergence between them and `summary.ekl` found in `Overall` folder. Cat.sh will generate this file.
......@@ -37,7 +41,7 @@ you can use the `test_dict` below to see available keys.
### db structure:
```
``` {.python}
tests = [
test_dict,
est_dict2...
......@@ -47,7 +51,7 @@ test_dict = {
"name": "some test",
"result": "pass/fail",
"group": "some group",
"test set": "some set",
"test set": "some set",
"sub set": "some subset",
"set guid": "XXXXXX",
"guid": "XXXXXX",
......@@ -56,7 +60,7 @@ test_dict = {
}
seqs = {
seqs = {
<guid> : seq_dict
<guid2> : seq_dict2...
}
......
---
toc: true
urlcolor: blue
---
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment