diff --git a/src/cps/pc_compat/pc_loader.cpp b/src/cps/pc_compat/pc_loader.cpp index cd2f052..22c10e5 100644 --- a/src/cps/pc_compat/pc_loader.cpp +++ b/src/cps/pc_compat/pc_loader.cpp @@ -130,8 +130,11 @@ namespace cps::pc_compat { return loader::Package{.name = name, .cps_version = std::string{loader::CPS_VERSION}, .components = components, + // TODO: consider how pkg-config actually handles version and + .compat_version = version, // TODO: treat PREFIX in pc file specially and translate it to @prefix@ .cps_path = std::nullopt, + .prefix = fs::path{""}, .filename = filename.string(), .default_components = std::vector{name}, .platform = std::nullopt, diff --git a/tests/meson.build b/tests/meson.build index 3b651c6..10cff19 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -56,3 +56,5 @@ foreach t : ['loader', 'version', 'utils', 'pc_parser'] protocol : 'gtest', ) endforeach + +subdir('pkgconf') diff --git a/tests/pkgconf/.editorconfig b/tests/pkgconf/.editorconfig new file mode 100644 index 0000000..cf056b3 --- /dev/null +++ b/tests/pkgconf/.editorconfig @@ -0,0 +1,6 @@ +# We need these mostly unset because we're testing weird whitespaces and formats +[*.pc] +end_of_line = unset +indent_style = unset +insert_final_newline = unset +trim_trailing_whitespace = unset diff --git a/tests/pkgconf/AUTHORS b/tests/pkgconf/AUTHORS new file mode 100644 index 0000000..9ba1de4 --- /dev/null +++ b/tests/pkgconf/AUTHORS @@ -0,0 +1,41 @@ +A. Wilcox +Alexander Tsoy +Alexpux +Alon Bar-Lev +Alyx +Ariadne Conill +Baptiste Daroussin +Baptiste Daroussin +Bryan Drewery +Dag-Erling Smørgrav +Dan Kegel +Dan Kegel +Dan Nicholson +David Michael +Emil Renner Berthing +Fabian Groffen +Graham Ollis +Gregor Richards +Ignacio Casal Quinteiro +Igor Gnatenko +Issam Maghni +JD Horelick +Jason Dusek +Javier Viguera +Jean-Sébastien Pédron +John Hein +Jussi Pakkanen +Leorize +Luca Barbato +Marcin Wojdyr +Maxin B. John +Michał Górny +Mike Frysinger +Seungha Yang +TingPing +Tobias Kortkamp +Tony Theodore +Volker Braun +Yu Kobayashi +orbea +✈ Graham ✈ diff --git a/tests/pkgconf/COPYING b/tests/pkgconf/COPYING new file mode 100644 index 0000000..35c7c16 --- /dev/null +++ b/tests/pkgconf/COPYING @@ -0,0 +1,10 @@ +Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 + pkgconf authors (see AUTHORS file in source directory). + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +This software is provided 'as is' and without any warranty, express or +implied. In no event shall the authors be liable for any damages arising +from the use of this software. diff --git a/tests/pkgconf/basic.toml b/tests/pkgconf/basic.toml new file mode 100644 index 0000000..96d380c --- /dev/null +++ b/tests/pkgconf/basic.toml @@ -0,0 +1,219 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[noargs] + exitcode = 1 + stderr = '' + expected_fail = true + +[libs] + stdout = "-L/test/lib -lfoo\n" + args = ["--libs", "foo"] + expected_fail = true + +[lib_cflags] + stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n" + args = ["--cflags", "--libs", "foo"] + expected_fail = true + +[lib_cflags_version] + stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n" + args = ["--cflags", "--libs", "foo > 1.2"] + expected_fail = true + +[lib_cflags_version_multiple] + stdout = "-fPIC -I/test/include/foo -L/test/lib -lbar -lfoo\n" + args = ["--cflags", "--libs", "foo > 1.2 bar >= 1.3"] + expected_fail = true + +[lib_cflags_version_multiple_comma] + stdout = "-fPIC -I/test/include/foo -L/test/lib -lbar -lfoo\n" + args = ["--cflags", "--libs", "foo > 1.2,bar >= 1.3"] + expected_fail = true + +[lib_cflags_version_alt] + stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n" + args = ["--cflags", "--libs", "foo", ">", "1.2"] + expected_fail = true + +[lib_cflags_version_different] + stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n" + args = ["--cflags", "--libs", "foo", "!=", "1.3"] + expected_fail = true + +[lib_cflags_version_different_bad] + exitcode = 1 + stderr = "Package dependency requirement 'foo != 1.2.3' could not be satisfied.\nPackage 'foo' has version '1.2.3', required version is '!= 1.2.3'\n" + args = ["--cflags", "--libs", "foo", "!=", "1.2.3"] + expected_fail = true + +[exists_nonexistent] + exitcode = 1 + args = ["--exists", "nonexistant"] + expected_fail = true + +[nonexistent] + exitcode = 1 + args = ["nonexistant"] + +[exists_version] + args = ["--exists", "foo > 1.2"] + expected_fail = true + +[exists_version_alt] + args = ["--exists", "foo", ">", "1.2"] + expected_fail = true + +[exists_version_bad] + exitcode = 1 + args = ["--exists", "foo > 1.2.3"] + expected_fail = true + +[uninstalled_bad] + exitcode = 1 + args = ["--uninstalled", "foo"] + expected_fail = true + +[uninstalled] + args = ["--uninstalled", "omg"] + expected_fail = true + +[exists_version_bad2] + exitcode = 1 + args = ["--exists", "foo >= "] + expected_fail = true + +[exists_version_bad3] + exitcode = 1 + args = ["--exists", "tilde >= 1.0.0"] + expected_fail = true + +[exists] + args = ["--exists", "tilde >= 1.0.0"] + expected_fail = true + +[exists2] + args = ["--exists", "tilde >= 1.0.0~rc1"] + expected_fail = true + +[exists3] + args = ["--exists", "", "foo"] + expected_fail = true + +[intermediary] + args = ["--libs", "intermediary-1", "intermediary-2"] + stdout = "-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz\n" + expected_fail = true + +[circular2] + args = ["circular-2", "--validate"] + stdout = "circular-1: breaking circular reference (circular-1 -> circular-2 -> circular-1)\n" + expected_fail = true + +[circular1] + args = ["circular-1", "--validate"] + stdout = "circular-3: breaking circular reference (circular-3 -> circular-1 -> circular-3)\n" + expected_fail = true + +[circular_direct_pc] + args = ["--libs", "{test_root}/lib1/circular-3.pc"] + stdout = "-lcircular-3 -lcircular-1 -lcircular-2\n" + expected_fail = true + +[libs_static] + args = ["--libs", "static-archive-libs"] + stdout = "/libfoo.a -pthread\n" + expected_fail = true + +[pkg_config_path] + args = ["--libs", "foo"] + stdout = "-L/test/lib -lfoo\n" + expected_fail = true + + [pkg_config_path.env] + PKG_CONFIG_PATH = "{test_root}/lib1:{test_root}/lib2" + +[pkg_config_path2] + args = ["--libs", "bar"] + stdout = "-L/test/lib -lbar -lfoo\n" + expected_fail = true + + [pkg_config_path2.env] + PKG_CONFIG_PATH = "{test_root}/lib1:{test_root}/lib2" + +[with_path] + args = ["--with-path={test_root}/lib", "--with-path={test_root}/lib2", "--libs", "foo"] + stdout = "-L/test/lib -lfoo\n" + expected_fail = true + +[with_path2] + args = ["--with-path={test_root}/lib", "--with-path={test_root}/lib2", "--libs", "bar"] + stdout = "-L/test/lib -lbar -lfoo\n" + expected_fail = true + +[nolibs] + args = ["--libs", "nolib"] + stdout = "\n" + expected_fail = true + +[nocflags] + args = ["--cflags", "nocflag"] + stdout = "\n" + +# TODO: [arbitrary_path] + +# TODO: This doesn't work, needs some more magic? +#[relocatable_body] +# args = ["--define-prefix", "--variable=prefix", "tests/lib-relocatable/lib/pkgconfig/foo.pc"] +# stdout = "tests/lib-relocatable\n" + +[single_depth_selectors] + args = ["--with-path={test_root}/lib3", "--print-requires", "bar"] + stdout = "foo\n" + expected_fail = true + + [single_depth_selectors.env] + PKG_CONFIG_MAXIMUM_TRAVERSAL_DEPTH = "1" + +[license_isc] + args = ["--license", "foo"] + stdout = "foo: ISC\n" + expected_fail = true + +[license_noassertion] + args = ["--license", "bar"] + stdout = "bar: NOASSERTION\nfoo: ISC\n" + expected_fail = true + +[modversion_noflatten] + args = ["--modversion", "bar"] + stdout = "1.3\n" + expected_fail = true + +[exists_cflags] + args = ["--with-path={test_root}/lib", "--cflags", "--exists-cflags", "--fragment-filter=D", "foo"] + stdout = "-DHAVE_FOO\n" + expected_fail = true + +[exists_cflags_env] + args = ["--with-path={test_root}/lib", "--cflags", "--exists-cflags", "--fragment-filter=D", "--env=FOO", "foo"] + stdout = "FOO_CFLAGS='-DHAVE_FOO'\n" + expected_fail = true + +[libs_env] + args = ["--with-path={test_root}/lib", "--libs", "--env=FOO", "foo"] + stdout = "FOO_LIBS='-L/test/lib -lfoo'\n" + expected_fail = true + +[print_variables_env] + args = ["--with-path={test_root}/lib", "--env=FOO", "--print-variables", "--cflags", "--libs", "foo"] + stdout = "FOO_CFLAGS='-fPIC -I/test/include/foo'\nFOO_LIBS='-L/test/lib -lfoo'\nFOO_INCLUDEDIR='/test/include'\nFOO_LIBDIR='/test/lib'\nFOO_EXEC_PREFIX='/test'\nFOO_PREFIX='/test'\nFOO_PCFILEDIR='{test_root}/lib1'\n" + expected_fail = true + +[variable_env] + args = ["--with-path={test_root}/lib", "--env=FOO", "--variable=includedir", "foo"] + stdout = "FOO_INCLUDEDIR='/test/include'\n" + expected_fail = true + +# TODO: variable_env diff --git a/tests/pkgconf/builtins.toml.in b/tests/pkgconf/builtins.toml.in new file mode 100644 index 0000000..c4544e9 --- /dev/null +++ b/tests/pkgconf/builtins.toml.in @@ -0,0 +1,23 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[modversion] + args = ["--modversion", "pkg-config"] + stdout = "@PKGCONF_VERSION@\n" + expected_fail = true + +[variable] + args = ["--variable=prefix", "foo"] + stdout = "/test\n" + expected_fail = true + +[define_variable] + args = ["--define-variable=prefix=/test2", "--variable=prefix", "foo"] + stdout = "/test2\n" + expected_fail = true + +# TODO: global_variable +# TODO: argv_parser_3 +# TODO: tilde_quoting +# TODO: paren_quoting diff --git a/tests/pkgconf/conflicts.toml b/tests/pkgconf/conflicts.toml new file mode 100644 index 0000000..bf4a7fc --- /dev/null +++ b/tests/pkgconf/conflicts.toml @@ -0,0 +1,13 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[libs] + args = ["--libs", "conflicts"] + stdout = "-L/test/lib -lconflicts\n" + expected_fail = true + +[ignore] + args = ["--ignore-conflicts", "--libs", "conflicts"] + stdout = "-L/test/lib -lconflicts\n" + expected_fail = true diff --git a/tests/pkgconf/framework.toml b/tests/pkgconf/framework.toml new file mode 100644 index 0000000..eaed0ab --- /dev/null +++ b/tests/pkgconf/framework.toml @@ -0,0 +1,18 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[libs1] + args = ["--libs", "framework-1"] + stdout = "-F/test/lib -framework framework-1\n" + expected_fail = true + +[libs2] + args = ["--libs", "framework-2"] + stdout = "-F/test/lib -framework framework-2 -framework framework-1\n" + expected_fail = true + +[libs3] + args = ["--libs", "framework-1", "framework-2"] + stdout = "-F/test/lib -framework framework-2 -framework framework-1\n" + expected_fail = true diff --git a/tests/pkgconf/lib-relocatable/lib/pkgconfig/foo.pc b/tests/pkgconf/lib-relocatable/lib/pkgconfig/foo.pc new file mode 100644 index 0000000..f154eb7 --- /dev/null +++ b/tests/pkgconf/lib-relocatable/lib/pkgconfig/foo.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foo +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo +Cflags: -fPIC -I${includedir}/foo +Cflags.private: -DFOO_STATIC diff --git a/tests/pkgconf/lib1/argv-parse-2.pc b/tests/pkgconf/lib1/argv-parse-2.pc new file mode 100644 index 0000000..cfc0fcf --- /dev/null +++ b/tests/pkgconf/lib1/argv-parse-2.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: argv-parse-2 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -llib-1 -pthread ${libdir}/lib2.so +Cflags: diff --git a/tests/pkgconf/lib1/argv-parse-3.pc b/tests/pkgconf/lib1/argv-parse-3.pc new file mode 100644 index 0000000..b115b30 --- /dev/null +++ b/tests/pkgconf/lib1/argv-parse-3.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: argv-parse-3 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -llib-1 \ + -pthread ${libdir}/lib2.so +Cflags: diff --git a/tests/pkgconf/lib1/argv-parse.pc b/tests/pkgconf/lib1/argv-parse.pc new file mode 100644 index 0000000..d445ae7 --- /dev/null +++ b/tests/pkgconf/lib1/argv-parse.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: argv-parse +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -llib-3 -llib-1 -llib-2 -lpthread +Cflags: diff --git a/tests/pkgconf/lib1/bar.pc b/tests/pkgconf/lib1/bar.pc new file mode 100644 index 0000000..9157d06 --- /dev/null +++ b/tests/pkgconf/lib1/bar.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: bar +Description: Another pkg-config test +Version: 1.3 +Libs: -L${libdir} -lbar +Requires: foo diff --git a/tests/pkgconf/lib1/baz.pc b/tests/pkgconf/lib1/baz.pc new file mode 100644 index 0000000..d9cb258 --- /dev/null +++ b/tests/pkgconf/lib1/baz.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: bar +Description: Another pkg-config test (with private Requires, ha!) +Version: 1.3 +Libs: -L${libdir} -lbaz +Libs.private: -L${libdir} -lzee +Requires.private: foo diff --git a/tests/pkgconf/lib1/billion-laughs.pc b/tests/pkgconf/lib1/billion-laughs.pc new file mode 100644 index 0000000..ad1ee79 --- /dev/null +++ b/tests/pkgconf/lib1/billion-laughs.pc @@ -0,0 +1,13 @@ +v9=lol +v8=${v9}${v9}${v9}${v9}${v9}${v9}${v9}${v9}${v9}${v9} +v7=${v8}${v8}${v8}${v8}${v8}${v8}${v8}${v8}${v8}${v8} +v6=${v7}${v7}${v7}${v7}${v7}${v7}${v7}${v7}${v7}${v7} +v5=${v6}${v6}${v6}${v6}${v6}${v6}${v6}${v6}${v6}${v6} +v4=${v5}${v5}${v5}${v5}${v5}${v5}${v5}${v5}${v5}${v5} +v3=${v4}${v4}${v4}${v4}${v4}${v4}${v4}${v4}${v4}${v4} +v2=${v3}${v3}${v3}${v3}${v3}${v3}${v3}${v3}${v3}${v3} +v1=${v2}${v2}${v2}${v2}${v2}${v2}${v2}${v2}${v2}${v2} +v0=${v1}${v1}${v1}${v1}${v1}${v1}${v1}${v1}${v1}${v1} +Name: One Billion Laughs +Version: ${v0} +Description: Don't install this! diff --git a/tests/pkgconf/lib1/case-sensitivity.pc b/tests/pkgconf/lib1/case-sensitivity.pc new file mode 100644 index 0000000..9618061 --- /dev/null +++ b/tests/pkgconf/lib1/case-sensitivity.pc @@ -0,0 +1,7 @@ +foo=3 +Foo=4 + +Name: case-sensitivity +Description: Package for testing case-sensitivity +Version: 1 +Requires: foo < ${foo} diff --git a/tests/pkgconf/lib1/cflags-internal.pc b/tests/pkgconf/lib1/cflags-internal.pc new file mode 100644 index 0000000..500e566 --- /dev/null +++ b/tests/pkgconf/lib1/cflags-internal.pc @@ -0,0 +1,9 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: cflags-internal +Description: A testing pkg-config file +Version: 1.2.3 +Cflags: -I${includedir}/foo diff --git a/tests/pkgconf/lib1/cflags-libs-only.pc b/tests/pkgconf/lib1/cflags-libs-only.pc new file mode 100644 index 0000000..718e7cd --- /dev/null +++ b/tests/pkgconf/lib1/cflags-libs-only.pc @@ -0,0 +1,10 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: cflags-libs-only +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo +Cflags: -I${includedir}/foo diff --git a/tests/pkgconf/lib1/cflags-libs-private-a.pc b/tests/pkgconf/lib1/cflags-libs-private-a.pc new file mode 100644 index 0000000..fbb7742 --- /dev/null +++ b/tests/pkgconf/lib1/cflags-libs-private-a.pc @@ -0,0 +1,7 @@ +Name: cflags-libs-private-a +Version: 1 +Description: test case for issue #370 +Cflags: +Libs: +Requires.private: cflags-libs-private-b + diff --git a/tests/pkgconf/lib1/cflags-libs-private-b.pc b/tests/pkgconf/lib1/cflags-libs-private-b.pc new file mode 100644 index 0000000..0d5e5a4 --- /dev/null +++ b/tests/pkgconf/lib1/cflags-libs-private-b.pc @@ -0,0 +1,7 @@ +Name: cflags-libs-private-b +Version: 1 +Description: test case for issue #370 +Cflags: +Libs: +Requires: cflags-libs-private-c + diff --git a/tests/pkgconf/lib1/cflags-libs-private-c.pc b/tests/pkgconf/lib1/cflags-libs-private-c.pc new file mode 100644 index 0000000..7efc38e --- /dev/null +++ b/tests/pkgconf/lib1/cflags-libs-private-c.pc @@ -0,0 +1,6 @@ +Name: cflags-libs-private-c +Version: 1 +Description: test case for issue #370 +Cflags: +Libs: -lc + diff --git a/tests/pkgconf/lib1/cflags-whitespace-trailing.pc b/tests/pkgconf/lib1/cflags-whitespace-trailing.pc new file mode 100644 index 0000000..2e66035 --- /dev/null +++ b/tests/pkgconf/lib1/cflags-whitespace-trailing.pc @@ -0,0 +1,4 @@ +Name: CFlags Trailing Whitespace Bug +Description: Demonstrates problems with -I with spaces +Version: 1 +Cflags: -I/usr/include -I/usr/include/foo diff --git a/tests/pkgconf/lib1/cflags-whitespace.pc b/tests/pkgconf/lib1/cflags-whitespace.pc new file mode 100644 index 0000000..4cd1cd1 --- /dev/null +++ b/tests/pkgconf/lib1/cflags-whitespace.pc @@ -0,0 +1,4 @@ +Name: CFlags Whitespace Bug +Description: Demonstrates problems with -I with spaces and sysroot munging +Version: 1 +Cflags: -I /opt/bad/include diff --git a/tests/pkgconf/lib1/child-prefix/pkgconfig/child-prefix-1.pc b/tests/pkgconf/lib1/child-prefix/pkgconfig/child-prefix-1.pc new file mode 100644 index 0000000..0d32d89 --- /dev/null +++ b/tests/pkgconf/lib1/child-prefix/pkgconfig/child-prefix-1.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=/usr +libdir=${prefix}/lib64 +includedir=${prefix}/include + +Name: child-prefix-1 +Description: child prefix 1 test data +Requires: +Version: 1.0 +Libs: -L${libdir} -lchild-prefix-1 +Cflags: -I${includedir}/child-prefix-1 diff --git a/tests/pkgconf/lib1/circular-1.pc b/tests/pkgconf/lib1/circular-1.pc new file mode 100644 index 0000000..bbdb9f7 --- /dev/null +++ b/tests/pkgconf/lib1/circular-1.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: circular-1 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lcircular-1 +Requires: circular-2 +Cflags: diff --git a/tests/pkgconf/lib1/circular-2.pc b/tests/pkgconf/lib1/circular-2.pc new file mode 100644 index 0000000..2086834 --- /dev/null +++ b/tests/pkgconf/lib1/circular-2.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: circular-2 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lcircular-2 +Requires: circular-3 +Cflags: diff --git a/tests/pkgconf/lib1/circular-3.pc b/tests/pkgconf/lib1/circular-3.pc new file mode 100644 index 0000000..e8b8e77 --- /dev/null +++ b/tests/pkgconf/lib1/circular-3.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: circular-3 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lcircular-3 +Requires: circular-1 +Cflags: diff --git a/tests/pkgconf/lib1/comments-in-fields.pc b/tests/pkgconf/lib1/comments-in-fields.pc new file mode 100644 index 0000000..8e65a65 --- /dev/null +++ b/tests/pkgconf/lib1/comments-in-fields.pc @@ -0,0 +1,9 @@ +Name: comments-in-fields +Description: Comments in fields test case +URL: http://pkgconf.org/ +Version: 0 +Requires: # foo +Requires.private: foo +Libs: -lfoo # -lbar +Libs.private: -lbar +Cflags: -I${includedir} diff --git a/tests/pkgconf/lib1/comments.pc b/tests/pkgconf/lib1/comments.pc new file mode 100644 index 0000000..be83b3e --- /dev/null +++ b/tests/pkgconf/lib1/comments.pc @@ -0,0 +1,6 @@ +Name: comments +Description: Portable CD-ROM I/O library +Version: 0 +#Requires: bar-2.0 +Libs: -lfoo +Cflags: -I${includedir} diff --git a/tests/pkgconf/lib1/conflicts.pc b/tests/pkgconf/lib1/conflicts.pc new file mode 100644 index 0000000..bec4869 --- /dev/null +++ b/tests/pkgconf/lib1/conflicts.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: conflicts +Description: A testing pkg-config file +Conflicts: foo <= 1.3 +Version: 1.2.3 +Libs: -L${libdir} -lconflicts +Cflags: -fPIC -I${includedir}/conflicts diff --git a/tests/pkgconf/lib1/depgraph-break.pc b/tests/pkgconf/lib1/depgraph-break.pc new file mode 100644 index 0000000..61e00cc --- /dev/null +++ b/tests/pkgconf/lib1/depgraph-break.pc @@ -0,0 +1,12 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: depgraph-break +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo +Cflags: -fPIC -I${includedir}/foo +Cflags.private: -DFOO_STATIC +Requires: nonexistant diff --git a/tests/pkgconf/lib1/dos-lineendings.pc b/tests/pkgconf/lib1/dos-lineendings.pc new file mode 100644 index 0000000..cf169f1 --- /dev/null +++ b/tests/pkgconf/lib1/dos-lineendings.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: dos-lineendings +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir}/dos-lineendings -ldos-lineendings +Cflags: -fPIC -I${includedir}/dos-lineendings diff --git a/tests/pkgconf/lib1/empty-tuple.pc b/tests/pkgconf/lib1/empty-tuple.pc new file mode 100644 index 0000000..a179495 --- /dev/null +++ b/tests/pkgconf/lib1/empty-tuple.pc @@ -0,0 +1,6 @@ +xcflags= + +Name: empty-tuple +Description: testing file +Version: 1 +CFlags: ${xcflags} diff --git a/tests/pkgconf/lib1/escaped-backslash.pc b/tests/pkgconf/lib1/escaped-backslash.pc new file mode 100644 index 0000000..6abcbb0 --- /dev/null +++ b/tests/pkgconf/lib1/escaped-backslash.pc @@ -0,0 +1,4 @@ +Name: escaped-backslash +Version: 1 +Description: test package for backslash escape scenario +Cflags: -IC:\\A diff --git a/tests/pkgconf/lib1/explicit-sysroot.pc b/tests/pkgconf/lib1/explicit-sysroot.pc new file mode 100644 index 0000000..63c7ca0 --- /dev/null +++ b/tests/pkgconf/lib1/explicit-sysroot.pc @@ -0,0 +1,7 @@ +prefix=/usr +datarootdir=${prefix}/share +pkgdatadir=${pc_sysrootdir}/${datarootdir}/test + +Name: Test +Description: Testing pc_sysrootdir auto-expansion +Version: 1.0 diff --git a/tests/pkgconf/lib1/flag-order-1.pc b/tests/pkgconf/lib1/flag-order-1.pc new file mode 100644 index 0000000..d841751 --- /dev/null +++ b/tests/pkgconf/lib1/flag-order-1.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +cflags=-I${includedir} + +Name: flag order 1 +Description: test for flag ordering +Version: 1 +Libs: -L${libdir} -Bdynamic -lfoo -Bstatic -lbar diff --git a/tests/pkgconf/lib1/flag-order-3.pc b/tests/pkgconf/lib1/flag-order-3.pc new file mode 100644 index 0000000..d813f50 --- /dev/null +++ b/tests/pkgconf/lib1/flag-order-3.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include +cflags=-I${includedir} + +Name: flag order 3 +Description: test for flag ordering +Version: 1 +Libs: -L${libdir} -Wl,--start-group -lfoo -lbar -Wl,--end-group diff --git a/tests/pkgconf/lib1/foo.pc b/tests/pkgconf/lib1/foo.pc new file mode 100644 index 0000000..daef9f9 --- /dev/null +++ b/tests/pkgconf/lib1/foo.pc @@ -0,0 +1,12 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foo +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo +Cflags: -fPIC -I${includedir}/foo +Cflags.private: -DFOO_STATIC +License: ISC diff --git a/tests/pkgconf/lib1/foobar.pc b/tests/pkgconf/lib1/foobar.pc new file mode 100644 index 0000000..e9aa843 --- /dev/null +++ b/tests/pkgconf/lib1/foobar.pc @@ -0,0 +1,12 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foobar +Description: A testing pkg-config file +Version: 3.2.1 +Libs: -L${libdir} -lfoobar +Cflags: -fPIC -I${includedir}/foobar +Cflags.private: -DFOOBAR_STATIC +License: ISC diff --git a/tests/pkgconf/lib1/fragment-collision-1.pc b/tests/pkgconf/lib1/fragment-collision-1.pc new file mode 100644 index 0000000..201bcb0 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-collision-1.pc @@ -0,0 +1,4 @@ +Name: fragment-collision-1 +Version: 0 +Description: fragment collision test package +Cflags: -D_THREAD_SAFE -pthread diff --git a/tests/pkgconf/lib1/fragment-collision-2.pc b/tests/pkgconf/lib1/fragment-collision-2.pc new file mode 100644 index 0000000..2e6feb4 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-collision-2.pc @@ -0,0 +1,4 @@ +Name: fragment-collision-2 +Version: 0 +Description: fragment collision test package +CFlags: -D_FOO diff --git a/tests/pkgconf/lib1/fragment-collision-intermediary.pc b/tests/pkgconf/lib1/fragment-collision-intermediary.pc new file mode 100644 index 0000000..1ddb6f5 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-collision-intermediary.pc @@ -0,0 +1,5 @@ +Name: fragment-collision-intermediary +Version: 0 +Description: fragment collision test package +Requires.private: fragment-collision-1, fragment-collision-2 +CFlags: -D_BAR diff --git a/tests/pkgconf/lib1/fragment-collision.pc b/tests/pkgconf/lib1/fragment-collision.pc new file mode 100644 index 0000000..c582675 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-collision.pc @@ -0,0 +1,6 @@ +Name: fragment-collision +Version: 0 +Description: fragment collision test package +Requires: fragment-collision-2, fragment-collision-intermediary +Requires.private: fragment-collision-1 +Cflags: -D_BAZ diff --git a/tests/pkgconf/lib1/fragment-comment.pc b/tests/pkgconf/lib1/fragment-comment.pc new file mode 100644 index 0000000..dfdd4f3 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-comment.pc @@ -0,0 +1,4 @@ +Name: fragment-comment +Description: Test case for issue #215 +Version: 1.0 +Cflags: kuku=\#ttt \ No newline at end of file diff --git a/tests/pkgconf/lib1/fragment-escaping-1.pc b/tests/pkgconf/lib1/fragment-escaping-1.pc new file mode 100644 index 0000000..b147951 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-escaping-1.pc @@ -0,0 +1,5 @@ +Name: fragment-escaping-1 +Version: 0 +Description: fragment escaping test +Cflags: "-IC:\\D E" +Libs: "-LC:\\D E" -lE diff --git a/tests/pkgconf/lib1/fragment-escaping-2.pc b/tests/pkgconf/lib1/fragment-escaping-2.pc new file mode 100644 index 0000000..12e03b3 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-escaping-2.pc @@ -0,0 +1,4 @@ +Name: fragment-escaping-2 +Version: 0 +Description: fragment escaping test +Cflags: '-IC:\D E' diff --git a/tests/pkgconf/lib1/fragment-escaping-3.pc b/tests/pkgconf/lib1/fragment-escaping-3.pc new file mode 100644 index 0000000..0f002dd --- /dev/null +++ b/tests/pkgconf/lib1/fragment-escaping-3.pc @@ -0,0 +1,4 @@ +Name: fragment-escaping-3 +Version: 0 +Description: fragment escaping test +Cflags: -IC:\\D\ E diff --git a/tests/pkgconf/lib1/fragment-quoting-2.pc b/tests/pkgconf/lib1/fragment-quoting-2.pc new file mode 100644 index 0000000..49c6ac7 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-quoting-2.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: fragment-quoting +Description: A testing pkg-config file +Version: 1.2.3 +Cflags: -fPIC -I${includedir}/foo -DQUOTED="${prefix}/share/doc" +Cflags.private: -DFOO_STATIC diff --git a/tests/pkgconf/lib1/fragment-quoting-3.pc b/tests/pkgconf/lib1/fragment-quoting-3.pc new file mode 100644 index 0000000..4ff59fc --- /dev/null +++ b/tests/pkgconf/lib1/fragment-quoting-3.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: fragment-quoting +Description: A testing pkg-config file +Version: 1.2.3 +Cflags: -fPIC -I${includedir}/foo -DQUOTED=\"${prefix}/share/doc\" +Cflags.private: -DFOO_STATIC diff --git a/tests/pkgconf/lib1/fragment-quoting-5.pc b/tests/pkgconf/lib1/fragment-quoting-5.pc new file mode 100644 index 0000000..22df0b3 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-quoting-5.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: fragment-quoting-5 +Description: A testing pkg-config file +Version: 1.2.3 +Cflags: -fPIC -I${includedir}/foo -DQUOTED='${prefix}/share/doc' +Cflags.private: -DFOO_STATIC diff --git a/tests/pkgconf/lib1/fragment-quoting-7.pc b/tests/pkgconf/lib1/fragment-quoting-7.pc new file mode 100644 index 0000000..902e2f6 --- /dev/null +++ b/tests/pkgconf/lib1/fragment-quoting-7.pc @@ -0,0 +1,4 @@ +Name: fragment-quoting-7 +Description: A testing pkg-config file, this time from Go +Version: 1.2.3 +Cflags: -Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\ world diff --git a/tests/pkgconf/lib1/fragment-quoting.pc b/tests/pkgconf/lib1/fragment-quoting.pc new file mode 100644 index 0000000..5d8e70b --- /dev/null +++ b/tests/pkgconf/lib1/fragment-quoting.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: fragment-quoting +Description: A testing pkg-config file +Version: 1.2.3 +Cflags: -fPIC -I${includedir}/foo -DQUOTED='"${prefix}/share/doc"' +Cflags.private: -DFOO_STATIC diff --git a/tests/pkgconf/lib1/framework-1.pc b/tests/pkgconf/lib1/framework-1.pc new file mode 100644 index 0000000..fcaa008 --- /dev/null +++ b/tests/pkgconf/lib1/framework-1.pc @@ -0,0 +1,9 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: framework-1 +Description: Another pkg-config test +Version: 1.3 +Libs: -F${libdir} -framework framework-1 diff --git a/tests/pkgconf/lib1/framework-2.pc b/tests/pkgconf/lib1/framework-2.pc new file mode 100644 index 0000000..793655a --- /dev/null +++ b/tests/pkgconf/lib1/framework-2.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: framework-2 +Description: Another pkg-config test +Version: 1.3 +Libs: -F${libdir} -framework framework-2 +Requires: framework-1 diff --git a/tests/pkgconf/lib1/idirafter-ordering.pc b/tests/pkgconf/lib1/idirafter-ordering.pc new file mode 100644 index 0000000..c42f702 --- /dev/null +++ b/tests/pkgconf/lib1/idirafter-ordering.pc @@ -0,0 +1,4 @@ +Name: Bad +Description: Demonstrates problems with -idirafter in old pkg-config; see also https://bugs.freedesktop.org/show_bug.cgi?id=23480 +Version: 1 +Cflags: -I/opt/bad/include1 -idirafter -I/opt/bad/include2 -I/opt/bad/include3 diff --git a/tests/pkgconf/lib1/idirafter.pc b/tests/pkgconf/lib1/idirafter.pc new file mode 100644 index 0000000..6c37c8b --- /dev/null +++ b/tests/pkgconf/lib1/idirafter.pc @@ -0,0 +1,4 @@ +Name: Bad +Description: Demonstrates problems with -idirafter in both old pkg-config and current pkgconf; see also https://bugs.freedesktop.org/show_bug.cgi?id=97337 +Version: 1 +Cflags: -idirafter /opt/bad/include -idirafter /opt/bad2/include diff --git a/tests/pkgconf/lib1/incomplete.pc b/tests/pkgconf/lib1/incomplete.pc new file mode 100644 index 0000000..40f0d91 --- /dev/null +++ b/tests/pkgconf/lib1/incomplete.pc @@ -0,0 +1,4 @@ +Name: incomplete +Description: incomplete package without CFLAGS/LIBS entries (freedesktop #54271) +Version: 1.2.3 + diff --git a/tests/pkgconf/lib1/intermediary-1.pc b/tests/pkgconf/lib1/intermediary-1.pc new file mode 100644 index 0000000..38ee483 --- /dev/null +++ b/tests/pkgconf/lib1/intermediary-1.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: intermediary-1 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lintermediary-1 -lfoo -lbar -lbaz +Cflags: diff --git a/tests/pkgconf/lib1/intermediary-2.pc b/tests/pkgconf/lib1/intermediary-2.pc new file mode 100644 index 0000000..188ce6b --- /dev/null +++ b/tests/pkgconf/lib1/intermediary-2.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: intermediary-2 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lintermediary-2 -lfoo -lbar -lbaz +Cflags: diff --git a/tests/pkgconf/lib1/isystem.pc b/tests/pkgconf/lib1/isystem.pc new file mode 100644 index 0000000..98416b5 --- /dev/null +++ b/tests/pkgconf/lib1/isystem.pc @@ -0,0 +1,4 @@ +Name: Bad +Description: Demonstrates problems with -isystem in both old pkg-config and current pkgconf; see also https://bugs.freedesktop.org/show_bug.cgi?id=72584 +Version: 1 +Cflags: -isystem /opt/bad/include -isystem /opt/bad2/include diff --git a/tests/pkgconf/lib1/malformed-1.pc b/tests/pkgconf/lib1/malformed-1.pc new file mode 100644 index 0000000..4f4a700 --- /dev/null +++ b/tests/pkgconf/lib1/malformed-1.pc @@ -0,0 +1,2 @@ +prefix=/usr\nName: GKrellM\nDescription: Extensible GTK system monitoring application\nVersion: 2.3.7\nRequires: gtk+-2.0 >= 2.4.0\nCflags: -I/usr/include\n + diff --git a/tests/pkgconf/lib1/malformed-quoting.pc b/tests/pkgconf/lib1/malformed-quoting.pc new file mode 100644 index 0000000..b8a324e --- /dev/null +++ b/tests/pkgconf/lib1/malformed-quoting.pc @@ -0,0 +1,4 @@ +Name: malformed-quoting +Version: 1 +Description: None. +Cflags: '-I/ABC diff --git a/tests/pkgconf/lib1/malformed-version.pc b/tests/pkgconf/lib1/malformed-version.pc new file mode 100644 index 0000000..41222cc --- /dev/null +++ b/tests/pkgconf/lib1/malformed-version.pc @@ -0,0 +1,5 @@ +Name: malformed-version +Version: 3.922 2018-03-17 +Description: None. +Cflags: -Ifoo +Libs: -lbar diff --git a/tests/pkgconf/lib1/metapackage-1.pc b/tests/pkgconf/lib1/metapackage-1.pc new file mode 100644 index 0000000..bb59db1 --- /dev/null +++ b/tests/pkgconf/lib1/metapackage-1.pc @@ -0,0 +1,6 @@ +Name: metapackage-1 +Version: 0.1 +Description: metapackage for testing purposes +Requires.private: metapackage-2 +Libs: -lmetapackage-1 +Cflags: -I/metapackage-1 diff --git a/tests/pkgconf/lib1/metapackage-2.pc b/tests/pkgconf/lib1/metapackage-2.pc new file mode 100644 index 0000000..d8bf7d6 --- /dev/null +++ b/tests/pkgconf/lib1/metapackage-2.pc @@ -0,0 +1,5 @@ +Name: metapackage-2 +Version: 0.1 +Description: metapackage for testing purposes +Libs: -lmetapackage-2 +Cflags: -I/metapackage-2 diff --git a/tests/pkgconf/lib1/metapackage-3.pc b/tests/pkgconf/lib1/metapackage-3.pc new file mode 100644 index 0000000..111954a --- /dev/null +++ b/tests/pkgconf/lib1/metapackage-3.pc @@ -0,0 +1,4 @@ +Name: metapackage-3 +Version: 0.1 +Description: metapackage for testing purposes +Requires.private: bar diff --git a/tests/pkgconf/lib1/metapackage.pc b/tests/pkgconf/lib1/metapackage.pc new file mode 100644 index 0000000..3ce0db3 --- /dev/null +++ b/tests/pkgconf/lib1/metapackage.pc @@ -0,0 +1,4 @@ +Name: metapackage +Version: 0.1 +Description: metapackage for testing purposes +Requires: metapackage-1, metapackage-2 diff --git a/tests/pkgconf/lib1/missing-require.pc b/tests/pkgconf/lib1/missing-require.pc new file mode 100644 index 0000000..ede148d --- /dev/null +++ b/tests/pkgconf/lib1/missing-require.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: missing-require +Description: A testing pkg-config file +Version: 1.2.3 +Requires.private: missing +Libs: -L${libdir} -lfoo +Cflags: -fPIC -I${includedir}/foo diff --git a/tests/pkgconf/lib1/multiline-bogus.pc b/tests/pkgconf/lib1/multiline-bogus.pc new file mode 100644 index 0000000..c7f0065 --- /dev/null +++ b/tests/pkgconf/lib1/multiline-bogus.pc @@ -0,0 +1,9 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: multiline +Description: A multiline +description blah blah blah +Version: 1.2.3 diff --git a/tests/pkgconf/lib1/multiline.pc b/tests/pkgconf/lib1/multiline.pc new file mode 100644 index 0000000..75b5902 --- /dev/null +++ b/tests/pkgconf/lib1/multiline.pc @@ -0,0 +1,9 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: multiline +Description: A multiline \ + description +Version: 1.2.3 diff --git a/tests/pkgconf/lib1/no-trailing-newline.pc b/tests/pkgconf/lib1/no-trailing-newline.pc new file mode 100644 index 0000000..eaf2f8f --- /dev/null +++ b/tests/pkgconf/lib1/no-trailing-newline.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: no-trailing-newline +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir}/no-trailing-newline -lno-trailing-newline +Cflags: -I${includedir}/no-trailing-newline diff --git a/tests/pkgconf/lib1/nocflag.pc b/tests/pkgconf/lib1/nocflag.pc new file mode 100644 index 0000000..0a3d752 --- /dev/null +++ b/tests/pkgconf/lib1/nocflag.pc @@ -0,0 +1,9 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foo +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo diff --git a/tests/pkgconf/lib1/nolib.pc b/tests/pkgconf/lib1/nolib.pc new file mode 100644 index 0000000..b47e30c --- /dev/null +++ b/tests/pkgconf/lib1/nolib.pc @@ -0,0 +1,9 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foo +Description: A testing pkg-config file +Version: 1.2.3 +Cflags: -fPIC -I${includedir}/foo diff --git a/tests/pkgconf/lib1/omg-sysroot-uninstalled.pc b/tests/pkgconf/lib1/omg-sysroot-uninstalled.pc new file mode 100644 index 0000000..7e391b9 --- /dev/null +++ b/tests/pkgconf/lib1/omg-sysroot-uninstalled.pc @@ -0,0 +1,10 @@ +prefix=${pc_sysrootdir}/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: omg-sysroot +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lomg +Cflags: -fPIC -I${includedir}/omg diff --git a/tests/pkgconf/lib1/omg-uninstalled.pc b/tests/pkgconf/lib1/omg-uninstalled.pc new file mode 100644 index 0000000..17d8078 --- /dev/null +++ b/tests/pkgconf/lib1/omg-uninstalled.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: omg +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lomg +Cflags: -fPIC -I${includedir}/omg diff --git a/tests/pkgconf/lib1/orphaned-requires-private.pc b/tests/pkgconf/lib1/orphaned-requires-private.pc new file mode 100644 index 0000000..c62bab4 --- /dev/null +++ b/tests/pkgconf/lib1/orphaned-requires-private.pc @@ -0,0 +1,8 @@ +Name: orphaned-requires-private +Version: 1 +Description: A testing module for pkgconf +URL: http://www.pkgconf.org/ +Requires: foo +Requires.private: orphaned-foo +Cflags: -DUNREACHABLE +Libs: diff --git a/tests/pkgconf/lib1/paren-quoting.pc b/tests/pkgconf/lib1/paren-quoting.pc new file mode 100644 index 0000000..08ed49d --- /dev/null +++ b/tests/pkgconf/lib1/paren-quoting.pc @@ -0,0 +1,5 @@ +Name: paren-quoting +Description: Another pkg-config test +Version: 1.3 +Libs: -L$(libdir) -ltilde +Cflags: -I$(includedir) diff --git a/tests/pkgconf/lib1/pcfiledir.pc b/tests/pkgconf/lib1/pcfiledir.pc new file mode 100644 index 0000000..fa6ada9 --- /dev/null +++ b/tests/pkgconf/lib1/pcfiledir.pc @@ -0,0 +1,8 @@ +prefix=${pcfiledir} +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foo +Description: A testing pkg-config file with a ${pcfiledir} +Version: 1.2.3 diff --git a/tests/pkgconf/lib1/prefix-foo1.pc b/tests/pkgconf/lib1/prefix-foo1.pc new file mode 100644 index 0000000..7a6e900 --- /dev/null +++ b/tests/pkgconf/lib1/prefix-foo1.pc @@ -0,0 +1,12 @@ +prefix=/test/bar +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: prefix-foo1 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo1 +Cflags: -fPIC -I${includedir}/foo -DBAR +Cflags.private: -DFOO_STATIC + diff --git a/tests/pkgconf/lib1/prefix-foo2.pc b/tests/pkgconf/lib1/prefix-foo2.pc new file mode 100644 index 0000000..0546975 --- /dev/null +++ b/tests/pkgconf/lib1/prefix-foo2.pc @@ -0,0 +1,12 @@ +prefix=/test/bar +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: prefix-foo2 +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo2 +Cflags: -fPIC -I${includedir}/foo -DFOO +Cflags.private: -DFOO_STATIC + diff --git a/tests/pkgconf/lib1/private-libs-duplication.pc b/tests/pkgconf/lib1/private-libs-duplication.pc new file mode 100644 index 0000000..7f0f573 --- /dev/null +++ b/tests/pkgconf/lib1/private-libs-duplication.pc @@ -0,0 +1,7 @@ +Name: private-libs-duplication +Description: test +Version: 1.0 +Requires: baz bar +Libs: -lprivate +Libs.private: -lfoo + diff --git a/tests/pkgconf/lib1/provides-request-simple.pc b/tests/pkgconf/lib1/provides-request-simple.pc new file mode 100644 index 0000000..7e12c2d --- /dev/null +++ b/tests/pkgconf/lib1/provides-request-simple.pc @@ -0,0 +1,6 @@ +Name: provides-request-simple +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lfoo +Cflags: -I/usr/include/foo +Requires: provides-test-foo diff --git a/tests/pkgconf/lib1/provides.pc b/tests/pkgconf/lib1/provides.pc new file mode 100644 index 0000000..0480c73 --- /dev/null +++ b/tests/pkgconf/lib1/provides.pc @@ -0,0 +1,6 @@ +Name: provides +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lfoo +Cflags: -I/usr/include/foo +Provides: provides-test-foo = 1.0.0, provides-test-bar > 1.1.0, provides-test-baz >= 1.1.0, provides-test-quux < 1.2.0, provides-test-moo <= 1.2.0, provides-test-meow != 1.3.0 diff --git a/tests/pkgconf/lib1/quotes.pc b/tests/pkgconf/lib1/quotes.pc new file mode 100644 index 0000000..3213fbe --- /dev/null +++ b/tests/pkgconf/lib1/quotes.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: quotes +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo +Cflags: -DQUOTED=\"bla\" -DA=\"escaped\ string\'\ \literal\" -DB="\1\$" -DC='bla' diff --git a/tests/pkgconf/lib1/requires-internal-2.pc b/tests/pkgconf/lib1/requires-internal-2.pc new file mode 100644 index 0000000..8467720 --- /dev/null +++ b/tests/pkgconf/lib1/requires-internal-2.pc @@ -0,0 +1,9 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: requires-internal +Description: A testing pkg-config file +Version: 1.2.3 +Requires.internal: cflags-internal diff --git a/tests/pkgconf/lib1/requires-internal-collision.pc b/tests/pkgconf/lib1/requires-internal-collision.pc new file mode 100644 index 0000000..2b257cf --- /dev/null +++ b/tests/pkgconf/lib1/requires-internal-collision.pc @@ -0,0 +1,10 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: requires-internal +Description: A testing pkg-config file +Version: 1.2.3 +Requires.internal: cflags-internal +Requires.private: cflags-internal diff --git a/tests/pkgconf/lib1/requires-internal-missing.pc b/tests/pkgconf/lib1/requires-internal-missing.pc new file mode 100644 index 0000000..8c55a1d --- /dev/null +++ b/tests/pkgconf/lib1/requires-internal-missing.pc @@ -0,0 +1,10 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: requires-internal +Description: A testing pkg-config file +Version: 1.2.3 +Requires.internal: static-libs, missing +Requires.private: foo diff --git a/tests/pkgconf/lib1/requires-internal.pc b/tests/pkgconf/lib1/requires-internal.pc new file mode 100644 index 0000000..b7d5a05 --- /dev/null +++ b/tests/pkgconf/lib1/requires-internal.pc @@ -0,0 +1,10 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: requires-internal +Description: A testing pkg-config file +Version: 1.2.3 +Requires.internal: static-libs +Requires.private: foo diff --git a/tests/pkgconf/lib1/spaces-in-paths.pc b/tests/pkgconf/lib1/spaces-in-paths.pc new file mode 100644 index 0000000..490624e --- /dev/null +++ b/tests/pkgconf/lib1/spaces-in-paths.pc @@ -0,0 +1,7 @@ +prefix=/test\ with\ spaces +includedir=${prefix}/include + +Name: spaces-in-paths +Version: 1 +Description: test package for properly expanding spaces in variables +Cflags: -I${includedir} -I${includedir}/subdir diff --git a/tests/pkgconf/lib1/static-archive-libs.pc b/tests/pkgconf/lib1/static-archive-libs.pc new file mode 100644 index 0000000..95f7bfb --- /dev/null +++ b/tests/pkgconf/lib1/static-archive-libs.pc @@ -0,0 +1,10 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: static-archive-libs +Description: A testing pkg-config file +Version: 1.2.3 +Libs: /libfoo.a -pthread +Cflags: -I${includedir}/foo diff --git a/tests/pkgconf/lib1/static-libs.pc b/tests/pkgconf/lib1/static-libs.pc new file mode 100644 index 0000000..075b331 --- /dev/null +++ b/tests/pkgconf/lib1/static-libs.pc @@ -0,0 +1,12 @@ +prefix=/test/local +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: static-libs +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -lbar +Libs.private: -lbar-private +Cflags: -I${includedir}/foo +Requires.private: foo diff --git a/tests/pkgconf/lib1/sysroot-dir-2.pc b/tests/pkgconf/lib1/sysroot-dir-2.pc new file mode 100644 index 0000000..31f3ffd --- /dev/null +++ b/tests/pkgconf/lib1/sysroot-dir-2.pc @@ -0,0 +1,7 @@ +prefix=${pc_sysrootdir}/usr + +Name: sysroot-dir +Description: Package for testing whether sysroot dirs are repeated or not +Version: 1 +CFlags: -I${prefix}/include +Libs: -L${prefix}/lib -lfoo diff --git a/tests/pkgconf/lib1/sysroot-dir-3.pc b/tests/pkgconf/lib1/sysroot-dir-3.pc new file mode 100644 index 0000000..8c53a45 --- /dev/null +++ b/tests/pkgconf/lib1/sysroot-dir-3.pc @@ -0,0 +1,9 @@ +prefix=/sysroot/usr +includedir=${prefix}/include +libdir=${prefix}/lib + +Name: sysroot-dir +Description: Package for testing whether sysroot dirs are repeated or not +Version: 1 +CFlags: -I${includedir} +Libs: -L${libdir} -lfoo diff --git a/tests/pkgconf/lib1/sysroot-dir-4.pc b/tests/pkgconf/lib1/sysroot-dir-4.pc new file mode 100644 index 0000000..524dc7c --- /dev/null +++ b/tests/pkgconf/lib1/sysroot-dir-4.pc @@ -0,0 +1,9 @@ +prefix=${pc_sysrootdir}/usr +includedir=${prefix}/include +libdir=${prefix}/lib + +Name: sysroot-dir +Description: Package for testing whether sysroot dirs are repeated or not +Version: 1 +CFlags: -I${includedir} +Libs: -L${libdir} -lfoo diff --git a/tests/pkgconf/lib1/sysroot-dir-5.pc b/tests/pkgconf/lib1/sysroot-dir-5.pc new file mode 100644 index 0000000..8c53a45 --- /dev/null +++ b/tests/pkgconf/lib1/sysroot-dir-5.pc @@ -0,0 +1,9 @@ +prefix=/sysroot/usr +includedir=${prefix}/include +libdir=${prefix}/lib + +Name: sysroot-dir +Description: Package for testing whether sysroot dirs are repeated or not +Version: 1 +CFlags: -I${includedir} +Libs: -L${libdir} -lfoo diff --git a/tests/pkgconf/lib1/sysroot-dir.pc b/tests/pkgconf/lib1/sysroot-dir.pc new file mode 100644 index 0000000..8334c50 --- /dev/null +++ b/tests/pkgconf/lib1/sysroot-dir.pc @@ -0,0 +1,5 @@ +Name: sysroot-dir +Description: Package for testing whether sysroot dirs are repeated or not +Version: 1 +CFlags: -I/sysroot/include +Libs: -L/sysroot/lib -lfoo diff --git a/tests/pkgconf/lib1/tilde-quoting.pc b/tests/pkgconf/lib1/tilde-quoting.pc new file mode 100644 index 0000000..4d37978 --- /dev/null +++ b/tests/pkgconf/lib1/tilde-quoting.pc @@ -0,0 +1,5 @@ +Name: tilde +Description: Another pkg-config test +Version: 1.3 +Libs: -L~ -ltilde +Cflags: -I~ diff --git a/tests/pkgconf/lib1/tilde.pc b/tests/pkgconf/lib1/tilde.pc new file mode 100644 index 0000000..a4002ec --- /dev/null +++ b/tests/pkgconf/lib1/tilde.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: Tilde version test +Description: Test package for checking rpmvercmp ~ handling +Version: 1.0.0~rc1 +Requires: +Libs: -L${libdir} -ltilde +Cflags: -I${includedir} diff --git a/tests/pkgconf/lib1/tuple-quoting.pc b/tests/pkgconf/lib1/tuple-quoting.pc new file mode 100644 index 0000000..666ba4a --- /dev/null +++ b/tests/pkgconf/lib1/tuple-quoting.pc @@ -0,0 +1,7 @@ +prefix="/test" +libdir=${prefix}/lib + +Name: tuple-quoting +Description: Another pkg-config test +Version: 1.3 +Libs: -L${libdir} -lfoo diff --git a/tests/pkgconf/lib1/typelibdir.pc b/tests/pkgconf/lib1/typelibdir.pc new file mode 100644 index 0000000..16e46c4 --- /dev/null +++ b/tests/pkgconf/lib1/typelibdir.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include +typelibdir=${libdir}/typelibdir + +Name: test +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -llib-1 +Cflags: diff --git a/tests/pkgconf/lib1/unavailable-provider.pc b/tests/pkgconf/lib1/unavailable-provider.pc new file mode 100644 index 0000000..a8eed66 --- /dev/null +++ b/tests/pkgconf/lib1/unavailable-provider.pc @@ -0,0 +1,11 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: unavailable_provider +Description: Provides an otherwise unavailable package +Version: 1.2.3 +Provides: unavailable = 1.2.3 +Libs: -lunavailable +Cflags: diff --git a/tests/pkgconf/lib1/utf8.pc b/tests/pkgconf/lib1/utf8.pc new file mode 100644 index 0000000..6507ec0 --- /dev/null +++ b/tests/pkgconf/lib1/utf8.pc @@ -0,0 +1,10 @@ +prefix=/tëst +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: utf8 +Description: Library installed in a prefix with UTF-8 +Version: 0 +Libs: -L${libdir} -lutf8 +Cflags: -I${includedir} diff --git a/tests/pkgconf/lib1/variable-whitespace.pc b/tests/pkgconf/lib1/variable-whitespace.pc new file mode 100644 index 0000000..8d8eab2 --- /dev/null +++ b/tests/pkgconf/lib1/variable-whitespace.pc @@ -0,0 +1,11 @@ + +prefix=/test +exec_prefix= ${prefix} +libdir= ${prefix}/lib64 +includedir=${prefix}/include + +Name: variable-whitespace +Description: A test for variable whitespace +Version: 2.12.3 +Libs: -lvariable-whitespace -L${libdir} +Cflags: -I${includedir} diff --git a/tests/pkgconf/lib2/foo.pc b/tests/pkgconf/lib2/foo.pc new file mode 100644 index 0000000..44588f2 --- /dev/null +++ b/tests/pkgconf/lib2/foo.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: foo +Description: A testing pkg-config file +Version: 1.2.3 +Libs: -L${libdir} -lfoo +Cflags: -fPIC -I${includedir}/foo diff --git a/tests/pkgconf/lib3/bar.pc b/tests/pkgconf/lib3/bar.pc new file mode 100644 index 0000000..9157d06 --- /dev/null +++ b/tests/pkgconf/lib3/bar.pc @@ -0,0 +1,10 @@ +prefix=/test +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: bar +Description: Another pkg-config test +Version: 1.3 +Libs: -L${libdir} -lbar +Requires: foo diff --git a/tests/pkgconf/meson.build b/tests/pkgconf/meson.build new file mode 100644 index 0000000..20ba470 --- /dev/null +++ b/tests/pkgconf/meson.build @@ -0,0 +1,30 @@ +tests = files( + 'basic.toml', + 'conflicts.toml', + 'framework.toml', + 'parser.toml', + 'provides.toml', + #'regress.toml', + #'requires.toml', + #'symlink.toml', + 'sysroot.toml', + 'version.toml', +) + +tests += [configure_file( + configuration : {'PKGCONF_VERSION' : meson.project_version()}, + input : 'builtins.toml.in', + output : '@BASENAME@', +)] + +test( + 'pkgconf tests', + python_interpreter, + args: [ + files('runner.py'), + '@0@ pkg-config'.format(cps_config.full_path()), + tests, + '--tap' + ], + protocol: 'tap', +) diff --git a/tests/pkgconf/parser.toml b/tests/pkgconf/parser.toml new file mode 100644 index 0000000..52860a2 --- /dev/null +++ b/tests/pkgconf/parser.toml @@ -0,0 +1,168 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[comments] + args = ["--libs", "comments"] + stdout = "-lfoo\n" + expected_fail = true + +[comments_in_fields] + args = ["--libs", "comments-in-fields"] + stdout = "-lfoo\n" + expected_fail = true + +[dos] + args = ["--libs", "dos-lineendings"] + stdout = "-L/test/lib/dos-lineendings -ldos-lineendings\n" + expected_fail = true + +[no_trailing_newline] + args = ["--cflags", "no-trailing-newline"] + stdout = "-I/test/include/no-trailing-newline\n" + +[argv_parse_body] + args = ["--libs", "argv-parse"] + stdout = "-llib-3 -llib-1 -llib-2 -lpthread\n" + expected_fail = true + +[bad_option] + args = ["--exists", "-foo"] + exitcode = 1 + stderr = '' + expected_fail = true + +[argv_parse_3] + args = ["--libs", "argv-parse-3"] + stdout = "-llib-1 -pthread /test/lib/lib2.so\n" + expected_fail = true + +[tilde_quoting_body] + args = ["--cflags", "--libs", "tilde-quoting"] + stdout = "-I~ -L~ -ltilde\n" + expected_fail = true + +[paren_quoting] + args = ["--libs", "paren-quoting"] + stdout = "-L$(libdir) -ltilde\n" + expected_fail = true + +[multiline_field_body] + args = ["--list-all"] + stdout_contains = "multiline description" + stderr = '' + expected_fail = true + +[multiline_bogus_header] + args = ["--exists", "multiline-bogus"] + expected_fail = true + +[escaped_backslash] + args = ["--cflags", "escaped-backslash"] + stderr = '' + stdout = "-IC:\\\\A\n" + expected_fail = true + +[quoted_body] + args = ["--cflags", "quotes"] + stdout = "-DQUOTED=\\\"bla\\\" -DA=\\\"escaped\\ string\\'\\ literal\\\" -DB=\\\\1$ -DC=bla\n" + expected_fail = true + +[flag_order_1] + args = ["--libs", "flag-order-1"] + stdout = "-L/test/lib -Bdynamic -lfoo -Bstatic -lbar\n" + expected_fail = true + +[flag_order_2] + args = ["--libs", "flag-order-1", "foo"] + stdout = "-L/test/lib -Bdynamic -lfoo -Bstatic -lbar -lfoo\n" + expected_fail = true + +[flag_order_3] + args = ["--libs", "flag-order-3"] + stdout = "-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group\n" + expected_fail = true + +[flag_order_4] + args = ["--libs", "flag-order-3", "foo"] + stdout = "-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group -lfoo\n" + expected_fail = true + +[variable_whitespace] + args = ["--cflags", "variable-whitespace"] + stdout = "-I/test/include\n" + expected_fail = true + +[fragment_quoting] + args = ["--cflags", "fragment-quoting"] + stdout = "-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\"\n" + expected_fail = true + +[fragment_quoting_2] + args = ["--cflags", "fragment-quoting-2"] + stdout = "-fPIC -I/test/include/foo -DQUOTED=/test/share/doc\n" + expected_fail = true + +[fragment_quoting_3] + args = ["--cflags", "fragment-quoting-3"] + stdout = "-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\"\n" + expected_fail = true + +[fragment_quoting_5] + args = ["--cflags", "fragment-quoting-5"] + stdout = "-fPIC -I/test/include/foo -DQUOTED=/test/share/doc\n" + expected_fail = true + +[fragment_quoting_7] + args = ["--cflags", "fragment-quoting-7"] + stdout = "-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\\ world\n" + expected_fail = true + +[fragment_escaping_1] + args = ["--cflags", "fragment-escaping-1"] + stdout = "-IC:\\\\D\\ E\n" + expected_fail = true + +[fragment_escaping_2] + args = ["--cflags", "fragment-escaping-2"] + stdout = "-IC:\\\\D\\ E\n" + expected_fail = true + +[fragment_escaping_3] + args = ["--cflags", "fragment-escaping-3"] + stdout = "-IC:\\\\D\\ E\n" + expected_fail = true + +# TODO: quoting 7a + +[comment_body] + args = ["--cflags", "fragment-comment"] + stdout = "kuku=\\#ttt\n" + expected_fail = true + +# TODO: fragment_comment + +[msvc_fragment_quoting] + args = ["--libs", "--msvc-syntax", "fragment-escaping-1"] + stdout = "/libpath:\"C:\\D E\" E.lib \n" + expected_fail = true + +[msvc_fragment_render_cflags] + args = ["--cflags", "--static", "--msvc-syntax", "foo"] + stdout = "/I/test/include/foo /DFOO_STATIC \n" + expected_fail = true + +[tuple_dequote] + args = ["--libs", "tuple-quoting"] + stdout = "-L/test/lib -lfoo\n" + expected_fail = true + +[version_with_whitespace] + args = ["--modversion", "malformed-version"] + stdout = "3.922\n" + expected_fail = true + +[version_with_whitespace_diagnostic] + args = ["--validate", "malformed-version"] + stdout_contains = "warning: malformed version field with whitespace, trimming to [3.922]" + expected_fail = true diff --git a/tests/pkgconf/provides.toml b/tests/pkgconf/provides.toml new file mode 100644 index 0000000..a1825c6 --- /dev/null +++ b/tests/pkgconf/provides.toml @@ -0,0 +1,315 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[simple1] + args = ["--print-provides", "provides"] + stdout = """ +provides-test-foo = 1.0.0 +provides-test-bar > 1.1.0 +provides-test-baz >= 1.1.0 +provides-test-quux < 1.2.0 +provides-test-moo <= 1.2.0 +provides-test-meow != 1.3.0 +provides = 1.2.3 +""" + expected_fail = true + +[simple2] + args = ["--libs", "provides-request-simple"] + stdout = "-lfoo\n" + expected_fail = true + +[simple3] + args = ["--no-provides", "--libs", "provides-request-simple"] + stderr = '' + exitcode = 1 + expected_fail = true + +[foo] + args = ["--libs", "provides-test-foo"] + stdout = '' + +[foo_eq] + args = ["--libs", "provides-test-foo = 1.0.0"] + stdout = '' + +[foo_ge] + args = ["--libs", "provides-test-foo >= 1.0.0"] + stdout = '' + +[foo_le] + args = ["--libs", "provides-test-foo <= 1.0.0"] + stdout = '' + +[foo_ne] + args = ["--libs", "provides-test-foo != 1.0.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[foo_gt] + args = ["--libs", "provides-test-foo > 1.0.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[foo_lt] + args = ["--libs", "provides-test-foo < 1.0.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[bar] + args = ["--libs", "provides-test-bar"] + stdout = '' + +[bar_eq] + args = ["--libs", "provides-test-bar = 1.1.1"] + stdout = '' + +[bar_ge] + args = ["--libs", "provides-test-bar >= 1.1.1"] + stdout = '' + +[bar_le] + args = ["--libs", "provides-test-bar <= 1.1.1"] + stdout = '' + +[bar_le2] + args = ["--libs", "provides-test-bar <= 1.1.0"] + exitcode = 1 + stdout = '' + stderr = '' + +[bar_le3] + args = ["--libs", "provides-test-bar <= 1.2.0"] + stdout = '' + +[bar_ne] + args = ["--libs", "provides-test-bar != 1.1.0"] + stdout = '' + +[bar_ne2] + args = ["--libs", "provides-test-bar != 1.1.1"] + exitcode = 1 + stdout = '' + stderr = '' + +[bar_gt] + args = ["--libs", "provides-test-bar > 1.1.1"] + stdout = '' + +[baz] + args = ["--libs", "provides-test-baz"] + stdout = '' + +[baz_eq] + args = ["--libs", "provides-test-baz = 1.1.0"] + stdout = '' + +[baz_ge] + args = ["--libs", "provides-test-baz >= 1.1.0"] + stdout = '' + +[baz_le] + args = ["--libs", "provides-test-baz <= 1.1.0"] + stdout = '' + +[baz_ne] + args = ["--libs", "provides-test-baz != 1.1.0"] + exitcode = 1 + stderr = '' + stdout = '' + +[baz_ne2] + args = ["--libs", "provides-test-baz != 1.0.0"] + stdout = '' + +[baz_gt1] + args = ["--libs", "provides-test-baz > 1.1.1"] + stdout = '' + +[baz_gt2] + args = ["--libs", "provides-test-baz > 1.1.0"] + stdout = '' + +[baz_lt1] + args = ["--libs", "provides-test-baz < 1.1.0"] + exitcode = 1 + stderr = '' + stdout = '' + +[baz_lt2] + args = ["--libs", "provides-test-baz < 1.2.0"] + stdout = '' + +[quux] + args = ["--libs", "provides-test-quux"] + stdout = '' + +[quux_eq] + args = ["--libs", "provides-test-quux = 1.1.9"] + stdout = '' + +[quux_ge] + args = ["--libs", "provides-test-quux >= 1.1.0"] + stdout = '' + +[quux_ge2] + args = ["--libs", "provides-test-quux >= 1.2.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[quux_le] + args = ["--libs", "provides-test-quux <= 1.1.9"] + stdout = '' + +[quux_ne] + args = ["--libs", "provides-test-quux != 1.2.0"] + stdout = '' + +[quux_ne2] + args = ["--libs", "provides-test-quux != 1.1.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[quux_ne3] + args = ["--libs", "provides-test-quux != 1.0.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[quux_gt] + args = ["--libs", "provides-test-quux > 1.1.9"] + stdout = '' + +[quux_gt2] + args = ["--libs", "provides-test-quux > 1.2.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[quux_lt] + args = ["--libs", "provides-test-quux < 1.1.0"] + stdout = '' + +[quux_lt2] + args = ["--libs", "provides-test-quux < 1.2.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[moo] + args = ["--libs", "provides-test-moo"] + stdout = '' + +[moo_eq] + args = ["--libs", "provides-test-moo = 1.2.0"] + stdout = '' + +[moo_ge] + args = ["--libs", "provides-test-moo >= 1.1.0"] + stdout = '' + +[moo_ge2] + args = ["--libs", "provides-test-moo >= 1.2.1"] + stdout = '' + stderr = '' + exitcode = 1 + +[moo_le] + args = ["--libs", "provides-test-moo <= 1.2.0"] + stdout = '' + +[moo_ne] + args = ["--libs", "provides-test-moo != 1.1.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[moo_ne2] + args = ["--libs", "provides-test-moo != 1.0.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[moo_gt] + args = ["--libs", "provides-test-moo > 1.1.9"] + stdout = '' + +[moo_gt2] + args = ["--libs", "provides-test-moo > 1.2.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[moo_lt] + args = ["--libs", "provides-test-moo < 1.1.0"] + stdout = '' + +[moo_lt2] + args = ["--libs", "provides-test-moo < 1.2.0"] + stdout = '' + +[meow] + args = ["--libs", "provides-test-meow"] + stdout = '' + +[meow_eq] + args = ["--libs", "provides-test-meow = 1.3.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[meow_ne] + args = ["--libs", "provides-test-meow != 1.3.0"] + stdout = '' + +[meow_gt] + args = ["--libs", "provides-test-meow > 1.2.9"] + stdout = '' + stderr = '' + exitcode = 1 + +[meow_lt] + args = ["--libs", "provides-test-meow < 1.3.1"] + stdout = '' + stderr = '' + exitcode = 1 + +[meow_lt2] + args = ["--libs", "provides-test-meow < 1.3.0"] + stdout = '' + +[meow_ge] + args = ["--libs", "provides-test-meow >= 1.3.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[meow_ge2] + args = ["--libs", "provides-test-meow >= 1.3.1"] + stdout = '' + +[meow_le] + args = ["--libs", "provides-test-meow <= 1.3.0"] + stdout = '' + stderr = '' + exitcode = 1 + +[meow_lt3] + args = ["--libs", "provides-test-meow < 1.2.9"] + stdout = '' + +[indirect_dependency_node_1] + args = ["--modversion", "provides-test-meow"] + stdout = "1.2.3\n" + expected_fail = true + +[indirect_dependency_node_2] + args = ["--modversion", "provides-test-meow = 1.3.0"] + stderr = '' + exitcode = 1 diff --git a/tests/pkgconf/runner.py b/tests/pkgconf/runner.py new file mode 100755 index 0000000..3290c3c --- /dev/null +++ b/tests/pkgconf/runner.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python +# SDPX-License-Identifier: MIT + +# Copyright (c) 2016 pkgconf authors (see AUTHORS). +# Copyright © 2023-2025 Intel Corporation +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# This software is provided 'as is' and without any warranty, express or +# implied. In no event shall the authors be liable for any damages arising +# from the use of this software. + +"""Simple runner for test cases.""" + +from __future__ import annotations +import argparse +import asyncio +import dataclasses +import enum +import os +import sys +import tomllib +import typing + + +if typing.TYPE_CHECKING: + + class TestDefinition(typing.TypedDict, total=False): + exitcode: int + stdout: str + stdout_contains: str + stderr: str + args: typing.List[str] + env: typing.Dict[str, str] + expected_fail: bool + + class TestSetup(typing.TypedDict, total=False): + env: typing.Dict[str, str] + + class Arguments(typing.Protocol): + suites: typing.List[str] + pkgconf: str + verbose: bool + tap: bool + + +TEST_ROOT = os.path.dirname(os.path.abspath(__file__)) + + +class TestResult(enum.Enum): + + PASS = enum.auto() + FAIL = enum.auto() + XPASS = enum.auto() + XFAIL = enum.auto() + +@dataclasses.dataclass +class Result: + + name: str + status: TestResult = TestResult.PASS + reason: typing.Optional[str] = None + + +def interpolate(input: str) -> str: + return input.format( + test_root=TEST_ROOT, + ) + + +async def run_test(pkgconf: str, name: str, suite: str, test: TestDefinition, + verbose: bool, setup: TestSetup, tap: bool) -> Result: + + env: typing.Dict[str, str] = {} + if (renv := setup.get('env')) is not None: + env.update({k: interpolate(v) for k, v in renv.items()}) + if (renv := test.get('env', None)) is not None: + env.update({k: interpolate(v) for k, v in renv.items()}) + + # We may need a better splitting algorithm here, shlex.split for *nix and... + # something for Windows. + exe, *args = pkgconf.split(" ") + proc = await asyncio.create_subprocess_exec( + exe, *args, *[interpolate(a) for a in test.get('args', [])], + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + env=env) + + rout, rerr = await proc.communicate() + out = rout.decode() if rout is not None else '' + err = rerr.decode() if rerr is not None else '' + + result = Result(name) + + if (ret := test.get('exitcode', 0)) and proc.returncode != ret: + result.reason = f"Return code was {proc.returncode}, but expected {ret}" + + # We either check contains, or we check match, but not both + if (exp := test.get('stdout_contains')) is not None: + exp = interpolate(exp) + if exp not in out: + result.reason = f"Stdout was {out!r}, which does not contain {exp!r}" + elif (exp := test.get('stdout', '')) != '': + exp = interpolate(exp) + if out != exp: + result.reason = f"Stdout was {out!r}, but expected {exp!r}" + + if (exp := test.get('stderr', '')) != '': + exp = interpolate(exp) + if err != exp: + result.reason = f"Stderr was {err!r}, but expected {exp!r}" + + x = (result.reason, test.get('expected_fail', False)) + if x == (None, False): + result.status = TestResult.PASS + if verbose: + print(f"{suite}.{name}: passed") + elif x == (None, True): + result.status = TestResult.XPASS + print(f"{suite}.{name}: unexpected passed") + elif x[1] is False: + result.status = TestResult.FAIL + print(f"{suite}.{name}: failure\n reason: {result.reason}") + else: + result.status = TestResult.XFAIL + if verbose: + print(f"{suite}.{name}: expected failure\n reason: {result.reason}") + + if tap: + print('ok' if result.status in {TestResult.PASS, TestResult.XFAIL} else 'not ok', + '-', name) + + return result + + +async def run(args: Arguments) -> bool: + tests: typing.List[typing.Coroutine[typing.Any, typing.Any, Result]] = [] + for suitef in args.suites: + with open(suitef, 'rb') as f: + suite: typing.Dict[str, TestDefinition] = tomllib.load(f) + + setup: TestSetup = suite.pop('setup') + suite_name = os.path.splitext(os.path.basename(suitef))[0] + + tests.extend( + [run_test(args.pkgconf, n, suite_name, s, args.verbose, setup, args.tap) for n, s in suite.items()]) + + if args.tap: + print(f'1..{len(tests)}') + results = await asyncio.gather(*tests) + totals = {'failure': 0, 'success': 0, 'xsuccess': 0, 'xfailure' : 0} + for r in results: + if r.status is TestResult.PASS: + totals['success'] += 1 + elif r.status is TestResult.FAIL: + totals['failure'] += 1 + elif r.status is TestResult.XPASS: + totals['xsuccess'] += 1 + elif r.status is TestResult.XFAIL: + totals['xfailure'] += 1 + + if not args.tap: + print('\nTotals') + print(' Passes: ', totals['success']) + print(' Failures: ', totals['failure']) + print(' Expected Failures:', totals['xfailure']) + print(' Unexpected Passes:', totals['xsuccess']) + + return totals['success'] + totals['xfailure'] == len(tests) + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument('pkgconf', help="Path to built pkgconf executable") + parser.add_argument('suites', nargs="+", help="One or more toml test suite definition") + parser.add_argument('--tap', action='store_true', + help="Print Top compatible output") + parser.add_argument('-v', '--verbose', action='store_true', + help="Print more information while running") + args: Arguments = parser.parse_args() + + loop = asyncio.new_event_loop() + success = loop.run_until_complete(run(args)) + + sys.exit(int(not success)) + + +if __name__ == "__main__": + main() diff --git a/tests/pkgconf/sysroot.toml b/tests/pkgconf/sysroot.toml new file mode 100644 index 0000000..f0c655a --- /dev/null +++ b/tests/pkgconf/sysroot.toml @@ -0,0 +1,94 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH = "{test_root}/lib1" + PKG_CONFIG_SYSROOT_DIR = "/sentinal" + +[do_not_eat_slash] + args = ["--cflags", "baz"] + stdout = "-fPIC -I/test/include/foo\n" + expected_fail = true + + [do_not_eat_slash.env] + PKG_CONFIG_SYSROOT_DIR = "/" + +[cflags] + args = ["--cflags", "baz"] + stdout = "-fPIC -I/sentinal/test/include/foo\n" + expected_fail = true + +[variable_prefix] + args = ["--variable=prefix", "foo"] + stdout = "{test_root}/test\n" + expected_fail = true + + [variable_prefix.env] + PKG_CONFIG_SYSROOT_DIR = "{test_root}" + +[variable_includedir] + args = ["--variable=includedir", "foo"] + stdout = "{test_root}/test/include\n" + expected_fail = true + + [variable_includedir.env] + PKG_CONFIG_SYSROOT_DIR = "{test_root}" + +[do_not_duplicate_sysroot_dir_2] + args = ["--cflags", "sysroot-dir-2"] + stdout = "-I/sysroot/usr/include\n" + expected_fail = true + + [do_not_duplicate_sysroot_dir_2.env] + PKG_CONFIG_SYSROOT_DIR = "/sysroot" + +[do_not_duplicate_sysroot_dir_3] + args = ["--cflags", "sysroot-dir-3"] + stdout = "-I/sysroot/usr/include\n" + expected_fail = true + + [do_not_duplicate_sysroot_dir_3.env] + PKG_CONFIG_SYSROOT_DIR = "/sysroot" + +[do_not_duplicate_sysroot_dir_4] + args = ["--cflags", "sysroot-dir-4"] + stdout = "-I/sentinal/usr/include\n" + expected_fail = true + +[do_not_duplicate_sysroot_dir_5] + args = ["--cflags", "sysroot-dir-5"] + stdout = "-I/sysroot/usr/include\n" + expected_fail = true + + [do_not_duplicate_sysroot_dir_5.env] + PKG_CONFIG_SYSROOT_DIR = "/sysroot" + +[uninstalled] + args = ["--libs", "omg"] + stdout = "-L/test/lib -lomg\n" + expected_fail = true + +[uninstalled_pkgconf1] + args = ["--libs", "omg"] + stdout = "-L/sysroot/test/lib -lomg\n" + expected_fail = true + + [uninstalled_pkgconf1.env] + PKG_CONFIG_SYSROOT_DIR = "/sysroot" + PKG_CONFIG_PKGCONF1_SYSROOT_RULES = "1" + +[uninstalled_fdo] + args = ["--libs", "omg"] + stdout = "-L/test/lib -lomg\n" + expected_fail = true + + [uninstalled_fdo.env] + PKG_CONFIG_SYSROOT_DIR = "/sysroot" + PKG_CONFIG_FDO_SYSROOT_RULES = "1" + +[uninstalled_fdo_pc_sysrootdir] + args = ["--libs", "omg-sysroot"] + stdout = "-L/sysroot/test/lib -lomg\n" + expected_fail = true + + [uninstalled_fdo_pc_sysrootdir.env] + PKG_CONFIG_SYSROOT_DIR = "/sysroot" + PKG_CONFIG_FDO_SYSROOT_RULES = "1" diff --git a/tests/pkgconf/version.toml b/tests/pkgconf/version.toml new file mode 100644 index 0000000..9458bd8 --- /dev/null +++ b/tests/pkgconf/version.toml @@ -0,0 +1,30 @@ +[setup] + [setup.env] + PKG_CONFIG_PATH="{test_root}/lib1" + +[atleast_valid] + args = ["--atleast-version", "1.0", "foo"] + expected_fail = true + +[atleast_invalid] + args = ["--atleast-version", "2.0", "foo"] + exitcode = 1 + expected_fail = true + +[exact_valid] + args = ["--exact-version", "1.2.3", "foo"] + expected_fail = true + +[exact_invalid] + args = ["--exact-version", "1.0", "foo"] + exitcode = 1 + expected_fail = true + +[max_valid] + args = ["--max-version", "2.0", "foo"] + expected_fail = true + +[max_invalid] + args = ["--max-version", "1.0", "foo"] + exitcode = 1 + expected_fail = true