aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-01-20 02:09:29 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-01-20 02:10:58 +0530
commitf934598865f7923d49b467e1f5db673c6e3b6636 (patch)
treeb845159fe5c49efcf207be78c12ef8329cebbfef
parent11f9425a5e123e7e4bb6296f4453a8e072eb95ed (diff)
downloadmeson-f934598865f7923d49b467e1f5db673c6e3b6636.zip
meson-f934598865f7923d49b467e1f5db673c6e3b6636.tar.gz
meson-f934598865f7923d49b467e1f5db673c6e3b6636.tar.bz2
Add a test for generated LLVM IR files
-rw-r--r--test cases/common/134 generated llvm ir/copy.py6
-rw-r--r--test cases/common/134 generated llvm ir/main.c14
-rw-r--r--test cases/common/134 generated llvm ir/meson.build24
-rw-r--r--test cases/common/134 generated llvm ir/square.ll.in4
4 files changed, 48 insertions, 0 deletions
diff --git a/test cases/common/134 generated llvm ir/copy.py b/test cases/common/134 generated llvm ir/copy.py
new file mode 100644
index 0000000..da503e2
--- /dev/null
+++ b/test cases/common/134 generated llvm ir/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/134 generated llvm ir/main.c b/test cases/common/134 generated llvm ir/main.c
new file mode 100644
index 0000000..97fe723
--- /dev/null
+++ b/test cases/common/134 generated llvm ir/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/134 generated llvm ir/meson.build b/test cases/common/134 generated llvm ir/meson.build
new file mode 100644
index 0000000..7982c23
--- /dev/null
+++ b/test cases/common/134 generated llvm ir/meson.build
@@ -0,0 +1,24 @@
+project('generated llvm ir', 'c')
+
+if meson.get_compiler('c').get_id() != 'clang'
+ error('MESON_SKIP_TEST: LLVM IR files can only be built with clang')
+endif
+
+copy = find_program('copy.py')
+
+copygen = generator(copy,
+ arguments : ['@INPUT@', '@OUTPUT@'],
+ output : '@BASENAME@')
+
+l = shared_library('square-gen', copygen.process('square.ll.in'))
+
+test('square-gen-test', executable('square-gen-test', 'main.c', link_with : l))
+
+copyct = custom_target('square',
+ input : 'square.ll.in',
+ output : 'square.ll',
+ 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/134 generated llvm ir/square.ll.in b/test cases/common/134 generated llvm ir/square.ll.in
new file mode 100644
index 0000000..7c321aa
--- /dev/null
+++ b/test cases/common/134 generated llvm ir/square.ll.in
@@ -0,0 +1,4 @@
+define i32 @square_unsigned(i32 %a) {
+ %1 = mul i32 %a, %a
+ ret i32 %1
+}