2016-09-18 20:48:13 +00:00
|
|
|
#!/usr/bin/env atf-sh
|
|
|
|
|
|
|
|
. $(atf_get_srcdir)/test_env.sh
|
|
|
|
|
|
|
|
tests_init \
|
2016-11-05 04:14:22 +00:00
|
|
|
comments \
|
|
|
|
comments_in_fields \
|
2016-09-18 20:48:13 +00:00
|
|
|
dos \
|
|
|
|
no_trailing_newline \
|
|
|
|
argv_parse \
|
|
|
|
bad_option \
|
|
|
|
argv_parse_3 \
|
|
|
|
tilde_quoting \
|
|
|
|
paren_quoting \
|
|
|
|
multiline_field \
|
2018-06-16 21:35:19 +00:00
|
|
|
multiline_bogus_header \
|
2017-09-23 05:08:12 +00:00
|
|
|
escaped_backslash \
|
2016-12-30 18:45:29 +00:00
|
|
|
flag_order_1 \
|
|
|
|
flag_order_2 \
|
|
|
|
flag_order_3 \
|
|
|
|
flag_order_4 \
|
2017-01-26 18:55:48 +00:00
|
|
|
quoted \
|
2017-02-03 18:58:11 +00:00
|
|
|
variable_whitespace \
|
2017-12-15 04:13:19 +00:00
|
|
|
fragment_escaping_1 \
|
|
|
|
fragment_escaping_2 \
|
|
|
|
fragment_escaping_3 \
|
2017-02-07 16:24:54 +00:00
|
|
|
fragment_quoting \
|
|
|
|
fragment_quoting_2 \
|
2017-02-25 19:57:38 +00:00
|
|
|
fragment_quoting_3 \
|
|
|
|
fragment_quoting_5 \
|
2018-01-05 17:31:43 +00:00
|
|
|
fragment_quoting_7 \
|
2018-01-06 00:05:47 +00:00
|
|
|
msvc_fragment_quoting \
|
2018-06-14 21:11:21 +00:00
|
|
|
msvc_fragment_render_cflags \
|
2019-07-12 11:22:41 +00:00
|
|
|
tuple_dequote \
|
2019-07-12 11:37:46 +00:00
|
|
|
version_with_whitespace \
|
|
|
|
version_with_whitespace_2
|
2016-09-18 20:48:13 +00:00
|
|
|
|
2016-11-05 04:14:22 +00:00
|
|
|
comments_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-lfoo \n" \
|
2016-11-05 04:14:22 +00:00
|
|
|
pkgconf --libs comments
|
|
|
|
}
|
|
|
|
|
|
|
|
comments_in_fields_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-lfoo \n" \
|
2016-11-05 04:14:22 +00:00
|
|
|
pkgconf --libs comments-in-fields
|
|
|
|
}
|
|
|
|
|
2016-09-18 20:48:13 +00:00
|
|
|
dos_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L/test/lib/dos-lineendings -ldos-lineendings \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --libs dos-lineendings
|
|
|
|
}
|
|
|
|
|
|
|
|
no_trailing_newline_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-I/test/include/no-trailing-newline \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --cflags no-trailing-newline
|
|
|
|
}
|
|
|
|
|
|
|
|
argv_parse_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-llib-3 -llib-1 -llib-2 -lpthread \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
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 \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-llib-1 -pthread /test/lib/lib2.so \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --libs argv-parse-3
|
|
|
|
}
|
|
|
|
|
|
|
|
tilde_quoting_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L~ -ltilde \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --libs tilde-quoting
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-I~ \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --cflags tilde-quoting
|
|
|
|
}
|
|
|
|
|
|
|
|
paren_quoting_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L\$(libdir) -ltilde \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --libs paren-quoting
|
|
|
|
}
|
|
|
|
|
|
|
|
multiline_field_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
|
|
|
-e ignore \
|
|
|
|
-o match:"multiline description" \
|
|
|
|
pkgconf --list-all
|
|
|
|
}
|
|
|
|
|
2018-06-16 21:35:19 +00:00
|
|
|
multiline_bogus_header_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
|
|
|
-s eq:0 \
|
|
|
|
pkgconf --exists multiline-bogus
|
|
|
|
}
|
|
|
|
|
2017-09-23 05:08:12 +00:00
|
|
|
escaped_backslash_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
|
|
|
-e ignore \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-IC:\\\\\\\\A \n" \
|
2017-09-23 05:08:12 +00:00
|
|
|
pkgconf --with-path=${selfdir}/lib1 --cflags escaped-backslash
|
|
|
|
}
|
|
|
|
|
2016-09-18 20:48:13 +00:00
|
|
|
quoted_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-DQUOTED=\\\"bla\\\" \n" \
|
2016-09-18 20:48:13 +00:00
|
|
|
pkgconf --cflags quotes
|
|
|
|
}
|
2016-12-30 18:45:29 +00:00
|
|
|
|
|
|
|
flag_order_1_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L/test/lib -Bdynamic -lfoo -Bstatic -lbar \n" \
|
2016-12-30 18:45:29 +00:00
|
|
|
pkgconf --libs flag-order-1
|
|
|
|
}
|
|
|
|
|
|
|
|
flag_order_2_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L/test/lib -Bdynamic -lfoo -Bstatic -lbar -lfoo \n" \
|
2016-12-30 18:45:29 +00:00
|
|
|
pkgconf --libs flag-order-1 foo
|
|
|
|
}
|
|
|
|
|
|
|
|
flag_order_3_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group \n" \
|
2016-12-30 18:45:29 +00:00
|
|
|
pkgconf --libs flag-order-3
|
|
|
|
}
|
|
|
|
|
|
|
|
flag_order_4_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group -lfoo \n" \
|
2016-12-30 18:45:29 +00:00
|
|
|
pkgconf --libs flag-order-3 foo
|
|
|
|
}
|
2017-01-26 18:55:48 +00:00
|
|
|
|
|
|
|
variable_whitespace_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2017-02-07 16:11:12 +00:00
|
|
|
-o inline:"-I/test/include \n" \
|
2017-01-26 18:55:48 +00:00
|
|
|
pkgconf --cflags variable-whitespace
|
|
|
|
}
|
2017-02-03 18:58:11 +00:00
|
|
|
|
|
|
|
fragment_quoting_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\" \n" \
|
2017-02-03 18:58:11 +00:00
|
|
|
pkgconf --cflags fragment-quoting
|
|
|
|
}
|
2017-02-07 16:24:54 +00:00
|
|
|
|
|
|
|
fragment_quoting_2_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
|
|
|
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc \n" \
|
|
|
|
pkgconf --cflags fragment-quoting-2
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment_quoting_3_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\" \n" \
|
2017-02-07 16:24:54 +00:00
|
|
|
pkgconf --cflags fragment-quoting-3
|
|
|
|
}
|
2017-02-25 19:57:38 +00:00
|
|
|
|
|
|
|
fragment_quoting_5_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
|
|
|
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc \n" \
|
|
|
|
pkgconf --cflags fragment-quoting-5
|
|
|
|
}
|
|
|
|
|
2017-03-29 21:58:04 +00:00
|
|
|
fragment_quoting_7_body()
|
|
|
|
{
|
2017-03-29 23:00:10 +00:00
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\\ world \n" \
|
2017-03-29 23:00:10 +00:00
|
|
|
pkgconf --cflags fragment-quoting-7
|
|
|
|
}
|
|
|
|
|
2017-12-15 04:13:19 +00:00
|
|
|
fragment_escaping_1_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-IC:\\\\\\\\D\\ E \n" \
|
2017-12-15 04:13:19 +00:00
|
|
|
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-escaping-1
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment_escaping_2_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-IC:\\\\\\\\D\\ E \n" \
|
2017-12-15 04:13:19 +00:00
|
|
|
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-escaping-2
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment_escaping_3_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
2018-01-22 21:35:54 +00:00
|
|
|
-o inline:"-IC:\\\\\\\\D\\ E \n" \
|
2017-12-15 04:13:19 +00:00
|
|
|
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-escaping-3
|
|
|
|
}
|
|
|
|
|
2017-03-29 23:00:10 +00:00
|
|
|
fragment_quoting_7a_body()
|
|
|
|
{
|
|
|
|
set -x
|
|
|
|
|
2017-03-29 21:58:04 +00:00
|
|
|
test_cflags=$(pkgconf --with-path=${selfdir}/lib1 --cflags fragment-quoting-7)
|
2017-03-29 23:00:10 +00:00
|
|
|
echo $test_cflags
|
|
|
|
# test_cflags='-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\\ world'
|
|
|
|
|
2017-03-29 21:58:04 +00:00
|
|
|
cat > test.c <<- __TESTCASE_END__
|
|
|
|
int main(int argc, char *argv[]) { return DEFINED_FROM_PKG_CONFIG; }
|
|
|
|
__TESTCASE_END__
|
|
|
|
cc -o test-fragment-quoting-7 ${test_cflags} ./test.c
|
|
|
|
atf_check -e 42 ./test-fragment-quoting-7
|
|
|
|
rm -f test.c test-fragment-quoting-7
|
2017-03-29 23:00:10 +00:00
|
|
|
|
|
|
|
set +x
|
2017-03-29 21:58:04 +00:00
|
|
|
}
|
2018-01-05 17:31:43 +00:00
|
|
|
|
|
|
|
msvc_fragment_quoting_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
|
|
|
-o inline:'/libpath:"C:\D E" E.lib \n' \
|
|
|
|
pkgconf --libs --msvc-syntax fragment-escaping-1
|
|
|
|
}
|
2018-01-06 00:05:47 +00:00
|
|
|
|
|
|
|
msvc_fragment_render_cflags_body()
|
|
|
|
{
|
|
|
|
export PKG_CONFIG_PATH="${selfdir}/lib1"
|
|
|
|
atf_check \
|
|
|
|
-o inline:'/I/test/include/foo /DFOO_STATIC \n' \
|
|
|
|
pkgconf --cflags --static --msvc-syntax foo
|
|
|
|
}
|
2018-06-14 21:11:21 +00:00
|
|
|
|
|
|
|
tuple_dequote_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
|
|
|
-o inline:'-L/test/lib -lfoo \n' \
|
|
|
|
pkgconf --with-path="${selfdir}/lib1" --libs tuple-quoting
|
|
|
|
}
|
2019-07-12 11:22:41 +00:00
|
|
|
|
|
|
|
version_with_whitespace_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
|
|
|
-o inline:'3.922\n' \
|
|
|
|
pkgconf --with-path="${selfdir}/lib1" --modversion malformed-version
|
|
|
|
}
|
2019-07-12 11:37:46 +00:00
|
|
|
|
|
|
|
version_with_whitespace_2_body()
|
|
|
|
{
|
|
|
|
atf_check \
|
|
|
|
-o inline:'malformed-version = 3.922\n' \
|
|
|
|
pkgconf --with-path="${selfdir}/lib1" --print-provides malformed-version
|
|
|
|
}
|