From 964cd37622d7a3056fda35875306c38b8d9422ee Mon Sep 17 00:00:00 2001 From: Nathan Pemberton Date: Fri, 28 Dec 2018 23:26:58 +0000 Subject: [PATCH] Better error messages for build and launch. Make post_run_hook a full config option and fix it to install properly. --- sw_manager.py | 23 ++++++++++++++++------- wlutil/config.py | 4 ++-- wlutil/install.py | 1 + wlutil/launch.py | 3 +-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/sw_manager.py b/sw_manager.py index 5b5f2358..1ba8865b 100755 --- a/sw_manager.py +++ b/sw_manager.py @@ -86,11 +86,15 @@ def main(): j['initramfs'] = True if args.command == "build": - if args.binOnly or args.imgOnly: - # It's fine if they pass -IB, it just builds both - wlutil.buildWorkload(cfgPath, cfgs, buildBin=args.binOnly, buildImg=args.imgOnly) - else: - wlutil.buildWorkload(cfgPath, cfgs) + try: + if args.binOnly or args.imgOnly: + # It's fine if they pass -IB, it just builds both + wlutil.buildWorkload(cfgPath, cfgs, buildBin=args.binOnly, buildImg=args.imgOnly) + else: + wlutil.buildWorkload(cfgPath, cfgs) + except Exception as e: + log.error("Error while building workload: ") + log.error(str(e)) elif args.command == "launch": # job-configs are named special internally @@ -100,8 +104,13 @@ def main(): else: log.error("Job " + args.job + " requested, but no jobs specified in config file\n") parser.print_help() - - wlutil.launchWorkload(cfgPath, cfgs, args.job, args.spike) + + try: + wlutil.launchWorkload(cfgPath, cfgs, args.job, args.spike) + except Exception as e: + log.error("Failed to launch workload:") + log.error(str(e)) + elif args.command == "test": skipCount = 0 failCount = 0 diff --git a/wlutil/config.py b/wlutil/config.py index f2eadf6a..10d22a8e 100644 --- a/wlutil/config.py +++ b/wlutil/config.py @@ -65,11 +65,11 @@ # These are the user-defined options that should be converted to absolute # paths (from workload-relative). Derived options are already absolute. -configToAbs = ['guest-init', 'run', 'overlay', 'linux-src', 'linux-config', 'host-init', 'cfg-file', 'bin', 'img', 'spike'] +configToAbs = ['guest-init', 'run', 'overlay', 'linux-src', 'linux-config', 'host-init', 'cfg-file', 'bin', 'img', 'spike', 'post_run_hook'] # These are the options that should be inherited from base configs (if not # explicitly provided) -configInherit = ['runSpec', 'files', 'outputs', 'linux-src', 'linux-config', 'builder', 'distro', 'spike', 'launch', 'bin'] +configInherit = ['runSpec', 'files', 'outputs', 'linux-src', 'linux-config', 'builder', 'distro', 'spike', 'launch', 'bin', 'post_run_hook'] # These are the permissible base-distributions to use (they get treated special) distros = { diff --git a/wlutil/install.py b/wlutil/install.py index cda21d74..6649ad3a 100644 --- a/wlutil/install.py +++ b/wlutil/install.py @@ -39,6 +39,7 @@ def installWorkload(cfgName, cfgs): } if 'post_run_hook' in targetCfg: + print("post_run_hook: " + targetCfg['post_run_hook']) fsCfg["post_run_hook"] = fullRel(fsTargetDir, targetCfg['post_run_hook']) if 'jobs' in targetCfg: diff --git a/wlutil/launch.py b/wlutil/launch.py index 057ec547..0fc10f26 100644 --- a/wlutil/launch.py +++ b/wlutil/launch.py @@ -86,8 +86,7 @@ def launchWorkload(cfgName, cfgs, job='all', spike=False): try: run(config['post_run_hook'] + " " + baseResDir, cwd=config['workdir'], shell=True) except sp.CalledProcessError as e: - log.error("Post run hook failed:") - log.error(e.output) + raise RuntimeError("Post run hook failed:\n" + e.output) log.info("\nRun output available in: " + os.path.dirname(runResDir)) else: