Add eclair scripts
copy these scripts from ci/tf-ci-scripts
Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I555cb85bcb207d247d84e06fcd47d22e55b4ac10
diff --git a/eclair/eclair_diff_report.py b/eclair/eclair_diff_report.py
new file mode 100755
index 0000000..ef3c208
--- /dev/null
+++ b/eclair/eclair_diff_report.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2022 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+# Script to produce cumulative "diff" report from ECLAIR individual
+# per-service diff reports.
+
+import sys
+import glob
+import os
+from string import Template
+
+
+def lcut(l, prefix):
+ if l.startswith(prefix):
+ l = l[len(prefix):]
+ return l
+
+
+def process_file(fname, del_or_add):
+ with open(fname) as f:
+ for l in f:
+ l = l.rstrip()
+ if not l:
+ break
+ for l in f:
+ if l.startswith("service "):
+ l = lcut(l, "service ")
+ if del_or_add == "del":
+ l = "Resolved for " + l
+ else:
+ l = "Added for " + l
+ elif l.startswith("End of report"):
+ l = "---------------\n"
+ sys.stdout.write(l)
+
+
+path = "."
+if len(sys.argv) > 1:
+ path = sys.argv[1]
+
+files = sorted(glob.glob(path + "/*.etr"))
+#print(files)
+
+EMPTY_REPORT_HEADER = Template("""\
+No new MISRA issues detected, good work!
+${BUILD_URL}artifact/
+""").safe_substitute(os.environ)
+
+NONEMPTY_REPORT_HEADER = Template("""\
+MISRA delta report: ${BUILD_URL}artifact/
+
+= MISRA delta report for the patch (issues resolved and/or newly added) =
+""").safe_substitute(os.environ)
+
+header_done = False
+
+for f in files:
+ if "/B.EXPLAIN" in f:
+ continue
+ comp = f.rsplit(".", 2)
+# print("*", f, comp)
+ if not header_done:
+ print(NONEMPTY_REPORT_HEADER)
+ header_done = True
+ process_file(f, comp[-2])
+
+if not header_done:
+ print(EMPTY_REPORT_HEADER)