@@ -42,94 +42,98 @@ def main():
script_path = os.path.realpath(__file__)
test_dir = os.path.dirname(script_path)
- if args.stdout:
- BRConfigTest.logtofile = False
-
- if args.list:
- print("List of tests")
- nose2.discover(argv=[script_path,
- "-s", test_dir,
- "-v",
- "--collect-only"],
- plugins=["nose2.plugins.collect"])
- return 0
-
- if args.download is None:
- args.download = os.getenv("BR2_DL_DIR")
+ try:
+ if args.stdout:
+ BRConfigTest.logtofile = False
+
+ if args.list:
+ print("List of tests")
+ nose2.discover(argv=[script_path,
+ "-s", test_dir,
+ "-v",
+ "--collect-only"],
+ plugins=["nose2.plugins.collect"])
+ return 0
+
if args.download is None:
- print("Missing download directory, please use -d/--download")
+ args.download = os.getenv("BR2_DL_DIR")
+ if args.download is None:
+ print("Missing download directory, please use -d/--download")
+ print("")
+ parser.print_help()
+ return 1
+
+ BRConfigTest.downloaddir = os.path.abspath(args.download)
+
+ if args.prepare_only:
+ emulator_builtin_binaries = ["kernel-vexpress-5.10.202",
+ "vexpress-v2p-ca9-5.10.202.dtb",
+ "kernel-versatile-5.10.202",
+ "versatile-pb-5.10.202.dtb"]
+ print("Downloading emulator builtin binaries")
+ for binary in emulator_builtin_binaries:
+ infra.download(BRConfigTest.downloaddir, binary)
+ return 0
+
+ if args.output is None:
+ print("Missing output directory, please use -o/--output")
print("")
parser.print_help()
return 1
- BRConfigTest.downloaddir = os.path.abspath(args.download)
-
- if args.prepare_only:
- emulator_builtin_binaries = ["kernel-vexpress-5.10.202",
- "vexpress-v2p-ca9-5.10.202.dtb",
- "kernel-versatile-5.10.202",
- "versatile-pb-5.10.202.dtb"]
- print("Downloading emulator builtin binaries")
- for binary in emulator_builtin_binaries:
- infra.download(BRConfigTest.downloaddir, binary)
- return 0
-
- if args.output is None:
- print("Missing output directory, please use -o/--output")
- print("")
- parser.print_help()
- return 1
-
- if not os.path.exists(args.output):
- os.mkdir(args.output)
+ if not os.path.exists(args.output):
+ os.mkdir(args.output)
- BRConfigTest.outputdir = os.path.abspath(args.output)
+ BRConfigTest.outputdir = os.path.abspath(args.output)
- if args.all is False and not args.testname:
- print("No test selected")
- print("")
- parser.print_help()
- return 1
-
- BRConfigTest.keepbuilds = args.keep
-
- if args.testcases != 1:
- if args.testcases < 1:
- print("Invalid number of testcases to run simultaneously")
+ if args.all is False and not args.testname:
+ print("No test selected")
print("")
parser.print_help()
return 1
- # same default BR2_JLEVEL as package/Makefile.in
- br2_jlevel = 1 + multiprocessing.cpu_count()
- each_testcase = int((br2_jlevel + args.testcases) / args.testcases)
- BRConfigTest.jlevel = each_testcase
-
- if args.jlevel:
- if args.jlevel < 0:
- print("Invalid BR2_JLEVEL to use for each testcase")
+
+ BRConfigTest.keepbuilds = args.keep
+
+ if args.testcases != 1:
+ if args.testcases < 1:
+ print("Invalid number of testcases to run simultaneously")
+ print("")
+ parser.print_help()
+ return 1
+ # same default BR2_JLEVEL as package/Makefile.in
+ br2_jlevel = 1 + multiprocessing.cpu_count()
+ each_testcase = int((br2_jlevel + args.testcases) / args.testcases)
+ BRConfigTest.jlevel = each_testcase
+
+ if args.jlevel:
+ if args.jlevel < 0:
+ print("Invalid BR2_JLEVEL to use for each testcase")
+ print("")
+ parser.print_help()
+ return 1
+ # the user can override the auto calculated value
+ BRConfigTest.jlevel = args.jlevel
+
+ if args.timeout_multiplier < 1:
+ print("Invalid multiplier for timeout values")
print("")
parser.print_help()
return 1
- # the user can override the auto calculated value
- BRConfigTest.jlevel = args.jlevel
-
- if args.timeout_multiplier < 1:
- print("Invalid multiplier for timeout values")
- print("")
- parser.print_help()
- return 1
- BRConfigTest.timeout_multiplier = args.timeout_multiplier
+ BRConfigTest.timeout_multiplier = args.timeout_multiplier
- nose2_args = ["-v",
- "-N", str(args.testcases),
- "-s", test_dir,
- "-c", os.path.join(test_dir, "conf/unittest.cfg")]
+ nose2_args = ["-v",
+ "-N", str(args.testcases),
+ "-s", test_dir,
+ "-c", os.path.join(test_dir, "conf/unittest.cfg")]
- if args.testname:
- nose2_args += args.testname
+ if args.testname:
+ nose2_args += args.testname
- nose2.discover(argv=nose2_args)
+ nose2.discover(argv=nose2_args)
+ finally:
+ # Placeholder for try, to be undone shortly
+ pass
if __name__ == "__main__":
sys.exit(main())
Cleanup code for try/finally is necessary for a separate patch. Utilize a separate patch to add a try block so that the other patches that actually will change the behavior are much more reviewable. Signed-off-by: Colin Foster <colin.foster@in-advantage.com> --- v2: New patch, broken out for reviewability --- support/testing/run-tests | 146 ++++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 71 deletions(-)