Merge lp:~jon-hill/fluidity/longtest_fix into lp:fluidity

Proposed by Jon Hill
Status: Merged
Merged at revision: 4153
Proposed branch: lp:~jon-hill/fluidity/longtest_fix
Merge into: lp:fluidity
Diff against target: 136 lines (+33/-9)
2 files modified
python/fluidity/regressiontest.py (+3/-2)
tools/testharness.py (+30/-7)
To merge this branch: bzr merge lp:~jon-hill/fluidity/longtest_fix
Reviewer Review Type Date Requested Status
Tim Greaves Approve
Review via email: mp+144123@code.launchpad.net

Description of the change

Added option --no_pbs to testharness which allows for the testing of longtests on local machines with no hacking of the XML. It will run on the number of processes specified in the XML.

Tim: can you check this doesn't break on CX1, please?

To post a comment you must log in.
Revision history for this message
Tim Greaves (tim-greaves) wrote :

Thanks Jon! I've merged in the two changes to the debug install in the amcgsoft account and am re-running coarse-corner now on those.

Revision history for this message
Tim Greaves (tim-greaves) wrote :

That just ran fine on buildbot - so happy to approve!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'python/fluidity/regressiontest.py'
2--- python/fluidity/regressiontest.py 2012-08-22 20:02:27 +0000
3+++ python/fluidity/regressiontest.py 2013-01-21 14:26:49 +0000
4@@ -12,7 +12,7 @@
5
6 class TestProblem:
7 """A test records input information as well as tests for the output."""
8- def __init__(self, filename, verbose=False, replace=None):
9+ def __init__(self, filename, verbose=False, replace=None, no_pbs=False):
10 """Read a regression test from filename and record its details."""
11 self.name = ""
12 self.command = replace
13@@ -26,6 +26,7 @@
14 self.pass_status = []
15 self.warn_status = []
16 self.filename = filename.split('/')[-1]
17+ self.no_pbs = no_pbs
18 # add dir to import path
19 sys.path.insert(0, os.path.dirname(filename))
20
21@@ -130,7 +131,7 @@
22 except OSError:
23 self.log("No Makefile, not calling make")
24
25- if self.nprocs > 1 or self.length == "long":
26+ if (not self.no_pbs) and (self.nprocs > 1 or self.length == "long"):
27 ret = self.call_genpbs(dir)
28 self.log("cd "+dir+"; qsub " + self.filename[:-4] + ".pbs: " + self.command_line)
29 os.system("cd "+dir+"; qsub " + self.filename[:-4] + ".pbs")
30
31=== modified file 'tools/testharness.py'
32--- tools/testharness.py 2012-11-08 17:26:18 +0000
33+++ tools/testharness.py 2013-01-21 14:26:49 +0000
34@@ -9,6 +9,7 @@
35 import traceback
36 import threading
37 import xml.parsers.expat
38+import string
39
40
41 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), os.pardir, "python"))
42@@ -21,7 +22,7 @@
43 def __init__(self, length="any", parallel=False, exclude_tags=None,
44 tags=None, file="", from_file=None,
45 verbose=True, justtest=False,
46- valgrind=False):
47+ valgrind=False, no_pbs=False):
48 self.tests = []
49 self.verbose = verbose
50 self.length = length
51@@ -33,6 +34,7 @@
52 self.completed_tests = []
53 self.justtest = justtest
54 self.valgrind = valgrind
55+ self.no_pbs = no_pbs
56
57 fluidity_command = self.decide_fluidity_command()
58
59@@ -87,9 +89,12 @@
60
61 if files:
62 for (subdir, xml_file) in [os.path.split(x) for x in xml_files]:
63- if xml_file in files:
64+ if xml_file == file:
65+ p = etree.parse(os.path.join(subdir,xml_file))
66+ prob_defn = p.findall("problem_definition")[0]
67+ prob_nprocs = int(prob_defn.attrib["nprocs"])
68 testprob = regressiontest.TestProblem(filename=os.path.join(subdir, xml_file),
69- verbose=self.verbose, replace=self.modify_command_line())
70+ verbose=self.verbose, replace=self.modify_command_line(prob_nprocs), no_pbs=no_pbs)
71 self.tests.append((subdir, testprob))
72 files.remove(xml_file)
73 if files != []:
74@@ -157,8 +162,12 @@
75 tagged_set = working_set
76
77 for (subdir, xml_file) in [os.path.split(x) for x in tagged_set]:
78+ # need to grab nprocs here to pass through to modify_command_line
79+ p = etree.parse(os.path.join(subdir,xml_file))
80+ prob_defn = p.findall("problem_definition")[0]
81+ prob_nprocs = int(prob_defn.attrib["nprocs"])
82 testprob = regressiontest.TestProblem(filename=os.path.join(subdir, xml_file),
83- verbose=self.verbose, replace=self.modify_command_line())
84+ verbose=self.verbose, replace=self.modify_command_line(prob_nprocs))
85 self.tests.append((subdir, testprob))
86
87 if len(self.tests) == 0:
88@@ -211,9 +220,9 @@
89
90 return None
91
92- def modify_command_line(self):
93+ def modify_command_line(self, nprocs):
94 flucmd = self.decide_fluidity_command()
95-
96+ print flucmd
97 def f(s):
98 if not flucmd in [None, "fluidity"]:
99 s = s.replace('fluidity ', flucmd + ' ')
100@@ -222,6 +231,18 @@
101 s = "valgrind --tool=memcheck --leak-check=full -v" + \
102 " --show-reachable=yes --num-callers=8 --error-limit=no " + \
103 "--log-file=test.log " + s
104+
105+ print s
106+ if (self.no_pbs):
107+ # check for mpiexec and the correct number of cores
108+ if (string.find(s, 'mpiexec') == -1):
109+ s = s.replace(flucmd+" ", "mpiexec "+flucmd+" ")
110+ print s
111+
112+ if (string.find(s, '-n') == -1):
113+ s = s.replace('mpiexec ', 'mpiexec -n '+str(nprocs)+' ')
114+ print s
115+
116 return s
117
118 return f
119@@ -355,6 +376,7 @@
120 parser.add_option("-c", "--clean", action="store_true", dest="clean", default = False)
121 parser.add_option("--just-test", action="store_true", dest="justtest")
122 parser.add_option("--just-list", action="store_true", dest="justlist")
123+ parser.add_option("--no_pbs", action="store_true", dest="no_pbs")
124 (options, args) = parser.parse_args()
125
126 if len(args) > 0: parser.error("Too many arguments.")
127@@ -393,7 +415,8 @@
128 file=options.file, verbose=True,
129 justtest=options.justtest,
130 valgrind=options.valgrind,
131- from_file=options.from_file)
132+ from_file=options.from_file,
133+ no_pbs=options.no_pbs)
134
135 if options.justlist:
136 testharness.list()