Merge branch 'kyua' (closes #96)

pull/100/head
William Pitcock 2016-11-04 23:32:50 -05:00
commit 0c74b5a4c2
19 changed files with 1248 additions and 468 deletions

View File

@ -4,6 +4,16 @@ compiler:
- clang
- gcc
addons:
apt:
packages:
- liblua5.2-dev
sudo: required
before_install:
scripts/install_deps.sh
script:
- sh ./autogen.sh
- ./configure

View File

@ -11,9 +11,7 @@ AM_CFLAGS = -Wall -Wextra -Wformat=2 -std=gnu99 -DPKG_DEFAULT_PATH=\"$(pkgconfig
bin_PROGRAMS = pkgconf
lib_LTLIBRARIES = libpkgconf.la
EXTRA_DIST = Kyuafile \
tests/Kyuafile \
pkg.m4 \
EXTRA_DIST = pkg.m4 \
tests/lib1/argv-parse-2.pc \
tests/lib1/dos-lineendings.pc \
tests/lib1/paren-quoting.pc \
@ -58,7 +56,25 @@ EXTRA_DIST = Kyuafile \
tests/lib1/cflags-whitespace.pc \
tests/lib1/cflags-whitespace-trailing.pc \
tests/lib1/provides.pc \
tests/lib1/provides-request-simple.pc
tests/lib1/provides-request-simple.pc \
tests/test_env.sh \
$(test_scripts)
test_scripts= \
tests/basic.sh \
tests/builtins.sh \
tests/conflicts.sh \
tests/framework.sh \
tests/parser.sh \
tests/provides.sh \
tests/regress.sh \
tests/requires.sh \
tests/sysroot.sh \
tests/version.sh
check_SCRIPTS= $(test_scripts:.sh=)
SUFFIXES= .sh
pkginclude_HEADERS = libpkgconf/bsdstubs.h libpkgconf/iter.h libpkgconf/libpkgconf.h libpkgconf/stdinc.h
libpkgconf_la_SOURCES = \
@ -85,7 +101,12 @@ dist_doc_DATA = README.md AUTHORS
m4datadir = $(datadir)/aclocal
m4data_DATA = pkg.m4
CLEANFILES = $(EXTRA_PROGRAMS)
CLEANFILES = $(EXTRA_PROGRAMS) \
$(check_SCRIPTS)
check: pkgconf
$(SHELL) tests/run.sh ./pkgconf
check: pkgconf $(check_SCRIPTS)
kyua --config=none test --kyuafile='$(top_builddir)/Kyuafile' \
--build-root='$(top_builddir)'
.sh:
install -m 755 $< $@

View File

@ -16,7 +16,7 @@ AC_INIT([pkgconf], [1.0.1], [http://github.com/pkgconf/pkgconf/issues])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([libpkgconf/config.h])
AC_CHECK_FUNCS([strlcpy strlcat strndup strtok_r])
AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects])
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects])
AM_SILENT_RULES([yes])
LT_INIT
@ -45,5 +45,5 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_CONFIG_FILES([Makefile tests/run.sh])
AC_CONFIG_FILES([Makefile Kyuafile tests/Kyuafile tests/test_env.sh])
AC_OUTPUT

65
scripts/install_deps.sh Executable file
View File

@ -0,0 +1,65 @@
#! /bin/sh
# Copyright (c) 2012 Bryan Drewery <bryan@shatow.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer
# in this position and unchanged.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Install build dependencies for pkg on Mac or Linux (Debiaun/Ubuntu) systems.
#
# This script is primarily intended for travis CI to be able to setup the
# build environment.
install_from_github() {
local name="${1}"
local ver="${2}"
local distname="${name}-${ver}"
# https://github.com/jmmv/kyua/releases/download/kyua-0.12/kyua-0.12.tar.gz
local url="https://github.com/jmmv/${name}"
wget "${url}/releases/download/${distname}/${distname}.tar.gz"
tar -xzvf "${distname}.tar.gz"
cd "${distname}"
./configure \
--disable-developer \
--without-atf \
--without-doxygen \
CPPFLAGS="-I/usr/local/include" \
LDFLAGS="-L/usr/local/lib -Wl,-R/usr/local/lib" \
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
make
sudo make install
cd -
rm -rf "${distname}" "${distname}.tar.gz"
}
if [ $(uname -s) = "Darwin" ]; then
brew update
brew install libarchive --with-xz
brew install openssl
brew install kyua
elif [ $(uname -s) = "Linux" ]; then
install_from_github atf 0.21
install_from_github lutok 0.4
install_from_github kyua 0.12
fi

