xref: /freebsd/contrib/pkgconf/tests/requires.sh (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1#!/usr/bin/env atf-sh
2
3. $(atf_get_srcdir)/test_env.sh
4
5tests_init \
6	libs \
7	libs_cflags \
8	libs_static \
9	libs_static_pure \
10	cflags_libs_private \
11	argv_parse2 \
12	static_cflags \
13	private_duplication \
14	private_duplication_digraph \
15	foo_bar \
16	bar_foo \
17	foo_metapackage_3 \
18	libs_static2 \
19	missing \
20	requires_internal \
21	requires_internal_missing \
22	requires_internal_collision \
23	orphaned_requires_private
24
25libs_body()
26{
27	export PKG_CONFIG_PATH="${selfdir}/lib1"
28	atf_check \
29		-o inline:"-L/test/lib -lbar -lfoo\n" \
30		pkgconf --libs bar
31}
32
33libs_cflags_body()
34{
35	export PKG_CONFIG_PATH="${selfdir}/lib1"
36	atf_check \
37		-o inline:"-fPIC -I/test/include/foo -L/test/lib -lbaz\n" \
38		pkgconf --libs --cflags baz
39}
40
41libs_static_body()
42{
43	export PKG_CONFIG_PATH="${selfdir}/lib1"
44	atf_check \
45		-o inline:"-L/test/lib -lbaz -L/test/lib -lzee -lfoo\n" \
46		pkgconf --static --libs baz
47}
48
49libs_static_pure_body()
50{
51	export PKG_CONFIG_PATH="${selfdir}/lib1"
52	atf_check \
53		-o inline:"-L/test/lib -lbaz -lfoo\n" \
54		pkgconf --static --pure --libs baz
55}
56
57argv_parse2_body()
58{
59	export PKG_CONFIG_PATH="${selfdir}/lib1"
60	atf_check \
61		-o inline:"-llib-1 -pthread /test/lib/lib2.so\n" \
62		pkgconf --static --libs argv-parse-2
63}
64
65static_cflags_body()
66{
67	export PKG_CONFIG_PATH="${selfdir}/lib1"
68	atf_check \
69		-o inline:"-fPIC -I/test/include/foo -DFOO_STATIC\n" \
70		pkgconf --static --cflags baz
71}
72
73private_duplication_body()
74{
75	export PKG_CONFIG_PATH="${selfdir}/lib1"
76	atf_check \
77		-o inline:"-lprivate -lbaz -lzee -lbar -lfoo\n" \
78		pkgconf --static --libs-only-l private-libs-duplication
79}
80
81private_duplication_digraph_body()
82{
83	export PKG_CONFIG_PATH="${selfdir}/lib1"
84	atf_check \
85		-o 'match:"user:request" -> "private-libs-duplication"' \
86		-o 'match:"private-libs-duplication" -> "bar"' \
87		-o 'match:"private-libs-duplication" -> "baz"' \
88		-o 'match:"bar" -> "foo"' \
89		-o 'match:"baz" -> "foo"' \
90		pkgconf --static --libs-only-l private-libs-duplication --digraph
91}
92
93bar_foo_body()
94{
95	export PKG_CONFIG_PATH="${selfdir}/lib1"
96	atf_check \
97		-o inline:"-lbar -lfoo\n" \
98		pkgconf --static --libs-only-l bar foo
99}
100
101foo_bar_body()
102{
103	export PKG_CONFIG_PATH="${selfdir}/lib1"
104	atf_check \
105		-o inline:"-lbar -lfoo\n" \
106		pkgconf --static --libs-only-l foo bar
107}
108
109foo_metapackage_3_body()
110{
111	export PKG_CONFIG_PATH="${selfdir}/lib1"
112	atf_check \
113		-o inline:"-lbar -lfoo\n" \
114		pkgconf --static --libs-only-l foo metapackage-3
115}
116
117libs_static2_body()
118{
119	export PKG_CONFIG_PATH="${selfdir}/lib1"
120	atf_check \
121		-o inline:"-lbar -lbar-private -L/test/lib -lfoo\n" \
122		pkgconf --static --libs static-libs
123}
124
125missing_body()
126{
127	export PKG_CONFIG_PATH="${selfdir}/lib1"
128	atf_check \
129		-s exit:1 \
130		-e ignore \
131		-o ignore \
132		pkgconf --cflags missing-require
133}
134
135requires_internal_body()
136{
137	atf_check \
138		-o inline:"-lbar -lbar-private -L/test/lib -lfoo\n" \
139		pkgconf --with-path="${selfdir}/lib1" --static --libs requires-internal
140}
141
142requires_internal_missing_body()
143{
144	atf_check \
145		-s exit:1 \
146		-e ignore \
147		-o ignore \
148		pkgconf --with-path="${selfdir}/lib1" --static --libs requires-internal-missing
149}
150
151requires_internal_collision_body()
152{
153	atf_check \
154		-o inline:"-I/test/local/include/foo\n" \
155		pkgconf --with-path="${selfdir}/lib1" --cflags requires-internal-collision
156}
157
158orphaned_requires_private_body()
159{
160	atf_check \
161		-s exit:1 \
162		-e ignore \
163		-o ignore \
164		pkgconf --with-path="${selfdir}/lib1" --cflags --libs orphaned-requires-private
165}
166
167cflags_libs_private_body()
168{
169	atf_check \
170		-o inline:"\n" \
171		pkgconf --with-path="${selfdir}/lib1" --libs cflags-libs-private-a
172
173	atf_check \
174		-o inline:"-lc\n" \
175		pkgconf --with-path="${selfdir}/lib1" --static --libs cflags-libs-private-a
176}
177