unit tests: Extend prebuilt test to test intermediate

This provides coverage for the bug:
https://github.com/mesonbuild/meson/issues/9542
pull/9628/head
Dylan Baker 3 years ago committed by Nirbheek Chauhan
parent 73bac14c8f
commit bd9d981871
  1. 27
      test cases/unit/17 prebuilt shared/meson.build
  2. 1
      test cases/unit/17 prebuilt shared/meson_options.txt
  3. 8
      test cases/unit/17 prebuilt shared/rejected.c
  4. 6
      test cases/unit/17 prebuilt shared/rejected.h
  5. 6
      test cases/unit/17 prebuilt shared/rejected_main.c
  6. 23
      unittests/allplatformstests.py

@ -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)

@ -0,0 +1 @@
option('search_dir', type : 'string', value : 'auto')

@ -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");
}

@ -0,0 +1,6 @@
#include <stdio.h>
#include <alexandria.h>
#pragma once
void say(void);

@ -0,0 +1,6 @@
#include "rejected.h"
int main(void) {
say();
return 0;
}

@ -1516,6 +1516,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):
'''

Loading…
Cancel
Save