View File

@ -1,5 +0,0 @@
syntax(2)
test_suite('pkgconf')
plain_test_program{name='run.sh'}

13
tests/Kyuafile.in Normal file
View File

@ -0,0 +1,13 @@
syntax(2)
test_suite('pkgconf')
atf_test_program{name='basic'}
atf_test_program{name='requires'}
atf_test_program{name='regress'}
atf_test_program{name='parser'}
atf_test_program{name='sysroot'}
atf_test_program{name='conflicts'}
atf_test_program{name='version'}
atf_test_program{name='framework'}
atf_test_program{name='provides'}

271
tests/basic.sh Executable file
View File

@ -0,0 +1,271 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
noargs \
libs \
libs_cflags \
libs_cflags_version \
libs_cflags_version_multiple \
libs_cflags_version_alt \
libs_cflags_version_different \
libs_cflags_version_different_bad \
exists_nonexitent \
nonexitent \
exists_version \
exists_version_bad \
exists_version_bad2 \
exists_version_bad3 \
exists \
exists2 \
exists3 \
exists_version_alt \
uninstalled_bad \
uninstalled \
libs_intermediary \
libs_circular1 \
libs_circular2 \
libs_circular_directpc \
libs_static \
pkg_config_path \
nolibs \
nocflags \
arbitary_path
noargs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check -s exit:1 -e ignore pkgconf
}
libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --libs foo
}
libs_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs foo
}
atf_test_case basic_libs_cflags_version
libs_cflags_version_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs 'foo > 1.2'
}
libs_cflags_version_multiple_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/include/foo -fPIC -L/test/lib -lbar -lfoo \n" \
pkgconf --cflags --libs 'foo > 1.2 bar >= 1.3'
}
libs_cflags_version_multiple_coma_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/include/foo -fPIC -L/test/lib -lbar -lfoo \n" \
pkgconf --cflags --libs 'foo > 1.2,bar >= 1.3'
}
libs_cflags_version_alt_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs 'foo' '>' '1.2'
}
libs_cflags_version_different_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs 'foo' '!=' '1.3.0'
}
atf_test_case basic_libs_cflags_version_different_bad
libs_cflags_version_different_bad_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
-e inline:"Package dependency requirement 'foo != 1.2.3' could not be satisfied.\nPackage 'foo' has version '1.2.3', required version is '!= 1.2.3'\n" \
pkgconf --cflags --libs 'foo' '!=' '1.2.3'
}
exists_nonexitent_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --exists nonexistant
}
nonexitent_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf nonexistant
}
exists_version_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --exists 'foo > 1.2'
}
exists_version_bad_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --exists 'foo > 1.2.3'
}
exists_version_alt_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --exists 'foo' '>' '1.2'
}
uninstalled_bad_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --uninstalled 'foo'
}
uninstalled_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --uninstalled 'omg'
}
exists_version_bad2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --exists 'foo >= '
}
exists_version_bad3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --exists 'tilde <= 1.0.0'
}
exists_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --exists 'tilde = 1.0.0~rc1'
}
exists2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --exists 'tilde >= 1.0.0'
}
exists3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --exists '' 'foo'
}
libs_intermediary_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz \n" \
pkgconf --libs intermediary-1 intermediary-2
}
libs_circular1_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lcircular-1 -lcircular-2 -lcircular-3 \n" \
pkgconf --libs circular-1
}
libs_circular2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lcircular-3 -lcircular-1 -lcircular-2 \n" \
pkgconf --libs circular-3
}
libs_circular_directpc_body()
{
atf_check \
-o inline:"-lcircular-1 -lcircular-2 -lcircular-3 \n" \
pkgconf --libs ${selfdir}/lib1/circular-3.pc
}
libs_static_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"/libfoo.a -pthread \n" \
pkgconf --libs static-archive-libs
}
pkg_config_path_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1${PATH_SEP}${selfdir}/lib2"
atf_check \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --libs foo
atf_check \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --libs bar
}
nolibs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:" \n" \
pkgconf --libs nolib
}
nocflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:" \n" \
pkgconf --cflags nocflag
}
arbitary_path_body()
{
cp ${selfdir}/lib1/foo.pc .
atf_check \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --libs foo.pc
}

