2012-05-03 06:50:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Tests for pkg-config compliance.
|
|
|
|
# * Copyright (c) 2012 Michał Górny <mgorny@gentoo.org>.
|
|
|
|
|
|
|
|
done=0
|
|
|
|
failed=0
|
|
|
|
|
|
|
|
run_test() {
|
|
|
|
local res t_ret 2>/dev/null || true
|
2012-07-25 22:47:09 +00:00
|
|
|
local cmdline 2>/dev/null || true
|
2012-05-03 06:50:57 +00:00
|
|
|
|
2012-07-25 22:47:09 +00:00
|
|
|
cmdline="${1}"
|
|
|
|
|
|
|
|
eval res="\$(${1})" 2>/dev/null
|
2012-05-03 06:50:57 +00:00
|
|
|
|
|
|
|
t_ret=0
|
|
|
|
while [ ${#} -gt 1 ]; do
|
|
|
|
shift
|
|
|
|
|
|
|
|
case "${res}" in
|
|
|
|
*${1}*)
|
|
|
|
;;
|
|
|
|
*)
|
2012-07-25 22:47:09 +00:00
|
|
|
echo
|
|
|
|
echo "***********************"
|
|
|
|
echo "!!! Test $done failed."
|
|
|
|
echo "!!! $ ${cmdline}"
|
|
|
|
echo "!!! ${res}"
|
|
|
|
echo "!!! expected '${1}' in output"
|
|
|
|
echo "***********************"
|
2012-05-03 06:50:57 +00:00
|
|
|
t_ret=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${t_ret} -eq 0 ]; then
|
2012-07-25 22:47:09 +00:00
|
|
|
echo -n "."
|
2012-05-03 06:50:57 +00:00
|
|
|
else
|
|
|
|
failed=$(( failed + 1 ))
|
|
|
|
fi
|
|
|
|
done=$(( done + 1 ))
|
|
|
|
}
|
|
|
|
|
|
|
|
selfdir=$(cd "$(dirname "${0}")"; pwd)
|
|
|
|
|
|
|
|
# 1) overall 'is it working?' test
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs foo" \
|
|
|
|
'-lfoo'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags --libs foo" \
|
|
|
|
'-lfoo' '-I/usr/include/foo' '-fPIC'
|
2012-07-20 22:18:35 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags --libs 'foo > 1.2'" \
|
|
|
|
'-lfoo' '-I/usr/include/foo' '-fPIC'
|
2012-07-20 23:08:54 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags --libs 'foo > 1.2 bar >= 1.3'" \
|
|
|
|
'-lfoo' '-I/usr/include/foo' '-fPIC'
|
2012-07-20 22:18:35 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags --libs 'foo' '>' '1.2'" \
|
|
|
|
'-lfoo' '-I/usr/include/foo' '-fPIC'
|
2012-05-03 06:50:57 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'foo > 1.2'; echo \$?" \
|
|
|
|
'0'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'foo > 1.2.3'; echo \$?" \
|
|
|
|
'1'
|
2012-05-06 02:18:40 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'foo' '>' '1.2'; echo \$?" \
|
|
|
|
'0'
|
2012-05-06 04:09:34 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --uninstalled 'foo'; echo \$?" \
|
|
|
|
'1'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --uninstalled 'omg'; echo \$?" \
|
|
|
|
'0'
|
2012-07-20 21:28:50 +00:00
|
|
|
run_test "${1} --modversion ${selfdir}/lib1/foo.pc" \
|
2012-05-06 05:12:00 +00:00
|
|
|
'1.2.3'
|
2012-07-21 00:55:06 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'foo >= '; echo \$?" \
|
|
|
|
'1'
|
2012-07-24 01:53:20 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'tilde <= 1.0.0'; echo \$?" \
|
2012-07-30 10:01:07 +00:00
|
|
|
'1'
|
2012-07-24 01:53:20 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'tilde = 1.0.0~rc1'; echo \$?" \
|
|
|
|
'0'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists 'tilde >= 1.0.0'; echo \$?" \
|
2012-07-30 10:01:07 +00:00
|
|
|
'0'
|
2012-07-25 15:18:09 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists '' 'foo'; echo \$?" \
|
|
|
|
'0'
|
2012-08-09 21:43:20 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs intermediary-1 intermediary-2" \
|
|
|
|
'-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz'
|
2012-05-03 06:50:57 +00:00
|
|
|
|
2012-05-03 07:04:48 +00:00
|
|
|
# 2) tests for PKG_CONFIG_PATH order
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1:${selfdir}/lib2 ${1} --libs foo" \
|
|
|
|
'-lfoo'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib2:${selfdir}/lib1 ${1} --libs foo" \
|
|
|
|
'-lbar'
|
|
|
|
|
2012-05-03 07:15:32 +00:00
|
|
|
# 3) tests for 'Requires' and 'Requires.private'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs bar" \
|
|
|
|
'-lfoo' '-lbar'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs --cflags baz" \
|
|
|
|
'-lbaz' '-fPIC' '-I/usr/include/foo'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --static --libs baz" \
|
2012-05-03 19:44:44 +00:00
|
|
|
'-lfoo' '-lbaz' '-lzee'
|
2012-07-25 22:07:34 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --static --libs argv-parse-2" \
|
|
|
|
'-pthread '
|
2012-05-03 07:15:32 +00:00
|
|
|
|
2012-05-05 17:43:53 +00:00
|
|
|
# 4) tests for parser bugs
|
2012-05-04 03:08:55 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs dos-lineendings" \
|
|
|
|
'-L/usr/lib/dos-lineendings -ldos-lineendings'
|
2012-05-05 17:43:53 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs argv-parse" \
|
|
|
|
'-llib-2 -lpthread'
|
2012-07-20 22:18:35 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exists -foo; echo \$?" \
|
|
|
|
'1'
|
2012-07-30 06:31:14 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs argv-parse-3" \
|
|
|
|
'-llib-1'
|
2012-05-04 03:08:55 +00:00
|
|
|
|
2012-05-05 21:55:27 +00:00
|
|
|
# 5) tests for other regressions
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --variable=includedir foo" \
|
|
|
|
'/usr/include'
|
2012-07-25 22:23:21 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs-only-L cflags-libs-only" \
|
|
|
|
'-L/usr/local/lib'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs-only-L --libs-only-l cflags-libs-only" \
|
|
|
|
'-lfoo'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags-only-I --cflags-only-other cflags-libs-only" \
|
|
|
|
'-I/usr/local/include'
|
2012-05-05 21:55:27 +00:00
|
|
|
|
2012-05-06 02:59:24 +00:00
|
|
|
# 6) tests for builtins
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --modversion pkg-config" \
|
2012-07-21 19:24:26 +00:00
|
|
|
'0.27'
|
2012-05-07 04:30:37 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --variable=prefix foo" \
|
|
|
|
'/usr'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --define-variable=prefix=/test --variable=prefix foo" \
|
|
|
|
'/test'
|
2012-07-21 19:44:38 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --variable=pcfiledir foo" \
|
|
|
|
"${selfdir}/lib1"
|
2012-05-06 02:59:24 +00:00
|
|
|
|
2012-05-07 08:44:59 +00:00
|
|
|
# 7) tests for env modifiers
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 PKG_CONFIG_SYSROOT_DIR=/test ${1} --cflags baz" \
|
|
|
|
'-I/test/usr/include/foo'
|
|
|
|
|
2012-05-12 01:32:32 +00:00
|
|
|
# 8) tests for 'Conflicts'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --libs conflicts; echo \$?" \
|
2012-07-30 07:46:03 +00:00
|
|
|
'0'
|
2012-05-12 01:32:32 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --ignore-conflicts --libs conflicts; echo \$?" \
|
|
|
|
'-lconflicts' '0'
|
|
|
|
|
2012-07-02 02:28:38 +00:00
|
|
|
# 9) tests for --atleast-version (with and without trailing space)
|
2012-07-02 02:24:53 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --atleast-version 1.0 foo; echo \$?" \
|
|
|
|
'0'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --atleast-version 2.0 foo; echo \$?" \
|
|
|
|
'1'
|
2012-07-02 03:03:07 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exact-version 1.0 foo; echo \$?" \
|
|
|
|
'1'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exact-version 1.2.3 foo; echo \$?" \
|
|
|
|
'0'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --max-version 1.0 foo; echo \$?" \
|
|
|
|
'1'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --max-version 2.0 foo; echo \$?" \
|
|
|
|
'0'
|
|
|
|
|
2012-07-02 02:28:38 +00:00
|
|
|
# tests for issue #20
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --atleast-version 1.0 'foo '; echo \$?" \
|
|
|
|
'0'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --atleast-version 2.0 'foo '; echo \$?" \
|
|
|
|
'1'
|
2012-07-02 03:03:07 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exact-version 1.0 'foo '; echo \$?" \
|
|
|
|
'1'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --exact-version 1.2.3 'foo '; echo \$?" \
|
|
|
|
'0'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --max-version 1.0 'foo '; echo \$?" \
|
|
|
|
'1'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --max-version 2.0 'foo '; echo \$?" \
|
|
|
|
'0'
|
2012-07-02 02:24:53 +00:00
|
|
|
|
2012-07-20 18:35:33 +00:00
|
|
|
# 10) tests for internal getopt implementation with options at the end
|
2012-07-25 22:56:10 +00:00
|
|
|
if [ "x@STRICT_MODE@" = "xno" ]; then
|
2012-07-20 21:33:48 +00:00
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} foo --libs" \
|
|
|
|
'-lfoo'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} foo --cflags --libs" \
|
|
|
|
'-lfoo' '-I/usr/include/foo' '-fPIC'
|
|
|
|
run_test "PKG_CONFIG_PATH=${selfdir}/lib1 ${1} --cflags foo --libs" \
|
|
|
|
'-lfoo' '-I/usr/include/foo' '-fPIC'
|
|
|
|
fi
|
2012-07-20 18:35:33 +00:00
|
|
|
|
2012-07-25 22:47:09 +00:00
|
|
|
echo
|
|
|
|
|
2012-05-03 06:50:57 +00:00
|
|
|
if [ ${failed} -gt 0 ]; then
|
|
|
|
echo "${failed} of ${done} tests failed. See output for details." >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "${done} tests done. All succeeded." >&2
|
|
|
|
exit 0
|
|
|
|
fi
|