aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-12-04 02:36:06 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2016-12-04 01:14:44 +0200
commitf3bd0d149174b2bbb4983b48e603e060a3e18c22 (patch)
tree35d80c4e6574f7de7dfc32c89ee691f72475bf11
parent0c22b8f7076e9c32a8755936244cf3244f045ba8 (diff)
downloadmeson-f3bd0d149174b2bbb4983b48e603e060a3e18c22.zip
meson-f3bd0d149174b2bbb4983b48e603e060a3e18c22.tar.gz
meson-f3bd0d149174b2bbb4983b48e603e060a3e18c22.tar.bz2
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.
-rw-r--r--test cases/linuxlike/1 pkg-config/meson.build11
-rw-r--r--test cases/linuxlike/1 pkg-config/prog-checkver.c15
2 files changed, 23 insertions, 3 deletions
diff --git a/test cases/linuxlike/1 pkg-config/meson.build b/test cases/linuxlike/1 pkg-config/meson.build
index 13361a7..5a8366c 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 0000000..16b7170
--- /dev/null
+++ b/test cases/linuxlike/1 pkg-config/prog-checkver.c
@@ -0,0 +1,15 @@
+#include <zlib.h>
+#include <stdio.h>
+#include <string.h>
+
+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;
+}