68
tests/builtins.sh Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
modversion \
variable \
define_variable \
global_variable
modversion_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"1.0.1 \n" \
pkgconf --modversion pkg-config
}
variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"/test \n" \
pkgconf --variable=prefix foo
}
define_variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"/test2 \n" \
pkgconf --define-variable=prefix=/test2 --variable=prefix foo
}
global_variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"${selfdir}/lib1 \n"
pkgconf --exists -foo
}
argv_parse_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-1 -pthread /test/lib/lib2.so \n" \
pkgconf --libs argv-parse-3
}
tilde_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L~ -ltilde \n" \
pkgconf --libs tilde-quoting
atf_check \
-o inline:"-I~ \n" \
pkgconf --cflags tilde-quoting
}
paren_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L\$(libdir) -ltilde \n" \
pkgconf --libs paren-quoting
}

23
tests/conflicts.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
libs \
ignore
libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lconflicts \n" \
pkgconf --libs conflicts
}
ignore_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lconflicts \n" \
pkgconf --ignore-conflicts --libs conflicts
}

20
tests/framework.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
libs
libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-F/test/lib -framework framework-1 \n" \
pkgconf --libs framework-1
atf_check \
-o inline:"-F/test/lib -framework framework-2 -F/test/lib -framework framework-1 \n" \
pkgconf --libs framework-2
atf_check \
-o inline:"-F/test/lib -framework framework-1 -F/test/lib -framework framework-2 \n" \
pkgconf --libs framework-1 framework-2
}

109
tests/parser.sh Executable file
View File

@ -0,0 +1,109 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
comments \
comments_in_fields \
dos \
no_trailing_newline \
argv_parse \
bad_option \
argv_parse_3 \
tilde_quoting \
paren_quoting \
multiline_field \
quoted
comments_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lfoo \n" \
pkgconf --libs comments
}
comments_in_fields_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lfoo \n" \
pkgconf --libs comments-in-fields
}
dos_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib/dos-lineendings -ldos-lineendings \n" \
pkgconf --libs dos-lineendings
}
no_trailing_newline_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/include/no-trailing-newline \n" \
pkgconf --cflags no-trailing-newline
}
argv_parse_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-3 -llib-1 -llib-2 -lpthread \n" \
pkgconf --libs argv-parse
}
bad_option_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-e ignore \
-s eq:1 \
pkgconf --exists -foo
}
argv_parse_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-1 -pthread /test/lib/lib2.so \n" \
pkgconf --libs argv-parse-3
}
tilde_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L~ -ltilde \n" \
pkgconf --libs tilde-quoting
atf_check \
-o inline:"-I~ \n" \
pkgconf --cflags tilde-quoting
}
paren_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L\$(libdir) -ltilde \n" \
pkgconf --libs paren-quoting
}
multiline_field_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-e ignore \
-o match:"multiline description" \
pkgconf --list-all
}
quoted_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-DQUOTED=\\\"bla\\\" \n" \
pkgconf --cflags quotes
}

298
tests/provides.sh Executable file
View File

