def do_tests(build, out_file): # make sure we've built stuff print("build = ", build) if build: os.system("./mk.sh") opts = "driver.verbose=0 vis.dovis=0 io.do_io=0".split() tests = [] tests.append(test("advection", "smooth", "inputs.smooth", opts)) tests.append(test("compressible", "quad", "inputs.quad", opts)) tests.append(test("diffusion", "gaussian", "inputs.gaussian", opts)) tests.append(test("incompressible", "shear", "inputs.shear", opts)) tests.append(test("lm_atm", "bubble", "inputs.bubble", opts)) results = {} for t in tests: err = pyro.doit(t.solver, t.problem, t.inputs, other_commands=t.options, comp_bench=True) results[t.solver] = err # standalone tests err = test_mg.test_poisson_dirichlet(256, comp_bench=True, verbose=0) results["mg_poisson_dirichlet"] = err err = test_mg_vc_dirichlet.test_vc_poisson_dirichlet(512, comp_bench=True, verbose=0) results["mg_vc_poisson_dirichlet"] = err err = test_mg_vc_periodic.test_vc_poisson_periodic(512, comp_bench=True, verbose=0) results["mg_vc_poisson_periodic"] = err err = test_mg_general_inhomogeneous.test_general_poisson_inhomogeneous(512, comp_bench=True, verbose=0) results["mg_general_poisson_inhomogeneous"] = err failed = 0 out = [sys.stdout] if not out_file == None: out.append(open(out_file, "w")) for f in out: f.write("pyro tests run: {}\n\n".format(str(datetime.datetime.now().replace(microsecond=0)))) for s, r in sorted(results.items()): if not r == 0: f.write("{:32} failed\n".format(s)) failed += 1 else: f.write("{:32} passed\n".format(s)) f.write("\n{} test(s) failed\n".format(failed)) if not f == sys.stdout: f.close()
def do_tests(build, out_file, do_standalone=True, do_main=True, reset_fails=False, store_all_benchmarks=False, single=None, solver=None): # make sure we've built stuff print("build = ", build) if build: os.system("./mk.sh") opts = "driver.verbose=0 vis.dovis=0 io.do_io=0".split() results = {} if do_main: tests = [] tests.append(PyroTest("advection", "smooth", "inputs.smooth", opts)) tests.append(PyroTest("advection_rk", "smooth", "inputs.smooth", opts)) tests.append(PyroTest("compressible", "quad", "inputs.quad", opts)) tests.append(PyroTest("compressible", "sod", "inputs.sod.x", opts)) tests.append(PyroTest("compressible", "rt", "inputs.rt", opts)) tests.append(PyroTest("compressible_rk", "rt", "inputs.rt", opts)) tests.append(PyroTest("diffusion", "gaussian", "inputs.gaussian", opts)) tests.append(PyroTest("incompressible", "shear", "inputs.shear", opts)) tests.append(PyroTest("lm_atm", "bubble", "inputs.bubble", opts)) if single is not None: tests_to_run = [q for q in tests if str(q) == single] elif solver is not None: tests_to_run = [q for q in tests if q.solver == solver] else: tests_to_run = tests for t in tests_to_run: err = pyro.doit(t.solver, t.problem, t.inputs, other_commands=t.options, comp_bench=True, reset_bench_on_fail=reset_fails, make_bench=store_all_benchmarks) results[str(t)] = err # standalone tests if do_standalone and single is None: err = mg_test_simple.test_poisson_dirichlet(256, comp_bench=True, store_bench=store_all_benchmarks, verbose=0) results["mg_poisson_dirichlet"] = err err = mg_test_vc_dirichlet.test_vc_poisson_dirichlet(512, comp_bench=True, store_bench=store_all_benchmarks, verbose=0) results["mg_vc_poisson_dirichlet"] = err err = mg_test_vc_periodic.test_vc_poisson_periodic(512, comp_bench=True, store_bench=store_all_benchmarks, verbose=0) results["mg_vc_poisson_periodic"] = err err = mg_test_general_inhomogeneous.test_general_poisson_inhomogeneous(512, comp_bench=True, store_bench=store_all_benchmarks, verbose=0) results["mg_general_poisson_inhomogeneous"] = err failed = 0 out = [sys.stdout] if not out_file == None: out.append(open(out_file, "w")) for f in out: f.write("pyro tests run: {}\n\n".format(str(datetime.datetime.now().replace(microsecond=0)))) for s, r in sorted(results.items()): if not r == 0: f.write("{:42} failed\n".format(s)) failed += 1 else: f.write("{:42} passed\n".format(s)) f.write("\n{} test(s) failed\n".format(failed)) if not f == sys.stdout: f.close()