tests/libpakfire/compress \
tests/libpakfire/config \
tests/libpakfire/db \
+ tests/libpakfire/dependencies \
tests/libpakfire/downloader \
tests/libpakfire/execute \
tests/libpakfire/key \
tests_libpakfire_db_LDADD = \
$(TESTSUITE_LDADD)
+dist_tests_libpakfire_dependencies_SOURCES = \
+ tests/libpakfire/dependencies.c
+
+tests_libpakfire_dependencies_CPPFLAGS = \
+ $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_dependencies_LDADD = \
+ $(TESTSUITE_LDADD)
+
dist_tests_libpakfire_downloader_SOURCES = \
tests/libpakfire/downloader.c
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2021 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <pakfire/parser.h>
+#include <pakfire/util.h>
+
+#include "../testsuite.h"
+
+static const char* relations[] = {
+ // Simple packages
+ "beep",
+ "bash",
+ "kernel-devel",
+
+ // Packages with a specific version
+ "beep = 1",
+ "bash = 2",
+ "kernel-devel = 3",
+
+ // Packages with version and release
+ "beep = 1-1.ip3",
+ "bash = 2-2.ip3",
+ "kernel-devel = 3-3.ip3",
+
+ // Packages with version, release and arch
+ "beep = 1-1.ip3.x86_64",
+ "bash = 2-2.ip3.aarch64",
+ "kernel-devel = 3-3.x86_64",
+
+ // Packages with a version greater/smaller/greater or equal/smaller or equal than
+ "beep > 1",
+ "bash > 2",
+ "kernel-devel > 3",
+ "beep < 1",
+ "bash < 2",
+ "kernel-devel < 3",
+ "beep >= 1",
+ "bash >= 2",
+ "kernel-devel >= 3",
+ "beep >= 1",
+ "bash >= 2",
+ "kernel-devel >= 3",
+
+ // Namespaces
+ "pakfire(test)",
+
+ NULL,
+};
+
+static int test_dependencies(const struct test* t) {
+ Id dep = 0;
+ const char* result = NULL;
+
+ for (const char** relation = relations; *relation; relation++) {
+ printf("Parsing '%s'...\n", *relation);
+
+ // Parse relation
+ dep = pakfire_str2dep(t->pakfire, *relation);
+
+ // Convert it back to string
+ result = pakfire_dep2str(t->pakfire, dep);
+ ASSERT(result);
+
+ // Check if the output matches the input
+ ASSERT_STRING_EQUALS(*relation, result);
+ }
+
+ return EXIT_SUCCESS;
+
+FAIL:
+ return EXIT_FAILURE;
+}
+
+int main(int argc, char** argv) {
+ testsuite_add_test(test_dependencies);
+
+ return testsuite_run();
+}