@ -0,0 +1,298 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
simple \
foo \
bar \
baz \
quux \
moo \
meow
simple_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
OUTPUT="provides-test-foo = 1.0.0
provides-test-bar > 1.1.0
provides-test-baz >= 1.1.0
provides-test-quux < 1.2.0
provides-test-moo <= 1.2.0
provides-test-meow != 1.3.0
provides = 1.2.3
"
atf_check \
-o inline:"${OUTPUT}" \
pkgconf --print-provides provides
atf_check \
-o inline:"-lfoo \n" \
pkgconf --libs provides-request-simple
atf_check \
-e ignore \
-s exit:1 \
pkgconf --no-provides --libs provides-request-simple
}
foo_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o ignore \
pkgconf --libs provides-test-foo
atf_check \
-o ignore \
pkgconf --libs 'provides-test-foo = 1.0.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-foo >= 1.0.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-foo <= 1.0.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-foo != 1.0.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-foo > 1.0.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-foo < 1.0.0'
}
bar_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o ignore \
pkgconf --libs provides-test-bar
atf_check \
-o ignore \
pkgconf --libs 'provides-test-bar = 1.1.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-bar >= 1.1.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-bar <= 1.1.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-bar != 1.1.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-bar != 1.1.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-bar > 1.1.1'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-bar <= 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-bar <= 1.2.0'
}
baz_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o ignore \
pkgconf --libs provides-test-baz
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz = 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz >= 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz <= 1.1.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-baz != 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz != 1.0.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz > 1.1.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz > 1.1.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-baz < 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-baz < 1.2.0'
}
quux_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o ignore \
pkgconf --libs provides-test-quux
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux = 1.1.9'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux >= 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux >= 1.1.9'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-quux >= 1.2.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-quux <= 1.2.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux <= 1.1.9'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux != 1.2.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-quux != 1.1.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-quux != 1.0.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux > 1.1.9'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-quux > 1.2.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-quux < 1.1.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-quux > 1.2.0'
}
moo_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o ignore \
pkgconf --libs provides-test-moo
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo = 1.2.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo >= 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo >= 1.2.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-moo >= 1.2.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo <= 1.2.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-moo != 1.1.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-moo != 1.0.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo > 1.1.9'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-moo > 1.2.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo < 1.1.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-moo < 1.2.0'
}
meow_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o ignore \
pkgconf --libs provides-test-meow
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-meow = 1.3.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-meow != 1.3.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-meow > 1.2.9'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-meow < 1.3.1'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-meow < 1.3.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-meow > 1.3.0'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-meow >= 1.3.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-meow >= 1.3.1'
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --libs 'provides-test-meow <= 1.3.0'
atf_check \
-o ignore \
pkgconf --libs 'provides-test-meow < 1.2.9'
}

174
tests/regress.sh Executable file
View File

@ -0,0 +1,174 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
case_sensitivity \
depgraph_break_1 \
depgraph_break_2 \
depgraph_break_3 \
define_variable \
variable \
keep_system_libs \
libs \
libs_only \
libs_never_mergeback \
cflags_only \
cflags_never_mergeback \
incomplete_libs \
incomplete_cflags \
isystem_munge_order \
isystem_munge_sysroot \
pcpath \
sysroot_munge
case_sensitivity_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"3\n" \
pkgconf --variable=foo case-sensitivity
atf_check \
-o inline:"4\n" \
pkgconf --variable=Foo case-sensitivity
}
depgraph_break_1_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check -s exit:1 -e ignore \
pkgconf --exists --print-errors 'foo > 0.6.0 foo < 0.8.0'
}
depgraph_break_2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check -s exit:1 -e ignore \
pkgconf --exists --print-errors 'nonexisting foo <= 3'
}
depgraph_break_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check -s exit:1 -e ignore \
pkgconf --exists --print-errors 'depgraph-break'
}
define_variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check -o inline:"\\\${libdir}/typelibdir\n" \
pkgconf --variable=typelibdir --define-variable='libdir=\${libdir}' typelibdir
}
variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"/test/include\n" \
pkgconf --variable=includedir foo
}
keep_system_libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/local/lib \n" \
pkgconf --libs-only-L --keep-system-libs cflags-libs-only
}
libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/local/lib -lfoo \n" \
pkgconf --libs cflags-libs-only
}
libs_only_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/local/lib -lfoo \n" \
pkgconf --libs-only-L --libs-only-l cflags-libs-only
}
libs_never_mergeback_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/bar/lib -lfoo1 \n" \
pkgconf --libs prefix-foo1
atf_check \
-o inline:"-L/test/bar/lib -lfoo1 -lfoo2 \n" \
pkgconf --libs prefix-foo1 prefix-foo2
}
cflags_only_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/local/include/foo \n" \
pkgconf --cflags-only-I --cflags-only-other cflags-libs-only
}
cflags_never_mergeback_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/bar/include/foo -DBAR -fPIC -DFOO \n" \
pkgconf --cflags prefix-foo1 prefix-foo2
}
incomplete_libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:" \n" \
pkgconf --libs incomplete
}
incomplete_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:" \n" \
pkgconf --cflags incomplete
}
isystem_munge_order_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-isystem /opt/bad/include -isystem /opt/bad2/include \n" \
pkgconf --cflags isystem
}
isystem_munge_sysroot_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR='/test'
atf_check \
-o match:"-isystem /test/opt/bad/include" \
pkgconf --cflags isystem
}
pcpath_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib2"
atf_check \
-o inline:"-fPIC -I/test/include/foo \n" \
pkgconf --cflags ${selfdir}/lib3/bar.pc
}
sysroot_munge_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR="/sysroot"
atf_check \
-o inline:"-L/sysroot/lib -lfoo \n" \
pkgconf --libs sysroot-dir
export PKG_CONFIG_SYSROOT_DIR="/sysroot2"
atf_check \
-o inline:"-L/sysroot2/sysroot/lib -lfoo \n" \
pkgconf --libs sysroot-dir
}

