[dvsim] Fix --cov + --build|run-only bugs
The `SimCfg` prunes the number of builds if there is no uniqueness among
the existing build objects. If a simulation is rerun with --run-only
switch (the assumption here being there is no need to rebuild the
simulation executables since the source code did not change), with the
old code, the build pruning is not performed, causing the tests to
reference non-existent builds and fail. This commit fixes that issue.
If `--cov --build-only` is passed on the command line (with the intent
to pass `--cov --run-only` later), builds get prematurely pruned out
because we turn off the coverage switch. This prevents us from doing
`--cov --build-only` and `--cov --run-only` as two separate steps.
Also, the coverage table and summary table end up throwing errors. This
change fixes that.
In addition, the `--cov-merge-previous` was also broken (appending Path
vars instead of str). The `odir_limiter` also has a minor fix such that
if `odir` does not exist, it still prunes and returns the old dirs.
The cov merge task also needed information from the builds, which do not
exist if `--run-only` switch is passed. The CovMerge code is updated to
seek the same information from runs instead.
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/util/dvsim/Deploy.py b/util/dvsim/Deploy.py
index 7ed1e01..0d2b55a 100644
--- a/util/dvsim/Deploy.py
+++ b/util/dvsim/Deploy.py
@@ -287,16 +287,17 @@
remain after deletion.
"""
- if not os.path.exists(odir):
- return []
-
- # If output directory exists, back it up.
- ts = datetime.fromtimestamp(os.stat(odir).st_ctime)
- ts = ts.strftime(self.sim_cfg.ts_format)
- shutil.move(odir, odir + "_" + ts)
+ if os.path.exists(odir):
+ # If output directory exists, back it up.
+ ts = datetime.fromtimestamp(os.stat(odir).st_ctime)
+ ts = ts.strftime(self.sim_cfg.ts_format)
+ shutil.move(odir, odir + "_" + ts)
# Get list of past output directories sorted by creation time.
pdir = Path(odir).resolve().parent
+ if not pdir.exists():
+ return []
+
dirs = sorted([old for old in pdir.iterdir() if old.is_dir()],
key=os.path.getctime,
reverse=True)
@@ -643,6 +644,7 @@
self.mandatory_misc_attrs.update({
"run_dir_name": False,
+ "cov_db_dir": False,
"cov_db_test_dir": False,
"run_pass_patterns": False,
"run_fail_patterns": False
@@ -797,9 +799,11 @@
CovMerge.items.append(self)
def __post_init__(self):
- # Add cov db dirs from all the builds that were kicked off.
- for bld in self.sim_cfg.builds:
- self.cov_db_dirs += bld.cov_db_dir + " "
+ # Extract cov db dirs from all the sim runs.
+ for item in self.dependencies:
+ if item.target == "run":
+ if item.cov_db_dir not in self.cov_db_dirs:
+ self.cov_db_dirs += item.cov_db_dir + " "
# Recursively search and replace wildcards, ignoring cov_db_dirs.
# We need to resolve it later based on cov_db_dirs value set below.
@@ -829,7 +833,8 @@
# that as well for merging, if the --cov-merge-previous command line
# switch is passed.
if self.sim_cfg.cov_merge_previous:
- self.cov_db_dirs += prev_cov_db_dirs
+ self.cov_db_dirs += " ".join(
+ [str(item) for item in prev_cov_db_dirs])
# Append cov_db_dirs to the list of exports.
self.exports["cov_db_dirs"] = "\"{}\"".format(self.cov_db_dirs)