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.
pull/417/head
Nirbheek Chauhan 9 years ago
parent 598997bdb5
commit 45c8557dc6
  1. 66
      run_tests.py
  2. 4
      test cases/common/27 library versions/installed_files.txt
  3. 9
      test cases/common/27 library versions/meson.build
  4. 5
      test cases/common/46 library chain/installed_files.txt
  5. 2
      test cases/common/46 library chain/subdir/meson.build
  6. 2
      test cases/common/46 library chain/subdir/subdir2/meson.build
  7. 2
      test cases/common/46 library chain/subdir/subdir3/meson.build
  8. 3
      test cases/common/49 subproject/installed_files.txt
  9. 2
      test cases/common/49 subproject/subprojects/sublib/meson.build
  10. 1
      test cases/common/51 pkgconfig-gen/installed_files.txt
  11. 2
      test cases/common/51 pkgconfig-gen/meson.build
  12. 2
      test cases/common/52 custom install dirs/installed_files.txt
  13. 3
      test cases/common/6 linkshared/installed_files.txt
  14. 2
      test cases/common/6 linkshared/meson.build
  15. 2
      test cases/common/60 install script/installed_files.txt
  16. 2
      test cases/common/60 install script/meson.build
  17. 3
      test cases/common/60 install script/myinstall.bat
  18. 4
      test cases/common/60 install script/myinstall.sh
  19. 0
      test cases/common/60 install script/no-installed-files
  20. 6
      test cases/common/67 foreach/installed_files.txt
  21. 3
      test cases/common/8 install/installed_files.txt
  22. 1
      test cases/common/8 install/meson.build
  23. 1
      test cases/common/8 install/shar.c
  24. 2
      test cases/csharp/2 library/installed_files.txt
  25. 9
      test cases/linuxlike/7 library versions/installed_files.txt
  26. 3
      test cases/linuxlike/7 library versions/lib.c
  27. 18
      test cases/linuxlike/7 library versions/meson.build
  28. 4
      test cases/osx/2 library versions/installed_files.txt
  29. 3
      test cases/osx/2 library versions/lib.c
  30. 18
      test cases/osx/2 library versions/meson.build
  31. 2
      test cases/rust/1 basic/installed_files.txt
  32. 2
      test cases/rust/2 sharedlib/installed_files.txt
  33. 2
      test cases/rust/3 staticlib/installed_files.txt
  34. 4
      test cases/windows/7 mingw dll versioning/installed_files.txt
  35. 6
      test cases/windows/7 mingw dll versioning/lib.c
  36. 17
      test cases/windows/7 mingw dll versioning/meson.build
  37. 0
      test cases/windows/7 mingw dll versioning/no-installed-files
  38. 4
      test cases/windows/8 msvc dll versioning/installed_files.txt
  39. 6
      test cases/windows/8 msvc dll versioning/lib.c
  40. 16
      test cases/windows/8 msvc dll versioning/meson.build
  41. 0
      test cases/windows/8 msvc dll versioning/no-installed-files

@ -124,44 +124,50 @@ def setup_commands(backend):
test_commands = [ninja_command, 'test', 'benchmark'] test_commands = [ninja_command, 'test', 'benchmark']
install_commands = [ninja_command, 'install'] install_commands = [ninja_command, 'install']
def platform_fix_filename(fname): def get_relative_files_list_from_dir(fromdir):
if mesonlib.is_osx(): paths = []
if fname.endswith('.so'): for (root, _, files) in os.walk(fromdir):
return fname[:-2] + 'dylib' reldir = os.path.relpath(root, start=fromdir)
return fname.replace('.so.', '.dylib.') for f in files:
elif mesonlib.is_windows(): path = os.path.join(reldir, f).replace('\\', '/')
if fname.endswith('.so'): if path.startswith('./'):
(p, f) = os.path.split(fname) path = path[2:]
f = f[3:-2] + 'dll' paths.append(path)
return os.path.join(p, f) return paths
if fname.endswith('.a'):
return fname[:-1] + 'lib' 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 return fname
def validate_install(srcdir, installdir): 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') info_file = os.path.join(srcdir, 'installed_files.txt')
expected = {} expected = {}
found = {} 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): if os.path.exists(info_file):
for line in open(info_file): for line in open(info_file):
expected[platform_fix_filename(line.strip())] = True expected[platform_fix_exe_name(line.strip())] = False
for root, _, files in os.walk(installdir): # Check if expected files were found
for fname in files: for fname in expected:
found_name = os.path.join(root, fname)[len(installdir)+1:] if os.path.exists(os.path.join(installdir, fname)):
found[found_name] = True expected[fname] = True
expected = set(expected) for (fname, found) in expected.items():
found = set(found) if not found:
missing = expected - found ret_msg += 'Expected file {0} missing.\n'.format(fname)
for fname in missing: # Check if there are any unexpected files
return 'Expected file %s missing.' % fname found = get_relative_files_list_from_dir(installdir)
extra = found - expected for fname in found:
for fname in extra: if fname not in expected:
return 'Found extra file %s.' % fname ret_msg += 'Extra file {0} found.\n'.format(fname)
return '' return ret_msg
def log_text_file(logfile, testdir, stdo, stde): def log_text_file(logfile, testdir, stdo, stde):
global stop, executor, futures global stop, executor, futures

