Skip to content

Commit ed4bdd6

Browse files
committed
Add script files used to drive Emscripten runs.
1 parent b5ff2de commit ed4bdd6

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

emcc/run_all_tests.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env python
2+
3+
import subprocess, glob, sys, os
4+
5+
tests = glob.glob('pthread_*')
6+
7+
tests = filter(lambda x: not 'pthread_atfork' in x, tests)
8+
tests = filter(lambda x: not 'pthread_sigmask' in x, tests)
9+
10+
#tests = filter(lambda x: 'pthread_attr_init' in x or 'pthread_barrier_init' in x, tests)
11+
12+
print 'Running ' + str(len(tests)) + ' tests: ' + str(tests)
13+
print ''
14+
15+
total_num_tests_passed = 0
16+
total_num_tests_skipped = 0
17+
total_num_tests_unknown = 0
18+
total_num_tests_failed = 0
19+
20+
origcwd = os.getcwd()
21+
for t in tests:
22+
os.chdir(os.path.join(origcwd, t))
23+
proc = subprocess.Popen('run_emcc_tests.py', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
24+
(stdout, stderr) = proc.communicate()
25+
stdout = stdout.strip()
26+
stderr = stderr.strip()
27+
if len(stdout) > 0:
28+
num_tests_passed = 0
29+
num_tests_skipped = 0
30+
num_tests_failed = 0
31+
num_tests_unknown = 0
32+
n = '\n'.join(filter(lambda x: ' tests passed:' in x, stdout.split('\n'))).strip().split()
33+
if len(n) > 0:
34+
num_tests_passed = int(n[0])
35+
total_num_tests_passed += num_tests_passed
36+
37+
n = '\n'.join(filter(lambda x: ' tests failed:' in x, stdout.split('\n'))).strip().split()
38+
if len(n) > 0:
39+
num_tests_failed = int(n[0])
40+
total_num_tests_failed += num_tests_failed
41+
42+
n = '\n'.join(filter(lambda x: ' tests skipped:' in x, stdout.split('\n'))).strip().split()
43+
if len(n) > 0:
44+
num_tests_skipped = int(n[0])
45+
total_num_tests_skipped += num_tests_skipped
46+
47+
n = '\n'.join(filter(lambda x: ' tests finished with unknown result:' in x, stdout.split('\n'))).strip().split()
48+
if len(n) > 0:
49+
num_tests_unknown = int(n[0])
50+
total_num_tests_unknown += num_tests_unknown
51+
52+
if '--verbose' in sys.argv or len(stderr) > 0 or num_tests_failed > 0 or num_tests_unknown > 0:
53+
print stdout
54+
else:
55+
print t + '/: ' + str(num_tests_passed) + ' passed, ' + str(num_tests_skipped) + ' skipped.'
56+
57+
if len(stderr) > 0:
58+
print stderr
59+
60+
print ''
61+
print '-------------- SUMMARY --------------'
62+
print str(total_num_tests_passed + total_num_tests_failed + total_num_tests_skipped + total_num_tests_unknown) + ' tests run total, of which:'
63+
print ' ' + str(total_num_tests_passed) + ' tests passed.'
64+
print ' ' + str(total_num_tests_failed) + ' tests failed.'
65+
print ' ' + str(total_num_tests_skipped) + ' tests skipped.'
66+
print ' ' + str(total_num_tests_unknown) + ' tests finished with unknown result.'
67+
print ''

emcc/run_emcc_tests.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python
2+
3+
import subprocess, glob, sys, os
4+
5+
if len(sys.argv) > 1:
6+
tests = sys.argv[1:]
7+
else:
8+
tests = filter(lambda x: x[0].isdigit(), glob.glob('*.c'))
9+
print ''
10+
print '---------------------------------- ' + os.path.basename(os.getcwd()) + '/ ----------------------------------'
11+
print 'Running ' + str(len(tests)) + ' tests: ' + str(tests) + ' in ' + os.getcwd()
12+
print ''
13+
14+
successes = []
15+
failures = []
16+
indeterminate = []
17+
skipped = []
18+
19+
for f in tests:
20+
out = f.replace('.c', '.html')
21+
cmd = ['emcc', f, '-lpthread', '-Wno-format-security', '-s', 'TOTAL_MEMORY=268435456', '-s', 'PTHREAD_POOL_SIZE=40', '-o', out, '-I../../../include', '--emrun']
22+
print ' '.join(cmd)
23+
subprocess.call(cmd)
24+
cmd = ['emrun', '--kill_start', '--kill_exit', '--timeout=15', '--silence_timeout=15', '--browser=/Users/jjylanki/mozilla-inbound-2/obj-x86_64-apple-darwin14.0.0/dist/Nightly.app/Contents/MacOS/firefox', out]
25+
#print ' '.join(cmd)
26+
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
27+
(stdout, stderr) = proc.communicate()
28+
stdout = '\n'.join(filter(lambda x: not x.startswith('2015-'), stdout.split('\n')))
29+
stderr = '\n'.join(filter(lambda x: not x.startswith('2015-'), stderr.split('\n')))
30+
stdout = stdout.strip()
31+
stderr = stderr.strip()
32+
if 'test skipped' in stdout.lower():
33+
skipped += [f]
34+
reason = '\n'.join(filter(lambda x: 'Test SKIPPED' in x, stdout.split('\n')))
35+
print reason.strip()
36+
elif proc.returncode == 0 and ('test pass' in stdout.lower() or 'Test executed successfully.' in stdout):
37+
successes += [f]
38+
print 'PASS'
39+
elif proc.returncode != 0:
40+
failures += [f]
41+
print 'FAILED:'
42+
# print 'stdout:'
43+
if len(stdout) > 0: print stdout
44+
# print ''
45+
# print 'stderr:'
46+
print stderr
47+
else:
48+
indeterminate += [f]
49+
print 'UNKNOWN:'
50+
# print 'stdout:'
51+
if len(stdout) > 0: print stdout
52+
# print ''
53+
# print 'stderr:'
54+
print stderr
55+
print ''
56+
57+
print '=== FINISHED ==='
58+
if len(successes) > 0:
59+
print str(len(successes)) + ' tests passed: '
60+
print ', '.join(successes)
61+
print ''
62+
63+
if len(failures) > 0:
64+
print str(len(failures)) + ' tests failed: '
65+
print ', '.join(failures)
66+
print ''
67+
68+
if len(indeterminate) > 0:
69+
print str(len(indeterminate)) + ' tests finished with unknown result: '
70+
print ', '.join(indeterminate)
71+
print ''
72+
73+
if len(skipped) > 0:
74+
print str(len(skipped)) + ' tests skipped: '
75+
print ', '.join(skipped)
76+
print ''
77+
print ''
78+
print ''

0 commit comments

Comments
 (0)