Skip to content

Commit

Permalink
Fix cross compilation tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed May 9, 2015
1 parent 717abc9 commit 572587f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
10 changes: 5 additions & 5 deletions cross/ubuntu-mingw.txt
@@ -1,8 +1,8 @@
name = 'windows'
exe_wrapper = 'wine' # A command used to run generated executables.
c = '/usr/bin/i586-mingw32msvc-gcc'
cpp = '/usr/bin/i586-mingw32msvc-g++'
ar = '/usr/i586-mingw32msvc/bin/ar'
strip = '/usr/i586-mingw32msvc/bin/strip'
c = '/usr/bin/i686-w64-mingw32-gcc'
cpp = '/usr/bin/i686-w64-mingw32-gcc'
ar = '/usr/bin/i686-w64-mingw32-ar'
strip = '/usr/bin/i686-w64-mingw32-strip'

root = '/usr/i586-mingw32msvc'
root = '/usr/i686-w64-mingw32'
8 changes: 6 additions & 2 deletions interpreter.py
Expand Up @@ -503,12 +503,16 @@ def __init__(self, compiler, env):
'has_function' : self.has_function_method,
'has_member' : self.has_member_method,
'alignment' : self.alignment_method,
'version' : self.version_method
'version' : self.version_method,
'cmd_array' : self.cmd_array_method,
})

def version_method(self, args, kwargs):
return self.compiler.version

def cmd_array_method(self, args, kwargs):
return self.compiler.exelist

def alignment_method(self, args, kwargs):
if len(args) != 1:
raise InterpreterException('Alignment method takes exactly one positional argument.')
Expand Down Expand Up @@ -1682,7 +1686,7 @@ def array_method_call(self, obj, method_name, args):
index = args[0]
if not isinstance(index, int):
raise InvalidArguments('Array index must be a number.')
if index < 0 or index >= len(obj):
if index < -len(obj) or index >= len(obj):
raise InvalidArguments('Array index %s is out of bounds for array of size %d.' % (index, len(obj)))
return obj[index]
raise InterpreterException('Arrays do not have a method called "%s".' % method_name)
Expand Down
5 changes: 4 additions & 1 deletion meson_test.py
Expand Up @@ -41,7 +41,10 @@ def __init__(self, res, returncode, duration, stdo, stde, cmd):
def write_log(logfile, test_name, result_str, result):
logfile.write(result_str + '\n\n')
logfile.write('--- command ---\n')
logfile.write(' '.join(result.cmd))
if result.cmd is None:
logfile.write('NONE')
else:
logfile.write(' '.join(result.cmd))
logfile.write('\n--- "%s" stdout ---\n' % test_name)
logfile.write(result.stdo)
logfile.write('\n--- "%s" stderr ---\n' % test_name)
Expand Down
2 changes: 1 addition & 1 deletion mparser.py
Expand Up @@ -41,7 +41,7 @@ def __init__(self):
# Need to be sorted longest to shortest.
('ignore', re.compile(r'[ \t]')),
('id', re.compile('[_a-zA-Z][_0-9a-zA-Z]*')),
('number', re.compile(r'\d+')),
('number', re.compile(r'-?\d+')),
('eol_cont', re.compile(r'\\\n')),
('eol', re.compile(r'\n')),
('multiline_string', re.compile(r"'''(.|\n)*?'''", re.M)),
Expand Down
6 changes: 4 additions & 2 deletions run_cross_test.py
Expand Up @@ -45,7 +45,7 @@ def run_test(testdir, should_succeed=True):
os.mkdir(test_build_dir)
os.mkdir(install_dir)
print('Running test: ' + testdir)
gen_command = [sys.executable, meson_command, '--prefix', install_dir, '--libdir', 'lib', testdir, test_build_dir] + extra_flags
gen_command = [sys.executable, meson_command, '--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir] + extra_flags
p = subprocess.Popen(gen_command)
p.wait()
if not should_succeed:
Expand All @@ -62,7 +62,9 @@ def run_test(testdir, should_succeed=True):
pt.wait()
if pt.returncode != 0:
raise RuntimeError('Running unit tests failed.')
pi = subprocess.Popen(install_commands, cwd=test_build_dir)
install_env = os.environ.copy()
install_env['DESTDIR'] = install_dir
pi = subprocess.Popen(install_commands, cwd=test_build_dir, env=install_env)
pi.wait()
if pi.returncode != 0:
raise RuntimeError('Running install failed.')
Expand Down
5 changes: 3 additions & 2 deletions test cases/common/59 object generator/meson.build
Expand Up @@ -12,10 +12,11 @@ else
outputname = '@BASENAME@.o'
endif

# Generate a header file that needs to be included.
cc = meson.get_compiler('c').cmd_array().get(0-1)
# Generate an object file manually.
gen = generator(python,
output : outputname,
arguments : [comp, '@INPUT@', '@OUTPUT@'])
arguments : [comp, cc, '@INPUT@', '@OUTPUT@'])

generated = gen.process('source.c')

Expand Down
15 changes: 8 additions & 7 deletions test cases/common/59 object generator/obj_generator.py
Expand Up @@ -5,14 +5,15 @@
import sys, shutil, subprocess

if __name__ == '__main__':
if len(sys.argv) != 3:
print(sys.argv[0], 'input_file output_file')
if len(sys.argv) != 4:
print(sys.argv[0], 'compiler input_file output_file')
sys.exit(1)
ifile = sys.argv[1]
ofile = sys.argv[2]
if shutil.which('cl'):
cmd = ['cl', '/nologo', '/Fo'+ofile, '/c', ifile]
compiler = sys.argv[1]
ifile = sys.argv[2]
ofile = sys.argv[3]
if compiler.endswith('cl'):
cmd = [compiler, '/nologo', '/Fo'+ofile, '/c', ifile]
else:
cmd = ['cc', '-c', ifile, '-o', ofile]
cmd = [compiler, '-c', ifile, '-o', ofile]
sys.exit(subprocess.call(cmd))

0 comments on commit 572587f

Please sign in to comment.