@ -1,3 +1 @@
usr/lib/libsomelib.so usr/lib/prefixsomelib.suffix
usr/lib/libsomelib.so.0
usr/lib/libsomelib.so.1.2.3

@ -1,6 +1,7 @@
project('library versions', 'c') project('library versions', 'c')
lib = shared_library('somelib', 'lib.c', \ shared_library('somelib', 'lib.c',
version : '1.2.3', \ name_prefix : 'prefix',
soversion : '0', \ name_suffix : 'suffix',
install : true) install_dir : 'lib',
install : true)

@ -1,4 +1 @@
usr/bin/prog usr/bin/prog?exe
usr/lib/liblib1.so
usr/lib/liblib2.so
usr/lib/liblib3.so

@ -1,4 +1,4 @@
subdir('subdir2') subdir('subdir2')
subdir('subdir3') 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/bin/user?exe
usr/lib/libsublib.so
usr/share/sublib/sublib.depmf usr/share/sublib/sublib.depmf

@ -13,7 +13,7 @@ if meson.project_version() != '1.0.0'
endif endif
i = include_directories('include') 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') c_args : '-DBUILDING_SUB=2')
t = executable('simpletest', 'simpletest.c', include_directories : i, link_with : l) t = executable('simpletest', 'simpletest.c', include_directories : i, link_with : l)
test('plain', t) test('plain', t)

@ -1,3 +1,2 @@
usr/include/simple.h usr/include/simple.h
usr/lib/libsimple.so
usr/lib/pkgconfig/simple.pc usr/lib/pkgconfig/simple.pc

@ -2,7 +2,7 @@ project('pkgconfig-gen', 'c')
pkgg = import('pkgconfig') pkgg = import('pkgconfig')
lib = shared_library('simple', 'simple.c', install : true) lib = shared_library('simple', 'simple.c')
libver = '1.0' libver = '1.0'
h = install_headers('simple.h') 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/some/dir/sample.h
usr/woman/prog.1.gz usr/woman/prog.1.gz
usr/meow/datafile.cat usr/meow/datafile.cat

@ -1,2 +1 @@
usr/bin/prog usr/bin/prog?exe
usr/lib/libmylib.so

@ -2,7 +2,7 @@ project('shared library linking test', 'c', 'cpp')
lib = shared_library('mylib', lib = shared_library('mylib',
'libfile.c' # Split to different lines before and after the comma to test parser. '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) exe = executable('prog', 'main.c', link_with : lib, install : true)
test('runtest', exe) test('runtest', exe)

@ -1,2 +1,2 @@
usr/bin/prog usr/bin/prog?exe
usr/diiba/daaba/file.dat usr/diiba/daaba/file.dat

@ -1,7 +1,7 @@
project('custom install script', 'c') project('custom install script', 'c')
if meson.get_compiler('c').get_id() == 'msvc' if meson.get_compiler('c').get_id() == 'msvc'
meson.add_install_script('myinstall.bat') install_data('no-installed-files', install_dir : '')
else else
meson.add_install_script('myinstall.sh') meson.add_install_script('myinstall.sh')
endif 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 echo Starting custom installation step
# These commands fail on Windows, but we don't really care.
mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba" mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba"
touch "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba/file.dat" 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/prog1?exe
usr/bin/prog2 usr/bin/prog2?exe
usr/bin/prog3 usr/bin/prog3?exe

@ -1,3 +1,2 @@
usr/bin/prog usr/bin/prog?exe
usr/lib/libshar.so
usr/lib/libstat.a usr/lib/libstat.a

@ -1,5 +1,4 @@
project('install test', 'c') project('install test', 'c')
stlib = static_library('stat', 'stat.c', install : true) stlib = static_library('stat', 'stat.c', install : true)
shlib = shared_library('shar', 'shar.c', install : true)
exe = executable('prog', 'prog.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/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 usr/lib/libstuff.rlib

@ -1,2 +1,2 @@
usr/bin/prog usr/bin/prog?exe
usr/lib/libstuff.rlib 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…
Cancel
Save