mirror of
https://gitlab.freedesktop.org/pkg-config/pkg-config.git
synced 2026-05-03 13:37:59 +02:00
Test ordering of flags based on package depth and path
The current tests are good at checking whether gathering the Cflags or Libs from one or two packages works correctly, but they don't check the sorting algorithm much at all. In particular, the interactions between the package order in the Requires chain and in the path can make the sorting of the flags subtly different.
This commit is contained in:
parent
e2910a6afd
commit
3e54448158
11 changed files with 301 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ TESTS = \
|
|||
check-conflicts \
|
||||
check-missing \
|
||||
check-idirafter \
|
||||
check-sort-order \
|
||||
check-whitespace \
|
||||
check-cmd-options \
|
||||
check-version \
|
||||
|
|
@ -51,4 +52,13 @@ EXTRA_DIST = \
|
|||
circular-1.pc \
|
||||
circular-2.pc \
|
||||
circular-3.pc \
|
||||
no-variables.pc
|
||||
no-variables.pc \
|
||||
sort-order-1-1.pc \
|
||||
sort/sort-order-2-1.pc \
|
||||
sort/sort/sort-order-3-1.pc \
|
||||
sort-order-1-2.pc \
|
||||
sort/sort-order-2-2.pc \
|
||||
sort/sort/sort-order-3-2.pc \
|
||||
sort-order-1-3.pc \
|
||||
sort/sort-order-2-3.pc \
|
||||
sort/sort/sort-order-3-3.pc
|
||||
|
|
|
|||
194
check/check-sort-order
Executable file
194
check/check-sort-order
Executable file
|
|
@ -0,0 +1,194 @@
|
|||
#! /bin/sh
|
||||
|
||||
# These tests check that the order of the flags in .pc files are correct
|
||||
# after resolving the package list. There are two things that are
|
||||
# critical in the current algorithm: the ordering of packages on the
|
||||
# command line, the ordering of packages based on Requires and the place
|
||||
# in the pkg-config path the .pc file was found, with packages earlier
|
||||
# in the path getting higher priority. There is one other factor that
|
||||
# makes the output currently work correctly that's only implicitly
|
||||
# tested here: stripping of all duplicates from the output string.
|
||||
#
|
||||
# There are 3 sets of packages here:
|
||||
#
|
||||
# 1. A typical setup where highest level package is earliest in the path
|
||||
# and has a straight dependency chain. 3-1 -> 2-1 -> 1-1 with 3-1 in the
|
||||
# first part of the user supplied path, 2-1 in the second part, and 1-1
|
||||
# found from the system path.
|
||||
#
|
||||
# 2. A similar setup to 1 except that now both 3-2 and 2-2 depend on
|
||||
# 1-2. This has a subtle effect on the algorithm when combined with the
|
||||
# order of the command line arguments. It only currently works because
|
||||
# duplicates get strip out in (hopefully) the correct order, so 1-2's
|
||||
# flags come out in the appropriate spot even though it was in the
|
||||
# package list twice.
|
||||
#
|
||||
# 3. Reverse the order of requirements so that the system level package
|
||||
# (1-3) depends on something in the user's path (2-3), which depends on
|
||||
# something earlier in the user's path (3-3). This is pretty unusual
|
||||
# since the user is typically overriding something higher in the stack
|
||||
# rather than lower, but it does illustrate the path ordering vs.
|
||||
# dependency ordering.
|
||||
|
||||
set -e
|
||||
|
||||
. ${srcdir}/common
|
||||
|
||||
order1="$srcdir/sort/sort:$srcdir/sort"
|
||||
order2="$srcdir/sort:$srcdir/sort/sort"
|
||||
|
||||
export PKG_CONFIG_PATH
|
||||
PKG_CONFIG_PATH="$order1"
|
||||
|
||||
# Check package set -1
|
||||
RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path3/include -I/path2/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-3-1
|
||||
run_test --cflags sort-order-3-1 sort-order-2-1
|
||||
run_test --cflags sort-order-2-1 sort-order-3-1
|
||||
run_test --cflags sort-order-3-1 sort-order-2-1 sort-order-1-1
|
||||
run_test --cflags sort-order-3-1 sort-order-1-1 sort-order-2-1
|
||||
run_test --cflags sort-order-2-1 sort-order-3-1 sort-order-1-1
|
||||
run_test --cflags sort-order-2-1 sort-order-1-1 sort-order-3-1
|
||||
run_test --cflags sort-order-1-1 sort-order-3-1 sort-order-2-1
|
||||
run_test --cflags sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
run_test --libs sort-order-3-1
|
||||
run_test --libs sort-order-3-1 sort-order-2-1
|
||||
run_test --libs sort-order-2-1 sort-order-3-1
|
||||
run_test --libs sort-order-3-1 sort-order-2-1 sort-order-1-1
|
||||
run_test --libs sort-order-3-1 sort-order-1-1 sort-order-2-1
|
||||
run_test --libs sort-order-2-1 sort-order-3-1 sort-order-1-1
|
||||
run_test --libs sort-order-2-1 sort-order-1-1 sort-order-3-1
|
||||
run_test --libs sort-order-1-1 sort-order-3-1 sort-order-2-1
|
||||
run_test --libs sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
# Check package set -2
|
||||
RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path3/include -I/path2/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-3-2
|
||||
run_test --cflags sort-order-3-2 sort-order-2-2
|
||||
run_test --cflags sort-order-2-2 sort-order-3-2
|
||||
run_test --cflags sort-order-3-2 sort-order-2-2 sort-order-1-2
|
||||
run_test --cflags sort-order-3-2 sort-order-1-2 sort-order-2-2
|
||||
run_test --cflags sort-order-2-2 sort-order-3-2 sort-order-1-2
|
||||
run_test --cflags sort-order-2-2 sort-order-1-2 sort-order-3-2
|
||||
run_test --cflags sort-order-1-2 sort-order-3-2 sort-order-2-2
|
||||
run_test --cflags sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
run_test --libs sort-order-3-2
|
||||
run_test --libs sort-order-3-2 sort-order-2-2
|
||||
run_test --libs sort-order-2-2 sort-order-3-2
|
||||
run_test --libs sort-order-3-2 sort-order-2-2 sort-order-1-2
|
||||
run_test --libs sort-order-3-2 sort-order-1-2 sort-order-2-2
|
||||
run_test --libs sort-order-2-2 sort-order-3-2 sort-order-1-2
|
||||
run_test --libs sort-order-2-2 sort-order-1-2 sort-order-3-2
|
||||
run_test --libs sort-order-1-2 sort-order-3-2 sort-order-2-2
|
||||
run_test --libs sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
# Check package set -3
|
||||
RESULT="-DPATH3 -DPATH2 -DPATH1 -I/path3/include -I/path2/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-1-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3
|
||||
run_test --cflags sort-order-2-3 sort-order-1-3
|
||||
run_test --cflags sort-order-3-3 sort-order-2-3 sort-order-1-3
|
||||
run_test --cflags sort-order-3-3 sort-order-1-3 sort-order-2-3
|
||||
run_test --cflags sort-order-2-3 sort-order-3-3 sort-order-1-3
|
||||
run_test --cflags sort-order-2-3 sort-order-1-3 sort-order-3-3
|
||||
run_test --cflags sort-order-1-3 sort-order-3-3 sort-order-2-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3 sort-order-3-3
|
||||
|
||||
RESULT="-Wl,-O3 -Wl,-O2 -Wl,-O1 -L/path3/lib -L/path2/lib -L/path1/lib \
|
||||
-lpath1 -lpath2 -lpath3"
|
||||
run_test --libs sort-order-1-3
|
||||
run_test --libs sort-order-1-3 sort-order-2-3
|
||||
run_test --libs sort-order-2-3 sort-order-1-3
|
||||
run_test --libs sort-order-3-3 sort-order-2-3 sort-order-1-3
|
||||
run_test --libs sort-order-3-3 sort-order-1-3 sort-order-2-3
|
||||
run_test --libs sort-order-2-3 sort-order-3-3 sort-order-1-3
|
||||
run_test --libs sort-order-2-3 sort-order-1-3 sort-order-3-3
|
||||
run_test --libs sort-order-1-3 sort-order-3-3 sort-order-2-3
|
||||
run_test --libs sort-order-1-3 sort-order-2-3 sort-order-3-3
|
||||
|
||||
# Switch pkg-config path order
|
||||
PKG_CONFIG_PATH="$order2"
|
||||
|
||||
# Check package set -1
|
||||
RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-3-1
|
||||
run_test --cflags sort-order-3-1 sort-order-2-1
|
||||
run_test --cflags sort-order-2-1 sort-order-3-1
|
||||
run_test --cflags sort-order-3-1 sort-order-2-1 sort-order-1-1
|
||||
run_test --cflags sort-order-3-1 sort-order-1-1 sort-order-2-1
|
||||
run_test --cflags sort-order-2-1 sort-order-3-1 sort-order-1-1
|
||||
run_test --cflags sort-order-2-1 sort-order-1-1 sort-order-3-1
|
||||
run_test --cflags sort-order-1-1 sort-order-3-1 sort-order-2-1
|
||||
run_test --cflags sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
run_test --libs sort-order-3-1
|
||||
run_test --libs sort-order-3-1 sort-order-2-1
|
||||
run_test --libs sort-order-2-1 sort-order-3-1
|
||||
run_test --libs sort-order-3-1 sort-order-2-1 sort-order-1-1
|
||||
run_test --libs sort-order-3-1 sort-order-1-1 sort-order-2-1
|
||||
run_test --libs sort-order-2-1 sort-order-3-1 sort-order-1-1
|
||||
run_test --libs sort-order-2-1 sort-order-1-1 sort-order-3-1
|
||||
run_test --libs sort-order-1-1 sort-order-3-1 sort-order-2-1
|
||||
run_test --libs sort-order-1-1 sort-order-2-1 sort-order-3-1
|
||||
|
||||
# Check package set -2
|
||||
RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-3-2
|
||||
run_test --cflags sort-order-3-2 sort-order-2-2
|
||||
run_test --cflags sort-order-2-2 sort-order-3-2
|
||||
run_test --cflags sort-order-3-2 sort-order-2-2 sort-order-1-2
|
||||
run_test --cflags sort-order-3-2 sort-order-1-2 sort-order-2-2
|
||||
run_test --cflags sort-order-2-2 sort-order-3-2 sort-order-1-2
|
||||
run_test --cflags sort-order-2-2 sort-order-1-2 sort-order-3-2
|
||||
run_test --cflags sort-order-1-2 sort-order-3-2 sort-order-2-2
|
||||
run_test --cflags sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \
|
||||
-lpath3 -lpath2 -lpath1"
|
||||
run_test --libs sort-order-3-2
|
||||
run_test --libs sort-order-3-2 sort-order-2-2
|
||||
run_test --libs sort-order-2-2 sort-order-3-2
|
||||
run_test --libs sort-order-3-2 sort-order-2-2 sort-order-1-2
|
||||
run_test --libs sort-order-3-2 sort-order-1-2 sort-order-2-2
|
||||
run_test --libs sort-order-2-2 sort-order-3-2 sort-order-1-2
|
||||
run_test --libs sort-order-2-2 sort-order-1-2 sort-order-3-2
|
||||
run_test --libs sort-order-1-2 sort-order-3-2 sort-order-2-2
|
||||
run_test --libs sort-order-1-2 sort-order-2-2 sort-order-3-2
|
||||
|
||||
# Check package set -3
|
||||
RESULT="-DPATH2 -DPATH3 -DPATH1 -I/path2/include -I/path3/include \
|
||||
-I/path1/include"
|
||||
run_test --cflags sort-order-1-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3
|
||||
run_test --cflags sort-order-2-3 sort-order-1-3
|
||||
run_test --cflags sort-order-3-3 sort-order-2-3 sort-order-1-3
|
||||
run_test --cflags sort-order-3-3 sort-order-1-3 sort-order-2-3
|
||||
run_test --cflags sort-order-2-3 sort-order-3-3 sort-order-1-3
|
||||
run_test --cflags sort-order-2-3 sort-order-1-3 sort-order-3-3
|
||||
run_test --cflags sort-order-1-3 sort-order-3-3 sort-order-2-3
|
||||
run_test --cflags sort-order-1-3 sort-order-2-3 sort-order-3-3
|
||||
|
||||
RESULT="-Wl,-O2 -Wl,-O3 -Wl,-O1 -L/path2/lib -L/path3/lib -L/path1/lib \
|
||||
-lpath1 -lpath2 -lpath3"
|
||||
run_test --libs sort-order-1-3
|
||||
run_test --libs sort-order-1-3 sort-order-2-3
|
||||
run_test --libs sort-order-2-3 sort-order-1-3
|
||||
run_test --libs sort-order-3-3 sort-order-2-3 sort-order-1-3
|
||||
run_test --libs sort-order-3-3 sort-order-1-3 sort-order-2-3
|
||||
run_test --libs sort-order-2-3 sort-order-3-3 sort-order-1-3
|
||||
run_test --libs sort-order-2-3 sort-order-1-3 sort-order-3-3
|
||||
run_test --libs sort-order-1-3 sort-order-3-3 sort-order-2-3
|
||||
run_test --libs sort-order-1-3 sort-order-2-3 sort-order-3-3
|
||||
10
check/sort-order-1-1.pc
Normal file
10
check/sort-order-1-1.pc
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
prefix=/path1
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 1-1
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O1 -lpath1
|
||||
Cflags: -I${includedir} -DPATH1
|
||||
10
check/sort-order-1-2.pc
Normal file
10
check/sort-order-1-2.pc
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
prefix=/path1
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 1-2
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O1 -lpath1
|
||||
Cflags: -I${includedir} -DPATH1
|
||||
11
check/sort-order-1-3.pc
Normal file
11
check/sort-order-1-3.pc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
prefix=/path1
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 1-3
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O1 -lpath1
|
||||
Cflags: -I${includedir} -DPATH1
|
||||
Requires: sort-order-2-3
|
||||
11
check/sort/sort-order-2-1.pc
Normal file
11
check/sort/sort-order-2-1.pc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
prefix=/path2
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 2-1
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O2 -lpath2
|
||||
Cflags: -I${includedir} -DPATH2
|
||||
Requires: sort-order-1-1
|
||||
11
check/sort/sort-order-2-2.pc
Normal file
11
check/sort/sort-order-2-2.pc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
prefix=/path2
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 2-2
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O2 -lpath2
|
||||
Cflags: -I${includedir} -DPATH2
|
||||
Requires: sort-order-1-2
|
||||
11
check/sort/sort-order-2-3.pc
Normal file
11
check/sort/sort-order-2-3.pc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
prefix=/path2
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 2-3
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O2 -lpath2
|
||||
Cflags: -I${includedir} -DPATH2
|
||||
Requires: sort-order-3-3
|
||||
11
check/sort/sort/sort-order-3-1.pc
Normal file
11
check/sort/sort/sort-order-3-1.pc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
prefix=/path3
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 3-1
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O3 -lpath3
|
||||
Cflags: -I${includedir} -DPATH3
|
||||
Requires: sort-order-2-1
|
||||
11
check/sort/sort/sort-order-3-2.pc
Normal file
11
check/sort/sort/sort-order-3-2.pc
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
prefix=/path3
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 3-2
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O3 -lpath3
|
||||
Cflags: -I${includedir} -DPATH3
|
||||
Requires: sort-order-2-2 sort-order-1-2
|
||||
10
check/sort/sort/sort-order-3-3.pc
Normal file
10
check/sort/sort/sort-order-3-3.pc
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
prefix=/path3
|
||||
exec_prefix=${prefix}
|
||||
libdir="${exec_prefix}/lib"
|
||||
includedir="${prefix}/include"
|
||||
|
||||
Name: Sort order Cflags and Libs test 3-3
|
||||
Description: Test package for testing flag sort order
|
||||
Version: 1.0.0
|
||||
Libs: -L${libdir} -Wl,-O3 -lpath3
|
||||
Cflags: -I${includedir} -DPATH3
|
||||
Loading…
Add table
Reference in a new issue