[dvsim] Fix regression publish result link with --remote switch
If we use `--remote` switch, the result summary path is not correct.
This is because to remove the root directory and get `rel_path` in
FlowCfg, we used
```
if self.rel_path == "":
self.rel_path = os.path.dirname(self.flow_cfg_file).replace(
self.proj_root + '/', '')
```
For this one, if remote switch is on, the self.proj_root is remote
repo_top. However, `self.flow_cfg_file` still uses the local abs path,
so the rel_path ended up still include the absolute path.
This PR fixed it by using the remote `cfg_path` if --remote is turned
on.
Signed-off-by: Cindy Chen <chencindy@google.com>
diff --git a/util/dvsim/dvsim.py b/util/dvsim/dvsim.py
index a54b677..b0a8f4d 100755
--- a/util/dvsim/dvsim.py
+++ b/util/dvsim/dvsim.py
@@ -162,22 +162,25 @@
proj_root is discovered using get_proj_root() method, unless the user
overrides it on the command line.
- This function returns the updated proj_root path.
+ This function returns the updated proj_root src and destination path. If
+ --remote env var is not set, the destination path is identical to the src path.
'''
- proj_root = args.proj_root or get_proj_root()
+ proj_root_src = args.proj_root or get_proj_root()
# Check if jobs are dispatched to external compute machines. If yes,
# then the repo needs to be copied over to the scratch area
# accessible to those machines.
# If --purge arg is set, then purge the repo_top that was copied before.
if args.remote:
- dest = os.path.join(args.scratch_root, args.branch, "repo_top")
- if args.purge and os.path.exists(dest):
- shutil.rmtree(dest)
- copy_repo(proj_root, dest, args.dry_run)
- proj_root = dest
+ proj_root_dest = os.path.join(args.scratch_root, args.branch,
+ "repo_top")
+ if args.purge and os.path.exists(proj_root_dest):
+ shutil.rmtree(proj_root_dest)
+ copy_repo(proj_root_src, proj_root_dest, args.dry_run)
+ else:
+ proj_root_dest = proj_root_src
- return proj_root
+ return proj_root_src, proj_root_dest
def sigint_handler(signal_received, frame):
@@ -601,10 +604,14 @@
args.scratch_root = resolve_scratch_root(args.scratch_root)
args.branch = resolve_branch(args.branch)
- args.cfg = os.path.abspath(args.cfg)
- proj_root = resolve_proj_root(args)
+ proj_root_src, proj_root = resolve_proj_root(args)
log.info("[proj_root]: %s", proj_root)
+ args.cfg = os.path.abspath(args.cfg)
+ if args.remote:
+ cfg_path = args.cfg.replace(proj_root_src + "/", "")
+ args.cfg = os.path.join(proj_root, cfg_path)
+
# Add timestamp to args that all downstream objects can use.
# Static variables - indicate timestamp.
ts_format_long = "%A %B %d %Y %I:%M:%S%p UTC"