aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-11-08 13:43:58 -0800
committerNirbheek Chauhan <nirbheek@centricular.com>2021-11-25 21:13:48 +0530
commitdc5b0cf50c65a93d9d9e4501d4f297a73aa32147 (patch)
tree4c1103dfa32c98a18b649fb0e65cc29e2b10f23a
parent35cf7c5dd54ee03a764576aa89ce7ae0b7456792 (diff)
downloadmeson-dc5b0cf50c65a93d9d9e4501d4f297a73aa32147.zip
meson-dc5b0cf50c65a93d9d9e4501d4f297a73aa32147.tar.gz
meson-dc5b0cf50c65a93d9d9e4501d4f297a73aa32147.tar.bz2
unit tests: Extend prebuilt test to test intermediate
This provides coverage for the bug: https://github.com/mesonbuild/meson/issues/9542
-rw-r--r--test cases/unit/17 prebuilt shared/meson.build27
-rw-r--r--test cases/unit/17 prebuilt shared/meson_options.txt1
-rw-r--r--test cases/unit/17 prebuilt shared/rejected.c8
-rw-r--r--test cases/unit/17 prebuilt shared/rejected.h6
-rw-r--r--test cases/unit/17 prebuilt shared/rejected_main.c6
-rw-r--r--unittests/allplatformstests.py23
6 files changed, 70 insertions, 1 deletions
diff --git a/test cases/unit/17 prebuilt shared/meson.build b/test cases/unit/17 prebuilt shared/meson.build
index 9a4eca0..7badcb7 100644
--- a/test cases/unit/17 prebuilt shared/meson.build
+++ b/test cases/unit/17 prebuilt shared/meson.build
@@ -1,7 +1,12 @@
project('prebuilt shared library', 'c')
+search_dir = get_option('search_dir')
+if search_dir == 'auto'
+ search_dir = meson.current_source_dir()
+endif
+
cc = meson.get_compiler('c')
-shlib = cc.find_library('alexandria', dirs : meson.current_source_dir())
+shlib = cc.find_library('alexandria', dirs : search_dir)
exe = executable('patron', 'patron.c', dependencies : shlib)
test('visitation', exe)
@@ -11,3 +16,23 @@ d = declare_dependency(dependencies : shlib)
exe2 = executable('another_visitor', 'another_visitor.c',
dependencies : d)
test('another', exe2)
+
+stlib = static_library(
+ 'rejected',
+ 'rejected.c',
+ dependencies : shlib,
+)
+
+rejected = executable(
+ 'rejected',
+ 'rejected_main.c',
+ link_with : stlib,
+)
+test('rejected', rejected)
+
+rejected_whole = executable(
+ 'rejected_whole',
+ 'rejected_main.c',
+ link_whole : stlib,
+)
+test('rejected (whole archive)', rejected_whole)
diff --git a/test cases/unit/17 prebuilt shared/meson_options.txt b/test cases/unit/17 prebuilt shared/meson_options.txt
new file mode 100644
index 0000000..7876a6f
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/meson_options.txt
@@ -0,0 +1 @@
+option('search_dir', type : 'string', value : 'auto')
diff --git a/test cases/unit/17 prebuilt shared/rejected.c b/test cases/unit/17 prebuilt shared/rejected.c
new file mode 100644
index 0000000..9d7ac94
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected.c
@@ -0,0 +1,8 @@
+#include "rejected.h"
+
+void say(void) {
+ printf("You are standing outside the Great Library of Alexandria.\n");
+ printf("You decide to go inside.\n\n");
+ alexandria_visit();
+ printf("The librarian tells you it's time to leave\n");
+}
diff --git a/test cases/unit/17 prebuilt shared/rejected.h b/test cases/unit/17 prebuilt shared/rejected.h
new file mode 100644
index 0000000..b9ccf31
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected.h
@@ -0,0 +1,6 @@
+#include <stdio.h>
+#include <alexandria.h>
+
+#pragma once
+
+void say(void);
diff --git a/test cases/unit/17 prebuilt shared/rejected_main.c b/test cases/unit/17 prebuilt shared/rejected_main.c
new file mode 100644
index 0000000..4d35061
--- /dev/null
+++ b/test cases/unit/17 prebuilt shared/rejected_main.c
@@ -0,0 +1,6 @@
+#include "rejected.h"
+
+int main(void) {
+ say();
+ return 0;
+}
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index adb458e..5428e68 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1520,6 +1520,29 @@ class AllPlatformTests(BasePlatformTests):
self.build()
self.run_tests()
+ def test_prebuilt_shared_lib_rpath(self) -> None:
+ (cc, _, object_suffix, shared_suffix) = self.detect_prebuild_env()
+ tdir = os.path.join(self.unit_test_dir, '17 prebuilt shared')
+ with tempfile.TemporaryDirectory() as d:
+ source = os.path.join(tdir, 'alexandria.c')
+ objectfile = os.path.join(d, 'alexandria.' + object_suffix)
+ impfile = os.path.join(d, 'alexandria.lib')
+ if cc.get_argument_syntax() == 'msvc':
+ shlibfile = os.path.join(d, 'alexandria.' + shared_suffix)
+ elif is_cygwin():
+ shlibfile = os.path.join(d, 'cygalexandria.' + shared_suffix)
+ else:
+ shlibfile = os.path.join(d, 'libalexandria.' + shared_suffix)
+ # Ensure MSVC extra files end up in the directory that gets deleted
+ # at the end
+ with chdir(d):
+ self.build_shared_lib(cc, source, objectfile, shlibfile, impfile)
+
+ # Run the test
+ self.init(tdir, extra_args=[f'-Dsearch_dir={d}'])
+ self.build()
+ self.run_tests()
+
@skipIfNoPkgconfig
def test_pkgconfig_static(self):
'''