File: run_tests.py

package info (click to toggle)
sail-ocaml 0.19.1%2Bdfsg5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,008 kB
  • sloc: ml: 75,941; ansic: 8,848; python: 1,342; exp: 560; sh: 474; makefile: 218; cpp: 36
file content (65 lines) | stat: -rwxr-xr-x 2,259 bytes parent folder | download
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
#!/usr/bin/env python3

import os
import re
import sys
import hashlib

mydir = os.path.dirname(__file__)
os.chdir(mydir)
sys.path.insert(0, os.path.realpath('..'))

from sailtest import *

sail_dir = get_sail_dir()
sail = get_sail()

print("Sail is {}".format(sail))
print("Sail dir is {}".format(sail_dir))

def chunks(filenames, cores):
    ys = []
    chunk = []
    for filename in filenames:
        chunk.append(filename)
        if len(chunk) >= cores:
            ys.append(list(chunk))
            chunk = []
    ys.append(list(chunk))
    return ys

libraries=['values', 'operators', 'instr_kinds', 'prompt_monad', 'prompt', 'operators_mwords', 'state_monad', 'state', 'string', 'undefined']
joiner = ' '
libpaths = joiner.join(['{}/src/gen_lib/sail2_{}.lem'.format(sail_dir, lib) for lib in libraries])
libml = joiner.join(['sail2_{}.ml'.format(lib) for lib in libraries])

def test():
    banner('Monomorphisation tests')
    results = Results('mono')
    for filenames in chunks(os.listdir('pass'), parallel()):
        tests = {}
        for filename in filenames:
            tests[filename] = os.fork()
            if tests[filename] == 0:
                with open('pass/{}'.format(filename)) as f:
                    arguments = f.read()
                step('mkdir -p _build_{}'.format(filename))
                step('\'{}\' --lem --lem-mwords --lem-lib Test_extra --lem-output-dir _build_{} -o out {}'.format(sail, filename, arguments))
                os.chdir('_build_{}'.format(filename))
                step('lem -ocaml -lib {}/src/lem_interp {} -outdir . ../test_extra.lem out_types.lem out.lem'.format(sail_dir, libpaths))
                step('if grep -q initial_regstate out.lem; then cp ../test_with_state.ml test.ml; else cp ../test.ml test.ml; fi')
                step('ocamlfind ocamlc -linkpkg -package zarith -package lem {} test_extra.ml out_types.ml out.ml test.ml'.format(libml))
                os.chdir('..')
                step('rm -r _build_{}'.format(filename))
                print_ok(filename)
                sys.exit()
        results.collect(tests)
    return results.finish()

xml = '<testsuites>\n'
xml += test()
xml += '</testsuites>\n'

output = open('tests.xml', 'w')
output.write(xml)
output.close()