Fix tests for the new library/executable naming scheme
Also add new tests for the platform-specific and compiler-specific versioning scheme. A rough summary is: 1. A bug in how run_tests.py:validate_install checked for files has been fixed. Earlier it wasn't checking the install directory properly. 2. Shared libraries are no longer installed in common tests, and the library name/path testing is now done in platform-specific tests. 3. Executables are now always called something?exe in the installed_files.txt file, and the suffix automatically corrected depending on the platform. 4. If a test installs a file called 'no-installed-files', the installed files for that test are not validated. This is required to implement compiler-specific tests for library names/paths such as MSVC vs MinGW 5. The platform-specific file renaming in run_tests.py has been mostly removed since it is broken for shared libraries and isn't needed for static libraries. 6. run_tests.py now reports all missing and extra files. The logic for finding these has been reworked.
This commit is contained in:
parent
598997bdb5
commit
45c8557dc6
66
run_tests.py
66
run_tests.py
|
@ -124,44 +124,50 @@ def setup_commands(backend):
|
|||
test_commands = [ninja_command, 'test', 'benchmark']
|
||||
install_commands = [ninja_command, 'install']
|
||||
|
||||
def platform_fix_filename(fname):
|
||||
if mesonlib.is_osx():
|
||||
if fname.endswith('.so'):
|
||||
return fname[:-2] + 'dylib'
|
||||
return fname.replace('.so.', '.dylib.')
|
||||
elif mesonlib.is_windows():
|
||||
if fname.endswith('.so'):
|
||||
(p, f) = os.path.split(fname)
|
||||
f = f[3:-2] + 'dll'
|
||||
return os.path.join(p, f)
|
||||
if fname.endswith('.a'):
|
||||
return fname[:-1] + 'lib'
|
||||
def get_relative_files_list_from_dir(fromdir):
|
||||
paths = []
|
||||
for (root, _, files) in os.walk(fromdir):
|
||||
reldir = os.path.relpath(root, start=fromdir)
|
||||
for f in files:
|
||||
path = os.path.join(reldir, f).replace('\\', '/')
|
||||
if path.startswith('./'):
|
||||
path = path[2:]
|
||||
paths.append(path)
|
||||
return paths
|
||||
|
||||
def platform_fix_exe_name(fname):
|
||||
if not fname.endswith('?exe'):
|
||||
return fname
|
||||
fname = fname[:-4]
|
||||
if mesonlib.is_windows():
|
||||
return fname + '.exe'
|
||||
return fname
|
||||
|
||||
def validate_install(srcdir, installdir):
|
||||
if mesonlib.is_windows():
|
||||
# Don't really know how Windows installs should work
|
||||
# so skip.
|
||||
return ''
|
||||
info_file = os.path.join(srcdir, 'installed_files.txt')
|
||||
expected = {}
|
||||
found = {}
|
||||
ret_msg = ''
|
||||
# Test expects to not install any files
|
||||
if os.path.exists(os.path.join(installdir, 'usr', 'no-installed-files')):
|
||||
return ''
|
||||
# Generate list of expected files
|
||||
if os.path.exists(info_file):
|
||||
for line in open(info_file):
|
||||
expected[platform_fix_filename(line.strip())] = True
|
||||
for root, _, files in os.walk(installdir):
|
||||
for fname in files:
|
||||
found_name = os.path.join(root, fname)[len(installdir)+1:]
|
||||
found[found_name] = True
|
||||
expected = set(expected)
|
||||
found = set(found)
|
||||
missing = expected - found
|
||||
for fname in missing:
|
||||
return 'Expected file %s missing.' % fname
|
||||
extra = found - expected
|
||||
for fname in extra:
|
||||
return 'Found extra file %s.' % fname
|
||||
return ''
|
||||
expected[platform_fix_exe_name(line.strip())] = False
|
||||
# Check if expected files were found
|
||||
for fname in expected:
|
||||
if os.path.exists(os.path.join(installdir, fname)):
|
||||
expected[fname] = True
|
||||
for (fname, found) in expected.items():
|
||||
if not found:
|
||||
ret_msg += 'Expected file {0} missing.\n'.format(fname)
|
||||
# Check if there are any unexpected files
|
||||
found = get_relative_files_list_from_dir(installdir)
|
||||
for fname in found:
|
||||
if fname not in expected:
|
||||
ret_msg += 'Extra file {0} found.\n'.format(fname)
|
||||
return ret_msg
|
||||
|
||||
def log_text_file(logfile, testdir, stdo, stde):
|
||||
global stop, executor, futures
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
usr/lib/libsomelib.so
|
||||
usr/lib/libsomelib.so.0
|
||||
usr/lib/libsomelib.so.1.2.3
|
||||
usr/lib/prefixsomelib.suffix
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
project('library versions', 'c')
|
||||
|
||||
lib = shared_library('somelib', 'lib.c', \
|
||||
version : '1.2.3', \
|
||||
soversion : '0', \
|
||||
install : true)
|
||||
shared_library('somelib', 'lib.c',
|
||||
name_prefix : 'prefix',
|
||||
name_suffix : 'suffix',
|
||||
install_dir : 'lib',
|
||||
install : true)
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
usr/bin/prog
|
||||
usr/lib/liblib1.so
|
||||
usr/lib/liblib2.so
|
||||
usr/lib/liblib3.so
|
||||
usr/bin/prog?exe
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
subdir('subdir2')
|
||||
subdir('subdir3')
|
||||
|
||||
lib1 = shared_library('lib1', 'lib1.c', install : true, link_with : [lib2, lib3])
|
||||
lib1 = shared_library('lib1', 'lib1.c', install : false, link_with : [lib2, lib3])
|
||||
|
|
|
@ -1 +1 @@
|
|||
lib2 = shared_library('lib2', 'lib2.c', install : true)
|
||||
lib2 = shared_library('lib2', 'lib2.c', install : false)
|
||||
|
|
|
@ -1 +1 @@
|
|||
lib3 = shared_library('lib3', 'lib3.c', install : true)
|
||||
lib3 = shared_library('lib3', 'lib3.c', install : false)
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
usr/bin/user
|
||||
usr/lib/libsublib.so
|
||||
usr/bin/user?exe
|
||||
usr/share/sublib/sublib.depmf
|
||||
|
|
|
@ -13,7 +13,7 @@ if meson.project_version() != '1.0.0'
|
|||
endif
|
||||
|
||||
i = include_directories('include')
|
||||
l = shared_library('sublib', 'sublib.c', include_directories : i, install : true,
|
||||
l = shared_library('sublib', 'sublib.c', include_directories : i, install : false,
|
||||
c_args : '-DBUILDING_SUB=2')
|
||||
t = executable('simpletest', 'simpletest.c', include_directories : i, link_with : l)
|
||||
test('plain', t)
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
usr/include/simple.h
|
||||
usr/lib/libsimple.so
|
||||
usr/lib/pkgconfig/simple.pc
|
||||
|
|
|
@ -2,7 +2,7 @@ project('pkgconfig-gen', 'c')
|
|||
|
||||
pkgg = import('pkgconfig')
|
||||
|
||||
lib = shared_library('simple', 'simple.c', install : true)
|
||||
lib = shared_library('simple', 'simple.c')
|
||||
libver = '1.0'
|
||||
h = install_headers('simple.h')
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
usr/dib/dab/dub/prog
|
||||
usr/dib/dab/dub/prog?exe
|
||||
usr/some/dir/sample.h
|
||||
usr/woman/prog.1.gz
|
||||
usr/meow/datafile.cat
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
usr/bin/prog
|
||||
usr/lib/libmylib.so
|
||||
usr/bin/prog?exe
|
||||
|
|
|
@ -2,7 +2,7 @@ project('shared library linking test', 'c', 'cpp')
|
|||
|
||||
lib = shared_library('mylib',
|
||||
'libfile.c' # Split to different lines before and after the comma to test parser.
|
||||
, install : true)
|
||||
, install : false) # Don't install libraries in common tests; the path is platform-specific
|
||||
exe = executable('prog', 'main.c', link_with : lib, install : true)
|
||||
|
||||
test('runtest', exe)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
usr/bin/prog
|
||||
usr/bin/prog?exe
|
||||
usr/diiba/daaba/file.dat
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
project('custom install script', 'c')
|
||||
|
||||
if meson.get_compiler('c').get_id() == 'msvc'
|
||||
meson.add_install_script('myinstall.bat')
|
||||
install_data('no-installed-files', install_dir : '')
|
||||
else
|
||||
meson.add_install_script('myinstall.sh')
|
||||
endif
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
@ECHO OFF
|
||||
|
||||
echo At this point we could do something.
|
|
@ -4,9 +4,7 @@ set -eu
|
|||
|
||||
echo Starting custom installation step
|
||||
|
||||
# These commands fail on Windows, but we don't really care.
|
||||
|
||||
mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba"
|
||||
touch "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba/file.dat"
|
||||
|
||||
echo Finishing custom install step
|
||||
echo Finished custom install step
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
usr/bin/prog1
|
||||
usr/bin/prog2
|
||||
usr/bin/prog3
|
||||
usr/bin/prog1?exe
|
||||
usr/bin/prog2?exe
|
||||
usr/bin/prog3?exe
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
usr/bin/prog
|
||||
usr/lib/libshar.so
|
||||
usr/bin/prog?exe
|
||||
usr/lib/libstat.a
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
project('install test', 'c')
|
||||
|
||||
stlib = static_library('stat', 'stat.c', install : true)
|
||||
shlib = shared_library('shar', 'shar.c', install : true)
|
||||
exe = executable('prog', 'prog.c', install : true)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
int func() { return 15; }
|
|
@ -1,2 +1,2 @@
|
|||
usr/bin/prog.exe
|
||||
usr/lib/libhelper.dll
|
||||
usr/lib/helper.dll
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
usr/lib/libsome.so
|
||||
usr/lib/libsome.so.0
|
||||
usr/lib/libsome.so.1.2.3
|
||||
usr/lib/libnoversion.so
|
||||
usr/lib/libonlyversion.so
|
||||
usr/lib/libonlyversion.so.1
|
||||
usr/lib/libonlyversion.so.1.4.5
|
||||
usr/lib/libonlysoversion.so
|
||||
usr/lib/libonlysoversion.so.5
|
|
@ -0,0 +1,3 @@
|
|||
int myFunc() {
|
||||
return 55;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
project('library versions', 'c')
|
||||
|
||||
shared_library('some', 'lib.c',
|
||||
version : '1.2.3',
|
||||
soversion : '0',
|
||||
install : true)
|
||||
|
||||
shared_library('noversion', 'lib.c',
|
||||
install : true)
|
||||
|
||||
shared_library('onlyversion', 'lib.c',
|
||||
version : '1.4.5',
|
||||
install : true)
|
||||
|
||||
shared_library('onlysoversion', 'lib.c',
|
||||
# Also test that int soversion is acceptable
|
||||
soversion : 5,
|
||||
install : true)
|
|
@ -0,0 +1,4 @@
|
|||
usr/lib/libsome.0.dylib
|
||||
usr/lib/libnoversion.dylib
|
||||
usr/lib/libonlyversion.1.dylib
|
||||
usr/lib/libonlysoversion.5.dylib
|
|
@ -0,0 +1,3 @@
|
|||
int myFunc() {
|
||||
return 55;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
project('library versions', 'c')
|
||||
|
||||
shared_library('some', 'lib.c',
|
||||
version : '1.2.3',
|
||||
soversion : '0',
|
||||
install : true)
|
||||
|
||||
shared_library('noversion', 'lib.c',
|
||||
install : true)
|
||||
|
||||
shared_library('onlyversion', 'lib.c',
|
||||
version : '1.4.5',
|
||||
install : true)
|
||||
|
||||
shared_library('onlysoversion', 'lib.c',
|
||||
# Also test that int soversion is acceptable
|
||||
soversion : 5,
|
||||
install : true)
|
|
@ -1 +1 @@
|
|||
usr/bin/prog
|
||||
usr/bin/prog?exe
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
usr/bin/prog
|
||||
usr/bin/prog?exe
|
||||
usr/lib/libstuff.rlib
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
usr/bin/prog
|
||||
usr/bin/prog?exe
|
||||
usr/lib/libstuff.rlib
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
usr/bin/libsome-0.dll
|
||||
usr/lib/libsome.dll.a
|
||||
usr/bin/libnoversion.dll
|
||||
usr/lib/libnoversion.dll.a
|
|
@ -0,0 +1,6 @@
|
|||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int myFunc() {
|
||||
return 55;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
project('mingw dll versioning', 'c')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
# Test that MinGW/GCC creates correctly-named dll files and dll.a files,
|
||||
# and also installs them in the right place
|
||||
if cc.get_id() != 'msvc'
|
||||
shared_library('some', 'lib.c',
|
||||
version : '1.2.3',
|
||||
soversion : '0',
|
||||
install : true)
|
||||
|
||||
shared_library('noversion', 'lib.c',
|
||||
install : true)
|
||||
else
|
||||
install_data('no-installed-files', install_dir : '')
|
||||
endif
|
|
@ -0,0 +1,4 @@
|
|||
usr/bin/some-0.dll
|
||||
usr/lib/some.lib
|
||||
usr/bin/noversion.dll
|
||||
usr/lib/noversion.lib
|
|
@ -0,0 +1,6 @@
|
|||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int myFunc() {
|
||||
return 55;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
project('msvc dll versioning', 'c')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
# Test that MSVC creates foo-0.dll and bar.dll
|
||||
if cc.get_id() == 'msvc'
|
||||
shared_library('some', 'lib.c',
|
||||
version : '1.2.3',
|
||||
soversion : '0',
|
||||
install : true)
|
||||
|
||||
shared_library('noversion', 'lib.c',
|
||||
install : true)
|
||||
else
|
||||
install_data('no-installed-files', install_dir : '')
|
||||
endif
|
Loading…
Reference in New Issue