79
tests/requires.sh Executable file
View File

@ -0,0 +1,79 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
libs \
libs_cflags \
libs_static \
argv_parse2 \
static_cflags \
private_duplication \
libs_static2 \
missing
libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --libs bar
}
libs_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lbaz \n" \
pkgconf --libs --cflags baz
}
libs_static_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbaz -L/test/lib -lzee -L/test/lib -lfoo \n" \
pkgconf --static --libs baz
}
argv_parse2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-1 -pthread /test/lib/lib2.so \n" \
pkgconf --static --libs argv-parse-2
}
static_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DFOO_STATIC \n" \
pkgconf --static --cflags baz
}
private_duplication_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lprivate -lfoo -lbaz -lzee -lbar -lfoo \n" \
pkgconf --static --libs-only-l private-libs-duplication
}
libs_static2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lbar -lbar-private -L/test/lib -lfoo \n" \
pkgconf --static --libs static-libs
}
missing_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
-e ignore \
-o inline:" \n" \
pkgconf --cflags missing-require
}

View File

@ -1,454 +0,0 @@
#!/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
local cmdline 2>/dev/null || true
cmdline="${1}"
eval res="\$(${1})" 2>/dev/null
t_ret=0
while [ ${#} -gt 1 ]; do
shift
case "${res}" in
*"${1}"*)
;;
*)
echo
echo "***********************"
echo "!!! Test $done failed."
echo "!!! $ ${cmdline}"
echo "!!! ${res}"
echo "!!! expected '${1}' in output"
echo "***********************"
t_ret=1
;;
esac
done
if [ ${t_ret} -eq 0 ]; then
printf "."
else
failed=$(( failed + 1 ))
fi
done=$(( done + 1 ))
}
selfdir="@abs_srcdir@"
PATH_SEP=":"
SYSROOT_DIR="${selfdir}/test"
if [ "$(uname -o)" = "Msys" ]; then
PATH_SEP=";"
fi
# 1) overall 'is it working?' test
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1}; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs foo" \
'-lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs foo" \
'-lfoo' '-I/test/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo > 1.2'" \
'-lfoo' '-I/test/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo > 1.2 bar >= 1.3'" \
'-lfoo' '-I/test/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo > 1.2,bar >= 1.3'" \
'-lbar' '-I/test/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo' '>' '1.2'" \
'-lfoo' '-I/test/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo' '!=' '1.3.0'" \
'-lfoo' '-I/test/include/foo' '-fPIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags --libs 'foo' '!=' '1.2.3'; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists nonexistant; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} nonexistant; echo \$?" \
'1'
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'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo' '>' '1.2'; echo \$?" \
'0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --uninstalled 'foo'; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --uninstalled 'omg'; echo \$?" \
'0'
run_test "${1} --modversion ${selfdir}/lib1/foo.pc" \
'1.2.3'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'foo >= '; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists 'tilde <= 1.0.0'; echo \$?" \
'1'
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 \$?" \
'0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists '' 'foo'; echo \$?" \
'0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs intermediary-1 intermediary-2" \
'-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs circular-1" \
'-lcircular-1 -lcircular-2 -lcircular-3'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs circular-3" \
'-lcircular-3 -lcircular-1 -lcircular-2'
run_test "${1} --libs ${selfdir}/lib1/circular-3.pc" \
'-lcircular-1 -lcircular-2 -lcircular-3'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs static-archive-libs" \
'/libfoo.a -pthread'
# 2) tests for PKG_CONFIG_PATH order
run_test "PKG_CONFIG_PATH='${selfdir}/lib1${PATH_SEP}${selfdir}/lib2' ${1} --libs foo" \
'-lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1${PATH_SEP}${selfdir}/lib2' ${1} --libs bar" \
'-lbar'
# 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/test/include/foo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --libs baz" \
'-lfoo' '-lbaz' '-lzee'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --libs argv-parse-2" \
'-pthread '
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --cflags baz" \
'-fPIC' '-I/test/include/foo' '-DFOO_STATIC'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --libs-only-l private-libs-duplication" \
'-lprivate -lfoo -lbaz -lzee -lbar -lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --static --libs static-libs" \
'-lbar -lbar-private -L/test/lib -lfoo'
# 4) tests for parser bugs
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs dos-lineendings" \
'-L/test/lib/dos-lineendings -ldos-lineendings'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags no-trailing-newline" \
'-I/test/include/no-trailing-newline'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs argv-parse" \
'-llib-2 -lpthread'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists -foo; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs argv-parse-3" \
'-llib-1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs tilde-quoting" \
'-L~'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags tilde-quoting" \
'-I~'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs paren-quoting" \
'-L$(libdir)'
# 5) tests for other regressions
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --variable=includedir foo" \
'/test/include'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs-only-L --keep-system-libs cflags-libs-only" \
'-L/test/local/lib'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs cflags-libs-only" \
'-L/test/local/lib -lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs-only-L --libs-only-l cflags-libs-only" \
'-L/test/local/lib -lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags-only-I --cflags-only-other cflags-libs-only" \
'-I/test/local/include'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs incomplete; echo \$?" \
'0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags incomplete" \
' '
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs incomplete" \
' '
# 6) tests for builtins
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --modversion pkg-config" \
'@PACKAGE_VERSION@'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --variable=prefix foo" \
'/test'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --define-variable=prefix=/test2 --variable=prefix foo" \
'/test2'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --variable=pcfiledir foo" \
"${selfdir}/lib1"
# 7) tests for env modifiers
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='${SYSROOT_DIR}' ${1} --cflags baz" \
"-I${SYSROOT_DIR}/test/include/foo"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='${SYSROOT_DIR}' ${1} --variable=prefix baz" \
"${SYSROOT_DIR}/test"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='${SYSROOT_DIR}' ${1} --variable=includedir baz" \
"${SYSROOT_DIR}/test/include"
# 8) tests for 'Conflicts'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs conflicts; echo \$?" \
'0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --ignore-conflicts --libs conflicts; echo \$?" \
'-lconflicts' '0'
# 9) tests for --atleast-version (with and without trailing space)
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'
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'
# 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'
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'
# test missing requires
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags missing-require; echo \$?" \
'1'
# test the multiline description field
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --list-all | grep -q 'multiline description'; echo \$?" \
'0'
# test quoted #35
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags quotes" \
"-DQUOTED=\\\"bla\\\""
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs nolib; echo \$?" \
'0'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs nocflag; echo \$?" \
'0'
# test 36 - running against file in CWD with no path
# File moved to CWD to allow arbitrary path to pkgconf and keep pc file in CWD
run_test "cp ${selfdir}/lib1/foo.pc . && ${1} --libs foo.pc; rm -f foo.pc" \
'-lfoo'
# test 47 - framework flags
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs framework-1" \
"-F/test/lib -framework framework-1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs framework-2" \
"-F/test/lib -framework framework-2 -F/test/lib -framework framework-1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs framework-1 framework-2" \
"-F/test/lib -framework framework-1 -F/test/lib -framework framework-2"
# test 87 - -isystem munging
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags isystem" \
"-isystem /opt/bad/include -isystem /opt/bad2/include"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists --print-errors 'foo > 0.6.0 foo < 0.8.0'; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists --print-errors 'nonexisting foo <= 3'; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --exists --print-errors 'depgraph-break'; echo \$?" \
'1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib2' ${1} ${selfdir}/lib3/bar.pc --cflags" \
'-fPIC -I/test/include/foo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --variable=foo case-sensitivity" \
"3"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --variable=Foo case-sensitivity" \
"4"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs comments-in-fields" \
"-lfoo"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs comments" \
"-lfoo"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='/sysroot' ${1} --libs sysroot-dir" \
'-L/sysroot/lib -lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='/sysroot2' ${1} --libs sysroot-dir" \
'-L/sysroot2/sysroot/lib -lfoo'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs prefix-foo1" \
'-L/test/bar/lib -lfoo1'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs prefix-foo1 prefix-foo2" \
'-L/test/bar/lib -lfoo1 -lfoo2'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --cflags prefix-foo1 prefix-foo2" \
'-I/test/bar/include/foo -DBAR -fPIC -DFOO'
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --variable=typelibdir --define-variable='libdir=\${libdir}' typelibdir" \
"\${libdir}/typelibdir"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='/test' ${1} --cflags isystem" \
"-isystem /test/opt/bad/include"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSROOT_DIR='/test' ${1} --cflags cflags-whitespace" \
"-I /test/opt/bad/include"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' PKG_CONFIG_SYSTEM_INCLUDE_PATH='/usr/include' ${1} --cflags cflags-whitespace-trailing" \
"-I/usr/include/foo"
# 10) tests for Provides system
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --print-provides provides" \
"provides = 1.2.3" "provides-test-foo = 1.0.0" "provides-test-baz >= 1.1.0" "provides-test-moo <= 1.2.0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs provides-request-simple" \
"-lfoo"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --no-provides --libs provides-request-simple; echo \$?" \
"1"
# provides-test-foo = 1.0.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo = 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo >= 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo <= 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo != 1.0.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo > 1.0.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-foo < 1.0.0'; echo \$?" \
"1"
# provides-test-bar > 1.1.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar = 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar >= 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar <= 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar != 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar != 1.1.1'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar > 1.1.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar <= 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar < 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-bar > 1.2.0'; echo \$?" \
"0"
# provides-test-baz >= 1.1.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz = 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz >= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz <= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz != 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz != 1.0.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz > 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz < 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-baz < 1.2.0'; echo \$?" \
"0"
# provides-test-quux < 1.2.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux = 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux >= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux >= 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux >= 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux <= 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux <= 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux != 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux != 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux != 1.0.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux > 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux > 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux < 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-quux < 1.2.0'; echo \$?" \
"1"
# provides-test-moo <= 1.2.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo = 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo >= 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo >= 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo >= 1.2.1'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo <= 1.2.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo != 1.1.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo != 1.0.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo > 1.1.9'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo > 1.2.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.1.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-moo < 1.2.0'; echo \$?" \
"0"
# provides-test-meow != 1.3.0
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow = 1.3.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow != 1.3.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow > 1.2.9'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow < 1.3.1'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow > 1.3.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow < 1.3.0'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow >= 1.3.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow >= 1.3.1'; echo \$?" \
"0"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow <= 1.3.0'; echo \$?" \
"1"
run_test "PKG_CONFIG_PATH='${selfdir}/lib1' ${1} --libs 'provides-test-meow <= 1.2.9'; echo \$?" \
"0"
run_test "${1} --blah; echo \$?" \
'1'
echo
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

