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=''):
27 Z3_NON_COMMERCIAL="yes"
29 init_components "/home/isabelle/contrib" "$ISABELLE_HOME/Admin/components/main"
30 init_components "/home/isabelle/contrib" "$ISABELLE_HOME/Admin/components/optional"
31 init_components "/home/isabelle/contrib" "$ISABELLE_HOME/Admin/components/nonfree"
35 writer = open(path.join(loc_isabelle, 'etc', 'settings'), 'a')
36 writer.write(extra_settings)
40 def isabelle_getenv(isabelle_home, var):
42 _, out = env.run_process('%s/bin/isabelle' % isabelle_home, 'getenv', var)
43 return out.split('=', 1)[1].strip()
46 def extract_isabelle_run_timing(logdata):
49 return (int(h) * 60 + int(m)) * 60 + int(s)
50 pat = r'Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time'
51 pat2 = r'Timing (\S+) \((\d+) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time, factor (\d+\.\d+)\)'
52 t = dict((name, {'elapsed': to_secs(eh,em,es), 'cpu': to_secs(ch,cm,cs)})
53 for name, eh, em, es, ch, cm, cs in re.findall(pat, logdata))
54 for name, threads, elapsed, cpu, gc, factor in re.findall(pat2, logdata):
59 t[name]['threads'] = int(threads)
60 t[name]['elapsed_inner'] = elapsed
61 t[name]['cpu_inner'] = cpu
63 t[name]['factor'] = factor
68 def extract_isabelle_run_summary(logdata):
70 re_error = re.compile(r'^(?:make: )?\*\*\* (.*)$', re.MULTILINE)
71 summary = '\n'.join(re_error.findall(logdata))
78 def extract_image_size(isabelle_home):
80 isabelle_output = isabelle_getenv(isabelle_home, 'ISABELLE_OUTPUT')
81 if not path.exists(isabelle_output):
84 return dict((p, path.getsize(path.join(isabelle_output, p))) for p in os.listdir(isabelle_output) if p != "log")
86 def extract_report_data(isabelle_home, logdata):
89 'timing': extract_isabelle_run_timing(logdata),
90 'image_size': extract_image_size(isabelle_home) }
93 def isabelle_build(env, case, paths, dep_paths, playground, *cmdargs, **kwargs):
95 more_settings = kwargs.get('more_settings', '')
96 keep_results = kwargs.get('keep_results', True)
97 timeout = kwargs.get('timeout', DEFAULT_TIMEOUT)
99 isabelle_home = paths[0]
101 home_user_dir = path.join(isabelle_home, 'home_user')
102 os.makedirs(home_user_dir)
104 # copy over build results from dependencies
105 heap_dir = path.join(isabelle_home, 'heaps')
106 classes_dir = path.join(heap_dir, 'classes')
107 os.makedirs(classes_dir)
109 for dep_path in dep_paths:
110 subprocess.check_call(['cp', '-a'] + glob(dep_path + '/*') + [heap_dir])
112 subprocess.check_call(['ln', '-s', classes_dir, path.join(isabelle_home, 'lib', 'classes')])
113 jars = glob(path.join(classes_dir, 'ext', '*.jar'))
115 subprocess.check_call(['touch'] + jars)
118 if 'lxbroy10' in misc.hostnames(): # special settings for lxbroy10
120 ISABELLE_GHC="/usr/bin/ghc"
123 prepare_isabelle_repository(isabelle_home, None, more_settings=more_settings)
124 os.chdir(isabelle_home)
126 args = (['-o', 'timeout=%s' % timeout] if timeout is not None else []) + list(cmdargs)
129 (return_code, log1) = env.run_process('%s/bin/isabelle' % isabelle_home, 'jedit', '-bf',
130 USER_HOME=home_user_dir)
131 (return_code, log2) = env.run_process('%s/bin/isabelle' % isabelle_home, 'build', '-s', '-v', *args,
132 USER_HOME=home_user_dir)
136 return (return_code == 0, extract_isabelle_run_summary(log),
137 extract_report_data(isabelle_home, log), {'log': log}, heap_dir if keep_results else None)
141 # Isabelle configurations
143 @configuration(repos = [Isabelle], deps = [])
146 return isabelle_build(*(args + ("-b", "Pure")))
148 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
151 return isabelle_build(*(args + ("-b", "HOL")))
153 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
154 def HOL_Library(*args):
156 return isabelle_build(*(args + ("-b", "HOL-Library")))
158 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
161 return isabelle_build(*(args + ("-b", "HOLCF")))
163 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
166 return isabelle_build(*(args + ("-b", "ZF")))
170 # enforce 64 bit, overriding smart detection
171 ML_PLATFORM="$ISABELLE_PLATFORM64"
172 ML_HOME="$(dirname $ML_HOME)/$ML_PLATFORM"
175 @configuration(repos = [Isabelle], deps = [])
176 def Isabelle_makeall(*args):
177 """Build all sessions"""
178 return isabelle_build(*(args + ("-j", "6", "-o", "threads=4", "-a")), more_settings=settings64, keep_results=False)
181 # Mutabelle configurations
183 def invoke_mutabelle(theory, env, case, paths, dep_paths, playground):
185 """Mutant testing for counterexample generators in Isabelle"""
187 (loc_isabelle,) = paths
188 (dep_isabelle,) = dep_paths
190 ISABELLE_GHC="/usr/bin/ghc"
192 prepare_isabelle_repository(loc_isabelle, dep_isabelle, more_settings = more_settings)
193 os.chdir(loc_isabelle)
195 (return_code, log) = env.run_process('bin/isabelle',
196 'mutabelle', '-O', playground, theory)
199 mutabelle_log = util.readfile(path.join(playground, 'log'))
203 mutabelle_data = dict(
204 (tool, {'counterexample': c, 'no_counterexample': n, 'timeout': t, 'error': e})
205 for tool, c, n, t, e in re.findall(r'(\S+)\s+: C: (\d+) N: (\d+) T: (\d+) E: (\d+)', log))
207 return (return_code == 0 and mutabelle_log != '', extract_isabelle_run_summary(log),
208 {'mutabelle_results': {theory: mutabelle_data}},
209 {'log': log, 'mutabelle_log': mutabelle_log}, None)
211 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
212 def Mutabelle_Relation(*args):
213 """Mutabelle regression suite on Relation theory"""
214 return invoke_mutabelle('Relation', *args)
216 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
217 def Mutabelle_List(*args):
218 """Mutabelle regression suite on List theory"""
219 return invoke_mutabelle('List', *args)
221 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
222 def Mutabelle_Set(*args):
223 """Mutabelle regression suite on Set theory"""
224 return invoke_mutabelle('Set', *args)
226 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
227 def Mutabelle_Map(*args):
228 """Mutabelle regression suite on Map theory"""
229 return invoke_mutabelle('Map', *args)
231 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
232 def Mutabelle_Divides(*args):
233 """Mutabelle regression suite on Divides theory"""
234 return invoke_mutabelle('Divides', *args)
236 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
237 def Mutabelle_MacLaurin(*args):
238 """Mutabelle regression suite on MacLaurin theory"""
239 return invoke_mutabelle('MacLaurin', *args)
241 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
242 def Mutabelle_Fun(*args):
243 """Mutabelle regression suite on Fun theory"""
244 return invoke_mutabelle('Fun', *args)
246 mutabelle_confs = 'Mutabelle_Relation Mutabelle_List Mutabelle_Set Mutabelle_Map Mutabelle_Divides Mutabelle_MacLaurin Mutabelle_Fun'.split(' ')
249 def mutabelle_scheduler(env):
250 """Scheduler for Mutabelle."""
251 return schedule.age_scheduler(env, 'Isabelle', mutabelle_confs)
254 # Judgement Day configurations
256 judgement_day_provers = ('e', 'spass', 'vampire', 'z3', 'cvc3', 'yices')
258 def judgement_day(base_path, theory, opts, env, case, paths, dep_paths, playground):
259 """Judgement Day regression suite"""
262 dep_path = dep_paths[0]
264 os.chdir(path.join(playground, '..', base_path)) # Mirabelle requires specific cwd
265 prepare_isabelle_repository(isa, dep_path)
271 for atp in judgement_day_provers:
273 log_dir = path.join(playground, 'mirabelle_log_' + atp)
276 cmd = ('%s/bin/isabelle mirabelle -q -O %s sledgehammer[prover=%s,%s] %s.thy'
277 % (isa, log_dir, atp, opts, theory))
280 output[atp] = util.readfile(path.join(log_dir, theory + '.log'))
282 percentages = list(re.findall(r'Success rate: (\d+)%', output[atp]))
283 if len(percentages) == 2:
284 success_rates[atp] = {
285 'sledgehammer': int(percentages[0]),
286 'metis': int(percentages[1])}
287 if success_rates[atp]['sledgehammer'] > 0:
290 success_rates[atp] = {}
293 data = {'success_rates': success_rates}
294 raw_attachments = dict((atp + "_output", output[atp]) for atp in judgement_day_provers)
296 return (some_success, '', data, raw_attachments, None)
299 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
301 """Judgement Day regression suite NS"""
302 return judgement_day('Isabelle/src/HOL/Auth', 'NS_Shared', 'prover_timeout=10', *args)
304 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
306 """Judgement Day regression suite FTA"""
307 return judgement_day('Isabelle/src/HOL/Library', 'Fundamental_Theorem_Algebra', 'prover_timeout=10', *args)
309 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
311 """Judgement Day regression suite Hoare"""
312 return judgement_day('Isabelle/src/HOL/IMPP', 'Hoare', 'prover_timeout=10', *args)
314 @configuration(repos = [Isabelle], deps = [(HOL, [0])])
316 """Judgement Day regression suite SN"""
317 return judgement_day('Isabelle/src/HOL/Proofs/Lambda', 'StrongNorm', 'prover_timeout=10', *args)
320 JD_confs = 'JD_NS JD_FTA JD_Hoare JD_SN JD_Arrow JD_FFT JD_Jinja JD_QE JD_S2S'.split(' ')
323 def judgement_day_scheduler(env):
324 """Scheduler for Judgement Day."""
325 return schedule.age_scheduler(env, 'Isabelle', JD_confs)
332 ML_HOME="/home/smlnj/110.76/bin"
333 ML_OPTIONS="@SMLdebug=/dev/null @SMLalloc=1024"
334 ML_PLATFORM=$(eval $("$ML_HOME/.arch-n-opsys" 2>/dev/null); echo "$HEAP_SUFFIX")
337 @configuration(repos = [Isabelle], deps = [(Pure, [0])])
339 """HOL image built with SML/NJ"""
340 return isabelle_build(*(args + ("-b", "HOL")), more_settings=smlnj_settings, timeout=SMLNJ_TIMEOUT)
342 @configuration(repos = [Isabelle], deps = [])
343 def SML_makeall(*args):
344 """SML/NJ build of all possible sessions"""
345 return isabelle_build(*(args + ("-j", "3", "-a")), more_settings=smlnj_settings, timeout=SMLNJ_TIMEOUT)