diff options
-rwxr-xr-x | auto_update_tests.py | 19 | ||||
-rwxr-xr-x | check.py | 47 | ||||
-rwxr-xr-x | scripts/clean_c_api_trace.py | 37 | ||||
-rw-r--r-- | src/binaryen-c.h | 2 |
4 files changed, 21 insertions, 84 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py index ef96072de..9f9a877b0 100755 --- a/auto_update_tests.py +++ b/auto_update_tests.py @@ -29,27 +29,14 @@ from scripts.test import wasm_opt def update_example_tests(): print('\n[ checking example testcases... ]\n') - for t in shared.get_tests(shared.get_test_dir('example')): - basename = os.path.basename(t) + for src in shared.get_tests(shared.get_test_dir('example')): + basename = os.path.basename(src) output_file = os.path.join(shared.options.binaryen_bin, 'example') libdir = os.path.join(shared.BINARYEN_INSTALL_DIR, 'lib') cmd = ['-I' + os.path.join(shared.options.binaryen_root, 'src'), '-g', '-pthread', '-o', output_file] - if t.endswith('.txt'): - # check if there is a trace in the file, if so, we should build it - out = subprocess.Popen([os.path.join(shared.options.binaryen_root, 'scripts', 'clean_c_api_trace.py'), t], stdout=subprocess.PIPE).communicate()[0] - if len(out) == 0: - print(' (no trace in ', basename, ')') - continue - print(' (will check trace in ', basename, ')') - src = 'trace.cpp' - with open(src, 'wb') as o: - o.write(out) - expected = t + '.txt' - else: - src = t - expected = os.path.splitext(t)[0] + '.txt' if not src.endswith(('.c', '.cpp')): continue + expected = os.path.splitext(src)[0] + '.txt' # windows + gcc will need some work if shared.skip_if_on_windows('gcc'): return @@ -286,37 +286,24 @@ def run_gcc_tests(): for t in sorted(os.listdir(shared.get_test_dir('example'))): output_file = 'example' - cmd = ['-I' + os.path.join(shared.options.binaryen_root, 'src'), '-g', '-pthread', '-o', output_file] - if t.endswith('.txt'): - # check if there is a trace in the file, if so, we should build it - out = subprocess.check_output([os.path.join(shared.options.binaryen_root, 'scripts', 'clean_c_api_trace.py'), os.path.join(shared.get_test_dir('example'), t)]) - if len(out) == 0: - print(' (no trace in ', t, ')') - continue - print(' (will check trace in ', t, ')') - src = 'trace.cpp' - with open(src, 'wb') as o: - o.write(out) - expected = os.path.join(shared.get_test_dir('example'), t + '.txt') - else: - src = os.path.join(shared.get_test_dir('example'), t) - expected = os.path.join(shared.get_test_dir('example'), '.'.join(t.split('.')[:-1]) + '.txt') - if src.endswith(('.c', '.cpp')): - # build the C file separately - libpath = os.path.join(os.path.dirname(shared.options.binaryen_bin), 'lib') - extra = [shared.NATIVECC, src, '-c', '-o', 'example.o', - '-I' + os.path.join(shared.options.binaryen_root, 'src'), '-g', '-L' + libpath, '-pthread'] - if src.endswith('.cpp'): - extra += ['-std=c++' + str(shared.cxx_standard)] - if os.environ.get('COMPILER_FLAGS'): - for f in os.environ.get('COMPILER_FLAGS').split(' '): - extra.append(f) - print('build: ', ' '.join(extra)) - subprocess.check_call(extra) - # Link against the binaryen C library DSO, using an executable-relative rpath - cmd = ['example.o', '-L' + libpath, '-lbinaryen'] + cmd + ['-Wl,-rpath,' + libpath] - else: + cmd = ['-I' + os.path.join(shared.options.binaryen_root, 't'), '-g', '-pthread', '-o', output_file] + if not t.endswith(('.c', '.cpp')): continue + src = os.path.join(shared.get_test_dir('example'), t) + expected = os.path.join(shared.get_test_dir('example'), '.'.join(t.split('.')[:-1]) + '.txt') + # build the C file separately + libpath = os.path.join(os.path.dirname(shared.options.binaryen_bin), 'lib') + extra = [shared.NATIVECC, src, '-c', '-o', 'example.o', + '-I' + os.path.join(shared.options.binaryen_root, 'src'), '-g', '-L' + libpath, '-pthread'] + if src.endswith('.cpp'): + extra += ['-std=c++' + str(shared.cxx_standard)] + if os.environ.get('COMPILER_FLAGS'): + for f in os.environ.get('COMPILER_FLAGS').split(' '): + extra.append(f) + print('build: ', ' '.join(extra)) + subprocess.check_call(extra) + # Link against the binaryen C library DSO, using an executable-relative rpath + cmd = ['example.o', '-L' + libpath, '-lbinaryen'] + cmd + ['-Wl,-rpath,' + libpath] print(' ', t, src, expected) if os.environ.get('COMPILER_FLAGS'): for f in os.environ.get('COMPILER_FLAGS').split(' '): diff --git a/scripts/clean_c_api_trace.py b/scripts/clean_c_api_trace.py deleted file mode 100755 index 0c6aabaf8..000000000 --- a/scripts/clean_c_api_trace.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2016 WebAssembly Community Group participants -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Cleans up output from the C api, makes a runnable C file -""" - -import sys - -trace = open(sys.argv[1]).read() - -start = trace.find('// beginning a Binaryen API trace') -end = trace.rfind('// ending a Binaryen API trace') -if start >= 0: - trace = trace[start:end] - - while 1: - start = trace.find('\n(') - if start < 0: - break - end = trace.find('\n)', start + 1) - assert end > 0 - trace = trace[:start] + trace[end + 2:] - - print(trace) diff --git a/src/binaryen-c.h b/src/binaryen-c.h index c84361d0e..5b6da7699 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -25,7 +25,7 @@ // graph (CFG) as input. // // The final part of the API contains miscellaneous utilities like -// debugging/tracing for the API itself. +// debugging for the API itself. // // --------------- // |