aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-01-20 02:59:50 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-01-21 20:17:21 +0530
commit86a0c39f4b66ac9c1378001ce62d8b0bcc72d293 (patch)
treedb22e9a95896ff2572efa627d8b5edb87f37b8f8 /test cases
parentf934598865f7923d49b467e1f5db673c6e3b6636 (diff)
downloadmeson-86a0c39f4b66ac9c1378001ce62d8b0bcc72d293.zip
meson-86a0c39f4b66ac9c1378001ce62d8b0bcc72d293.tar.gz
meson-86a0c39f4b66ac9c1378001ce62d8b0bcc72d293.tar.bz2
Add test for generated assembly
We weren't testing for this and it was broken
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/135 generated assembly/copy.py6
-rw-r--r--test cases/common/135 generated assembly/main.c14
-rw-r--r--test cases/common/135 generated assembly/meson.build39
-rw-r--r--test cases/common/135 generated assembly/square-arm.S.in12
-rw-r--r--test cases/common/135 generated assembly/square-x86.S.in33
-rw-r--r--test cases/common/135 generated assembly/square-x86_64.S.in39
-rw-r--r--test cases/common/135 generated assembly/symbol-underscore.h5
7 files changed, 148 insertions, 0 deletions
diff --git a/test cases/common/135 generated assembly/copy.py b/test cases/common/135 generated assembly/copy.py
new file mode 100644
index 0000000..da503e2
--- /dev/null
+++ b/test cases/common/135 generated assembly/copy.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import sys
+import shutil
+
+shutil.copyfile(sys.argv[1], sys.argv[2])
diff --git a/test cases/common/135 generated assembly/main.c b/test cases/common/135 generated assembly/main.c
new file mode 100644
index 0000000..97fe723
--- /dev/null
+++ b/test cases/common/135 generated assembly/main.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+unsigned square_unsigned (unsigned a);
+
+int
+main (int argc, char * argv[])
+{
+ unsigned int ret = square_unsigned (2);
+ if (ret != 4) {
+ printf("Got %u instead of 4\n", ret);
+ return 1;
+ }
+ return 0;
+}
diff --git a/test cases/common/135 generated assembly/meson.build b/test cases/common/135 generated assembly/meson.build
new file mode 100644
index 0000000..b5e81d5
--- /dev/null
+++ b/test cases/common/135 generated assembly/meson.build
@@ -0,0 +1,39 @@
+project('generated assembly', 'c')
+
+cc = meson.get_compiler('c')
+
+if cc.get_id() == 'msvc'
+ error('MESON_SKIP_TEST: assembly files cannot be compiled directly by MSVC')
+endif
+
+cpu = host_machine.cpu_family()
+supported_cpus = ['arm', 'x86', 'x86_64']
+
+if not supported_cpus.contains(cpu)
+ error('MESON_SKIP_TEST: unsupported cpu family: ' + cpu)
+endif
+
+if cc.symbols_have_underscore_prefix()
+ add_project_arguments('-DMESON_TEST__UNDERSCORE_SYMBOL', language : 'c')
+endif
+
+copy = find_program('copy.py')
+output = 'square-@0@.S'.format(cpu)
+input = output + '.in'
+
+copygen = generator(copy,
+ arguments : ['@INPUT@', '@OUTPUT@'],
+ output : '@BASENAME@')
+
+l = shared_library('square-gen', copygen.process(input))
+
+test('square-gen-test', executable('square-gen-test', 'main.c', link_with : l))
+
+copyct = custom_target('square',
+ input : input,
+ output : output,
+ command : [copy, '@INPUT@', '@OUTPUT@'])
+
+l = shared_library('square-ct', copyct)
+
+test('square-ct-test', executable('square-ct-test', 'main.c', link_with : l))
diff --git a/test cases/common/135 generated assembly/square-arm.S.in b/test cases/common/135 generated assembly/square-arm.S.in
new file mode 100644
index 0000000..b13c8a0
--- /dev/null
+++ b/test cases/common/135 generated assembly/square-arm.S.in
@@ -0,0 +1,12 @@
+#include "symbol-underscore.h"
+
+.text
+.globl SYMBOL_NAME(square_unsigned)
+#ifndef __APPLE__
+.type square_unsigned,%function
+#endif
+
+SYMBOL_NAME(square_unsigned):
+ mul r1, r0, r0
+ mov r0, r1
+ mov pc, lr
diff --git a/test cases/common/135 generated assembly/square-x86.S.in b/test cases/common/135 generated assembly/square-x86.S.in
new file mode 100644
index 0000000..31688b1
--- /dev/null
+++ b/test cases/common/135 generated assembly/square-x86.S.in
@@ -0,0 +1,33 @@
+#include "symbol-underscore.h"
+
+#ifdef _MSC_VER
+
+.386
+.MODEL FLAT, C
+
+PUBLIC square_unsigned
+_TEXT SEGMENT
+
+square_unsigned PROC var1:DWORD
+ mov eax, var1
+ imul eax, eax
+ ret
+square_unsigned ENDP
+
+_TEXT ENDS
+END
+
+#else
+
+.text
+.globl SYMBOL_NAME(square_unsigned)
+# ifndef __APPLE__
+.type square_unsigned,@function
+# endif
+
+SYMBOL_NAME(square_unsigned):
+ movl 4(%esp), %eax
+ imull %eax, %eax
+ retl
+
+#endif
diff --git a/test cases/common/135 generated assembly/square-x86_64.S.in b/test cases/common/135 generated assembly/square-x86_64.S.in
new file mode 100644
index 0000000..5aedd81
--- /dev/null
+++ b/test cases/common/135 generated assembly/square-x86_64.S.in
@@ -0,0 +1,39 @@
+#include "symbol-underscore.h"
+
+#include "symbol-underscore.h"
+
+#ifdef _MSC_VER /* MSVC on Windows */
+
+PUBLIC SYMBOL_NAME(square_unsigned)
+_TEXT SEGMENT
+
+SYMBOL_NAME(square_unsigned) PROC
+ mov eax, ecx
+ imul eax, eax
+ ret
+SYMBOL_NAME(square_unsigned) ENDP
+
+_TEXT ENDS
+END
+
+#else
+
+.text
+.globl SYMBOL_NAME(square_unsigned)
+# ifndef __APPLE__
+.type square_unsigned,@function
+# endif
+
+# ifdef _WIN32 /* MinGW */
+SYMBOL_NAME(square_unsigned):
+ imull %ecx, %ecx
+ movl %ecx, %eax
+ retq
+# else /* Linux and OS X */
+SYMBOL_NAME(square_unsigned):
+ imull %edi, %edi
+ movl %edi, %eax
+ retq
+# endif
+
+#endif
diff --git a/test cases/common/135 generated assembly/symbol-underscore.h b/test cases/common/135 generated assembly/symbol-underscore.h
new file mode 100644
index 0000000..d0f3ef9
--- /dev/null
+++ b/test cases/common/135 generated assembly/symbol-underscore.h
@@ -0,0 +1,5 @@
+#if defined(MESON_TEST__UNDERSCORE_SYMBOL)
+# define SYMBOL_NAME(name) _##name
+#else
+# define SYMBOL_NAME(name) name
+#endif