[dvsim] Replaced dicts with OrderedDicts
- Fixes #1478
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/util/dvsim/Deploy.py b/util/dvsim/Deploy.py
index e61e687..7ec8494 100644
--- a/util/dvsim/Deploy.py
+++ b/util/dvsim/Deploy.py
@@ -12,6 +12,7 @@
import shlex
import sys
import time
+from collections import OrderedDict
import hjson
from tabulate import tabulate
@@ -231,7 +232,7 @@
" | awk '{print $2}'")
rm_dirs = rm_dirs.replace('\n', ' ')
dirs = dirs.replace(rm_dirs, "")
- os.system("/usr/bin/rm -rf " + rm_dirs)
+ os.system("/bin/rm -rf " + rm_dirs)
except IOError:
log.error("Failed to delete old run directories!")
return dirs
@@ -328,7 +329,7 @@
return "%02i:%02i:%02i" % (hh, mm, ss)
def dispatch_items(items):
- item_names = {}
+ item_names = OrderedDict()
for item in items:
if item.target not in item_names.keys():
item_names[item.target] = ""
@@ -346,7 +347,7 @@
all_done = True
for target in status.keys():
if "target_done" in status[target].keys(): continue
- stats = {}
+ stats = OrderedDict()
stats["Q"] = 0
stats["D"] = 0
stats["P"] = 0
@@ -372,14 +373,14 @@
return all_done
all_done = False
- status = {}
+ status = OrderedDict()
print_status_flag = True
# Queue all items
queued_items.extend(items)
for item in queued_items:
if item.target not in status.keys():
- status[item.target] = {}
+ status[item.target] = OrderedDict()
status[item.target][item] = "Q"
while not all_done:
@@ -403,7 +404,7 @@
queued_items.extend(item.sub)
for sub_item in item.sub:
if sub_item.target not in status.keys():
- status[sub_item.target] = {}
+ status[sub_item.target] = OrderedDict()
status[sub_item.target][sub_item] = "Q"
status[item.target][item] = item.status
@@ -615,7 +616,7 @@
if os.path.exists(self.cov_db_test_dir):
log.log(VERBOSE, "Deleting coverage data of failing test:\n%s",
self.cov_db_test_dir)
- os.system("/usr/bin/rm -rf " + self.cov_db_test_dir)
+ os.system("/bin/rm -rf " + self.cov_db_test_dir)
@staticmethod
def get_seed():
diff --git a/util/dvsim/OneShotCfg.py b/util/dvsim/OneShotCfg.py
index a4d94fc..28a8887 100644
--- a/util/dvsim/OneShotCfg.py
+++ b/util/dvsim/OneShotCfg.py
@@ -7,6 +7,7 @@
import logging as log
import sys
+from collections import OrderedDict
from Deploy import *
from FlowCfg import FlowCfg
@@ -52,8 +53,8 @@
self.regressions = []
# Flow results
- self.result = {}
- self.result_summary = {}
+ self.result = OrderedDict()
+ self.result_summary = OrderedDict()
self.dry_run = args.dry_run
diff --git a/util/dvsim/SimCfg.py b/util/dvsim/SimCfg.py
index e0d04a5..c70c075 100644
--- a/util/dvsim/SimCfg.py
+++ b/util/dvsim/SimCfg.py
@@ -7,6 +7,7 @@
import logging as log
import sys
+from collections import OrderedDict
from testplanner import class_defs, testplan_utils
@@ -94,7 +95,7 @@
self.deploy = []
self.cov_merge_deploy = None
self.cov_report_deploy = None
- self.results_summary = {}
+ self.results_summary = OrderedDict()
# If is_master_cfg is set, then each cfg will have its own cov_deploy.
# Maintain an array of those in cov_deploys.
@@ -504,6 +505,8 @@
results_str += self.cov_report_deploy.cov_results
self.results_summary[
"Coverage"] = self.cov_report_deploy.cov_total
+ else:
+ self.results_summary["Coverage"] = "--"
# append link of detail result to block name
self.results_summary["Name"] = self._get_results_page_link(
@@ -534,7 +537,8 @@
row = []
for title in item.results_summary:
row.append(item.results_summary[title])
- if row != []: table.append(row)
+ if row == []: continue
+ table.append(row)
self.results_summary_md = "## " + self.results_title + " (Summary)\n"
self.results_summary_md += "### " + self.timestamp_long + "\n"
self.results_summary_md += tabulate(table,
diff --git a/util/dvsim/testplanner/class_defs.py b/util/dvsim/testplanner/class_defs.py
index b7a2522..a7c9eed 100644
--- a/util/dvsim/testplanner/class_defs.py
+++ b/util/dvsim/testplanner/class_defs.py
@@ -6,6 +6,7 @@
import re
import sys
+from collections import OrderedDict
import mistletoe
from tabulate import tabulate
@@ -161,7 +162,7 @@
def __init__(self, name):
self.name = name
self.entries = []
- self.results_summary = {}
+ self.results_summary = OrderedDict()
self.results = ""
if name == "":