2 Test configuration descriptions for mira.
9 from datetime import datetime
14 from mira import schedule, misc
15 from mira.environment import scheduler
16 from mira import repositories
18 # build and evaluation tools
20 DEFAULT_TIMEOUT = 2 * 60 * 60
21 SMLNJ_TIMEOUT = 72 * 60 * 60
23 def prepare_isabelle_repository(loc_isabelle, loc_dependency_heaps, more_settings=''):
28 init_components "/home/isabelle/contrib" "$ISABELLE_HOME/Admin/components/main"
29 init_components "/home/isabelle/contrib" "$ISABELLE_HOME/Admin/components/optional"
30 init_components "/home/isabelle/contrib" "$ISABELLE_HOME/Admin/components/nonfree"
34 writer = open(path.join(loc_isabelle, 'etc', 'settings'), 'a')
35 writer.write(extra_settings)
39 def isabelle_getenv(isabelle_home, var):
41 _, out = env.run_process('%s/bin/isabelle' % isabelle_home, 'getenv', var)
42 return out.split('=', 1)[1].strip()
45 def extract_isabelle_run_timing(logdata):
48 return (int(h) * 60 + int(m)) * 60 + int(s)
49 pat = r'Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time'
50 pat2 = r'Timing (\S+) \((\d+) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time, factor (\d+\.\d+)\)'
51 t = dict((name, {'elapsed': to_secs(eh,em,es), 'cpu': to_secs(ch,cm,cs)})
52 for name, eh, em, es, ch, cm, cs in re.findall(pat, logdata))
53 for name, threads, elapsed, cpu, gc, factor in re.findall(pat2, logdata):
58 t[name]['threads'] = int(threads)
59 t[name]['elapsed_inner'] = elapsed
60 t[name]['cpu_inner'] = cpu
62 t[name]['factor'] = factor
67 def extract_isabelle_run_summary(logdata):
69 re_error = re.compile(r'^(?:make: )?\*\*\* (.*)$', re.MULTILINE)
70 summary = '\n'.join(re_error.findall(logdata))
77 def extract_image_size(isabelle_home):
79 isabelle_output = isabelle_getenv(isabelle_home, 'ISABELLE_OUTPUT')
80 if not path.exists(isabelle_output):
83 return dict((p, path.getsize(path.join(isabelle_output, p))) for p in os.listdir(isabelle_output) if p != "log")
85 def extract_report_data(isabelle_home, logdata):
88 'timing': extract_isabelle_run_timing(logdata),
89 'image_size': extract_image_size(isabelle_home) }
92 def isabelle_build(env, case, paths, dep_paths, playground, *cmdargs, **kwargs):
94 more_settings = kwargs.get('more_settings', '')
95 keep_results = kwargs.get('keep_results', True)
96 timeout = kwargs.get('timeout', DEFAULT_TIMEOUT)
98 isabelle_home = paths[0]
100 home_user_dir = path.join(isabelle_home, 'home_user')
101 os.makedirs(home_user_dir)
103 # copy over build results from dependencies
104 heap_dir = path.join(isabelle_home, 'heaps')
105 classes_dir = path.join(heap_dir, 'classes')
106 os.makedirs(classes_dir)
108 for dep_path in dep_paths:
109 subprocess.check_call(['cp', '-a'] + glob(dep_path + '/*') + [heap_dir])
111 subprocess.check_call(['ln', '-s', classes_dir, path.join(isabelle_home, 'lib', 'classes')])
112 jars = glob(path.join(classes_dir, 'ext', '*.jar'))
114 subprocess.check_call(['touch'] + jars)
117 if 'lxbroy10' in misc.hostnames(): # special settings for lxbroy10
119 ISABELLE_GHC="/usr/bin/ghc"
122 prepare_isabelle_repository(isabelle_home, None, more_settings=more_settings)
123 os.chdir(isabelle_home)
125 args = (['-o', 'timeout=%s' % timeout] if timeout is not None else []) + list(cmdargs)
128 (return_code, log1) = env.run_process('%s/bin/isabelle' % isabelle_home, 'jedit', '-bf',
129 USER_HOME=home_user_dir)
130 (return_code, log2) = env.run_process('%s/bin/isabelle' % isabelle_home, 'build', '-s', '-v', *args,
131 USER_HOME=home_user_dir)
135 return (return_code == 0, extract_isabelle_run_summary(log),
136 extract_report_data(isabelle_home, log), {'log': log}, heap_dir if keep_results else None)
140 # Isabelle configurations
142 @configuration(repos = [Isabelle], deps = [])
145 return isabelle_build(*(args + ("-b", "Pure")))
147 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
150 return isabelle_build(*(args + ("-b", "HOL")))
152 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
153 def HOL_Library(*args):
155 return isabelle_build(*(args + ("-b", "HOL-Library")))
157 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
160 return isabelle_build(*(args + ("-b", "HOLCF")))
162 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
165 return isabelle_build(*(args + ("-b", "ZF")))
169 # enforce 64 bit, overriding smart detection
170 ML_PLATFORM="$ISABELLE_PLATFORM64"
171 ML_HOME="$(dirname $ML_HOME)/$ML_PLATFORM"
174 @configuration(repos = [Isabelle], deps = [])
175 def Isabelle_makeall(*args):
176 """Build all sessions"""
177 return isabelle_build(*(args + ("-j", "6", "-o", "threads=4", "-a")), more_settings=settings64, keep_results=False)
180 # Mutabelle configurations
182 def invoke_mutabelle(theory, env, case, paths, dep_paths, playground):
184 """Mutant testing for counterexample generators in Isabelle"""
186 (loc_isabelle,) = paths
187 (dep_isabelle,) = dep_paths
189 ISABELLE_GHC="/usr/bin/ghc"
191 prepare_isabelle_repository(loc_isabelle, dep_isabelle, more_settings = more_settings)
192 os.chdir(loc_isabelle)
194 (return_code, log) = env.run_process('bin/isabelle',
195 'mutabelle', '-O', playground, theory)
198 mutabelle_log = util.readfile(path.join(playground, 'log'))
202 mutabelle_data = dict(
203 (tool, {'counterexample': c, 'no_counterexample': n, 'timeout': t, 'error': e})
204 for tool, c, n, t, e in re.findall(r'(\S+)\s+: C: (\d+) N: (\d+) T: (\d+) E: (\d+)', log))
206 return (return_code == 0 and mutabelle_log != '', extract_isabelle_run_summary(log),
207 {'mutabelle_results': {theory: mutabelle_data}},
208 {'log': log, 'mutabelle_log': mutabelle_log}, None)
210 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
211 def Mutabelle_Relation(*args):
212 """Mutabelle regression suite on Relation theory"""
213 return invoke_mutabelle('Relation', *args)
215 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
216 def Mutabelle_List(*args):
217 """Mutabelle regression suite on List theory"""
218 return invoke_mutabelle('List', *args)
220 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
221 def Mutabelle_Set(*args):
222 """Mutabelle regression suite on Set theory"""
223 return invoke_mutabelle('Set', *args)
225 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
226 def Mutabelle_Map(*args):
227 """Mutabelle regression suite on Map theory"""
228 return invoke_mutabelle('Map', *args)
230 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
231 def Mutabelle_Divides(*args):
232 """Mutabelle regression suite on Divides theory"""
233 return invoke_mutabelle('Divides', *args)
235 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
236 def Mutabelle_MacLaurin(*args):
237 """Mutabelle regression suite on MacLaurin theory"""
238 return invoke_mutabelle('MacLaurin', *args)
240 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
241 def Mutabelle_Fun(*args):
242 """Mutabelle regression suite on Fun theory"""
243 return invoke_mutabelle('Fun', *args)
245 mutabelle_confs = 'Mutabelle_Relation Mutabelle_List Mutabelle_Set Mutabelle_Map Mutabelle_Divides Mutabelle_MacLaurin Mutabelle_Fun'.split(' ')
248 def mutabelle_scheduler(env):
249 """Scheduler for Mutabelle."""
250 return schedule.age_scheduler(env, 'Isabelle', mutabelle_confs)
253 # Judgement Day configurations
255 judgement_day_provers = ('e', 'spass', 'vampire', 'z3', 'cvc3', 'yices')
257 def judgement_day(base_path, theory, opts, env, case, paths, dep_paths, playground):
258 """Judgement Day regression suite"""
261 dep_path = dep_paths[0]
263 os.chdir(path.join(playground, '..', base_path)) # Mirabelle requires specific cwd
264 prepare_isabelle_repository(isa, dep_path)
270 for atp in judgement_day_provers:
272 log_dir = path.join(playground, 'mirabelle_log_' + atp)
275 cmd = ('%s/bin/isabelle mirabelle -q -O %s sledgehammer[prover=%s,%s] %s.thy'
276 % (isa, log_dir, atp, opts, theory))
279 output[atp] = util.readfile(path.join(log_dir, theory + '.log'))
281 percentages = list(re.findall(r'Success rate: (\d+)%', output[atp]))
282 if len(percentages) == 2:
283 success_rates[atp] = {
284 'sledgehammer': int(percentages[0]),
285 'metis': int(percentages[1])}
286 if success_rates[atp]['sledgehammer'] > 0:
289 success_rates[atp] = {}
292 data = {'success_rates': success_rates}
293 raw_attachments = dict((atp + "_output", output[atp]) for atp in judgement_day_provers)
295 return (some_success, '', data, raw_attachments, None)
298 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
300 """Judgement Day regression suite NS"""
301 return judgement_day('Isabelle/src/HOL/Auth', 'NS_Shared', 'prover_timeout=10', *args)
303 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
305 """Judgement Day regression suite FTA"""
306 return judgement_day('Isabelle/src/HOL/Library', 'Fundamental_Theorem_Algebra', 'prover_timeout=10', *args)
308 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
310 """Judgement Day regression suite Hoare"""
311 return judgement_day('Isabelle/src/HOL/IMPP', 'Hoare', 'prover_timeout=10', *args)
313 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
315 """Judgement Day regression suite SN"""
316 return judgement_day('Isabelle/src/HOL/Proofs/Lambda', 'StrongNorm', 'prover_timeout=10', *args)
319 JD_confs = 'JD_NS JD_FTA JD_Hoare JD_SN JD_Arrow JD_FFT JD_Jinja JD_QE JD_S2S'.split(' ')
322 def judgement_day_scheduler(env):
323 """Scheduler for Judgement Day."""
324 return schedule.age_scheduler(env, 'Isabelle', JD_confs)
331 ML_HOME="/home/smlnj/110.76/bin"
332 ML_OPTIONS="@SMLdebug=/dev/null @SMLalloc=1024"
333 ML_PLATFORM=$(eval $("$ML_HOME/.arch-n-opsys" 2>/dev/null); echo "$HEAP_SUFFIX")
336 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
338 """HOL image built with SML/NJ"""
339 return isabelle_build(*(args + ("-b", "HOL")), more_settings=smlnj_settings, timeout=SMLNJ_TIMEOUT)
341 @configuration(repos = [Isabelle], deps = [])
342 def SML_makeall(*args):
343 """SML/NJ build of all possible sessions"""
344 return isabelle_build(*(args + ("-j", "3", "-a")), more_settings=smlnj_settings, timeout=SMLNJ_TIMEOUT)