diff --git a/README.md b/README.md
index 847c8f59c353c52ba9bb3101af06b0a7060dc4d6..dfc6fb99336f2bca1c405b66e2ef46779692d3e3 100644
--- a/README.md
+++ b/README.md
@@ -16,8 +16,8 @@ command. The parsed report can be found in `result.md`.
``` {.sh}
$ ./parser.py --config EBBR.yaml \
- \
-
+ \
+
INFO apply_rules: Updated 200 test(s) out of 12206 after applying 124 rule(s)
INFO main: 0 dropped(s), 1 failure(s), 93 ignored(s), 106 known u-boot limitation(s), 12006 pass(s), 0 warning(s)
```
@@ -265,13 +265,29 @@ override the result of some tests with the following ones:
filesystem implementation limitations and they do
not prevent an OS to boot.
- `KNOWN ACS LIMITATION` Genuine bugs, which are fixed in a more recent version
- of the ACS or which must ultimately be fixed and which
- we know about.
+ `KNOWN ACS LIMITATION` Genuine bugs, which are fixed in a more recent
+ version of the ACS or which must ultimately be fixed
+ and which we know about.
-------------------------------------------------------------------------------
Some of the rules just add a `comments` field with some help text.
+### Database of sequence files
+
+The `seq.db` file contains a list of known sequence files, which allows to
+identify the input sequence file.
+
+This database file contains lines describing each known sequence file in turn,
+in the following format:
+
+```
+sha256 description
+```
+
+Everything appearing after a '#' sign is treated as a comment and ignored.
+
+The database filename can be specified with the `--seq-db` option.
+
## Notes
### Known Issues:
* "comment" is currently not implemented, as formatting is not currently consistent, should reflect the comments from the test.
diff --git a/parser.py b/parser.py
index dc2da208ca57f36c6b14e7381d7d516dbf843744..4c8dba83d095ad7a9e30540bc3cd0e4bbffa233b 100755
--- a/parser.py
+++ b/parser.py
@@ -8,6 +8,8 @@ import csv
import logging
import json
import re
+import hashlib
+import os
try:
from packaging import version
@@ -504,26 +506,29 @@ def gen_template(cross_check, filename):
def do_print(cross_check, fields):
logging.debug(f'Print (fields: {fields})')
- # First pass to find the width for each field except the last one
- fm1 = fields[:len(fields) - 1]
+ # First pass to find the width for each field
w = {}
- for f in fm1:
+ for f in fields:
w[f] = len(f)
for x in cross_check:
- for f in fm1:
+ for f in fields:
w[f] = max(w[f], len(str(x[f]) if f in x else ''))
# Second pass where we print
+ fm1 = fields[:len(fields) - 1]
lf = fields[len(fields) - 1]
+ sep = ' '
+
+ print(sep.join([
+ *map(lambda f: f"{f.capitalize():{w[f]}}", fm1),
+ lf.capitalize()]))
- print(' '.join([
- *map(lambda f: f"{f:{w[f]}}", fm1),
- lf]))
+ print(sep.join([*map(lambda f: '-' * w[f], fields)]))
for x in cross_check:
- print(' '.join([
+ print(sep.join([
*map(lambda f: f"{x[f] if f in x else '':{w[f]}}", fm1),
x[lf] if lf in x else '']))
@@ -597,6 +602,50 @@ def combine_dbs(db1, db2):
return cross_check
+# Load the database of known sequence files.
+def load_known_seq(seq_db):
+ known_seqs = {}
+
+ with open(seq_db, 'r') as f:
+ for line in f:
+ line = line.rstrip()
+ line = re.sub(r'#.*', '', line)
+ m = re.match(r'\s*([0-9a-fA-F]+)\s+(.*)', line)
+
+ if not m:
+ continue
+
+ kh = m.group(1)
+ d = m.group(2)
+ assert(kh not in known_seqs)
+ logging.debug(f'{kh} {d}')
+ known_seqs[kh] = d
+
+ logging.debug(f'{len(known_seqs)} known seq file(s)')
+ return known_seqs
+
+
+# Try to identify the .seq file in a list of known versions using its sha256.
+def ident_seq(seq_file, seq_db):
+ known_seqs = load_known_seq(seq_db)
+
+ # Hash seq file
+ hm = 'sha256'
+ hl = hashlib.new(hm)
+
+ with open(seq_file, 'rb') as f:
+ hl.update(f.read())
+
+ h = hl.hexdigest()
+ logging.debug(f'{hm} {h} {seq_file}')
+
+ # Try to identify the seq file
+ if h in known_seqs:
+ logging.info(f"""Identified `{seq_file}' as "{known_seqs[h]}".""")
+ else:
+ logging.debug(f"Could not identify `{seq_file}'...")
+
+
# Read the .ekl log file and the .seq file and combine them into a single
# database, which we return.
def read_log_and_seq(log_file, seq_file):
@@ -714,6 +763,8 @@ def read_md(input_md):
if __name__ == '__main__':
+ me = os.path.realpath(__file__)
+ here = os.path.dirname(me)
parser = argparse.ArgumentParser(
description='Process SCT results.'
' This program takes the SCT summary and sequence files,'
@@ -740,6 +791,9 @@ if __name__ == '__main__':
parser.add_argument(
'--print', action='store_true', help='Print results to stdout')
parser.add_argument('--input-md', help='Input .md filename')
+ parser.add_argument(
+ '--seq-db', help='Known sequence files database filename',
+ default=f'{here}/seq.db')
parser.add_argument('log_file', help='Input .ekl filename')
parser.add_argument('seq_file', help='Input .seq filename')
parser.add_argument('find_key', nargs='?', help='Search key')
@@ -765,6 +819,10 @@ if __name__ == '__main__':
else:
# Command line argument 1 is the ekl file to open.
# Command line argument 2 is the seq file to open.
+
+ # Try to identify the sequence file
+ ident_seq(args.seq_file, args.seq_db)
+
# Read both and combine them into a single cross_check database.
cross_check = read_log_and_seq(args.log_file, args.seq_file)
diff --git a/seq.db b/seq.db
new file mode 100644
index 0000000000000000000000000000000000000000..1a1fe9093d984f75a260c83f0346eb47b458445b
--- /dev/null
+++ b/seq.db
@@ -0,0 +1,7 @@
+# List of known sequence files and their sha256
+6a381192057c511b2b69282c58d6107c1daeaf0b95038605d4c58383eb5cc88b Test sample.seq
+6ae5a92f0b83b3a1469c89f6a02b0771ae3818a424e7118a28bba053be394078 Supplied SBBR.seq
+6b83dbfbd1f07fc61a918297f02f449591a72131b64ac746f969a4210f97aee8 ACS-IR v21.05_0.8_BETA-0 EBBR.seq
+c06684b3f8b35871e37b9447f609f9aab6070a7ca1c4ba63a52e029c018c9b73 ACS-IR v21.07_0.9_BETA EBBR.seq
+ec730fd81eada415278b39533fe7cc21147b39183447dc11fa77ad4419d13969 Supplied EBBR.seq
+f7793d53c10106c1c275a4992e1710ce9863e210dd07581a3d783c4f4cf2312b ACS-IR v21.07_0.9_BETA EBBR_manual.seq