xref: /freebsd/contrib/pkgconf/tests/sysroot.sh (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1#!/usr/bin/env atf-sh
2
3. $(atf_get_srcdir)/test_env.sh
4
5tests_init \
6	cflags \
7	variable \
8	do_not_eat_slash \
9	do_not_duplicate_sysroot_dir \
10	uninstalled \
11	uninstalled_pkgconf1 \
12	uninstalled_fdo \
13	uninstalled_fdo_pc_sysrootdir
14
15do_not_eat_slash_body()
16{
17	export PKG_CONFIG_PATH="${selfdir}/lib1"
18	export PKG_CONFIG_SYSROOT_DIR="/"
19	atf_check \
20		-o inline:"-fPIC -I/test/include/foo\n" \
21		pkgconf --cflags baz
22}
23
24cflags_body()
25{
26	export PKG_CONFIG_PATH="${selfdir}/lib1"
27	export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
28	atf_check \
29		-o inline:"-fPIC -I${SYSROOT_DIR}/test/include/foo\n" \
30		pkgconf --cflags baz
31}
32
33variable_body()
34{
35	export PKG_CONFIG_PATH="${selfdir}/lib1"
36	export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
37	atf_check \
38		-o inline:"${SYSROOT_DIR}/test\n" \
39		pkgconf --variable=prefix foo
40	atf_check \
41		-o inline:"${SYSROOT_DIR}/test/include\n" \
42		pkgconf --variable=includedir foo
43}
44
45do_not_duplicate_sysroot_dir_body()
46{
47	export PKG_CONFIG_PATH="${selfdir}/lib1"
48	export PKG_CONFIG_SYSROOT_DIR="/sysroot"
49
50	atf_check \
51		-o inline:"-I/sysroot/usr/include\n" \
52		pkgconf --cflags sysroot-dir-2
53
54	atf_check \
55		-o inline:"-I/sysroot/usr/include\n" \
56		pkgconf --cflags sysroot-dir-3
57
58	atf_check \
59		-o inline:"-I/sysroot/usr/include\n" \
60		pkgconf --cflags sysroot-dir-5
61
62	export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
63
64	atf_check \
65		-o inline:"-I${SYSROOT_DIR}/usr/include\n" \
66		pkgconf --cflags sysroot-dir-4
67}
68
69uninstalled_body()
70{
71	export PKG_CONFIG_PATH="${selfdir}/lib1"
72	export PKG_CONFIG_SYSROOT_DIR="/sysroot"
73
74	atf_check \
75		-o inline:"-L/test/lib -lomg\n" \
76		pkgconf --libs omg
77}
78
79uninstalled_pkgconf1_body()
80{
81	export PKG_CONFIG_PATH="${selfdir}/lib1"
82	export PKG_CONFIG_SYSROOT_DIR="/sysroot"
83	export PKG_CONFIG_PKGCONF1_SYSROOT_RULES="1"
84
85	atf_check \
86		-o inline:"-L/sysroot/test/lib -lomg\n" \
87		pkgconf --libs omg
88}
89
90uninstalled_fdo_body()
91{
92	export PKG_CONFIG_PATH="${selfdir}/lib1"
93	export PKG_CONFIG_SYSROOT_DIR="/sysroot"
94	export PKG_CONFIG_FDO_SYSROOT_RULES="1"
95
96	atf_check \
97		-o inline:"-L/test/lib -lomg\n" \
98		pkgconf --libs omg
99}
100
101uninstalled_fdo_pc_sysrootdir_body()
102{
103	export PKG_CONFIG_PATH="${selfdir}/lib1"
104	export PKG_CONFIG_SYSROOT_DIR="/sysroot"
105	export PKG_CONFIG_FDO_SYSROOT_RULES="1"
106
107	atf_check \
108		-o inline:"-L/sysroot/test/lib -lomg\n" \
109		pkgconf --libs omg-sysroot
110}
111