Repository navigation
Expand file tree
/
Copy pathtesting.py
More file actions
78 lines (63 loc) · 2.46 KB
/
Copy pathtesting.py
File metadata and controls
78 lines (63 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import sys
import argparse
import os
import copy
import subprocess
import string
sys.path.insert(0, '../pythonutil')
from config import *
from util import *
# Define the command line arguments
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--case', help='name of test case', default='peaks')
parser.add_argument('-ml', '--maxlevels', type=int, nargs='+', help='braid_maxlevels to be tested', default=[1,10])
parser.add_argument('-npt', '--nprocs', type=int, nargs='+', help='number of processors to be tested', default=[1,2,5])
# Parse command line arguments
args = parser.parse_args()
case = args.case
nptlist = args.nprocs
braid_maxlevelslist = args.maxlevels
print("Testing case \"" + case + "\", npt=" + str(nptlist) + ", braid_maxlevels=" + str(braid_maxlevelslist))
# Specify the output file to compare
outfile = "optim.dat"
# Get the global config file
config = Config(case + ".cfg")
# Iterate over configuration
for j,ml in enumerate(braid_maxlevelslist):
# Iterate over number of processors
for i,npt in enumerate(nptlist):
# Set the test case name
testname = case + ".npt" + str(npt) + ".ml" + str(ml)
# Create testing folder
testfoldername = "test." + testname
if os.path.exists(testfoldername):
pass
else:
os.mkdir(testfoldername)
# create a link to training and validation data
datafolder = config.datafolder
make_link(datafolder, testfoldername + "/data" )
# Set the new configuration
konfig = copy.deepcopy(config)
konfig.braid_maxlevels = ml
konfig.datafolder = "data"
# create the config file
testconfig = testname + ".cfg"
konfig.dump(testfoldername + "/" + testconfig)
# run the test
os.chdir(testfoldername)
runcommand = "mpirun -n " + str(npt) + " ../../main " + testconfig + " > tmp"
print("Running Test: " + testname)
#print(" " + runcommand)
subprocess.call(runcommand, shell=True)
os.chdir("../")
# compare output file to the reference
refname = testname + "." + outfile
err = comparefiles(refname, testfoldername + "/" + outfile)
# Print result
if (err > 0):
print(" !!! Test failed !!!")
print(" vimdiff " + refname + " " + testfoldername + "/" + outfile)
else:
print(" Test passed!")