aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 020f2bdb..3c2ce8f3 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6785,6 +6785,25 @@ Pass: 0.000012 0.000012''')
'''
self.do_run(src, '2, , black\n2, ., #001100\n2, X, #111100');
+ def test_sscanf_6(self):
+ src = r'''
+ #include <stdio.h>
+
+ int main()
+ {
+ char *date = "18.07.2013w";
+ char c[10];
+ int y, m, d, i;
+ i = sscanf(date, "%d.%d.%4d%c", &d, &m, &y, c);
+ printf("date: %s; day %2d, month %2d, year %4d, extra: %c, %d\n", date, d, m, y, c[0], i);
+ i = sscanf(date, "%d.%d.%3c", &d, &m, c);
+ printf("date: %s; day %2d, month %2d, year %4d, extra: %s, %d\n", date, d, m, y, c, i);
+ }
+ '''
+ self.do_run(src, '''date: 18.07.2013w; day 18, month 7, year 2013, extra: w, 4
+date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
+''');
+
def test_sscanf_skip(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip("need ta2 for full i64")
@@ -10817,6 +10836,50 @@ f.close()
args=['-I' + path_from_root('tests', 'bullet', 'src')])
+ def test_outline(self):
+ def test(name, src, libs, expected, expected_ranges, args=[], suffix='cpp'):
+ print name
+
+ def measure_funcs(filename):
+ i = 0
+ start = -1
+ curr = '?'
+ ret = {}
+ for line in open(filename):
+ i += 1
+ if line.startswith('function '):
+ start = i
+ curr = line
+ elif line.startswith('}'):
+ size = i - start
+ if size > 100: ret[curr] = size
+ return ret
+
+ for outlining_limit in [1000, 2000, 5000, 0]:
+ Popen([PYTHON, EMCC, src] + libs + ['-o', 'test.js', '-O2', '-g3', '-s', 'OUTLINING_LIMIT=%d' % outlining_limit] + args).communicate()
+ assert os.path.exists('test.js')
+ shutil.copyfile('test.js', '%d_test.js' % outlining_limit)
+ for engine in JS_ENGINES:
+ out = run_js('test.js', engine=engine, stderr=PIPE, full_output=True)
+ self.assertContained(expected, out)
+ if engine == SPIDERMONKEY_ENGINE: self.validate_asmjs(out)
+ low = expected_ranges[outlining_limit][0]
+ seen = max(measure_funcs('test.js').values())
+ high = expected_ranges[outlining_limit][1]
+ print outlining_limit, ' ', low, '<=', seen, '<=', high
+ assert low <= seen <= high
+
+ test('zlib', path_from_root('tests', 'zlib', 'example.c'),
+ self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a']),
+ open(path_from_root('tests', 'zlib', 'ref.txt'), 'r').read(),
+ {
+ 1000: (380, 390),
+ 2000: (395, 410),
+ 5000: (800, 1100),
+ 0: (1500, 1800)
+ },
+ args=['-I' + path_from_root('tests', 'zlib')], suffix='c')
+
def test_symlink(self):
if os.name == 'nt':
return self.skip('Windows FS does not need to be tested for symlinks support, since it does not have them.')