gitlab.arm.com will be in the maintainance mode on Wednesday June 29th 01:00 - 10:00 (UTC+1). Repositories is read only during the maintainance.

Commit 513784ec authored by Jeff Booher-Kaeding's avatar Jeff Booher-Kaeding
Browse files

Moved to MD from CSV, bandaid on ekl/GUID issues

Need to address the ekl parser ASAP, unfortunately the logs are not as parsable as original thought.
Generated MD is very rudimentary, needs more attetion, list bandid also restrics CSV output.
parent 3afe3a32
B[Test Case]
#SCT log parser
#BIGFIXME: need to Decide on Definite Structure, and do a deeper dive into how logs are represented.gi
import sys
import csv
import json
#import csv
#based loosley on https://stackoverflow.com/a/4391978
# returns a filtered dict of dicts that meet some Key-value pair.
# I.E. key="result" value="FAILURE"
#if tests ar in lists.
def key_value_find(dict1, key, value):
found = {}
for key2 in dict1:
test = dict1[key2]
#print(key)
found = list()
for test in dict1:
if test[key] == value:
found[key2]=test
found.append(test)
return found
#if tests are in dicts.
#def key_value_find(dict1, key, value):
# found = {}
# for key2 in dict1:
# test = dict1[key2]
# if test[key] == value:
# found[key2]=test
# return found
#Were we intrept test logs into test dicts
def test_parser(string,current_group,current_test_set,current_set_guid,current_sub_set):
test_dict = {
"name": string[2], #FIXME:ACS just the name, SCT has name and Description.
# ACS tests don't follow the same format as the rest of UEFI tests
"name": string[2], #FIXME:Sometimes, SCT has name and Description,
"result": string[1],
"group": current_group,
"test set": current_test_set,
"sub set": current_sub_set,
"set guid": current_set_guid,
"guid": string[0], #FIXME:ACS GUID's overlap... need fix...
"guid": string[0], #FIXME:GUID's overlap... need fix...
#"comment": string[-1], #FIXME:need to hash this out, sometime there is no comments
"log": string
"log":
}
return test_dict["guid"], test_dict
return (test_dict["guid"]+test_dict["set guid"]), test_dict
#Parse the ekl file, and create a map of the tests
def ekl_parser (file):
#create our "database" dict
db_dict = dict()
#db_dict = dict()
db_dict = list()
#All tests are grouped by the "HEAD" line the procedes them.
current_group = "N/A"
current_set = "N/A"
......@@ -49,7 +62,6 @@ def ekl_parser (file):
continue
#The "HEAD" tag is the only indcation we are on a new test set
#i.e.
if split_line[0]=="HEAD":
#split the header into test group and test set.
current_group, current_set = split_line[8].split('\\')
......@@ -64,7 +76,8 @@ def ekl_parser (file):
split_test = [new_string for old_string in split_line for new_string in old_string.split(':')]
#put the test into a dict, and then place that dict in another dict with GUID as key
guid,tmp_dict = test_parser(split_test,current_group,current_set,current_set_guid,current_sub_set)
db_dict[guid]=tmp_dict
#print(guid)
db_dict.append(tmp_dict)
return db_dict
......@@ -113,51 +126,85 @@ def main():
db2 = seq_parser(f)
#cross check is filled only with tests labled as "run" int the seq file
cross_check_dict = dict()
cross_check_dict = list()
#cross_check_dict = list()
#combine a list of test sets that did not run for whatever reason.
would_not_run = []
would_not_run = list()
#would_not_run = dict()
for x in db2: #for each "set guid" in db2
temp_dict = key_value_find(db1,"set guid",x)#find tests in db1 with given set guid
if bool(temp_dict): #if its not empty, apprend it to our dict
cross_check_dict = {**cross_check_dict, **temp_dict}
#list
cross_check_dict = (cross_check_dict +temp_dict)
#dict
#cross_check_dict = {**cross_check_dict, **temp_dict}
else: #if it is empty, this test set was not run.
would_not_run.append(db2[x])
#search for failures and warnings & passes,
failures = key_value_find(cross_check_dict,"result","FAILURE")
warnings = key_value_find(cross_check_dict,"result","WARNING")
passes = key_value_find(cross_check_dict,"result","PASS")
fail_and_warn = {**failures, **warnings}#dict of failures and warnings
#list
fail_and_warn = (failures + warnings)#dict of failures and warnings
#dict
#fail_and_warn = {**failures, **warnings}#dict of failures and warnings
#FIXME:? Do we want CSV and MD.
# generate CSV summary
with open('result.csv', 'w') as csvfile:
result_writer = csv.writer(csvfile, delimiter=',')
result_writer.writerow(['']*9)
result_writer.writerow(["Failures:",len(failures)])
result_writer.writerow(["Warnings:",len(warnings)])
result_writer.writerow(["Pass:",len(passes)])
result_writer.writerow(['']*9)
#If there were any silently dropped, lets print them
# with open('result.csv', 'w') as csvfile:
# result_writer = csv.writer(csvfile, delimiter=',')
# result_writer.writerow(['']*9)
# result_writer.writerow(["Failures:",len(failures)])
# result_writer.writerow(["Warnings:",len(warnings)])
# result_writer.writerow(["Pass:",len(passes)])
# result_writer.writerow(['']*9)
#
# #If there were any silently dropped, lets print them
# if len(would_not_run) > 0:
# result_writer.writerow(["Silently Dropped:"])
# not_run_writer = csv.DictWriter(csvfile, would_not_run[0])
# not_run_writer.writeheader()
# for x in would_not_run:
# not_run_writer.writerow(x)
# result_writer.writerow(['']*9)
#
# #lets print every test that failed or had a wanring. if any did!
# result_writer.writerow(["Fail & Warn tests:"])
# first_guid = fail_and_warn[0]["guid"]
# test_writer = csv.DictWriter(csvfile, fail_and_warn[first_guid])
# test_writer.writeheader()
# for x in fail_and_warn:
# test_writer.writerow(fail_and_warn[x])
# generate MD summary
#TODO: this should be split out into functions, and also "Beautified"
with open('result.md', 'w') as resultfile:
resultfile.write("# SCT Summary \n")
resultfile.write("### Failures:"+str(len(failures))+"\n")
resultfile.write("### Warnings:"+str(len(warnings))+"\n")
resultfile.write("### Passes:"+str(len(passes))+"\n")
resultfile.write("### Dropped:"+str(len(would_not_run))+"\n")
if len(would_not_run) > 0:
result_writer.writerow(["Silently Dropped:"])
not_run_writer = csv.DictWriter(csvfile, would_not_run[0])
not_run_writer.writeheader()
resultfile.write("\n\n# Silently dropped or missing \n")
resultfile.write("|dict| \n")
resultfile.write("|---| \n")
for x in would_not_run:
not_run_writer.writerow(x)
result_writer.writerow(['']*9)
#lets print every test that failed or had a wanring. if any did!
result_writer.writerow(["Fail & Warn tests:"])
first_guid = (list(fail_and_warn.keys())[0])
test_writer = csv.DictWriter(csvfile, fail_and_warn[first_guid])
test_writer.writeheader()
for x in fail_and_warn:
test_writer.writerow(fail_and_warn[x])
resultfile.write("| ")
json.dump(x,resultfile)
resultfile.write(" |\n")
if len(fail_and_warn) > 0:
resultfile.write("\n# Failures & warnings\n")
resultfile.write("|dict| \n")
resultfile.write("|---| \n")
for x in fail_and_warn:
json.dump(x,resultfile)
resultfile.write(" |\n")
#command line argument 3&4, key are to support a key & value search.
#these will be displayed in CLI
if len(sys.argv) >= 5:
......
......@@ -30,18 +30,22 @@ you can use the `test_dict` below to see available keys.
## Notes
### Known Issues:
* "comment" is currently not implemented, as formatting is not currently consistent, should reflect the comments from the test.
* Currently ACS tests have shared GUIDs
* ACS follows different naming convention
* some SCT tests have shared GUIDs, Currently using lists to keep tests from squashing each other.
* some lines in ekl file follow Different naming Conventions
### Need to test
would a concatenation of all `.ekl` logs work?
### Dict structure:
### 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.
* look into repated GUIDs & non test nots within `.ekl` file
* build functions to help better render markdown.
### db structure:
```
tests = {
<guid> : test_dict
<guid2> : test_dict2...
}
tests = [
test_dict,
est_dict2...
]
test_dict = {
"name": "some test",
......
B[Test Case]
#!/bin/bash
find log/ -name '*.ekl' -exec cat {} \; > cat_summary.ekl
###Dict structure:
tests = {
<guid> : test_dict
<guid2> : test_dict2...
}
test_dict = {
"name": "some test",
"result": "pass/fail",
"group": "some group",
"test set": "some set",
"sub set": "some subset",
"set guid": "XXXXXX",
"guid": "XXXXXX",
"comment": "some comment"
"log": "full log output"
}
seqs = {
<guid> : seq_dict
<guid2> : seq_dict2...
}
seq_dict = {
"name": "set name",
"guid": "set guid",
"Iteration": "some hex/num of how many times to run",
"rev": "some hex/numb",
"Order": "some hex/num"
}
\ No newline at end of file
Markdown is supported
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