aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-03-30 00:47:00 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-03-30 00:47:00 +0530
commit92612438348105871e9640db247f9a3b4c238f28 (patch)
tree6e27e56d7806d58c9b6ff7b054337e01b1440215
parentfa09b122b00848c685d76ec047c813235c1dfdad (diff)
downloadmeson-92612438348105871e9640db247f9a3b4c238f28.zip
meson-92612438348105871e9640db247f9a3b4c238f28.tar.gz
meson-92612438348105871e9640db247f9a3b4c238f28.tar.bz2
tests/common/141: Also test C + asm targets
Ensure that they are all built with and linked with the C compiler
-rwxr-xr-xrun_unittests.py20
-rw-r--r--test cases/common/141 c cpp and asm/main.c8
-rw-r--r--test cases/common/141 c cpp and asm/meson.build1
3 files changed, 27 insertions, 2 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 416cbb7..8f98ad2 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -886,7 +886,7 @@ class AllPlatformTests(BasePlatformTests):
if env.detect_c_compiler(False).get_id() == 'msvc':
raise unittest.SkipTest('MSVC can\'t compile assembly')
self.init(testdir)
- commands = {'cpp-asm': {}, 'cpp-c-asm': {}, 'c-cpp-asm': {}}
+ commands = {'c-asm': {}, 'cpp-asm': {}, 'cpp-c-asm': {}, 'c-cpp-asm': {}}
for cmd in self.get_compdb():
# Get compiler
split = shlex.split(cmd['command'])
@@ -895,7 +895,14 @@ class AllPlatformTests(BasePlatformTests):
else:
compiler = split[0]
# Classify commands
- if 'Icpp-asm' in cmd['command']:
+ if 'Ic-asm' in cmd['command']:
+ if cmd['file'].endswith('.S'):
+ commands['c-asm']['asm'] = compiler
+ elif cmd['file'].endswith('.c'):
+ commands['c-asm']['c'] = compiler
+ else:
+ raise AssertionError('{!r} found in cpp-asm?'.format(cmd['command']))
+ elif 'Icpp-asm' in cmd['command']:
if cmd['file'].endswith('.S'):
commands['cpp-asm']['asm'] = compiler
elif cmd['file'].endswith('.cpp'):
@@ -922,12 +929,21 @@ class AllPlatformTests(BasePlatformTests):
raise AssertionError('{!r} found in cpp-c-asm?'.format(cmd['command']))
else:
raise AssertionError('Unknown command {!r} found'.format(cmd['command']))
+ # Check that .S files are always built with the C compiler
+ self.assertEqual(commands['c-asm']['asm'], commands['c-asm']['c'])
+ self.assertEqual(commands['c-asm']['asm'], commands['cpp-asm']['asm'])
self.assertEqual(commands['cpp-asm']['asm'], commands['c-cpp-asm']['c'])
self.assertEqual(commands['c-cpp-asm']['asm'], commands['c-cpp-asm']['c'])
self.assertEqual(commands['cpp-c-asm']['asm'], commands['cpp-c-asm']['c'])
self.assertNotEqual(commands['cpp-asm']['asm'], commands['cpp-asm']['cpp'])
self.assertNotEqual(commands['c-cpp-asm']['c'], commands['c-cpp-asm']['cpp'])
self.assertNotEqual(commands['cpp-c-asm']['c'], commands['cpp-c-asm']['cpp'])
+ # Check that the c-asm target is always linked with the C linker
+ build_ninja = os.path.join(self.builddir, 'build.ninja')
+ with open(build_ninja, 'r', encoding='utf-8') as f:
+ contents = f.read()
+ m = re.search('build c-asm.*: c_LINKER', contents)
+ self.assertIsNotNone(m, msg=contents)
class WindowsTests(BasePlatformTests):
diff --git a/test cases/common/141 c cpp and asm/main.c b/test cases/common/141 c cpp and asm/main.c
new file mode 100644
index 0000000..8976723
--- /dev/null
+++ b/test cases/common/141 c cpp and asm/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int get_retval(void);
+
+int main(int argc, char **argv) {
+ printf("C seems to be working.\n");
+ return get_retval();
+}
diff --git a/test cases/common/141 c cpp and asm/meson.build b/test cases/common/141 c cpp and asm/meson.build
index 5004ef8..9c90434 100644
--- a/test cases/common/141 c cpp and asm/meson.build
+++ b/test cases/common/141 c cpp and asm/meson.build
@@ -12,6 +12,7 @@ if meson.get_compiler('c').get_id() == 'msvc'
error('MESON_SKIP_TEST MSVC can\'t compile assembly')
endif
+test('test-c-asm', executable('c-asm', ['main.c', 'retval-' + cpu + '.S']))
test('test-cpp-asm', executable('cpp-asm', ['main.cpp', 'retval-' + cpu + '.S']))
test('test-c-cpp-asm', executable('c-cpp-asm', ['somelib.c', 'main.cpp', 'retval-' + cpu + '.S']))
test('test-cpp-c-asm', executable('cpp-c-asm', ['main.cpp', 'somelib.c', 'retval-' + cpu + '.S']))