28
tests/sysroot.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
cflags \
variable
cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
atf_check \
-o inline:"-fPIC -I${SYSROOT_DIR}/test/include/foo \n" \
pkgconf --cflags baz
}
variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
atf_check \
-o inline:"${SYSROOT_DIR}/test\n" \
pkgconf --variable=prefix foo
atf_check \
-o inline:"${SYSROOT_DIR}/test/include\n" \
pkgconf --variable=includedir foo
}

22
tests/test_env.sh.in Normal file
View File

@ -0,0 +1,22 @@
export PATH="$(atf_get_srcdir)/../:${PATH}"
selfdir="@abs_top_srcdir@/tests"
PATH_SEP=":"
SYSROOT_DIR="${selfdir}/test"
if [ "$(uname -s)" = "Msys" ]; then
PATH_SEP=";"
fi
tests_init()
{
TESTS="$@"
export TESTS
for t ; do
atf_test_case $t
done
}
atf_init_test_cases() {
for t in ${TESTS}; do
atf_add_test_case $t
done
}

38
tests/version.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
atleast \
exact \
max
atleast_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --atleast-version 1.0 foo
atf_check \
-s exit:1 \
pkgconf --atleast-version 2.0 foo
}
exact_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --exact-version 1.0 foo
atf_check \
pkgconf --exact-version 1.2.3 foo
}
max_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --max-version 1.0 foo
atf_check \
pkgconf --max-version 2.0 foo
}