summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-11-09 05:58:36 -0800
committerDan Nicholson <dbn.lists@gmail.com>2012-11-28 05:52:06 -0800
commit3e54448158f42677cfc2de06ff1a910d4289ae59 (patch)
tree8e76e5ae32f37abbac08cae92474a4464ff14a13
parente2910a6afd709e57ccad59ed9665c55a25f06b5c (diff)
downloadpkg-config-3e54448158f42677cfc2de06ff1a910d4289ae59.tar.gz
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.
-rw-r--r--check/Makefile.am12
-rwxr-xr-xcheck/check-sort-order194
-rw-r--r--check/sort-order-1-1.pc10
-rw-r--r--check/sort-order-1-2.pc10
-rw-r--r--check/sort-order-1-3.pc11
-rw-r--r--check/sort/sort-order-2-1.pc11
-rw-r--r--check/sort/sort-order-2-2.pc11
-rw-r--r--check/sort/sort-order-2-3.pc11
-rw-r--r--check/sort/sort/sort-order-3-1.pc11
-rw-r--r--check/sort/sort/sort-order-3-2.pc11
-rw-r--r--check/sort/sort/sort-order-3-3.pc10
11 files changed, 301 insertions, 1 deletions
diff --git a/check/Makefile.am b/check/Makefile.am
index 8b8485f..e8a4435 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -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
diff --git a/check/check-sort-order b/check/check-sort-order
new file mode 100755
index 0000000..ad1bad2
--- /dev/null
+++ b/check/check-sort-order
@@ -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
diff --git a/check/sort-order-1-1.pc b/check/sort-order-1-1.pc
new file mode 100644
index 0000000..adead0a
--- /dev/null
+++ b/check/sort-order-1-1.pc
@@ -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
diff --git a/check/sort-order-1-2.pc b/check/sort-order-1-2.pc
new file mode 100644
index 0000000..85cc278
--- /dev/null
+++ b/check/sort-order-1-2.pc
@@ -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
diff --git a/check/sort-order-1-3.pc b/check/sort-order-1-3.pc
new file mode 100644
index 0000000..a910756
--- /dev/null
+++ b/check/sort-order-1-3.pc
@@ -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
diff --git a/check/sort/sort-order-2-1.pc b/check/sort/sort-order-2-1.pc
new file mode 100644
index 0000000..3baebdc
--- /dev/null
+++ b/check/sort/sort-order-2-1.pc
@@ -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
diff --git a/check/sort/sort-order-2-2.pc b/check/sort/sort-order-2-2.pc
new file mode 100644
index 0000000..0991aa5
--- /dev/null
+++ b/check/sort/sort-order-2-2.pc
@@ -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
diff --git a/check/sort/sort-order-2-3.pc b/check/sort/sort-order-2-3.pc
new file mode 100644
index 0000000..7230a26
--- /dev/null
+++ b/check/sort/sort-order-2-3.pc
@@ -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
diff --git a/check/sort/sort/sort-order-3-1.pc b/check/sort/sort/sort-order-3-1.pc
new file mode 100644
index 0000000..03e0679
--- /dev/null
+++ b/check/sort/sort/sort-order-3-1.pc
@@ -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
diff --git a/check/sort/sort/sort-order-3-2.pc b/check/sort/sort/sort-order-3-2.pc
new file mode 100644
index 0000000..0a1504f
--- /dev/null
+++ b/check/sort/sort/sort-order-3-2.pc
@@ -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
diff --git a/check/sort/sort/sort-order-3-3.pc b/check/sort/sort/sort-order-3-3.pc
new file mode 100644
index 0000000..e7bdcd6
--- /dev/null
+++ b/check/sort/sort/sort-order-3-3.pc
@@ -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