diff options
| author | Pierre Pronchery <khorben@FreeBSD.org> | 2026-06-25 22:30:05 +0000 |
|---|---|---|
| committer | Pierre Pronchery <khorben@FreeBSD.org> | 2026-06-29 05:21:48 +0000 |
| commit | b0fc1b7a2fe8fcb18ee407227591bf25a86ffbaf (patch) | |
| tree | 0cc32f86bf808bcf9d79da95db969cd76f0feadb | |
| parent | eaa637963bcfde283b411c14968b7903b02d6aa1 (diff) | |
126 files changed, 2388 insertions, 64 deletions
diff --git a/Makefile.am b/Makefile.am index 603b49054127..601e35e7ef71 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,17 +26,72 @@ EXTRA_DIST = pkg.m4 \ t/cli/about.test \ t/cli/atleast-pkgconfig-version-fail.test \ t/cli/atleast-pkgconfig-version-pass.test \ + t/cli/atleast-version-fail.test \ + t/cli/atleast-version-inline-constraint.test \ + t/cli/atleast-version-inline-overrides.test \ + t/cli/atleast-version-pass.test \ t/cli/cflags-libs.test \ + t/cli/debug.test \ + t/cli/define-variable.test \ + t/cli/dont-define-prefix.test \ + t/cli/dump-personality-loaded.test \ t/cli/dump-personality.test \ + t/cli/env-allow-system-cflags-default.test \ + t/cli/env-allow-system-cflags.test \ + t/cli/env-allow-system-libs-default.test \ + t/cli/env-allow-system-libs.test \ + t/cli/env-dont-relocate-paths.test \ + t/cli/env-early-trace.test \ + t/cli/env-log.test \ + t/cli/env-maximum-traverse-depth.test \ + t/cli/env-msvc-syntax.test \ + t/cli/env-only.test \ + t/cli/env-top-build-dir.test \ + t/cli/env.test \ + t/cli/exact-version-fail.test \ + t/cli/exact-version-inline-constraint.test \ + t/cli/exact-version-inline-overrides.test \ + t/cli/exact-version-pass.test \ t/cli/exists-missing.test \ t/cli/exists-valid.test \ + t/cli/fragment-filter.test \ t/cli/help.test \ + t/cli/internal-cflags.test \ + t/cli/keep-system-cflags-flag.test \ + t/cli/keep-system-libs-flag.test \ + t/cli/list-package-names.test \ + t/cli/log-file.test \ + t/cli/max-version-fail.test \ + t/cli/max-version-inline-constraint.test \ + t/cli/max-version-inline-overrides.test \ + t/cli/max-version-pass.test \ + t/cli/maximum-traverse-depth.test \ t/cli/missing-package.test \ t/cli/missing-package-error.test \ t/cli/modversion.test \ t/cli/no-arguments.test \ + t/cli/no-cache.test \ + t/cli/no-provides.test \ + t/cli/no-uninstalled.test \ + t/cli/path.test \ + t/cli/personality.test \ + t/cli/prefix-variable.test \ + t/cli/print-provides.test \ + t/cli/print-requires-private.test \ + t/cli/print-requires.test \ + t/cli/print-variables.test \ + t/cli/shared.test \ + t/cli/short-errors.test \ + t/cli/silence-errors.test \ + t/cli/simulate.test \ + t/cli/solution.test \ t/cli/unknown-option.test \ + t/cli/validate-warning.test \ + t/cli/validate.test \ + t/cli/variable.test \ + t/cli/verbose.test \ t/cli/version.test \ + t/cli/with-path.test \ t/basic/arbitrary-path.test \ t/basic/builtin-pkg-config-exists.test \ t/basic/builtin-pkg-config-pc_path-variable.test \ @@ -229,6 +284,7 @@ EXTRA_DIST = pkg.m4 \ t/bomtool/no-license.test \ t/bomtool/output-file.test \ t/bomtool/package-whitespace.test \ + t/bomtool/private-dependency.test \ t/bomtool/source-date-epoch.test \ t/bomtool/source-date-epoch-precedence.test \ t/bomtool/special-chars.test \ @@ -256,6 +312,7 @@ EXTRA_DIST = pkg.m4 \ t/spdxtool/no-license.test \ t/spdxtool/output-file.test \ t/spdxtool/package-whitespace.test \ + t/spdxtool/private-dependency.test \ t/spdxtool/source-date-epoch.test \ t/spdxtool/source-date-epoch-precedence.test \ t/spdxtool/special-chars.test \ @@ -307,6 +364,8 @@ EXTRA_DIST = pkg.m4 \ t/sysroot/no-pc_sysrootdir-rewriting-variable.test \ t/sysroot/path-segment-awareness.test \ t/sysroot/skip-rewriting-when-sysroot-dir-is-root-dir.test \ + t/sysroot/sysroot-differs-from-destdir-injects.test \ + t/sysroot/sysroot-equals-destdir-fdo-rules.test \ t/sysroot/undefined-pc_sysrootdir-should-be-empty.test \ t/sysroot/uninstalled-rewriting-fdo-rules-with-pc_sysrootdir.test \ t/sysroot/uninstalled-rewriting-fdo-rules.test \ @@ -330,18 +389,6 @@ EXTRA_DIST = pkg.m4 \ t/link-abi/multi-dedup.test \ tests/win-shim.h \ tests/api/test-api.h \ - tests/api/test-audit.c \ - tests/api/test-buffer.c \ - tests/api/test-bytecode.c \ - tests/api/test-client.c \ - tests/api/test-dependency.c \ - tests/api/test-fileio.c \ - tests/api/test-fragment.c \ - tests/api/test-license.c \ - tests/api/test-path-utils.c \ - tests/api/test-serialize.c \ - tests/api/test-tuple.c \ - tests/api/test-variable.c \ tests/lib-relocatable/lib/pkgconfig/foo.pc \ tests/lib1/argv-parse-2.pc \ tests/lib1/billion-laughs.pc \ @@ -389,6 +436,7 @@ EXTRA_DIST = pkg.m4 \ tests/lib1/circular-3.pc \ tests/lib1/no-trailing-newline.pc \ tests/lib1/tilde.pc \ + tests/lib1/top-builddir.pc \ tests/lib1/comments-in-fields.pc \ tests/lib1/nocflag.pc \ tests/lib1/typelibdir.pc \ @@ -475,6 +523,8 @@ EXTRA_DIST = pkg.m4 \ tests/lib-sbom/special.pc \ tests/lib-sbom/variable-test1.pc \ tests/lib-sbom/variable-test2.pc \ + tests/lib-sbom/priv-parent.pc \ + tests/lib-sbom/priv-child.pc \ tests/lib-sbom-files/agent_name.json \ tests/lib-sbom-files/agent_name_space.json \ tests/lib-sbom-files/basic.json \ @@ -490,6 +540,7 @@ EXTRA_DIST = pkg.m4 \ tests/lib-sbom-files/nolicense.json \ tests/lib-sbom-files/special.json \ tests/lib-sbom-files/with_dependency.json \ + tests/lib-sbom-files/private_dependency.json \ tests/lib-sbom-files/bomtool-basic.txt \ tests/lib-sbom-files/bomtool-define_variable.txt \ tests/lib-sbom-files/bomtool-define_variable_with_dependency.txt \ @@ -498,7 +549,9 @@ EXTRA_DIST = pkg.m4 \ tests/lib-sbom-files/bomtool-nolicense.txt \ tests/lib-sbom-files/bomtool-special.txt \ tests/lib-sbom-files/bomtool-with_dependency.txt \ + tests/lib-sbom-files/bomtool-private_dependency.txt \ tests/personality-data/i386-linux-gnu.personality \ + tests/personality-data/sysrooted.personality \ doc/conf.py \ doc/extract.py \ doc/index.rst \ @@ -592,9 +645,12 @@ API_TEST_PROGS = \ test-api-fragment \ test-api-license \ test-api-path-utils \ + test-api-personality \ + test-api-queue \ test-api-serialize \ test-api-tuple \ - test-api-variable + test-api-variable \ + test-api-version noinst_PROGRAMS = test-runner $(API_TEST_PROGS) @@ -645,6 +701,14 @@ test_api_path_utils_LDADD = $(api_test_ldadd) test_api_path_utils_SOURCES = tests/api/test-path-utils.c test_api_path_utils_CPPFLAGS = $(api_test_cppflags) +test_api_personality_LDADD = $(api_test_ldadd) +test_api_personality_SOURCES = tests/api/test-personality.c +test_api_personality_CPPFLAGS = $(api_test_cppflags) + +test_api_queue_LDADD = $(api_test_ldadd) +test_api_queue_SOURCES = tests/api/test-queue.c +test_api_queue_CPPFLAGS = $(api_test_cppflags) + test_api_serialize_LDADD = $(api_test_ldadd) test_api_serialize_SOURCES = \ tests/api/test-serialize.c \ @@ -663,6 +727,10 @@ test_api_variable_LDADD = $(api_test_ldadd) test_api_variable_SOURCES = tests/api/test-variable.c test_api_variable_CPPFLAGS = $(api_test_cppflags) +test_api_version_LDADD = $(api_test_ldadd) +test_api_version_SOURCES = tests/api/test-version.c +test_api_version_CPPFLAGS = $(api_test_cppflags) + dist_doc_DATA = CONTRIBUTING.md DCO README.md AUTHORS COPYING m4datadir = $(datadir)/aclocal @@ -680,9 +748,12 @@ check: pkgconf test-runner $(API_TEST_PROGS) $(builddir)/test-api-fragment$(EXEEXT) $(builddir)/test-api-license$(EXEEXT) $(builddir)/test-api-path-utils$(EXEEXT) + $(builddir)/test-api-personality$(EXEEXT) + $(builddir)/test-api-queue$(EXEEXT) $(builddir)/test-api-serialize$(EXEEXT) $(builddir)/test-api-tuple$(EXEEXT) $(builddir)/test-api-variable$(EXEEXT) + $(builddir)/test-api-version$(EXEEXT) $(builddir)/test-runner$(EXEEXT) --test-fixtures=$(top_srcdir)/tests --tool-dir="$(PWD)" $(top_srcdir)/t/basic $(builddir)/test-runner$(EXEEXT) --test-fixtures=$(top_srcdir)/tests --tool-dir="$(PWD)" $(top_srcdir)/t/cli $(builddir)/test-runner$(EXEEXT) --test-fixtures=$(top_srcdir)/tests --tool-dir="$(PWD)" $(top_srcdir)/t/link-abi @@ -696,3 +767,15 @@ check: pkgconf test-runner $(API_TEST_PROGS) $(builddir)/test-runner$(EXEEXT) --test-fixtures=$(top_srcdir)/tests --tool-dir="$(PWD)" $(top_srcdir)/t/symlink $(builddir)/test-runner$(EXEEXT) --test-fixtures=$(top_srcdir)/tests --tool-dir="$(PWD)" $(top_srcdir)/t/sysroot $(builddir)/test-runner$(EXEEXT) --test-fixtures=$(top_srcdir)/tests --tool-dir="$(PWD)" $(top_srcdir)/t/tuple + +pkgconf-final-stamp: + @echo + @echo "============================================================================" + @echo "WARNING: Autotools support is deprecated and will be removed in pkgconf 3.1." + @echo "Please migrate to Meson or Muon." + @echo "See README.md for instructions on building with Meson." + @echo "============================================================================" + @echo + +all: pkgconf-final-stamp +install-exec-hook: pkgconf-final-stamp diff --git a/Makefile.lite b/Makefile.lite index 678aa18364ab..2b2c1d147084 100644 --- a/Makefile.lite +++ b/Makefile.lite @@ -60,7 +60,7 @@ all: pkgconf-lite libpkgconf/config.h: @echo '#define PACKAGE_NAME "pkgconf-lite"' >> $@ @echo '#define PACKAGE_BUGREPORT "https://git.dereferenced.org/pkgconf/pkgconf/issues"' >> $@ - @echo '#define PACKAGE_VERSION "2.9.91"' >> $@ + @echo '#define PACKAGE_VERSION "2.9.92"' >> $@ @echo '#define PACKAGE PACKAGE_NAME " " PACKAGE_VERSION' >> $@ pkgconf-lite: preflight libpkgconf/config.h ${PKGCONF_OBJS} @@ -79,6 +79,9 @@ Changes from 2.5.1 to 3.0.0: - pkgconf now falls back to readlink(2) on systems which lack readlinkat(2). - A fallback is provided for platforms without nl_langinfo_l, and xlocale.h is included where needed to build on macOS. + - Fixed -Werror=format build failures on MinGW caused by the PRIu64 macro + expanding to an MSVCRT format specifier that the GNU format-string checker + rejects; serial and identifier values are now printed with %llu. The expanded platform CI and the nl_langinfo_l/xlocale.h fallbacks are by moi15moi. diff --git a/cli/bomtool/main.c b/cli/bomtool/main.c index 106820a41230..a41502e5a0cf 100644 --- a/cli/bomtool/main.c +++ b/cli/bomtool/main.c @@ -38,7 +38,6 @@ static const char *creation_time = NULL; static pkgconf_client_t pkg_client; static uint64_t want_flags; -static size_t maximum_package_count = 0; static int maximum_traverse_depth = 2000; static FILE *error_msgout = NULL; static FILE *sbom_out = NULL; @@ -458,12 +457,6 @@ main(int argc, char *argv[]) if (package == NULL) break; - /* check if there is a limit to the number of packages allowed to be included, if so and we have hit - * the limit, stop adding packages to the queue. - */ - if (maximum_package_count > 0 && pkgq.length > maximum_package_count) - break; - while (isspace((unsigned char)package[0])) package++; diff --git a/cli/core.c b/cli/core.c index abdbeb8a5167..dfc849ac5ec9 100644 --- a/cli/core.c +++ b/cli/core.c @@ -276,8 +276,8 @@ print_solution_node(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused) { (void) unused; - pkgconf_output_fmt(client->output, PKGCONF_OUTPUT_STDOUT, "%s (%"PRIu64")%s\n", - pkg->id, pkg->identifier, + pkgconf_output_fmt(client->output, PKGCONF_OUTPUT_STDOUT, "%s (%llu)%s\n", + pkg->id, (unsigned long long) pkg->identifier, (pkg->flags & PKGCONF_PKG_PROPF_VISITED_PRIVATE) == PKGCONF_PKG_PROPF_VISITED_PRIVATE ? " [private]" : ""); } diff --git a/cli/spdxtool/core.c b/cli/spdxtool/core.c index 5cf7f10e81e1..7dc7a8b41cce 100644 --- a/cli/spdxtool/core.c +++ b/cli/spdxtool/core.c @@ -222,8 +222,15 @@ spdxtool_core_creation_info_to_object(pkgconf_client_t *client, const spdxtool_c if (!(spdxtool_serialize_object_add_string(object_list, "type", creation->type) && spdxtool_serialize_object_add_string(object_list, "@id", creation->id) && - spdxtool_serialize_object_add_string(object_list, "created", creation->created) && - spdxtool_serialize_object_add_array(object_list, "createdBy", created_by) && + spdxtool_serialize_object_add_string(object_list, "created", creation->created))) + { + /* created_by has not been handed to the object list yet */ + spdxtool_serialize_array_free(created_by); + goto err; + } + + /* object_add_array takes ownership of created_by, freeing it on failure */ + if (!(spdxtool_serialize_object_add_array(object_list, "createdBy", created_by) && spdxtool_serialize_object_add_string(object_list, "specVersion", creation->spec_version))) { goto err; @@ -329,6 +336,13 @@ spdxtool_core_spdx_document_free(spdxtool_core_spdx_document_t *spdx) free(iter); } + PKGCONF_FOREACH_LIST_ENTRY_SAFE(spdx->maintainers.head, iter_next, iter) + { + spdxtool_core_agent_t *maintainer = iter->data; + spdxtool_core_agent_free(maintainer); + free(iter); + } + PKGCONF_FOREACH_LIST_ENTRY_SAFE(spdx->packages.head, iter_next, iter) { free(iter); @@ -547,6 +561,60 @@ spdxtool_core_spdx_document_add_element(pkgconf_client_t *client, spdxtool_core_ /* * !doc * + * .. c:function:: const char *spdxtool_core_spdx_document_add_maintainer(pkgconf_client_t *client, spdxtool_core_spdx_document_t *spdx, const char *name) + * + * Register a package maintainer as an Agent and add it to the SpdxDocument so that + * packages may reference it via their ``suppliedBy`` field. Maintainers are + * deduplicated by their spdxId, so a maintainer shared between packages is only + * emitted once. The first time a maintainer is seen, its spdxId is also added to + * the document element list. + * + * :param pkgconf_client_t *client: The pkgconf client being accessed. + * :param spdxtool_core_spdx_document_t *spdx: SpdxDocument struct being used. + * :param const char *name: Maintainer name as declared in the package. + * :return: the maintainer Agent spdxId (owned by the document) on success, NULL on failure + */ +const char * +spdxtool_core_spdx_document_add_maintainer(pkgconf_client_t *client, spdxtool_core_spdx_document_t *spdx, const char *name) +{ + pkgconf_node_t *iter = NULL; + + if (!client || !spdx || !name) + return NULL; + + spdxtool_core_agent_t *agent = spdxtool_core_agent_new(client, spdx->creation_info, name); + if (!agent) + return NULL; + + PKGCONF_FOREACH_LIST_ENTRY(spdx->maintainers.head, iter) + { + spdxtool_core_agent_t *existing = iter->data; + if (!strcmp(existing->spdx_id, agent->spdx_id)) + { + spdxtool_core_agent_free(agent); + return existing->spdx_id; + } + } + + pkgconf_node_t *node = calloc(1, sizeof(pkgconf_node_t)); + if (!node) + { + pkgconf_error(client, "spdxtool_core_spdx_document_add_maintainer: out of memory"); + spdxtool_core_agent_free(agent); + return NULL; + } + + pkgconf_node_insert_tail(node, agent, &spdx->maintainers); + + if (!spdxtool_core_spdx_document_add_element(client, spdx, agent->spdx_id)) + return NULL; + + return agent->spdx_id; +} + +/* + * !doc + * * .. c:function:: bool spdxtool_core_spdx_document_add_relationship(pkgconf_client_t *client, spdxtool_core_spdx_document_t *spdx, spdxtool_core_relationship_t *relationship) * * Add relationship rel to SpdxDocument @@ -650,6 +718,40 @@ err: /* * !doc * + * .. c:function:: bool spdxtool_core_relationship_set_scope(pkgconf_client_t *client, spdxtool_core_relationship_t *relationship, const char *scope) + * + * Promote a relationship to a /Core/LifecycleScopedRelationship by attaching a lifecycle + * scope (for example, ``development`` for a private build dependency). This is the SPDX 3.0 + * representation of SPDX 2.x's ``*_DEPENDENCY_OF`` relationship variants. + * + * :param pkgconf_client_t *client: The pkgconf client being accessed. + * :param spdxtool_core_relationship_t *relationship: Relationship struct to scope. + * :param const char *scope: LifecycleScopeType value, e.g. "development". + * :return: true on success, false on failure + */ +bool +spdxtool_core_relationship_set_scope(pkgconf_client_t *client, spdxtool_core_relationship_t *relationship, const char *scope) +{ + if (!relationship || !scope) + return false; + + char *scope_copy = strdup(scope); + if (!scope_copy) + { + pkgconf_error(client, "spdxtool_core_relationship_set_scope: out of memory"); + return false; + } + + free(relationship->scope); + relationship->scope = scope_copy; + relationship->type = "LifecycleScopedRelationship"; + + return true; +} + +/* + * !doc + * * .. c:function:: void spdxtool_core_relationship_free(spdxtool_core_relationship_t *relationship) * * Free /Core/Relationship struct @@ -669,6 +771,7 @@ spdxtool_core_relationship_free(spdxtool_core_relationship_t *relationship) pkgconf_license_free(relationship->to); free(relationship->to); free(relationship->relationship_type); + free(relationship->scope); free(relationship); } @@ -717,6 +820,12 @@ spdxtool_core_relationship_to_object(pkgconf_client_t *client, const spdxtool_co goto err; } + if (relationship->scope != NULL && + !spdxtool_serialize_object_add_string(object_list, "scope", relationship->scope)) + { + goto err; + } + ret = spdxtool_serialize_value_object(object_list); object_list = NULL; diff --git a/cli/spdxtool/core.h b/cli/spdxtool/core.h index 0cbb1f4b3d51..9575310ebd1f 100644 --- a/cli/spdxtool/core.h +++ b/cli/spdxtool/core.h @@ -55,6 +55,9 @@ spdxtool_core_spdx_document_add_package(pkgconf_client_t *client, spdxtool_core_ bool spdxtool_core_spdx_document_add_element(pkgconf_client_t *client, spdxtool_core_spdx_document_t *spdx, const char *element); +const char * +spdxtool_core_spdx_document_add_maintainer(pkgconf_client_t *client, spdxtool_core_spdx_document_t *spdx, const char *name); + void spdxtool_core_spdx_document_free(spdxtool_core_spdx_document_t *spdx); @@ -64,6 +67,9 @@ spdxtool_core_spdx_document_to_object(pkgconf_client_t *client, spdxtool_core_sp spdxtool_core_relationship_t * spdxtool_core_relationship_new(pkgconf_client_t *client, const char *creation_info_id, const char *spdx_id, const char *from, pkgconf_list_t *to, const char *relationship_type); +bool +spdxtool_core_relationship_set_scope(pkgconf_client_t *client, spdxtool_core_relationship_t *relationship, const char *scope); + void spdxtool_core_relationship_free(spdxtool_core_relationship_t *relationship); diff --git a/cli/spdxtool/main.c b/cli/spdxtool/main.c index 70cdce2dd891..7d52abe56670 100644 --- a/cli/spdxtool/main.c +++ b/cli/spdxtool/main.c @@ -30,7 +30,6 @@ static int maximum_traverse_depth = 2000; static pkgconf_client_t pkg_client; static uint64_t want_flags; -static size_t maximum_package_count = 0; // static int maximum_traverse_depth = 2000; static FILE *error_msgout = NULL; static FILE *sbom_out = NULL; @@ -94,6 +93,15 @@ generate_spdx_package(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *ptr) pkgconf_tuple_add(client, &pkg->vars, "creationInfo", document->creation_info, false, 0); pkgconf_tuple_add(client, &pkg->vars, "agent", document->agent, false, 0); + if (pkg->maintainer != NULL) + { + const char *supplier = spdxtool_core_spdx_document_add_maintainer(client, document, pkg->maintainer); + if (!supplier) + goto err; + + pkgconf_tuple_add(client, &pkg->vars, "suppliedBy", supplier, false, 0); + } + if (pkg->license.head != NULL) { pkgconf_buffer_t spdx_id_buf = PKGCONF_BUFFER_INITIALIZER; @@ -364,12 +372,6 @@ main(int argc, char *argv[]) if (package == NULL) break; - /* check if there is a limit to the number of packages allowed to be included, if so and we have hit - * the limit, stop adding packages to the queue. - */ - if (maximum_package_count > 0 && pkgq.length > maximum_package_count) - break; - while (isspace((unsigned char)package[0])) package++; diff --git a/cli/spdxtool/serialize.c b/cli/spdxtool/serialize.c index 69ef3a70a3b1..fc5c460d77cb 100644 --- a/cli/spdxtool/serialize.c +++ b/cli/spdxtool/serialize.c @@ -169,7 +169,8 @@ spdxtool_serialize_object_add_take(spdxtool_serialize_object_list_t *object_list { free(node); free(keycopy); - spdxtool_serialize_object_free(object); + /* object->key/value are not assigned yet; free the struct itself */ + free(object); spdxtool_serialize_value_free(value); return NULL; } @@ -397,6 +398,18 @@ spdxtool_serialize_sbom(pkgconf_client_t *client, spdxtool_core_agent_t *agent, goto err; pkgconf_node_t *iter = NULL; + PKGCONF_FOREACH_LIST_ENTRY(spdx->maintainers.head, iter) + { + spdxtool_core_agent_t *maintainer = iter->data; + if (!maintainer) + { + errstr = "maintainers list corrupted"; + goto err; + } + if (!spdxtool_serialize_array_add_take(graph, spdxtool_core_agent_to_object(client, maintainer))) + goto err; + } + PKGCONF_FOREACH_LIST_ENTRY(spdx->licenses.head, iter) { spdxtool_simplelicensing_license_expression_t *expression = iter->data; diff --git a/cli/spdxtool/serialize.h b/cli/spdxtool/serialize.h index e04b7f38b741..a1eb99403406 100644 --- a/cli/spdxtool/serialize.h +++ b/cli/spdxtool/serialize.h @@ -203,7 +203,10 @@ spdxtool_serialize_value_object(spdxtool_serialize_object_list_t *object_list) { spdxtool_serialize_value_t *value = calloc(1, sizeof(spdxtool_serialize_value_t)); if (!value) + { + spdxtool_serialize_object_list_free(object_list); return NULL; + } value->type = SPDXTOOL_SERIALIZE_TYPE_OBJECT; value->value.o = object_list; @@ -227,7 +230,10 @@ spdxtool_serialize_value_array(spdxtool_serialize_array_t *array) { spdxtool_serialize_value_t *value = calloc(1, sizeof(spdxtool_serialize_value_t)); if (!value) + { + spdxtool_serialize_array_free(array); return NULL; + } value->type = SPDXTOOL_SERIALIZE_TYPE_ARRAY; value->value.a = array; diff --git a/cli/spdxtool/software.c b/cli/spdxtool/software.c index 4e9712ba6942..ac76cf73e7de 100644 --- a/cli/spdxtool/software.c +++ b/cli/spdxtool/software.c @@ -162,6 +162,37 @@ spdxtool_software_sbom_to_object(pkgconf_client_t *client, spdxtool_software_sbo free(spdx_id_relation); } + PKGCONF_FOREACH_LIST_ENTRY(sbom->rootElement->requires_private.head, node) + { + pkgconf_dependency_t *dep = node->data; + pkgconf_pkg_t *match = dep->match; + pkgconf_buffer_t relationship_buf = PKGCONF_BUFFER_INITIALIZER; + + pkgconf_buffer_append_fmt(&relationship_buf, "%s%cdependsOn%c%s", sbom->rootElement->id, sep, sep, match->id); + char *relationship_str = pkgconf_buffer_freeze(&relationship_buf); + if (!relationship_str) + goto err; + + char *spdx_id_relation = spdxtool_util_get_spdx_id_string(client, "Relationship", relationship_str); + free(relationship_str); + if (!spdx_id_relation) + goto err; + + if (!spdxtool_serialize_array_add_string(element_array, spdx_id_relation)) + { + free(spdx_id_relation); + goto err; + } + + if (!spdxtool_core_spdx_document_add_element(client, sbom->spdx_document, spdx_id_relation)) + { + free(spdx_id_relation); + goto err; + } + + free(spdx_id_relation); + } + char *value = spdxtool_util_tuple_lookup(client, &sbom->rootElement->vars, "hasDeclaredLicense"); if (value) { @@ -275,9 +306,11 @@ spdxtool_software_package_to_object(pkgconf_client_t *client, pkgconf_pkg_t *pkg spdxtool_serialize_value_t *ret = NULL; spdxtool_serialize_object_list_t *object_list = NULL; spdxtool_serialize_array_t *originated_by = NULL; + spdxtool_serialize_array_t *supplied_by = NULL; char *creation_info = NULL; char *spdx_id = NULL; char *agent = NULL; + char *supplier = NULL; char *spdx_id_license = NULL; pkgconf_list_t relations = PKGCONF_LIST_INITIALIZER; pkgconf_list_t *cpy_relations = NULL; @@ -314,6 +347,21 @@ spdxtool_software_package_to_object(pkgconf_client_t *client, pkgconf_pkg_t *pkg goto err; originated_by = NULL; + supplier = spdxtool_util_tuple_lookup(client, &pkg->vars, "suppliedBy"); + if (supplier) + { + supplied_by = spdxtool_serialize_array_new(); + if (!supplied_by) + goto err; + + if (!spdxtool_serialize_array_add_string(supplied_by, supplier)) + goto err; + + if (!spdxtool_serialize_object_add_array(object_list, "suppliedBy", supplied_by)) + goto err; + supplied_by = NULL; + } + if (!serialize_copyright_lines_to_object(object_list, &pkg->copyright)) goto err; @@ -430,6 +478,56 @@ spdxtool_software_package_to_object(pkgconf_client_t *client, pkgconf_pkg_t *pkg cpy_relations = NULL; } + PKGCONF_FOREACH_LIST_ENTRY(pkg->requires_private.head, node) + { + pkgconf_dependency_t *dep = node->data; + pkgconf_pkg_t *match = dep->match; + pkgconf_buffer_t relationship_buf = PKGCONF_BUFFER_INITIALIZER; + + pkgconf_buffer_append_fmt(&relationship_buf, "%s%cdependsOn%c%s", pkg->id, sep, sep, match->id); + char *relationship_str = pkgconf_buffer_freeze(&relationship_buf); + if (!relationship_str) + goto err; + + char *spdx_id_relation = spdxtool_util_get_spdx_id_string(client, "Relationship", relationship_str); + free(relationship_str); + if (!spdx_id_relation) + goto err; + + char *spdx_id_package = spdxtool_util_get_spdx_id_string(client, "Package", match->id); + if (!spdx_id_package) + { + free(spdx_id_relation); + goto err; + } + + cpy_relations = calloc(1, sizeof(pkgconf_list_t)); + if (!cpy_relations) + { + free(spdx_id_relation); + free(spdx_id_package); + goto err; + } + + pkgconf_license_insert(client, cpy_relations, PKGCONF_LICENSE_UNKNOWN, spdx_id_package); + spdxtool_core_relationship_t *relationship = spdxtool_core_relationship_new(client, creation_info, spdx_id_relation, spdx_id, cpy_relations, "dependsOn"); + free(spdx_id_relation); + free(spdx_id_package); + if (!relationship) + goto err; + cpy_relations = NULL; + if (!spdxtool_core_relationship_set_scope(client, relationship, "development")) + { + spdxtool_core_relationship_free(relationship); + goto err; + } + if (!spdxtool_core_spdx_document_add_relationship(client, spdx, relationship)) + { + spdxtool_core_relationship_free(relationship); + goto err; + } + } + ret = spdxtool_serialize_value_object(object_list); object_list = NULL; @@ -440,8 +538,10 @@ err: free(creation_info); free(spdx_id); free(agent); + free(supplier); free(spdx_id_license); spdxtool_serialize_object_list_free(object_list); spdxtool_serialize_array_free(originated_by); + spdxtool_serialize_array_free(supplied_by); return ret; } diff --git a/cli/spdxtool/util.h b/cli/spdxtool/util.h index e39c173e64c5..645d93a5a8e9 100644 --- a/cli/spdxtool/util.h +++ b/cli/spdxtool/util.h @@ -49,6 +49,7 @@ typedef struct spdxtool_core_spdx_document pkgconf_list_t rootElement; pkgconf_list_t relationships; pkgconf_list_t packages; + pkgconf_list_t maintainers; } spdxtool_core_spdx_document_t; typedef struct spdxtool_software_sbom_ @@ -76,6 +77,7 @@ typedef struct spdxtool_core_relationship_ char *from; pkgconf_list_t *to; char *relationship_type; + char *scope; } spdxtool_core_relationship_t; void diff --git a/codecov.yml b/codecov.yml index b152448ef21a..6727f664d2a4 100644 --- a/codecov.yml +++ b/codecov.yml @@ -18,3 +18,6 @@ ignore: # the test runner itself should not count as part of coverage testing - "tests/test-runner.c" + + # the fuzzing harnesses and their corpus-replay driver are test scaffolding + - "fuzzer/*.c" diff --git a/configure.ac b/configure.ac index af4081147910..6778b38a4075 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,13 @@ dnl implied. In no event shall the authors be liable for any damages arising dnl from the use of this software. AC_PREREQ([2.71]) -AC_INIT([pkgconf],[2.9.91],[https://github.com/pkgconf/pkgconf/issues/new]) +AC_INIT([pkgconf],[2.9.92],[https://github.com/pkgconf/pkgconf/issues/new]) +AC_MSG_WARN([ +=================================================================== +Autotools support is deprecated and will be removed in pkgconf 3.1. +Please migrate to Meson or Muon. +=================================================================== +]) AC_CONFIG_SRCDIR([cli/main.c]) AC_CONFIG_MACRO_DIR([m4]) AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"]) @@ -80,6 +86,14 @@ AC_CONFIG_FILES([Makefile libpkgconf.pc]) AC_OUTPUT cat << EOF + +=================================================================== +*** WARNING *** +Autotools support is deprecated and will be removed in pkgconf 3.1. +Please migrate to Meson or Muon. +See README.md for instructions on building with Meson or Muon. +=================================================================== + Build configuration: Default personality search paths: ${PERSONALITY_PATH} diff --git a/fuzzer/replay.c b/fuzzer/replay.c new file mode 100644 index 000000000000..b02b88af1678 --- /dev/null +++ b/fuzzer/replay.c @@ -0,0 +1,104 @@ +/* + * replay.c + * Standalone driver that replays corpus files through a libFuzzer + * LLVMFuzzerTestOneInput entry point, without libFuzzer. + * + * This lets the fuzz targets (and the allocator fault injection they drive via + * alloc-inject) run deterministically over their seed corpus under an ordinary + * compiler -- in particular a coverage build -- so their OOM-path coverage is + * captured by codecov, which the libFuzzer/clang fuzz job does not provide. + * + * SPDX-License-Identifier: pkgconf + * + * Copyright (c) 2026 pkgconf authors (see AUTHORS). + * + * 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. + */ + +#include <libpkgconf/stdinc.h> +#include <sys/stat.h> +#include <dirent.h> + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +static void +replay_file(const char *path) +{ + FILE *f = fopen(path, "rb"); + if (f == NULL) + return; + + if (fseek(f, 0, SEEK_END) != 0) + { + fclose(f); + return; + } + + long len = ftell(f); + rewind(f); + + if (len < 0) + { + fclose(f); + return; + } + + uint8_t *buf = malloc((size_t) len + 1); + if (buf == NULL) + { + fclose(f); + return; + } + + size_t got = fread(buf, 1, (size_t) len, f); + fclose(f); + + LLVMFuzzerTestOneInput(buf, got); + free(buf); +} + +static void +replay_path(const char *path) +{ + struct stat st; + if (stat(path, &st) != 0) + return; + + if (!S_ISDIR(st.st_mode)) + { + replay_file(path); + return; + } + + DIR *dir = opendir(path); + if (dir == NULL) + return; + + struct dirent *ent; + while ((ent = readdir(dir)) != NULL) + { + if (ent->d_name[0] == '.') + continue; + + char child[4096]; + snprintf(child, sizeof child, "%s/%s", path, ent->d_name); + replay_path(child); + } + + closedir(dir); +} + +int +main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; i++) + replay_path(argv[i]); + + return 0; +} diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 205e88e6e8b6..22b6c97a94f8 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -71,8 +71,8 @@ typedef struct pkgconf_license_ pkgconf_license_t; #define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \ for ((value) = (tail); (value) != NULL; (value) = (value)->prev) -#define LIBPKGCONF_VERSION 20991 -#define LIBPKGCONF_VERSION_STR "2.9.91" +#define LIBPKGCONF_VERSION 20992 +#define LIBPKGCONF_VERSION_STR "2.9.92" struct pkgconf_queue_ { pkgconf_node_t iter; diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index 79a4e1d6065f..16e38e6e3783 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -1678,7 +1678,7 @@ pkgconf_pkg_traverse_main(pkgconf_client_t *client, if (root->identifier == 0) root->identifier = ++client->identifier; - PKGCONF_TRACE(client, "%s: level %d, serial %"PRIu64, root->id, maxdepth, client->serial); + PKGCONF_TRACE(client, "%s: level %d, serial %llu", root->id, maxdepth, (unsigned long long) client->serial); if ((root->flags & PKGCONF_PKG_PROPF_VIRTUAL) != PKGCONF_PKG_PROPF_VIRTUAL || (client->flags & PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) != PKGCONF_PKG_PKGF_SKIP_ROOT_VIRTUAL) { diff --git a/libpkgconf/version.c b/libpkgconf/version.c index 7b597bd721b2..9a958fe3d1f6 100644 --- a/libpkgconf/version.c +++ b/libpkgconf/version.c @@ -23,8 +23,7 @@ typedef enum { PKGCONF_VERSION_TOKEN_END = 0, PKGCONF_VERSION_TOKEN_TILDE, PKGCONF_VERSION_TOKEN_NUMERIC, - PKGCONF_VERSION_TOKEN_ALPHA, - PKGCONF_VERSION_TOKEN_OTHER + PKGCONF_VERSION_TOKEN_ALPHA } pkgconf_version_token_kind_t; typedef struct { @@ -85,17 +84,14 @@ pkgconf_version_next_token(pkgconf_version_iter_t *it) return tok; } - if (isalpha((unsigned char)*s)) - { - tok.kind = PKGCONF_VERSION_TOKEN_ALPHA; - while (*tok.end && isalpha((unsigned char)*tok.end)) - tok.end++; - it->cur = tok.end; - return tok; - } - - tok.kind = PKGCONF_VERSION_TOKEN_OTHER; - tok.end = s + 1; + /* + * Having skipped separators and ruled out end-of-string, tilde and + * digits, the only remaining possibility is alpha: isalnum(c) is by + * definition isalpha(c) || isdigit(c). + */ + tok.kind = PKGCONF_VERSION_TOKEN_ALPHA; + while (*tok.end && isalpha((unsigned char)*tok.end)) + tok.end++; it->cur = tok.end; return tok; @@ -190,20 +186,10 @@ pkgconf_version_compare_token(const pkgconf_version_token_t *a, const pkgconf_ve } /* left-side is alpha, any right-side non-alpha wins */ - if (a->kind == PKGCONF_VERSION_TOKEN_ALPHA) - { - if (b->kind != PKGCONF_VERSION_TOKEN_ALPHA) - return -1; - - return pkgconf_version_compare_alpha(a, b); - } - - if (a->kind < b->kind) + if (b->kind != PKGCONF_VERSION_TOKEN_ALPHA) return -1; - if (a->kind > b->kind) - return 1; - return 0; + return pkgconf_version_compare_alpha(a, b); } /* diff --git a/meson.build b/meson.build index 6eb7304c5d5e..358a15035dfc 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('pkgconf', 'c', - version : '2.9.91', + version : '2.9.92', license : 'ISC', default_options : [ 'c_std=c99', @@ -155,7 +155,7 @@ else build_static = '-DPKGCONFIG_IS_NOT_STATIC' endif -libpkgconf = library('pkgconf', +libpkgconf_sources = [ 'libpkgconf/argvsplit.c', 'libpkgconf/audit.c', 'libpkgconf/buffer.c', @@ -177,6 +177,10 @@ libpkgconf = library('pkgconf', 'libpkgconf/tuple.c', 'libpkgconf/variable.c', 'libpkgconf/version.c', +] + +libpkgconf = library('pkgconf', + libpkgconf_sources, c_args: ['-DLIBPKGCONF_EXPORT', build_static], install : true, version : '8.0.0', @@ -281,8 +285,11 @@ api_tests = [ 'fragment', 'license', 'path-utils', + 'personality', + 'queue', 'tuple', 'variable', + 'version', ] foreach t : api_tests @@ -312,6 +319,68 @@ test_api_serialize_exe = executable('test-api-serialize', install : false) test('api-serialize', test_api_serialize_exe) +# Allocation-failure (OOM) tests. These drive the shared fuzzer/alloc-inject +# fault injector through the linker's --wrap, so they are built wherever --wrap +# is supported: glibc and musl Linux (GNU ld / lld), and skipped on macOS ld64 +# and MSVC. +build_oom_tests = host_machine.system() == 'linux' \ + and cc.has_link_argument('-Wl,--wrap=calloc') + +# Allocator set wrapped by fuzzer/alloc-inject.c. +oom_wrap_args = [ + '-Wl,--wrap=malloc', '-Wl,--wrap=calloc', '-Wl,--wrap=realloc', + '-Wl,--wrap=reallocarray', '-Wl,--wrap=strdup', '-Wl,--wrap=strndup', +] + +if build_oom_tests + # Unit test: fault-inject spdxtool's own allocations. It links libpkgconf + # normally (shared); only spdxtool's compiled-in allocations are wrapped, + # which is exactly what we want to fail here. + test_api_oom_spdxtool_exe = executable('test-api-oom-spdxtool', + 'tests/api/test-oom-spdxtool.c', + 'fuzzer/alloc-inject.c', + 'cli/spdxtool/core.c', + 'cli/spdxtool/software.c', + 'cli/spdxtool/serialize.c', + 'cli/spdxtool/simplelicensing.c', + 'cli/spdxtool/util.c', + windows_manifest, + link_with : libpkgconf, + c_args : build_static, + link_args : oom_wrap_args, + include_directories : [include_directories('.'), include_directories('tests/api'), include_directories('cli/spdxtool'), include_directories('fuzzer')], + install : false) + test('api-oom-spdxtool', test_api_oom_spdxtool_exe) + + # Replay the existing parser/solver fuzz targets over their seed corpus, + # deterministically and without libFuzzer, so the libpkgconf OOM paths they + # exercise via alloc-inject are captured by a coverage build (the clang/ + # libFuzzer fuzz job is not coverage-instrumented). --wrap only reaches + # allocations linked into the executable, so these link a static libpkgconf. + libpkgconf_fault = static_library('pkgconf-fault', + libpkgconf_sources, + c_args : ['-DLIBPKGCONF_EXPORT', build_static], + install : false) + + fuzz_replays = [ + ['parser', join_paths(meson.current_source_dir(), 'tests', 'lib1')], + ['solver', join_paths(meson.current_source_dir(), 'fuzzer', 'solver-corpus')], + ] + foreach r : fuzz_replays + replay_exe = executable('fuzz-replay-' + r[0], + 'fuzzer/replay.c', + 'fuzzer' / (r[0] + '-fuzzer.c'), + 'fuzzer/alloc-inject.c', + link_with : libpkgconf_fault, + c_args : build_static, + link_args : oom_wrap_args, + include_directories : [include_directories('.'), include_directories('fuzzer')], + install : false) + # The exhaustive per-input injection loop is slow under ASAN; give it room. + test('fuzz-replay-' + r[0], replay_exe, args : [r[1]], timeout : 120) + endforeach +endif + fixtures_dir = join_paths(meson.current_source_dir(), 'tests') tool_dir = meson.current_build_dir() diff --git a/t/bomtool/private-dependency.test b/t/bomtool/private-dependency.test new file mode 100644 index 000000000000..88b584d41f50 --- /dev/null +++ b/t/bomtool/private-dependency.test @@ -0,0 +1,5 @@ +Tool: bomtool +ToolArgs: --creation-time=test priv-parent +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib-sbom +ExpectedStdoutFile: ../../tests/lib-sbom-files/bomtool-private_dependency.txt +ExpectedExitCode: 0 diff --git a/t/cli/atleast-version-fail.test b/t/cli/atleast-version-fail.test new file mode 100644 index 000000000000..4d318cc88d79 --- /dev/null +++ b/t/cli/atleast-version-fail.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --atleast-version=2.0.0 foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 1 diff --git a/t/cli/atleast-version-inline-constraint.test b/t/cli/atleast-version-inline-constraint.test new file mode 100644 index 000000000000..0c7353377a0e --- /dev/null +++ b/t/cli/atleast-version-inline-constraint.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --atleast-version=1 "foo > 2" +ExpectedExitCode: 1 diff --git a/t/cli/atleast-version-inline-overrides.test b/t/cli/atleast-version-inline-overrides.test new file mode 100644 index 000000000000..e691482eceb9 --- /dev/null +++ b/t/cli/atleast-version-inline-overrides.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --atleast-version=3 "foo > 1" +ExpectedExitCode: 0 diff --git a/t/cli/atleast-version-pass.test b/t/cli/atleast-version-pass.test new file mode 100644 index 000000000000..181fd3df33f8 --- /dev/null +++ b/t/cli/atleast-version-pass.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --atleast-version=1.0.0 foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 0 diff --git a/t/cli/debug.test b/t/cli/debug.test new file mode 100644 index 000000000000..a6a851c86e07 --- /dev/null +++ b/t/cli/debug.test @@ -0,0 +1,7 @@ +Tool: pkgconf +ToolArgs: --debug --exists foo 2>&1 +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedStdout: preloading pkg +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/define-variable.test b/t/cli/define-variable.test new file mode 100644 index 000000000000..58747e745167 --- /dev/null +++ b/t/cli/define-variable.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --define-variable=prefix=/test2 --variable=prefix foo +ExpectedStdout: /test2 +ExpectedExitCode: 0 diff --git a/t/cli/dont-define-prefix.test b/t/cli/dont-define-prefix.test new file mode 100644 index 000000000000..b58dc4382f74 --- /dev/null +++ b/t/cli/dont-define-prefix.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --define-prefix --dont-define-prefix --variable=prefix %TEST_FIXTURES_DIR%/lib-relocatable/lib/pkgconfig/foo.pc +ExpectedStdout: /test +ExpectedExitCode: 0 diff --git a/t/cli/dump-personality-loaded.test b/t/cli/dump-personality-loaded.test new file mode 100644 index 000000000000..3a3640308aea --- /dev/null +++ b/t/cli/dump-personality-loaded.test @@ -0,0 +1,12 @@ +Tool: pkgconf +ToolArgs: --personality=%TEST_FIXTURES_DIR%/personality-data/sysrooted.personality --dump-personality +ExpectedStdout: Triplet: i386-linux-gnu +ExpectedStdout: SysrootDir: /custom/sysroot +ExpectedStdout: DefaultSearchPaths: /usr/lib/i386-linux-gnu/pkgconfig:/usr/share/pkgconfig +ExpectedStdout: SystemIncludePaths: /usr/lib/i386-linux-gnu/include +ExpectedStdout: SystemLibraryPaths: /usr/lib/i386-linux-gnu/lib +ExpectedStdout: WantDefaultPure: true +ExpectedStdout: WantDefaultStatic: true +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/env-allow-system-cflags-default.test b/t/cli/env-allow-system-cflags-default.test new file mode 100644 index 000000000000..e5243d1a3766 --- /dev/null +++ b/t/cli/env-allow-system-cflags-default.test @@ -0,0 +1,7 @@ +Tool: pkgconf +ToolArgs: --cflags-only-I cflags-libs-only +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_SYSTEM_INCLUDE_PATH=/test/local/include/foo +ExpectedStdout: +MatchStdout: empty +ExpectedExitCode: 0 diff --git a/t/cli/env-allow-system-cflags.test b/t/cli/env-allow-system-cflags.test new file mode 100644 index 000000000000..019d3f14254d --- /dev/null +++ b/t/cli/env-allow-system-cflags.test @@ -0,0 +1,7 @@ +Tool: pkgconf +ToolArgs: --cflags-only-I cflags-libs-only +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_SYSTEM_INCLUDE_PATH=/test/local/include/foo +Environment: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 +ExpectedStdout: -I/test/local/include/foo +ExpectedExitCode: 0 diff --git a/t/cli/env-allow-system-libs-default.test b/t/cli/env-allow-system-libs-default.test new file mode 100644 index 000000000000..90803db8aeaa --- /dev/null +++ b/t/cli/env-allow-system-libs-default.test @@ -0,0 +1,7 @@ +Tool: pkgconf +ToolArgs: --libs-only-L cflags-libs-only +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_SYSTEM_LIBRARY_PATH=/test/local/lib +ExpectedStdout: +MatchStdout: empty +ExpectedExitCode: 0 diff --git a/t/cli/env-allow-system-libs.test b/t/cli/env-allow-system-libs.test new file mode 100644 index 000000000000..ecf9e846642e --- /dev/null +++ b/t/cli/env-allow-system-libs.test @@ -0,0 +1,7 @@ +Tool: pkgconf +ToolArgs: --libs-only-L cflags-libs-only +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_SYSTEM_LIBRARY_PATH=/test/local/lib +Environment: PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 +ExpectedStdout: -L/test/local/lib +ExpectedExitCode: 0 diff --git a/t/cli/env-dont-relocate-paths.test b/t/cli/env-dont-relocate-paths.test new file mode 100644 index 000000000000..0cf931d39f3b --- /dev/null +++ b/t/cli/env-dont-relocate-paths.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --libs bar +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_DONT_RELOCATE_PATHS=1 +ExpectedStdout: -L/test/lib -lbar -lfoo +ExpectedExitCode: 0 diff --git a/t/cli/env-early-trace.test b/t/cli/env-early-trace.test new file mode 100644 index 000000000000..4502a4be7127 --- /dev/null +++ b/t/cli/env-early-trace.test @@ -0,0 +1,8 @@ +Tool: pkgconf +ToolArgs: --exists foo 2>&1 +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_EARLY_TRACE=1 +ExpectedStdout: installing default unveil handler +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/env-log.test b/t/cli/env-log.test new file mode 100644 index 000000000000..0c71e673ac0f --- /dev/null +++ b/t/cli/env-log.test @@ -0,0 +1,9 @@ +Tool: pkgconf +ToolArgs: --exists foo; cat out/audit.log +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_LOG=out/audit.log +SetupMkdir: out +ExpectedStdout: foo [1.2.3] +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: windows diff --git a/t/cli/env-maximum-traverse-depth.test b/t/cli/env-maximum-traverse-depth.test new file mode 100644 index 000000000000..62fb03f59096 --- /dev/null +++ b/t/cli/env-maximum-traverse-depth.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --libs bar +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_MAXIMUM_TRAVERSE_DEPTH=1 +ExpectedStdout: -L/test/lib -lbar +ExpectedExitCode: 0 diff --git a/t/cli/env-msvc-syntax.test b/t/cli/env-msvc-syntax.test new file mode 100644 index 000000000000..60b49fb39023 --- /dev/null +++ b/t/cli/env-msvc-syntax.test @@ -0,0 +1,7 @@ +Tool: pkgconf +ToolArgs: --libs foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_MSVC_SYNTAX=1 +ExpectedStdout: /libpath:/test/lib foo.lib +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/env-only.test b/t/cli/env-only.test new file mode 100644 index 000000000000..db543ccf6f44 --- /dev/null +++ b/t/cli/env-only.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --env-only --libs foo +Environment: PKG_CONFIG_LIBDIR=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 1 diff --git a/t/cli/env-top-build-dir.test b/t/cli/env-top-build-dir.test new file mode 100644 index 000000000000..02beb8a917dc --- /dev/null +++ b/t/cli/env-top-build-dir.test @@ -0,0 +1,5 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --cflags top-builddir +Environment: PKG_CONFIG_TOP_BUILD_DIR=/my/build +ExpectedStdout: -I/my/build/include +ExpectedExitCode: 0 diff --git a/t/cli/env.test b/t/cli/env.test new file mode 100644 index 000000000000..49f773a30db4 --- /dev/null +++ b/t/cli/env.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --env=FOO --cflags --libs foo +ExpectedStdout: FOO_CFLAGS='-fPIC -I/test/include/foo' +ExpectedStdout: FOO_LIBS='-L/test/lib -lfoo' +MatchStdout: partial +ExpectedExitCode: 0 diff --git a/t/cli/exact-version-fail.test b/t/cli/exact-version-fail.test new file mode 100644 index 000000000000..09178f3d1344 --- /dev/null +++ b/t/cli/exact-version-fail.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --exact-version=1.2.4 foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 1 diff --git a/t/cli/exact-version-inline-constraint.test b/t/cli/exact-version-inline-constraint.test new file mode 100644 index 000000000000..1ca42b1f4913 --- /dev/null +++ b/t/cli/exact-version-inline-constraint.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --exact-version=1.2.3 "foo > 2" +ExpectedExitCode: 1 diff --git a/t/cli/exact-version-inline-overrides.test b/t/cli/exact-version-inline-overrides.test new file mode 100644 index 000000000000..72940975bf26 --- /dev/null +++ b/t/cli/exact-version-inline-overrides.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --exact-version=9 "foo > 1" +ExpectedExitCode: 0 diff --git a/t/cli/exact-version-pass.test b/t/cli/exact-version-pass.test new file mode 100644 index 000000000000..171f05ad3cb9 --- /dev/null +++ b/t/cli/exact-version-pass.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --exact-version=1.2.3 foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 0 diff --git a/t/cli/fragment-filter.test b/t/cli/fragment-filter.test new file mode 100644 index 000000000000..0746506dd155 --- /dev/null +++ b/t/cli/fragment-filter.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --fragment-filter=L --libs foo +ExpectedStdout: -L/test/lib +ExpectedExitCode: 0 diff --git a/t/cli/internal-cflags.test b/t/cli/internal-cflags.test new file mode 100644 index 000000000000..889e1cf148b1 --- /dev/null +++ b/t/cli/internal-cflags.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --internal-cflags --cflags requires-internal-2 +ExpectedStdout: -I/test/local/include/foo +ExpectedExitCode: 0 diff --git a/t/cli/keep-system-cflags-flag.test b/t/cli/keep-system-cflags-flag.test new file mode 100644 index 000000000000..8051d7520878 --- /dev/null +++ b/t/cli/keep-system-cflags-flag.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --keep-system-cflags --cflags-only-I cflags-libs-only +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_SYSTEM_INCLUDE_PATH=/test/local/include/foo +ExpectedStdout: -I/test/local/include/foo +ExpectedExitCode: 0 diff --git a/t/cli/keep-system-libs-flag.test b/t/cli/keep-system-libs-flag.test new file mode 100644 index 000000000000..db10db75525f --- /dev/null +++ b/t/cli/keep-system-libs-flag.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --keep-system-libs --libs-only-L cflags-libs-only +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +Environment: PKG_CONFIG_SYSTEM_LIBRARY_PATH=/test/local/lib +ExpectedStdout: -L/test/local/lib +ExpectedExitCode: 0 diff --git a/t/cli/list-package-names.test b/t/cli/list-package-names.test new file mode 100644 index 000000000000..eac0222adde0 --- /dev/null +++ b/t/cli/list-package-names.test @@ -0,0 +1,5 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --list-package-names +ExpectedStdout: pkg-config +MatchStdout: partial +ExpectedExitCode: 0 diff --git a/t/cli/log-file.test b/t/cli/log-file.test new file mode 100644 index 000000000000..e539f4212e10 --- /dev/null +++ b/t/cli/log-file.test @@ -0,0 +1,8 @@ +Tool: pkgconf +ToolArgs: --log-file=out/audit.log --exists foo; cat out/audit.log +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +SetupMkdir: out +ExpectedStdout: foo [1.2.3] +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: windows diff --git a/t/cli/max-version-fail.test b/t/cli/max-version-fail.test new file mode 100644 index 000000000000..1fe96b3d4fa8 --- /dev/null +++ b/t/cli/max-version-fail.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --max-version=1.0.0 foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 1 diff --git a/t/cli/max-version-inline-constraint.test b/t/cli/max-version-inline-constraint.test new file mode 100644 index 000000000000..c7b89f4b5999 --- /dev/null +++ b/t/cli/max-version-inline-constraint.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --max-version=9 "foo > 2" +ExpectedExitCode: 1 diff --git a/t/cli/max-version-inline-overrides.test b/t/cli/max-version-inline-overrides.test new file mode 100644 index 000000000000..63462b185bab --- /dev/null +++ b/t/cli/max-version-inline-overrides.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --max-version=0 "foo > 1" +ExpectedExitCode: 0 diff --git a/t/cli/max-version-pass.test b/t/cli/max-version-pass.test new file mode 100644 index 000000000000..5c2feaabdedd --- /dev/null +++ b/t/cli/max-version-pass.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --max-version=2.0.0 foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedExitCode: 0 diff --git a/t/cli/maximum-traverse-depth.test b/t/cli/maximum-traverse-depth.test new file mode 100644 index 000000000000..6bfd0706fc66 --- /dev/null +++ b/t/cli/maximum-traverse-depth.test @@ -0,0 +1,5 @@ +Tool: pkgconf +ToolArgs: --maximum-traverse-depth=1 --libs bar +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedStdout: -L/test/lib -lbar +ExpectedExitCode: 0 diff --git a/t/cli/no-cache.test b/t/cli/no-cache.test new file mode 100644 index 000000000000..988e54bcb99f --- /dev/null +++ b/t/cli/no-cache.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --no-cache --libs foo +ExpectedStdout: -L/test/lib -lfoo +ExpectedExitCode: 0 diff --git a/t/cli/no-provides.test b/t/cli/no-provides.test new file mode 100644 index 000000000000..e017bc5d296f --- /dev/null +++ b/t/cli/no-provides.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --no-provides --exists provides-test-foo +ExpectedExitCode: 1 diff --git a/t/cli/no-uninstalled.test b/t/cli/no-uninstalled.test new file mode 100644 index 000000000000..6e194fd63a26 --- /dev/null +++ b/t/cli/no-uninstalled.test @@ -0,0 +1,3 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --no-uninstalled --exists omg +ExpectedExitCode: 1 diff --git a/t/cli/path.test b/t/cli/path.test new file mode 100644 index 000000000000..a8a1f0165a21 --- /dev/null +++ b/t/cli/path.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --path foo +ExpectedStdout: %TEST_FIXTURES_DIR%/lib1 +ExpectedStdout: foo.pc +MatchStdout: partial +ExpectedExitCode: 0 diff --git a/t/cli/personality.test b/t/cli/personality.test new file mode 100644 index 000000000000..20ffaba959a9 --- /dev/null +++ b/t/cli/personality.test @@ -0,0 +1,5 @@ +Tool: pkgconf +ToolArgs: --personality=%TEST_FIXTURES_DIR%/personality-data/i386-linux-gnu.personality --variable=pc_path pkg-config +ExpectedStdout: /usr/lib/i386-linux-gnu/pkgconfig:/usr/share/pkgconfig +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/prefix-variable.test b/t/cli/prefix-variable.test new file mode 100644 index 000000000000..2dd6ccd7758b --- /dev/null +++ b/t/cli/prefix-variable.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --define-prefix --prefix-variable=prefix --variable=prefix %TEST_FIXTURES_DIR%/lib-relocatable/lib/pkgconfig/foo.pc +ExpectedStdout: %TEST_FIXTURES_DIR%/lib-relocatable +ExpectedExitCode: 0 diff --git a/t/cli/print-provides.test b/t/cli/print-provides.test new file mode 100644 index 000000000000..42ed931bc841 --- /dev/null +++ b/t/cli/print-provides.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --print-provides provides +ExpectedStdout: provides-test-foo = 1.0.0 +ExpectedStdout: provides-test-meow != 1.3.0 +MatchStdout: partial +ExpectedExitCode: 0 diff --git a/t/cli/print-requires-private.test b/t/cli/print-requires-private.test new file mode 100644 index 000000000000..0bd638667455 --- /dev/null +++ b/t/cli/print-requires-private.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --print-requires-private baz +ExpectedStdout: foo +ExpectedExitCode: 0 diff --git a/t/cli/print-requires.test b/t/cli/print-requires.test new file mode 100644 index 000000000000..e1975e7d96fe --- /dev/null +++ b/t/cli/print-requires.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --print-requires bar +ExpectedStdout: foo +ExpectedExitCode: 0 diff --git a/t/cli/print-variables.test b/t/cli/print-variables.test new file mode 100644 index 000000000000..34dc81da475f --- /dev/null +++ b/t/cli/print-variables.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --print-variables foo +ExpectedStdout: pcfiledir +ExpectedStdout: includedir +MatchStdout: partial +ExpectedExitCode: 0 diff --git a/t/cli/shared.test b/t/cli/shared.test new file mode 100644 index 000000000000..629fddcd2719 --- /dev/null +++ b/t/cli/shared.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --static --shared --libs baz +ExpectedStdout: -L/test/lib -lbaz +ExpectedExitCode: 0 diff --git a/t/cli/short-errors.test b/t/cli/short-errors.test new file mode 100644 index 000000000000..34c47fde69b0 --- /dev/null +++ b/t/cli/short-errors.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --short-errors --cflags nonexistent 2>&1 +ExpectedStdout: Package 'nonexistent' not found +ExpectedExitCode: 1 diff --git a/t/cli/silence-errors.test b/t/cli/silence-errors.test new file mode 100644 index 000000000000..93cf87d47641 --- /dev/null +++ b/t/cli/silence-errors.test @@ -0,0 +1,5 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --silence-errors --cflags nonexistent 2>&1 +ExpectedStdout: +MatchStdout: empty +ExpectedExitCode: 1 diff --git a/t/cli/simulate.test b/t/cli/simulate.test new file mode 100644 index 000000000000..dabd47dd8a3e --- /dev/null +++ b/t/cli/simulate.test @@ -0,0 +1,8 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --simulate bar +ExpectedStdout: node 'virtual:world' { +ExpectedStdout: node 'bar' { +ExpectedStdout: dependency 'foo'; +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/solution.test b/t/cli/solution.test new file mode 100644 index 000000000000..39f141b2b63e --- /dev/null +++ b/t/cli/solution.test @@ -0,0 +1,8 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --solution bar +ExpectedStdout: virtual:world +ExpectedStdout: bar +ExpectedStdout: foo +MatchStdout: partial +ExpectedExitCode: 0 +SkipPlatforms: lite diff --git a/t/cli/validate-warning.test b/t/cli/validate-warning.test new file mode 100644 index 000000000000..823dde3f5603 --- /dev/null +++ b/t/cli/validate-warning.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --validate malformed-version +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedStdout: warning: malformed version field with whitespace +MatchStdout: partial +ExpectedExitCode: 0 diff --git a/t/cli/validate.test b/t/cli/validate.test new file mode 100644 index 000000000000..cc1b1e98b686 --- /dev/null +++ b/t/cli/validate.test @@ -0,0 +1,6 @@ +Tool: pkgconf +ToolArgs: --validate foo +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib1 +ExpectedStdout: +MatchStdout: empty +ExpectedExitCode: 0 diff --git a/t/cli/variable.test b/t/cli/variable.test new file mode 100644 index 000000000000..d3cfe7f15497 --- /dev/null +++ b/t/cli/variable.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --variable=prefix foo +ExpectedStdout: /test +ExpectedExitCode: 0 diff --git a/t/cli/verbose.test b/t/cli/verbose.test new file mode 100644 index 000000000000..b7a02e6bc374 --- /dev/null +++ b/t/cli/verbose.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --verbose --modversion foo +ExpectedStdout: foo: 1.2.3 +ExpectedExitCode: 0 diff --git a/t/cli/with-path.test b/t/cli/with-path.test new file mode 100644 index 000000000000..0196261f0f9a --- /dev/null +++ b/t/cli/with-path.test @@ -0,0 +1,4 @@ +Tool: pkgconf +ToolArgs: --with-path=%TEST_FIXTURES_DIR%/lib1 --libs foo +ExpectedStdout: -L/test/lib -lfoo +ExpectedExitCode: 0 diff --git a/t/spdxtool/private-dependency.test b/t/spdxtool/private-dependency.test new file mode 100644 index 000000000000..3d21e0d254a0 --- /dev/null +++ b/t/spdxtool/private-dependency.test @@ -0,0 +1,5 @@ +Tool: spdxtool +ToolArgs: --creation-time=test priv-parent +Environment: PKG_CONFIG_PATH=%TEST_FIXTURES_DIR%/lib-sbom +ExpectedStdoutFile: ../../tests/lib-sbom-files/private_dependency.json +ExpectedExitCode: 0 diff --git a/t/sysroot/sysroot-differs-from-destdir-injects.test b/t/sysroot/sysroot-differs-from-destdir-injects.test new file mode 100644 index 000000000000..759ab54c8658 --- /dev/null +++ b/t/sysroot/sysroot-differs-from-destdir-injects.test @@ -0,0 +1,6 @@ +Environment: PKG_CONFIG_SYSROOT_DIR=/sysroot +Environment: DESTDIR=/other +PackageSearchPath: lib1 +Query: foo +WantedFlags: libs cflags +ExpectedStdout: -fPIC -I/sysroot/test/include/foo -L/sysroot/test/lib -lfoo diff --git a/t/sysroot/sysroot-equals-destdir-fdo-rules.test b/t/sysroot/sysroot-equals-destdir-fdo-rules.test new file mode 100644 index 000000000000..3145952c7c40 --- /dev/null +++ b/t/sysroot/sysroot-equals-destdir-fdo-rules.test @@ -0,0 +1,6 @@ +Environment: PKG_CONFIG_SYSROOT_DIR=/sysroot +Environment: DESTDIR=/sysroot +PackageSearchPath: lib1 +Query: foo +WantedFlags: libs cflags +ExpectedStdout: -fPIC -I/test/include/foo -L/test/lib -lfoo diff --git a/tests/api/oom.h b/tests/api/oom.h new file mode 100644 index 000000000000..2d3818c86b52 --- /dev/null +++ b/tests/api/oom.h @@ -0,0 +1,59 @@ +/* + * oom.h + * Exhaustive allocation-failure test driver, built on the fuzzer/alloc-inject + * fault injector. + * + * SPDX-License-Identifier: pkgconf + * + * Copyright (c) 2026 pkgconf authors (see AUTHORS). + * + * 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. + */ + +#ifndef TEST_API_OOM_H +#define TEST_API_OOM_H + +#include "test-api.h" +#include "alloc-inject.h" + +/* + * Exhaustively fail each successive allocation an expression makes until it can + * complete with none failing. Every injected failure must be reported + * gracefully (NULL for OOM_TEST_PTR, false for OOM_TEST_BOOL); on the run where + * no allocation fails the value succeeds and the loop ends. Under ASAN this + * also asserts each partial-construction error path leaks nothing. + */ +#define OOM_TEST_PTR(objvar, make_expr, free_stmt) \ + do { \ + for (unsigned long _oom_n = 1; ; _oom_n++) \ + { \ + alloc_inject_arm(_oom_n); \ + (objvar) = (make_expr); \ + bool _oom_f = alloc_inject_fired(); \ + alloc_inject_disarm(); \ + if (!_oom_f) { free_stmt; break; } \ + TEST_ASSERT_NULL(objvar); \ + free_stmt; \ + } \ + } while (0) + +#define OOM_TEST_BOOL(make_expr) \ + do { \ + for (unsigned long _oom_n = 1; ; _oom_n++) \ + { \ + alloc_inject_arm(_oom_n); \ + bool _oom_ok = (make_expr); \ + bool _oom_f = alloc_inject_fired(); \ + alloc_inject_disarm(); \ + if (!_oom_f) { TEST_ASSERT_TRUE(_oom_ok); break; } \ + TEST_ASSERT_FALSE(_oom_ok); \ + } \ + } while (0) + +#endif // TEST_API_OOM_H diff --git a/tests/api/test-oom-spdxtool.c b/tests/api/test-oom-spdxtool.c new file mode 100644 index 000000000000..aa3b36c1c013 --- /dev/null +++ b/tests/api/test-oom-spdxtool.c @@ -0,0 +1,160 @@ +/* + * test-oom.c + * Allocation-failure (OOM) tests for spdxtool, using the oom.h injection + * harness. For each target, a failure is injected at every successive + * allocation; the target must report the error gracefully (NULL) and, under + * ASAN, leak nothing on the error path. + * + * SPDX-License-Identifier: pkgconf + * + * Copyright (c) 2026 pkgconf authors (see AUTHORS). + * + * 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. + */ + +#include <libpkgconf/stdinc.h> +#include <libpkgconf/libpkgconf.h> +#include "oom.h" +#include "core.h" +#include "software.h" +#include "simplelicensing.h" +#include "serialize.h" +#include "util.h" + +static pkgconf_client_t *g_client; + +static void +oom_setup(void) +{ + g_client = test_client_new(); + // Mirror cli/spdxtool/main.c: the constructors read these globals + spdxtool_util_set_uri_root(g_client, "https://example.com/test"); + spdxtool_util_set_uri_separator_colon(g_client, false); + spdxtool_util_set_spdx_version(g_client, "3.0.1"); + spdxtool_util_set_spdx_license(g_client, "CC0-1.0"); +} + +/* + * ============================================== + * core / software / simplelicensing constructors + * ============================================== + */ + +static void +test_oom_agent_new(void) +{ + spdxtool_core_agent_t *a; + OOM_TEST_PTR(a, spdxtool_core_agent_new(g_client, "_:c1", "Agent Name"), spdxtool_core_agent_free(a)); +} + +static void +test_oom_creation_info_new(void) +{ + spdxtool_core_creation_info_t *c; + // NULL time exercises the get_current_iso8601_time() strdup path too + OOM_TEST_PTR(c, spdxtool_core_creation_info_new(g_client, "agentid", "_:c1", NULL), + spdxtool_core_creation_info_free(c)); +} + +static void +test_oom_spdx_document_new(void) +{ + spdxtool_core_spdx_document_t *d; + OOM_TEST_PTR(d, spdxtool_core_spdx_document_new(g_client, "docid", "_:c1", "agentid"), + spdxtool_core_spdx_document_free(d)); +} + +static void +test_oom_sbom_new(void) +{ + spdxtool_software_sbom_t *s; + OOM_TEST_PTR(s, spdxtool_software_sbom_new(g_client, "sbomid", "_:c1", "build"), spdxtool_software_sbom_free(s)); +} + +static void +test_oom_license_expression_new(void) +{ + spdxtool_simplelicensing_license_expression_t *e; + OOM_TEST_PTR(e, spdxtool_simplelicensing_licenseExpression_new(g_client, "MIT"), + spdxtool_simplelicensing_licenseExpression_free(e)); +} + +/* + * ====================== + * serializer value model + * ====================== + */ + +static void +test_oom_serialize_constructors(void) +{ + spdxtool_serialize_object_list_t *o; + OOM_TEST_PTR(o, spdxtool_serialize_object_list_new(), spdxtool_serialize_object_list_free(o)); + + spdxtool_serialize_array_t *a; + OOM_TEST_PTR(a, spdxtool_serialize_array_new(), spdxtool_serialize_array_free(a)); + + spdxtool_serialize_value_t *v; + OOM_TEST_PTR(v, spdxtool_serialize_value_string("hello"), spdxtool_serialize_value_free(v)); + OOM_TEST_PTR(v, spdxtool_serialize_value_int(7), spdxtool_serialize_value_free(v)); + OOM_TEST_PTR(v, spdxtool_serialize_value_bool(true), spdxtool_serialize_value_free(v)); + OOM_TEST_PTR(v, spdxtool_serialize_value_null(), spdxtool_serialize_value_free(v)); +} + +/* + * ============================================================ + * *_to_object serializers that depend only on their own struct + * ============================================================ + */ + +static void +test_oom_to_object(void) +{ + spdxtool_serialize_value_t *v; + + spdxtool_core_agent_t *agent = spdxtool_core_agent_new(g_client, "_:c1", "Agent"); + TEST_ASSERT_NONNULL(agent); + OOM_TEST_PTR(v, spdxtool_core_agent_to_object(g_client, agent), + spdxtool_serialize_value_free(v)); + spdxtool_core_agent_free(agent); + + spdxtool_core_creation_info_t *ci = + spdxtool_core_creation_info_new(g_client, "agentid", "_:c1", "2020-01-01T00:00:00Z"); + TEST_ASSERT_NONNULL(ci); + OOM_TEST_PTR(v, spdxtool_core_creation_info_to_object(g_client, ci), + spdxtool_serialize_value_free(v)); + spdxtool_core_creation_info_free(ci); + + spdxtool_simplelicensing_license_expression_t *le = + spdxtool_simplelicensing_licenseExpression_new(g_client, "MIT"); + TEST_ASSERT_NONNULL(le); + OOM_TEST_PTR(v, spdxtool_simplelicensing_licenseExpression_to_object(g_client, "_:c1", le), + spdxtool_serialize_value_free(v)); + spdxtool_simplelicensing_licenseExpression_free(le); +} + +int +main(int argc, const char **argv) +{ + (void) argc; + const char *basename = pkgconf_path_find_basename(argv[0]); + + oom_setup(); + + TEST_RUN(basename, test_oom_agent_new); + TEST_RUN(basename, test_oom_creation_info_new); + TEST_RUN(basename, test_oom_spdx_document_new); + TEST_RUN(basename, test_oom_sbom_new); + TEST_RUN(basename, test_oom_license_expression_new); + TEST_RUN(basename, test_oom_serialize_constructors); + TEST_RUN(basename, test_oom_to_object); + + pkgconf_client_free(g_client); + return EXIT_SUCCESS; +} diff --git a/tests/api/test-path-utils.c b/tests/api/test-path-utils.c index 519cadb6f639..029f03b052a5 100644 --- a/tests/api/test-path-utils.c +++ b/tests/api/test-path-utils.c @@ -105,6 +105,154 @@ test_determine_prefix_logic(void) pkgconf_buffer_finalize(&buf); } +static const char * +nth_path(const pkgconf_list_t *list, size_t idx) +{ + pkgconf_node_t *n; + size_t i = 0; + + PKGCONF_FOREACH_LIST_ENTRY(list->head, n) + { + const pkgconf_path_t *p = n->data; + + if (i++ == idx) + return p->path; + } + + return NULL; +} + +static void +test_path_prepend(void) +{ + pkgconf_list_t list = PKGCONF_LIST_INITIALIZER; + + pkgconf_path_prepend("/a", &list, false); + pkgconf_path_prepend("/b", &list, false); + pkgconf_path_prepend("/c", &list, false); + + TEST_ASSERT_EQ(list.length, 3); + TEST_ASSERT_STRCMP_EQ(nth_path(&list, 0), "/c"); + TEST_ASSERT_STRCMP_EQ(nth_path(&list, 1), "/b"); + TEST_ASSERT_STRCMP_EQ(nth_path(&list, 2), "/a"); + + pkgconf_path_add("/d", &list, false); + TEST_ASSERT_EQ(list.length, 4); + TEST_ASSERT_STRCMP_EQ(nth_path(&list, 0), "/c"); + TEST_ASSERT_STRCMP_EQ(nth_path(&list, 3), "/d"); + + pkgconf_path_prepend("/e//f", &list, false); + TEST_ASSERT_STRCMP_EQ(nth_path(&list, 0), "/e/f"); + + pkgconf_path_free(&list); + TEST_ASSERT_EQ(list.length, 0); + TEST_ASSERT_NULL(list.head); + TEST_ASSERT_NULL(list.tail); +} + +static void +test_path_prepend_filter(void) +{ + pkgconf_list_t list = PKGCONF_LIST_INITIALIZER; + + pkgconf_path_prepend(".", &list, true); + TEST_ASSERT_EQ(list.length, 1); + + pkgconf_path_prepend(".", &list, true); + TEST_ASSERT_EQ(list.length, 1); + + pkgconf_path_prepend("..", &list, true); + TEST_ASSERT_EQ(list.length, 2); + + pkgconf_path_prepend(".", &list, false); + TEST_ASSERT_EQ(list.length, 3); + + pkgconf_path_free(&list); +} + +static void +test_path_prepend_list(void) +{ + pkgconf_list_t src = PKGCONF_LIST_INITIALIZER; + pkgconf_list_t dst = PKGCONF_LIST_INITIALIZER; + + pkgconf_path_add("/s1", &src, false); + pkgconf_path_add("/s2", &src, false); + pkgconf_path_add("/s3", &src, false); + + pkgconf_path_add("/d1", &dst, false); + pkgconf_path_add("/d2", &dst, false); + + pkgconf_path_prepend_list(&dst, &src); + + TEST_ASSERT_EQ(dst.length, 5); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 0), "/s3"); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 1), "/s2"); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 2), "/s1"); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 3), "/d1"); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 4), "/d2"); + + TEST_ASSERT_EQ(src.length, 3); + TEST_ASSERT_STRCMP_EQ(nth_path(&src, 0), "/s1"); + TEST_ASSERT_TRUE(nth_path(&dst, 2) != nth_path(&src, 0)); + + pkgconf_path_free(&dst); + TEST_ASSERT_EQ(dst.length, 0); + + TEST_ASSERT_EQ(src.length, 3); + TEST_ASSERT_STRCMP_EQ(nth_path(&src, 2), "/s3"); + + pkgconf_path_prepend_list(&dst, &src); + TEST_ASSERT_EQ(dst.length, 3); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 0), "/s3"); + TEST_ASSERT_STRCMP_EQ(nth_path(&dst, 2), "/s1"); + + pkgconf_path_free(&src); + pkgconf_path_free(&dst); +} + +static bool +plausible(const char *text) +{ + pkgconf_buffer_t buf = PKGCONF_BUFFER_INITIALIZER; + bool result; + + pkgconf_buffer_append(&buf, text); + result = pkgconf_path_is_plausible(&buf); + pkgconf_buffer_finalize(&buf); + + return result; +} + +static void +test_path_is_plausible(void) +{ + pkgconf_buffer_t empty = PKGCONF_BUFFER_INITIALIZER; + + TEST_ASSERT_FALSE(pkgconf_path_is_plausible(NULL)); + TEST_ASSERT_FALSE(pkgconf_path_is_plausible(&empty)); + pkgconf_buffer_finalize(&empty); + + TEST_ASSERT_FALSE(plausible("")); + TEST_ASSERT_FALSE(plausible(" ")); + TEST_ASSERT_FALSE(plausible("libfoo")); + TEST_ASSERT_FALSE(plausible("foo bar")); + TEST_ASSERT_FALSE(plausible(".")); + TEST_ASSERT_FALSE(plausible("..")); + + TEST_ASSERT_TRUE(plausible("/usr/lib/pkgconfig")); + TEST_ASSERT_TRUE(plausible(" /usr/lib")); + TEST_ASSERT_TRUE(plausible("./foo")); + TEST_ASSERT_TRUE(plausible("../foo")); + TEST_ASSERT_TRUE(plausible(".\\foo")); + TEST_ASSERT_TRUE(plausible("..\\foo")); + TEST_ASSERT_TRUE(plausible("C:/foo")); + TEST_ASSERT_TRUE(plausible("C:\\foo")); + TEST_ASSERT_TRUE(plausible("relative/path")); + TEST_ASSERT_TRUE(plausible("relative\\path")); + TEST_ASSERT_TRUE(plausible("Program Files/MySDK")); +} + int main(int argc, char *argv[]) { @@ -114,6 +262,10 @@ main(int argc, char *argv[]) TEST_RUN(basename, test_path_find_basename); TEST_RUN(basename, test_path_trim_basename); TEST_RUN(basename, test_determine_prefix_logic); + TEST_RUN(basename, test_path_prepend); + TEST_RUN(basename, test_path_prepend_filter); + TEST_RUN(basename, test_path_prepend_list); + TEST_RUN(basename, test_path_is_plausible); return EXIT_SUCCESS; } diff --git a/tests/api/test-personality.c b/tests/api/test-personality.c new file mode 100644 index 000000000000..11d44854411d --- /dev/null +++ b/tests/api/test-personality.c @@ -0,0 +1,187 @@ +/* + * test-personality.c + * Tests for libpkgconf personality functions. + * + * SPDX-License-Identifier: pkgconf + * + * Copyright (c) 2026 pkgconf authors (see AUTHORS). + * + * 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. + */ + +#include "test-api.h" + +static void +test_personality_deinit_null(void) +{ + // Should not crash + pkgconf_cross_personality_deinit(NULL); +} + +static void +test_personality_default_refcount(void) +{ + pkgconf_cross_personality_t *p1 = pkgconf_cross_personality_default(); + pkgconf_cross_personality_t *p2 = pkgconf_cross_personality_default(); + + TEST_ASSERT_NONNULL(p1); + TEST_ASSERT_NONNULL(p2); + // Both calls must return the same singleton pointer + TEST_ASSERT_EQ((long long)(uintptr_t)p1, (long long)(uintptr_t)p2); + + // Refcount is 2 -> first deinit drops it to 1, must not free + pkgconf_cross_personality_deinit(p1); + // Refcount is 1 -> second deinit drops to 0, frees internal state + pkgconf_cross_personality_deinit(p2); + + // Re-initialise from scratch + pkgconf_cross_personality_t *p3 = pkgconf_cross_personality_default(); + TEST_ASSERT_NONNULL(p3); + pkgconf_cross_personality_deinit(p3); +} + +#ifndef PKGCONF_LITE + +static void +test_personality_find_invalid_triplet(void) +{ + /* "bad triplet!" has a space and '!' — both rejected by valid_triplet, + * and the direct-file open will also fail, so result must be NULL. */ + pkgconf_cross_personality_t *p = pkgconf_cross_personality_find("bad triplet!"); + TEST_ASSERT_NULL(p); +} + +static void +test_personality_find_direct_path(void) +{ + char path[] = "test-personality-XXXXXX"; + int fd = mkstemp(path); + TEST_ASSERT_TRUE(fd >= 0); + + FILE *f = fdopen(fd, "w"); + TEST_ASSERT_NONNULL(f); + + fprintf(f, + "Triplet: x86_64-linux-musl\n" + "DefaultSearchPaths: /usr/lib/pkgconfig:/usr/share/pkgconfig\n" + "SysrootDir: /opt/sysroot\n" + "SystemIncludePaths: /opt/sysroot/usr/include\n" + "SystemLibraryPaths: /opt/sysroot/usr/lib\n" + "WantDefaultStatic: true\n" + "WantDefaultPure: yes\n"); + fclose(f); + + pkgconf_cross_personality_t *p = pkgconf_cross_personality_find(path); + TEST_ASSERT_NONNULL(p); + TEST_ASSERT_STRCMP_EQ(p->name, "x86_64-linux-musl"); + TEST_ASSERT_NONNULL(p->sysroot_dir); + TEST_ASSERT_STRCMP_EQ(p->sysroot_dir, "/opt/sysroot"); + TEST_ASSERT_TRUE(p->want_default_static); + TEST_ASSERT_TRUE(p->want_default_pure); + TEST_ASSERT_NONNULL(p->dir_list.head); + + // Exercises the non-default free path + pkgconf_cross_personality_deinit(p); + unlink(path); +} + +#if !defined(_WIN32) && !defined(__HAIKU__) + +static void +test_personality_find_via_xdg(void) +{ + char tmpdir[] = "test-personality-xdg-XXXXXX"; + char *d = mkdtemp(tmpdir); + TEST_ASSERT_NONNULL(d); + + // build: <tmpdir>/pkgconfig/personality.d/ + char pkgconfig_dir[4096]; + char personality_d[4096]; + char file_path[4096]; + + snprintf(pkgconfig_dir, sizeof pkgconfig_dir, "%s/pkgconfig", tmpdir); + snprintf(personality_d, sizeof personality_d, "%s/pkgconfig/personality.d", tmpdir); + snprintf(file_path, sizeof file_path, "%s/pkgconfig/personality.d/xdg-test-triplet.personality", tmpdir); + + TEST_ASSERT_EQ(mkdir(pkgconfig_dir, 0755), 0); + TEST_ASSERT_EQ(mkdir(personality_d, 0755), 0); + + FILE *f = fopen(file_path, "w"); + TEST_ASSERT_NONNULL(f); + fprintf(f, "SysrootDir: /xdg/sysroot\n"); + fclose(f); + + setenv("XDG_DATA_HOME", tmpdir, 1); + + pkgconf_cross_personality_t *p = pkgconf_cross_personality_find("xdg-test-triplet"); + TEST_ASSERT_NONNULL(p); + TEST_ASSERT_NONNULL(p->sysroot_dir); + TEST_ASSERT_STRCMP_EQ(p->sysroot_dir, "/xdg/sysroot"); + + // Verify it is NOT the default singleton + pkgconf_cross_personality_t *def = pkgconf_cross_personality_default(); + TEST_ASSERT_NE((long long)(uintptr_t)p, (long long)(uintptr_t)def); + // Balance the _default() call above + pkgconf_cross_personality_deinit(def); + + // Clean up + pkgconf_cross_personality_deinit(p); + unsetenv("XDG_DATA_HOME"); + + unlink(file_path); + rmdir(personality_d); + rmdir(pkgconfig_dir); + rmdir(tmpdir); +} + +#endif // !_WIN32 && !__HAIKU__ + +static void +test_personality_find_missing_returns_default(void) +{ + // clear XDG / HOME so search goes to known-empty places + unsetenv("XDG_DATA_HOME"); + unsetenv("XDG_DATA_DIRS"); + unsetenv("HOME"); + + pkgconf_cross_personality_t *found = pkgconf_cross_personality_find("nonexistent-triplet-xyzzy"); + TEST_ASSERT_NONNULL(found); + + // The find internally called _default(); call it ourselves to compare + pkgconf_cross_personality_t *def = pkgconf_cross_personality_default(); + TEST_ASSERT_EQ((long long)(uintptr_t)found, (long long)(uintptr_t)def); + + // Two deinits: one for find's internal _default(), one for ours above + pkgconf_cross_personality_deinit(found); + pkgconf_cross_personality_deinit(def); +} + +#endif /* !PKGCONF_LITE */ + +int +main(int argc, char *argv[]) +{ + (void) argc; + const char *basename = pkgconf_path_find_basename(argv[0]); + + // refcount test must run first so the singleton starts at 0 + TEST_RUN(basename, test_personality_deinit_null); + TEST_RUN(basename, test_personality_default_refcount); + +#ifndef PKGCONF_LITE + TEST_RUN(basename, test_personality_find_invalid_triplet); + TEST_RUN(basename, test_personality_find_direct_path); +#if !defined(_WIN32) && !defined(__HAIKU__) + TEST_RUN(basename, test_personality_find_via_xdg); +#endif + TEST_RUN(basename, test_personality_find_missing_returns_default); +#endif + + return EXIT_SUCCESS; +} diff --git a/tests/api/test-queue.c b/tests/api/test-queue.c new file mode 100644 index 000000000000..e18903c2fd9d --- /dev/null +++ b/tests/api/test-queue.c @@ -0,0 +1,250 @@ +/* + * test-queue.c + * Tests for the public libpkgconf queue API. + * + * SPDX-License-Identifier: pkgconf + * + * Copyright (c) 2026 pkgconf authors (see AUTHORS). + * + * 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. + */ + +#include "test-api.h" + +#define FIXTURE_DIR "test-queue-pcdir" + +static void +write_pc(const char *name, const char *contents) +{ + char path[512]; + FILE *f; + + snprintf(path, sizeof path, "%s/%s", FIXTURE_DIR, name); + f = fopen(path, "wb"); + TEST_ASSERT_NONNULL(f); + fwrite(contents, 1, strlen(contents), f); + fclose(f); +} + +static void +setup_fixtures(void) +{ + mkdir(FIXTURE_DIR, 0755); + write_pc("qbar.pc", "Name: qbar\nDescription: bar\nVersion: 2.0\n"); + write_pc("qfoo.pc", + "Name: qfoo\nDescription: foo\nVersion: 1.0\nRequires: qbar >= 1.0\n"); +} + +static void +teardown_fixtures(void) +{ + remove(FIXTURE_DIR "/qfoo.pc"); + remove(FIXTURE_DIR "/qbar.pc"); + rmdir(FIXTURE_DIR); +} + +static pkgconf_client_t * +fixture_client(void) +{ + pkgconf_client_t *client = test_client_new(); + + pkgconf_path_free(&client->dir_list); + pkgconf_path_add(FIXTURE_DIR, &client->dir_list, false); + + return client; +} + +static size_t +required_count(const pkgconf_pkg_t *world) +{ + size_t n = 0; + const pkgconf_node_t *iter; + + PKGCONF_FOREACH_LIST_ENTRY(world->required.head, iter) + { + n++; + } + + return n; +} + +static bool +contains_dep(const pkgconf_pkg_t *world, const char *name) +{ + const pkgconf_node_t *iter; + + PKGCONF_FOREACH_LIST_ENTRY(world->required.head, iter) + { + const pkgconf_dependency_t *dep = iter->data; + + if (!strcmp(dep->package, name)) + return true; + } + + return false; +} + +static void +test_queue_validate_success(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + + pkgconf_queue_push(&queue, "qfoo"); + TEST_ASSERT_TRUE(pkgconf_queue_validate(client, &queue, -1)); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +static void +test_queue_validate_version_satisfied(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + + pkgconf_queue_push(&queue, "qbar >= 1.0"); + TEST_ASSERT_TRUE(pkgconf_queue_validate(client, &queue, -1)); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +static void +test_queue_validate_missing_package(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + + pkgconf_queue_push(&queue, "does-not-exist"); + TEST_ASSERT_FALSE(pkgconf_queue_validate(client, &queue, -1)); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +static void +test_queue_validate_unsatisfiable_version(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + + pkgconf_queue_push(&queue, "qbar >= 99.0"); + TEST_ASSERT_FALSE(pkgconf_queue_validate(client, &queue, -1)); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +static void +test_queue_validate_empty(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + + TEST_ASSERT_FALSE(pkgconf_queue_validate(client, &queue, -1)); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +struct apply_state { + int calls; + size_t deps; + bool saw_qfoo; + bool saw_qbar; + bool retval; +}; + +static bool +apply_cb(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth) +{ + struct apply_state *st = data; + + (void) client; + (void) maxdepth; + + st->calls++; + st->deps = required_count(world); + st->saw_qfoo = contains_dep(world, "qfoo"); + st->saw_qbar = contains_dep(world, "qbar"); + + return st->retval; +} + +static void +test_queue_apply_success(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + struct apply_state st = { .retval = true }; + + pkgconf_queue_push(&queue, "qfoo"); + TEST_ASSERT_TRUE(pkgconf_queue_apply(client, &queue, apply_cb, -1, &st)); + + TEST_ASSERT_EQ(st.calls, 1); + TEST_ASSERT_GE(st.deps, 2); + TEST_ASSERT_TRUE(st.saw_qfoo); + TEST_ASSERT_TRUE(st.saw_qbar); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +static void +test_queue_apply_callback_failure(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + struct apply_state st = { .retval = false }; + + pkgconf_queue_push(&queue, "qfoo"); + TEST_ASSERT_FALSE(pkgconf_queue_apply(client, &queue, apply_cb, -1, &st)); + TEST_ASSERT_EQ(st.calls, 1); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +static void +test_queue_apply_missing_package(void) +{ + pkgconf_client_t *client = fixture_client(); + pkgconf_list_t queue = PKGCONF_LIST_INITIALIZER; + struct apply_state st = { .retval = true }; + + pkgconf_queue_push(&queue, "does-not-exist"); + TEST_ASSERT_FALSE(pkgconf_queue_apply(client, &queue, apply_cb, -1, &st)); + TEST_ASSERT_EQ(st.calls, 0); + + pkgconf_queue_free(&queue); + pkgconf_client_free(client); +} + +int +main(int argc, char *argv[]) +{ + (void) argc; + const char *basename = pkgconf_path_find_basename(argv[0]); + + setup_fixtures(); + + TEST_RUN(basename, test_queue_validate_success); + TEST_RUN(basename, test_queue_validate_version_satisfied); + TEST_RUN(basename, test_queue_validate_missing_package); + TEST_RUN(basename, test_queue_validate_unsatisfiable_version); + TEST_RUN(basename, test_queue_validate_empty); + TEST_RUN(basename, test_queue_apply_success); + TEST_RUN(basename, test_queue_apply_callback_failure); + TEST_RUN(basename, test_queue_apply_missing_package); + + teardown_fixtures(); + + return EXIT_SUCCESS; +} diff --git a/tests/api/test-version.c b/tests/api/test-version.c new file mode 100644 index 000000000000..71ed2c1de811 --- /dev/null +++ b/tests/api/test-version.c @@ -0,0 +1,133 @@ +/* + * test-version.c + * Tests for the public libpkgconf version comparison API. + * + * SPDX-License-Identifier: pkgconf + * + * Copyright (c) 2026 pkgconf authors (see AUTHORS). + * + * 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. + */ + +#include "test-api.h" + +static void +cmp_lt(const char *a, const char *b) +{ + TEST_ASSERT_EQ(pkgconf_compare_version(a, b), -1); + TEST_ASSERT_EQ(pkgconf_compare_version(b, a), 1); +} + +static void +cmp_eq(const char *a, const char *b) +{ + TEST_ASSERT_EQ(pkgconf_compare_version(a, b), 0); + TEST_ASSERT_EQ(pkgconf_compare_version(b, a), 0); +} + +static void +test_version_equal(void) +{ + cmp_eq("1.0.0", "1.0.0"); + cmp_eq("", ""); + cmp_eq("abc", "abc"); + cmp_eq("1.0a", "1.0A"); + cmp_eq("RELEASE", "release"); +} + +static void +test_version_null(void) +{ + TEST_ASSERT_EQ(pkgconf_compare_version(NULL, NULL), -1); + cmp_lt(NULL, "1.0"); + cmp_lt(NULL, ""); +} + +static void +test_version_numeric(void) +{ + cmp_lt("1.0.0", "1.0.1"); + cmp_lt("0.9", "1.0"); + cmp_lt("1.9.9", "2.0.0"); + cmp_lt("1.9", "1.10"); + cmp_lt("1.9", "1.100"); +} + +static void +test_version_leading_zeros(void) +{ + cmp_eq("1.0", "1.00"); + cmp_eq("1.7", "1.007"); + cmp_eq("01.02.03", "1.2.3"); + cmp_lt("1.0.1", "1.0.10"); +} + +static void +test_version_component_count(void) +{ + cmp_lt("1.0", "1.0.1"); + cmp_lt("1.0", "1.0.0"); + cmp_lt("1.2.3", "1.2.3.1"); +} + +static void +test_version_separators(void) +{ + cmp_eq("1.2.3", "1-2-3"); + cmp_eq("1.2.3", "1_2_3"); + cmp_eq("1.2.3", "1:2:3"); + cmp_eq("1.0", "1...0"); +} + +static void +test_version_tilde(void) +{ + cmp_lt("1.0~rc1", "1.0"); + cmp_lt("1.0~rc1", "1.0~rc2"); + cmp_lt("1.0~~", "1.0~"); + cmp_lt("1.0~1", "1.0.1"); + cmp_lt("1.0.0~beta", "1.0.0"); +} + +static void +test_version_alpha_numeric(void) +{ + cmp_lt("1.b", "1.5"); + cmp_lt("1.0.alpha", "1.0.beta"); + cmp_lt("1.0alpha", "1.0alphabeta"); + cmp_lt("1.0", "1.0pre"); +} + +static void +test_version_real_world(void) +{ + cmp_lt("2.5.1", "2.9.91"); + cmp_lt("2.9.91", "3.0.0"); + cmp_lt("1.0.0~beta", "1.0.0~rc1"); + cmp_lt("1.0.0~rc1", "1.0.0"); +} + +int +main(int argc, char *argv[]) +{ + (void) argc; + const char *basename = pkgconf_path_find_basename(argv[0]); + + TEST_RUN(basename, test_version_equal); + TEST_RUN(basename, test_version_null); + TEST_RUN(basename, test_version_numeric); + TEST_RUN(basename, test_version_leading_zeros); + TEST_RUN(basename, test_version_component_count); + TEST_RUN(basename, test_version_separators); + TEST_RUN(basename, test_version_tilde); + TEST_RUN(basename, test_version_alpha_numeric); + TEST_RUN(basename, test_version_real_world); + + return EXIT_SUCCESS; +} diff --git a/tests/lib-sbom-files/agent_name.json b/tests/lib-sbom-files/agent_name.json index 4441e714331f..37694702a5bc 100644 --- a/tests/lib-sbom-files/agent_name.json +++ b/tests/lib-sbom-files/agent_name.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/myagent" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/myagent", + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasConcludedLicense", diff --git a/tests/lib-sbom-files/agent_name_space.json b/tests/lib-sbom-files/agent_name_space.json index e29416adba4e..c773ce8ed5f4 100644 --- a/tests/lib-sbom-files/agent_name_space.json +++ b/tests/lib-sbom-files/agent_name_space.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/my_agent" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/my_agent", + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasConcludedLicense", diff --git a/tests/lib-sbom-files/basic-spdx-base-id.json b/tests/lib-sbom-files/basic-spdx-base-id.json index f9c67b9b9cfb..6271c947609f 100644 --- a/tests/lib-sbom-files/basic-spdx-base-id.json +++ b/tests/lib-sbom-files/basic-spdx-base-id.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://distfiles.ariadne.space/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://distfiles.ariadne.space/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "https://distfiles.ariadne.space/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://distfiles.ariadne.space/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "https://distfiles.ariadne.space/pkgconf/Agent/default", + "https://distfiles.ariadne.space/pkgconf/Agent/test3_maintainer", "https://distfiles.ariadne.space/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", "https://distfiles.ariadne.space/pkgconf/Relationship/test3/hasDeclaredLicense", "https://distfiles.ariadne.space/pkgconf/Relationship/test3/hasConcludedLicense", diff --git a/tests/lib-sbom-files/basic-use-uri.json b/tests/lib-sbom-files/basic-use-uri.json index e9913a92a764..338493050545 100644 --- a/tests/lib-sbom-files/basic-use-uri.json +++ b/tests/lib-sbom-files/basic-use-uri.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "github.com:pkgconf:pkgconf:Agent:test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "github.com:pkgconf:pkgconf:simplelicensing_LicenseExpression:BSD-4-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "github.com:pkgconf:pkgconf:Agent:default" ], + "suppliedBy": [ + "github.com:pkgconf:pkgconf:Agent:test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "github.com:pkgconf:pkgconf:Agent:default", + "github.com:pkgconf:pkgconf:Agent:test3_maintainer", "github.com:pkgconf:pkgconf:simplelicensing_LicenseExpression:BSD-4-Clause", "github.com:pkgconf:pkgconf:Relationship:test3:hasDeclaredLicense", "github.com:pkgconf:pkgconf:Relationship:test3:hasConcludedLicense", diff --git a/tests/lib-sbom-files/basic.json b/tests/lib-sbom-files/basic.json index 3b241ff3442d..b924b0317604 100644 --- a/tests/lib-sbom-files/basic.json +++ b/tests/lib-sbom-files/basic.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasConcludedLicense", diff --git a/tests/lib-sbom-files/bomtool-basic.txt b/tests/lib-sbom-files/bomtool-basic.txt index 9adeec9ae8dc..6c1fa22e8a6c 100644 --- a/tests/lib-sbom-files/bomtool-basic.txt +++ b/tests/lib-sbom-files/bomtool-basic.txt @@ -13,6 +13,7 @@ PackageName: test3@3.0.0 SPDXID: SPDXRef-Package-test3C403.0.0 PackageVersion: 3.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test3 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: BSD-4-Clause PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-define_variable.txt b/tests/lib-sbom-files/bomtool-define_variable.txt index 95478ffc6431..13fa3a04a042 100644 --- a/tests/lib-sbom-files/bomtool-define_variable.txt +++ b/tests/lib-sbom-files/bomtool-define_variable.txt @@ -13,6 +13,7 @@ PackageName: variable-test1@1.0-123 SPDXID: SPDXRef-Package-variable-test1C401.0-123 PackageVersion: 1.0-123 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Variabletest1 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/releases/ PackageLicenseDeclared: BSD-2-Clause PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-define_variable_with_dependency.txt b/tests/lib-sbom-files/bomtool-define_variable_with_dependency.txt index 571ec7cc58ea..6ced6ec3e758 100644 --- a/tests/lib-sbom-files/bomtool-define_variable_with_dependency.txt +++ b/tests/lib-sbom-files/bomtool-define_variable_with_dependency.txt @@ -13,6 +13,7 @@ PackageName: variable-test2@2.0 SPDXID: SPDXRef-Package-variable-test2C402.0 PackageVersion: 2.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Variabletest2 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/releases/ PackageLicenseDeclared: MIT PackageLicenseConcluded: NOASSERTION @@ -27,6 +28,7 @@ PackageName: variable-test1@1.0-123 SPDXID: SPDXRef-Package-variable-test1C401.0-123 PackageVersion: 1.0-123 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Variabletest1 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/releases/ PackageLicenseDeclared: BSD-2-Clause PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-meta_package.txt b/tests/lib-sbom-files/bomtool-meta_package.txt index 6aa089dc5a48..0a24d37c0695 100644 --- a/tests/lib-sbom-files/bomtool-meta_package.txt +++ b/tests/lib-sbom-files/bomtool-meta_package.txt @@ -13,6 +13,7 @@ PackageName: meta_package@1.0.0 SPDXID: SPDXRef-Package-metaC5fpackageC401.0.0 PackageVersion: 1.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Meta Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf PackageLicenseDeclared: BSD-2-Clause PackageLicenseConcluded: NOASSERTION @@ -27,6 +28,7 @@ PackageName: test1@1.0.0 SPDXID: SPDXRef-Package-test1C401.0.0 PackageVersion: 1.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test1 Maintainer PackageLicenseDeclared: BSD-1-Clause PackageLicenseConcluded: NOASSERTION PackageCopyrightText: <text>Test1 copyright text</text> @@ -40,6 +42,7 @@ PackageName: test2@2.0.0 SPDXID: SPDXRef-Package-test2C402.0.0 PackageVersion: 2.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test2 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: BSD-2-Clause PackageLicenseConcluded: NOASSERTION @@ -54,6 +57,7 @@ PackageName: test3@3.0.0 SPDXID: SPDXRef-Package-test3C403.0.0 PackageVersion: 3.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test3 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: BSD-4-Clause PackageLicenseConcluded: NOASSERTION @@ -68,6 +72,7 @@ PackageName: test4@4.0.0 SPDXID: SPDXRef-Package-test4C404.0.0 PackageVersion: 4.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test4 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: MIT PackageLicenseConcluded: NOASSERTION @@ -82,6 +87,7 @@ PackageName: test5@5.0.0 SPDXID: SPDXRef-Package-test5C405.0.0 PackageVersion: 5.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test5 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: MIT PackageLicenseConcluded: NOASSERTION @@ -96,6 +102,7 @@ PackageName: test6@6.0.0 SPDXID: SPDXRef-Package-test6C406.0.0 PackageVersion: 6.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test6 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/releases/ PackageLicenseDeclared: Apache-2.0 PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-multiple_packages.txt b/tests/lib-sbom-files/bomtool-multiple_packages.txt index 58c1e2dc827d..2637e3ee3076 100644 --- a/tests/lib-sbom-files/bomtool-multiple_packages.txt +++ b/tests/lib-sbom-files/bomtool-multiple_packages.txt @@ -13,6 +13,7 @@ PackageName: test5@5.0.0 SPDXID: SPDXRef-Package-test5C405.0.0 PackageVersion: 5.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test5 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: MIT PackageLicenseConcluded: NOASSERTION @@ -27,6 +28,7 @@ PackageName: test6@6.0.0 SPDXID: SPDXRef-Package-test6C406.0.0 PackageVersion: 6.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test6 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/releases/ PackageLicenseDeclared: Apache-2.0 PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-nolicense.txt b/tests/lib-sbom-files/bomtool-nolicense.txt index 3fdca7694ef7..d79fa8c4345c 100644 --- a/tests/lib-sbom-files/bomtool-nolicense.txt +++ b/tests/lib-sbom-files/bomtool-nolicense.txt @@ -13,6 +13,7 @@ PackageName: nolicense@1.0.0 SPDXID: SPDXRef-Package-nolicenseC401.0.0 PackageVersion: 1.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Nolicense Maintainer PackageHomePage: https://example.com/nolicense PackageLicenseDeclared: NOASSERTION PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-private_dependency.txt b/tests/lib-sbom-files/bomtool-private_dependency.txt new file mode 100644 index 000000000000..a9657ee553f9 --- /dev/null +++ b/tests/lib-sbom-files/bomtool-private_dependency.txt @@ -0,0 +1,45 @@ +SPDXVersion: SPDX-2.2 +DataLicense: CC0-1.0 +SPDXID: SPDXRef-DOCUMENT +DocumentName: SBOM-SPDX-priv-parentC401.0.0 +DocumentNamespace: https://spdx.org/spdxdocs/bomtool +Creator: Tool: bomtool +Created: test + + +##### Package: priv-parent@1.0.0 + +PackageName: priv-parent@1.0.0 +SPDXID: SPDXRef-Package-priv-parentC401.0.0 +PackageVersion: 1.0.0 +PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Privparent Maintainer +PackageHomePage: https://example.com/priv-parent +PackageLicenseDeclared: MIT +PackageLicenseConcluded: NOASSERTION +PackageCopyrightText: NOASSERTION +PackageSummary: <text>Package with a private dependency</text> +PackageDownloadLocation: NOASSERTION + + +##### Package: priv-child@1.0.0 + +PackageName: priv-child@1.0.0 +SPDXID: SPDXRef-Package-priv-childC401.0.0 +PackageVersion: 1.0.0 +PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Privchild Maintainer +PackageHomePage: https://example.com/priv-child +PackageLicenseDeclared: MIT +PackageLicenseConcluded: NOASSERTION +PackageCopyrightText: NOASSERTION +PackageSummary: <text>Private dependency child</text> +PackageDownloadLocation: NOASSERTION + + +Relationship: SPDXRef-Package-priv-parentC401.0.0 DEPENDS_ON SPDXRef-Package-priv-childC401.0.0 +Relationship: SPDXRef-Package-priv-childC401.0.0 DEV_DEPENDENCY_OF SPDXRef-Package-priv-parentC401.0.0 + + +Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-Package-priv-parentC401.0.0 +Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-Package-priv-childC401.0.0 diff --git a/tests/lib-sbom-files/bomtool-special.txt b/tests/lib-sbom-files/bomtool-special.txt index 415d0f448c25..3cabf2da4fe4 100644 --- a/tests/lib-sbom-files/bomtool-special.txt +++ b/tests/lib-sbom-files/bomtool-special.txt @@ -13,6 +13,7 @@ PackageName: special@1.0.0 SPDXID: SPDXRef-Package-specialC401.0.0 PackageVersion: 1.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Special Maintainer PackageHomePage: https://example.com/special PackageLicenseDeclared: MIT PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/bomtool-with_dependency.txt b/tests/lib-sbom-files/bomtool-with_dependency.txt index 6e40e06a683b..e74f6c398104 100644 --- a/tests/lib-sbom-files/bomtool-with_dependency.txt +++ b/tests/lib-sbom-files/bomtool-with_dependency.txt @@ -13,6 +13,7 @@ PackageName: test2@2.0.0 SPDXID: SPDXRef-Package-test2C402.0.0 PackageVersion: 2.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test2 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: BSD-2-Clause PackageLicenseConcluded: NOASSERTION @@ -27,6 +28,7 @@ PackageName: test3@3.0.0 SPDXID: SPDXRef-Package-test3C403.0.0 PackageVersion: 3.0.0 PackageDownloadLocation: NOASSERTION +PackageSupplier: Person: Test3 Maintainer PackageHomePage: https://github.com/pkgconf/pkgconf/ PackageLicenseDeclared: BSD-4-Clause PackageLicenseConcluded: NOASSERTION diff --git a/tests/lib-sbom-files/creation_id.json b/tests/lib-sbom-files/creation_id.json index 529d5b8ec296..ef09de67cba9 100644 --- a/tests/lib-sbom-files/creation_id.json +++ b/tests/lib-sbom-files/creation_id.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:custom_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:custom_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/test3/hasConcludedLicense", diff --git a/tests/lib-sbom-files/define_variable.json b/tests/lib-sbom-files/define_variable.json index bef19f2f3de1..d97d0080fed4 100644 --- a/tests/lib-sbom-files/define_variable.json +++ b/tests/lib-sbom-files/define_variable.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/variabletest1_maintainer", + "name": "Variabletest1 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/variabletest1_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/releases/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/variabletest1_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", "https://github.com/pkgconf/pkgconf/Relationship/variable-test1/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/variable-test1/hasConcludedLicense", diff --git a/tests/lib-sbom-files/define_variable_with_dependency.json b/tests/lib-sbom-files/define_variable_with_dependency.json index cad5b0b269b3..1aa4d8495c41 100644 --- a/tests/lib-sbom-files/define_variable_with_dependency.json +++ b/tests/lib-sbom-files/define_variable_with_dependency.json @@ -17,6 +17,18 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/variabletest2_maintainer", + "name": "Variabletest2 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/variabletest1_maintainer", + "name": "Variabletest1 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", @@ -67,6 +79,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/variabletest2_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/releases/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -80,6 +95,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/variabletest1_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/releases/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -145,7 +163,9 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/variabletest2_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", + "https://github.com/pkgconf/pkgconf/Agent/variabletest1_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", "https://github.com/pkgconf/pkgconf/Relationship/variable-test2/dependsOn/variable-test1", "https://github.com/pkgconf/pkgconf/Relationship/variable-test2/hasDeclaredLicense", diff --git a/tests/lib-sbom-files/meta_package-use-uri-spdx-base-id.json b/tests/lib-sbom-files/meta_package-use-uri-spdx-base-id.json index ad18ded896c3..b21e316c6a14 100644 --- a/tests/lib-sbom-files/meta_package-use-uri-spdx-base-id.json +++ b/tests/lib-sbom-files/meta_package-use-uri-spdx-base-id.json @@ -17,6 +17,48 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:meta_maintainer", + "name": "Meta Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:test1_maintainer", + "name": "Test1 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:test2_maintainer", + "name": "Test2 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:test3_maintainer", + "name": "Test3 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:test4_maintainer", + "name": "Test4 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:test5_maintainer", + "name": "Test5 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "distfiles.ariadne.space:pkgconf:Agent:test6_maintainer", + "name": "Test6 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "distfiles.ariadne.space:pkgconf:simplelicensing_LicenseExpression:BSD-2-Clause", @@ -168,6 +210,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:meta_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -181,6 +226,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:test1_maintainer" + ], "software_copyrightText": "Test1 copyright text", "software_homePage": "", "software_downloadLocation": "", @@ -194,6 +242,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:test2_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -207,6 +258,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -220,6 +274,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:test4_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -233,6 +290,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:test5_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -246,6 +306,9 @@ "originatedBy": [ "distfiles.ariadne.space:pkgconf:Agent:default" ], + "suppliedBy": [ + "distfiles.ariadne.space:pkgconf:Agent:test6_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/releases/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -496,10 +559,17 @@ ], "element": [ "distfiles.ariadne.space:pkgconf:Agent:default", + "distfiles.ariadne.space:pkgconf:Agent:meta_maintainer", "distfiles.ariadne.space:pkgconf:simplelicensing_LicenseExpression:BSD-2-Clause", + "distfiles.ariadne.space:pkgconf:Agent:test1_maintainer", "distfiles.ariadne.space:pkgconf:simplelicensing_LicenseExpression:BSD-1-Clause", + "distfiles.ariadne.space:pkgconf:Agent:test2_maintainer", + "distfiles.ariadne.space:pkgconf:Agent:test3_maintainer", "distfiles.ariadne.space:pkgconf:simplelicensing_LicenseExpression:BSD-4-Clause", + "distfiles.ariadne.space:pkgconf:Agent:test4_maintainer", "distfiles.ariadne.space:pkgconf:simplelicensing_LicenseExpression:MIT", + "distfiles.ariadne.space:pkgconf:Agent:test5_maintainer", + "distfiles.ariadne.space:pkgconf:Agent:test6_maintainer", "distfiles.ariadne.space:pkgconf:simplelicensing_LicenseExpression:Apache-2.0", "distfiles.ariadne.space:pkgconf:Relationship:meta_package:dependsOn:test1", "distfiles.ariadne.space:pkgconf:Relationship:meta_package:dependsOn:test2", diff --git a/tests/lib-sbom-files/meta_package.json b/tests/lib-sbom-files/meta_package.json index 248d663a6a1e..d033211f40cb 100644 --- a/tests/lib-sbom-files/meta_package.json +++ b/tests/lib-sbom-files/meta_package.json @@ -17,6 +17,48 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/meta_maintainer", + "name": "Meta Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test1_maintainer", + "name": "Test1 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test2_maintainer", + "name": "Test2 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test4_maintainer", + "name": "Test4 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test5_maintainer", + "name": "Test5 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test6_maintainer", + "name": "Test6 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", @@ -168,6 +210,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/meta_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -181,6 +226,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test1_maintainer" + ], "software_copyrightText": "Test1 copyright text", "software_homePage": "", "software_downloadLocation": "", @@ -194,6 +242,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test2_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -207,6 +258,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -220,6 +274,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test4_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -233,6 +290,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test5_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -246,6 +306,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test6_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/releases/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -496,10 +559,17 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/meta_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", + "https://github.com/pkgconf/pkgconf/Agent/test1_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-1-Clause", + "https://github.com/pkgconf/pkgconf/Agent/test2_maintainer", + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", + "https://github.com/pkgconf/pkgconf/Agent/test4_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", + "https://github.com/pkgconf/pkgconf/Agent/test5_maintainer", + "https://github.com/pkgconf/pkgconf/Agent/test6_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/Apache-2.0", "https://github.com/pkgconf/pkgconf/Relationship/meta_package/dependsOn/test1", "https://github.com/pkgconf/pkgconf/Relationship/meta_package/dependsOn/test2", diff --git a/tests/lib-sbom-files/multi_copyright.json b/tests/lib-sbom-files/multi_copyright.json index cf32487cfe19..651ca80deb3d 100644 --- a/tests/lib-sbom-files/multi_copyright.json +++ b/tests/lib-sbom-files/multi_copyright.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/mc_maintainer", + "name": "MC Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/mc_maintainer" + ], "software_copyrightText": "First copyright holder\nSecond copyright holder", "software_homePage": "https://example.com/mc", "software_downloadLocation": "", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/mc_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", "https://github.com/pkgconf/pkgconf/Relationship/multi-copyright/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/multi-copyright/hasConcludedLicense", diff --git a/tests/lib-sbom-files/multiple_packages.json b/tests/lib-sbom-files/multiple_packages.json index 3e9303c478b7..62cb4d4f68a5 100644 --- a/tests/lib-sbom-files/multiple_packages.json +++ b/tests/lib-sbom-files/multiple_packages.json @@ -17,6 +17,18 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test5_maintainer", + "name": "Test5 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test6_maintainer", + "name": "Test6 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", @@ -66,6 +78,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test5_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -79,6 +94,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test6_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/releases/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -134,7 +152,9 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/test5_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", + "https://github.com/pkgconf/pkgconf/Agent/test6_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/Apache-2.0", "https://github.com/pkgconf/pkgconf/Relationship/test5/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/test5/hasConcludedLicense", diff --git a/tests/lib-sbom-files/nolicense.json b/tests/lib-sbom-files/nolicense.json index d5d8ac639979..e45dd5c2299f 100644 --- a/tests/lib-sbom-files/nolicense.json +++ b/tests/lib-sbom-files/nolicense.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/nolicense_maintainer", + "name": "Nolicense Maintainer" + }, + { "type": "software_Sbom", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/software_Sbom/nolicense", @@ -37,6 +43,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/nolicense_maintainer" + ], "software_copyrightText": "Nolicense copyright text", "software_homePage": "https://example.com/nolicense", "software_downloadLocation": "https://example.com/nolicense/nolicense-1.0.0.tar.gz", @@ -51,6 +60,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/nolicense_maintainer", "https://github.com/pkgconf/pkgconf/software_Sbom/nolicense", "https://github.com/pkgconf/pkgconf/Package/nolicense" ] diff --git a/tests/lib-sbom-files/private_dependency.json b/tests/lib-sbom-files/private_dependency.json new file mode 100644 index 000000000000..c824794183f7 --- /dev/null +++ b/tests/lib-sbom-files/private_dependency.json @@ -0,0 +1,176 @@ +{ + "@context": "https://spdx.org/rdf/3.0.1/spdx-context.jsonld", + "@graph": [ + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/default", + "name": "Default" + }, + { + "type": "CreationInfo", + "@id": "_:creationinfo_1", + "created": "test", + "createdBy": [ + "https://github.com/pkgconf/pkgconf/Agent/default" + ], + "specVersion": "3.0.1" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/privparent_maintainer", + "name": "Privparent Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/privchild_maintainer", + "name": "Privchild Maintainer" + }, + { + "type": "simplelicensing_LicenseExpression", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", + "simplelicensing_licenseExpression": "MIT" + }, + { + "type": "software_Sbom", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/software_Sbom/priv-parent", + "software_sbomType": [ + "build" + ], + "rootElement": [ + "https://github.com/pkgconf/pkgconf/Package/priv-parent" + ], + "element": [ + "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/dependsOn/priv-child", + "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/hasDeclaredLicense", + "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/hasConcludedLicense" + ] + }, + { + "type": "software_Sbom", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/software_Sbom/priv-child", + "software_sbomType": [ + "build" + ], + "rootElement": [ + "https://github.com/pkgconf/pkgconf/Package/priv-child" + ], + "element": [ + "https://github.com/pkgconf/pkgconf/Relationship/priv-child/hasDeclaredLicense", + "https://github.com/pkgconf/pkgconf/Relationship/priv-child/hasConcludedLicense" + ] + }, + { + "type": "software_Package", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Package/priv-parent", + "name": "priv-parent", + "originatedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/default" + ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/privparent_maintainer" + ], + "software_copyrightText": "NOASSERTION", + "software_homePage": "https://example.com/priv-parent", + "software_downloadLocation": "", + "software_packageVersion": "1.0.0" + }, + { + "type": "software_Package", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Package/priv-child", + "name": "priv-child", + "originatedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/default" + ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/privchild_maintainer" + ], + "software_copyrightText": "NOASSERTION", + "software_homePage": "https://example.com/priv-child", + "software_downloadLocation": "", + "software_packageVersion": "1.0.0" + }, + { + "type": "Relationship", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/hasDeclaredLicense", + "from": "https://github.com/pkgconf/pkgconf/Package/priv-parent", + "to": [ + "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT" + ], + "relationshipType": "hasDeclaredLicense" + }, + { + "type": "Relationship", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/hasConcludedLicense", + "from": "https://github.com/pkgconf/pkgconf/Package/priv-parent", + "to": [ + "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT" + ], + "relationshipType": "hasConcludedLicense" + }, + { + "type": "LifecycleScopedRelationship", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/dependsOn/priv-child", + "from": "https://github.com/pkgconf/pkgconf/Package/priv-parent", + "to": [ + "https://github.com/pkgconf/pkgconf/Package/priv-child" + ], + "relationshipType": "dependsOn", + "scope": "development" + }, + { + "type": "Relationship", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Relationship/priv-child/hasDeclaredLicense", + "from": "https://github.com/pkgconf/pkgconf/Package/priv-child", + "to": [ + "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT" + ], + "relationshipType": "hasDeclaredLicense" + }, + { + "type": "Relationship", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Relationship/priv-child/hasConcludedLicense", + "from": "https://github.com/pkgconf/pkgconf/Package/priv-child", + "to": [ + "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT" + ], + "relationshipType": "hasConcludedLicense" + }, + { + "type": "SpdxDocument", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/spdxDocument/1", + "rootElement": [ + "https://github.com/pkgconf/pkgconf/software_Sbom/priv-parent", + "https://github.com/pkgconf/pkgconf/software_Sbom/priv-child" + ], + "element": [ + "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/privparent_maintainer", + "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", + "https://github.com/pkgconf/pkgconf/Agent/privchild_maintainer", + "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/dependsOn/priv-child", + "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/hasDeclaredLicense", + "https://github.com/pkgconf/pkgconf/Relationship/priv-parent/hasConcludedLicense", + "https://github.com/pkgconf/pkgconf/Relationship/priv-child/hasDeclaredLicense", + "https://github.com/pkgconf/pkgconf/Relationship/priv-child/hasConcludedLicense", + "https://github.com/pkgconf/pkgconf/software_Sbom/priv-parent", + "https://github.com/pkgconf/pkgconf/Package/priv-parent", + "https://github.com/pkgconf/pkgconf/software_Sbom/priv-child", + "https://github.com/pkgconf/pkgconf/Package/priv-child" + ] + } + ] +} diff --git a/tests/lib-sbom-files/special.json b/tests/lib-sbom-files/special.json index 34d55df409ee..3d4fa7abae69 100644 --- a/tests/lib-sbom-files/special.json +++ b/tests/lib-sbom-files/special.json @@ -17,6 +17,12 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/special_maintainer", + "name": "Special Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", @@ -45,6 +51,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/special_maintainer" + ], "software_copyrightText": "Quote \" backslash \\ and\ttab", "software_homePage": "https://example.com/special", "software_downloadLocation": "", @@ -79,6 +88,7 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/special_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/MIT", "https://github.com/pkgconf/pkgconf/Relationship/special/hasDeclaredLicense", "https://github.com/pkgconf/pkgconf/Relationship/special/hasConcludedLicense", diff --git a/tests/lib-sbom-files/with_dependency.json b/tests/lib-sbom-files/with_dependency.json index d2036259550c..583fd5a6d81b 100644 --- a/tests/lib-sbom-files/with_dependency.json +++ b/tests/lib-sbom-files/with_dependency.json @@ -17,6 +17,18 @@ "specVersion": "3.0.1" }, { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test2_maintainer", + "name": "Test2 Maintainer" + }, + { + "type": "Agent", + "creationInfo": "_:creationinfo_1", + "spdxId": "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", + "name": "Test3 Maintainer" + }, + { "type": "simplelicensing_LicenseExpression", "creationInfo": "_:creationinfo_1", "spdxId": "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", @@ -67,6 +79,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test2_maintainer" + ], "software_copyrightText": "NOASSERTION", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -80,6 +95,9 @@ "originatedBy": [ "https://github.com/pkgconf/pkgconf/Agent/default" ], + "suppliedBy": [ + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer" + ], "software_copyrightText": "Test3 copyright text", "software_homePage": "https://github.com/pkgconf/pkgconf/", "software_downloadLocation": "https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz", @@ -145,7 +163,9 @@ ], "element": [ "https://github.com/pkgconf/pkgconf/Agent/default", + "https://github.com/pkgconf/pkgconf/Agent/test2_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-2-Clause", + "https://github.com/pkgconf/pkgconf/Agent/test3_maintainer", "https://github.com/pkgconf/pkgconf/simplelicensing_LicenseExpression/BSD-4-Clause", "https://github.com/pkgconf/pkgconf/Relationship/test2/dependsOn/test3", "https://github.com/pkgconf/pkgconf/Relationship/test2/hasDeclaredLicense", diff --git a/tests/lib-sbom/meta_package.pc b/tests/lib-sbom/meta_package.pc index f3dd872ad2d5..37ec64c2d350 100644 --- a/tests/lib-sbom/meta_package.pc +++ b/tests/lib-sbom/meta_package.pc @@ -10,3 +10,4 @@ Requires: test1 \ test6 Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz License: BSD-2-Clause +Maintainer: Meta Maintainer diff --git a/tests/lib-sbom/multi-copyright.pc b/tests/lib-sbom/multi-copyright.pc index 464a641d47db..3a9c443c6617 100644 --- a/tests/lib-sbom/multi-copyright.pc +++ b/tests/lib-sbom/multi-copyright.pc @@ -5,3 +5,4 @@ Version: 1.0.0 License: MIT Copyright: First copyright holder Copyright: Second copyright holder +Maintainer: MC Maintainer diff --git a/tests/lib-sbom/nolicense.pc b/tests/lib-sbom/nolicense.pc index 0793297f637b..ca992a39b736 100644 --- a/tests/lib-sbom/nolicense.pc +++ b/tests/lib-sbom/nolicense.pc @@ -4,3 +4,4 @@ URL: https://example.com/nolicense Version: 1.0.0 Copyright: Nolicense copyright text Source: https://example.com/nolicense/nolicense-1.0.0.tar.gz +Maintainer: Nolicense Maintainer diff --git a/tests/lib-sbom/priv-child.pc b/tests/lib-sbom/priv-child.pc new file mode 100644 index 000000000000..ce9f8f8eb2b0 --- /dev/null +++ b/tests/lib-sbom/priv-child.pc @@ -0,0 +1,6 @@ +Name: priv-child +Description: Private dependency child +URL: https://example.com/priv-child +Version: 1.0.0 +License: MIT +Maintainer: Privchild Maintainer diff --git a/tests/lib-sbom/priv-parent.pc b/tests/lib-sbom/priv-parent.pc new file mode 100644 index 000000000000..400cfb2b1bf2 --- /dev/null +++ b/tests/lib-sbom/priv-parent.pc @@ -0,0 +1,7 @@ +Name: priv-parent +Description: Package with a private dependency +URL: https://example.com/priv-parent +Version: 1.0.0 +License: MIT +Requires.private: priv-child +Maintainer: Privparent Maintainer diff --git a/tests/lib-sbom/special.pc b/tests/lib-sbom/special.pc index 7d95d54584fa..80edc08d834a 100644 --- a/tests/lib-sbom/special.pc +++ b/tests/lib-sbom/special.pc @@ -4,3 +4,4 @@ URL: https://example.com/special Version: 1.0.0 License: MIT Copyright: Quote " backslash \ and tab +Maintainer: Special Maintainer diff --git a/tests/lib-sbom/test1.pc b/tests/lib-sbom/test1.pc index 2cde40250c3f..f7446cac23a6 100644 --- a/tests/lib-sbom/test1.pc +++ b/tests/lib-sbom/test1.pc @@ -4,3 +4,4 @@ Version: 1.0.0 License: BSD-1-Clause Copyright: Test1 copyright text Requires: test1 +Maintainer: Test1 Maintainer diff --git a/tests/lib-sbom/test2.pc b/tests/lib-sbom/test2.pc index d8c6f5dc9537..87240758b1dc 100644 --- a/tests/lib-sbom/test2.pc +++ b/tests/lib-sbom/test2.pc @@ -5,3 +5,4 @@ Version: 2.0.0 Requires: test3 License: BSD-2-Clause Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz +Maintainer: Test2 Maintainer diff --git a/tests/lib-sbom/test3.pc b/tests/lib-sbom/test3.pc index af65789843c1..d589d7eb9611 100644 --- a/tests/lib-sbom/test3.pc +++ b/tests/lib-sbom/test3.pc @@ -6,3 +6,4 @@ License: BSD-4-Clause Copyright: Test3 copyright text Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz +Maintainer: Test3 Maintainer diff --git a/tests/lib-sbom/test4.pc b/tests/lib-sbom/test4.pc index 502a5fec8445..ce57ce8c8fa9 100644 --- a/tests/lib-sbom/test4.pc +++ b/tests/lib-sbom/test4.pc @@ -6,3 +6,4 @@ License: MIT Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz Requires: test5 \ test6 +Maintainer: Test4 Maintainer diff --git a/tests/lib-sbom/test5.pc b/tests/lib-sbom/test5.pc index 62e77cc3e05a..257c86045016 100644 --- a/tests/lib-sbom/test5.pc +++ b/tests/lib-sbom/test5.pc @@ -5,3 +5,4 @@ Version: 5.0.0 License: MIT Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz +Maintainer: Test5 Maintainer diff --git a/tests/lib-sbom/test6.pc b/tests/lib-sbom/test6.pc index b87c3805ed25..07eadd15d65f 100644 --- a/tests/lib-sbom/test6.pc +++ b/tests/lib-sbom/test6.pc @@ -5,3 +5,4 @@ Version: 6.0.0 License: Apache-2.0 Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz +Maintainer: Test6 Maintainer diff --git a/tests/lib-sbom/variable-test1.pc b/tests/lib-sbom/variable-test1.pc index 51a1a710dc5a..172bebb46c74 100644 --- a/tests/lib-sbom/variable-test1.pc +++ b/tests/lib-sbom/variable-test1.pc @@ -5,3 +5,4 @@ Version: ${VERSION_VARIABLE_TEST} License: BSD-2-Clause Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz +Maintainer: Variabletest1 Maintainer diff --git a/tests/lib-sbom/variable-test2.pc b/tests/lib-sbom/variable-test2.pc index 52033aba61b9..14450f88c0f0 100644 --- a/tests/lib-sbom/variable-test2.pc +++ b/tests/lib-sbom/variable-test2.pc @@ -5,3 +5,4 @@ Version: 2.0 License: ${license_variable_test} Source: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.5.1.tar.gz Requires: variable-test1 +Maintainer: Variabletest2 Maintainer diff --git a/tests/lib1/top-builddir.pc b/tests/lib1/top-builddir.pc new file mode 100644 index 000000000000..c60e499825ba --- /dev/null +++ b/tests/lib1/top-builddir.pc @@ -0,0 +1,4 @@ +Name: top-builddir +Description: exercises pc_top_builddir / PKG_CONFIG_TOP_BUILD_DIR +Version: 1.0 +Cflags: -I${pc_top_builddir}/include diff --git a/tests/personality-data/sysrooted.personality b/tests/personality-data/sysrooted.personality new file mode 100644 index 000000000000..9b25e7ee5b02 --- /dev/null +++ b/tests/personality-data/sysrooted.personality @@ -0,0 +1,7 @@ +Triplet: i386-linux-gnu +SysrootDir: /custom/sysroot +DefaultSearchPaths: /usr/lib/i386-linux-gnu/pkgconfig:/usr/share/pkgconfig +SystemIncludePaths: /usr/lib/i386-linux-gnu/include +SystemLibraryPaths: /usr/lib/i386-linux-gnu/lib +WantDefaultPure: true +WantDefaultStatic: true diff --git a/tests/win-shim.h b/tests/win-shim.h index a58c83d794cc..d870d96fc284 100644 --- a/tests/win-shim.h +++ b/tests/win-shim.h @@ -22,6 +22,8 @@ #include <direct.h> #include <io.h> +#include <fcntl.h> +#include <sys/stat.h> // Shims shared by both MSVC and MSYS2 #define mkdir(p, m) _mkdir(p) @@ -51,6 +53,14 @@ mkdtemp(char *tmpl) return NULL; return tmpl; } + +static inline int +mkstemp(char *tmpl) +{ + if (_mktemp_s(tmpl, strlen(tmpl) + 1) != 0) + return -1; + return _open(tmpl, _O_CREAT | _O_EXCL | _O_RDWR | _O_BINARY, _S_IREAD | _S_IWRITE); +} #endif // _MSC_VER #endif // _WIN32 |
