From f3bd0d149174b2bbb4983b48e603e060a3e18c22 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sun, 4 Dec 2016 02:36:06 +0530 Subject: tests/linuxlike/1: Improve zlib pkg-config test Just checking that the version retrieved from the pkg-config file matches is not enough. It's nearly tautological since it just checks that we aren't returning garbage in dep.version(). Instead, check in the test executable that the pkg-config version retrieved matches the ZLIB_VERSION exported by zlib. Also don't require zlib 1.2.8 since RHEL (EPEL) 7 still has 1.2.7 and we don't really need 1.2.8 anyway. --- test cases/linuxlike/1 pkg-config/meson.build | 11 ++++++++--- test cases/linuxlike/1 pkg-config/prog-checkver.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 test cases/linuxlike/1 pkg-config/prog-checkver.c (limited to 'test cases/linuxlike') diff --git a/test cases/linuxlike/1 pkg-config/meson.build b/test cases/linuxlike/1 pkg-config/meson.build index 13361a7f3..5a8366c6a 100644 --- a/test cases/linuxlike/1 pkg-config/meson.build +++ b/test cases/linuxlike/1 pkg-config/meson.build @@ -2,11 +2,16 @@ project('external dependency', 'c') # Zlib is probably on all dev machines. -dep = dependency('zlib', version : '>=1.2.8') -exe = executable('zlibprog', 'prog.c', dependencies : dep) +dep = dependency('zlib', version : '>=1.2') +exe = executable('zlibprog', 'prog-checkver.c', + dependencies : dep, + c_args : '-DFOUND_ZLIB="' + dep.version() + '"') -assert(dep.version().version_compare('>=1.2.8'), 'Pkg-config version numbers exposed incorrectly.') +assert(dep.version().version_compare('>=1.2'), 'Pkg-config version numbers exposed incorrectly.') +# Check that the version exposed by zlib internally is the same as the one we +# retrieve from the pkg-config file. This assumes that the packager didn't mess +# up, but we can be reasonably sure of that. test('zlibtest', exe) zprefix = dep.get_pkgconfig_variable('prefix') # Always set but we can't be sure what the value is. diff --git a/test cases/linuxlike/1 pkg-config/prog-checkver.c b/test cases/linuxlike/1 pkg-config/prog-checkver.c new file mode 100644 index 000000000..16b717059 --- /dev/null +++ b/test cases/linuxlike/1 pkg-config/prog-checkver.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int main(int argc, char **argv) { + void * something = deflate; + if(strcmp(ZLIB_VERSION, FOUND_ZLIB) != 0) { + printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); + return 2; + } + if(something != 0) + return 0; + printf("Couldn't find 'deflate'\n"); + return 1; +} -- cgit v1.2.3