tools: Enhance reference to robot.result.statistics critical tag

Change reporting tool to handle deprecated critical tag in updated v4.0+ robotframework.

- Patchset #1: initial commit.
- Patchset #2: change to total testcase count and Non-Critical test message.

Test:
- Change was tested with
Robot Framework 3.0.4 (Python 3.8.10 on linux)
Robot Framework 4.1.1 (Python 3.8.10 on linux)

Signed-off-by: Peter D  Phan <peterp@us.ibm.com>
Change-Id: I64a7f738c1ceaa8ac627854add4e2b1259de76df
diff --git a/tools/ct_metrics/gen_csv_results.py b/tools/ct_metrics/gen_csv_results.py
index eca4301..78b323d 100755
--- a/tools/ct_metrics/gen_csv_results.py
+++ b/tools/ct_metrics/gen_csv_results.py
@@ -165,16 +165,40 @@
                                     (e.g. "Master").
     """
 
+    # Initialize tallies
+    total_critical_tc = 0
+    total_critical_passed = 0
+    total_critical_failed = 0
+    total_non_critical_tc = 0
+    total_non_critical_passed = 0
+    total_non_critical_failed = 0
+
     result = ExecutionResult(xml_file_path)
     result.configure(stat_config={'suite_stat_level': 2,
                                   'tag_stat_combine': 'tagANDanother'})
 
     stats = result.statistics
     print("--------------------------------------")
-    total_tc = stats.total.critical.passed + stats.total.critical.failed
-    print("Total Test Count:\t %d" % total_tc)
-    print("Total Test Failed:\t %d" % stats.total.critical.failed)
-    print("Total Test Passed:\t %d" % stats.total.critical.passed)
+    try:
+        total_critical_tc = stats.total.critical.passed + stats.total.critical.failed
+        total_critical_passed = stats.total.critical.passed
+        total_critical_failed = stats.total.critical.failed
+    except AttributeError:
+        pass
+
+    try:
+        total_non_critical_tc = stats.total.passed + stats.total.failed
+        total_non_critical_passed = stats.total.passed
+        total_non_critical_failed = stats.total.failed
+    except AttributeError:
+        pass
+
+    print("Total Test Count:\t %d" % (total_non_critical_tc + total_critical_tc))
+
+    print("Total Critical Test Failed:\t %d" % total_critical_failed)
+    print("Total Critical Test Passed:\t %d" % total_critical_passed)
+    print("Total Non-Critical Test Failed:\t %d" % total_non_critical_failed)
+    print("Total Non-Critical Test Passed:\t %d" % total_non_critical_passed)
     print("Test Start Time:\t %s" % result.suite.starttime)
     print("Test End Time:\t\t %s" % result.suite.endtime)
     print("--------------------------------------")