--- /dev/null
+###############################################################################
+# IPFire.org - An Open Source Firewall Solution #
+# Copyright (C) - IPFire Development Team <info@ipfire.org> #
+###############################################################################
+
+name = dummy
+version = 1.0
+release = 1
+
+groups = Dummy
+url = https://www.example.org
+license = GPLv2+
+summary = This is a dummy package
+
+description
+ This package is a dummy package and its sole purpose is to have something
+ that we can use for packaging in the test environment.
+
+ This package purposefully does not download any files.
+end
+
+sources =
+
+# This package has a simple build requirement
+build
+ requires = gcc
+end
#include <stdlib.h>
#include <string.h>
+#include <pakfire/dist.h>
#include <pakfire/package.h>
#include <pakfire/parser.h>
#include <pakfire/repo.h>
return r;
}
+/*
+ This test tries to dist() on a dummy package
+*/
+static int test_dist_dummy(const struct test* t) {
+ int r = EXIT_FAILURE;
+
+ struct pakfire_archive* archive = NULL;
+ struct pakfire_package* package = NULL;
+
+ // Create a directory to write packages to
+ char* tmp = test_mkdtemp();
+ ASSERT(tmp);
+
+ char* filename = NULL;
+
+ // Attempt to dist the dummy package
+ ASSERT_SUCCESS(pakfire_dist(t->pakfire,
+ TEST_SRC_PATH "data/packages/dummy/dummy.nm", tmp, &filename));
+
+ // Check if filename is set
+ ASSERT(filename);
+
+ // Check if we can read the archive
+ ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, filename));
+
+ // Extract all package metadata
+ ASSERT_SUCCESS(pakfire_archive_make_package(archive, NULL, &package));
+
+ // Check name
+ const char* name = pakfire_package_get_name(package);
+ ASSERT_STRING_EQUALS(name, "dummy");
+
+ // Check EVR
+ const char* evr = pakfire_package_get_evr(package);
+ ASSERT_STRING_EQUALS(evr, "1.0-1");
+
+ // Check arch
+ const char* arch = pakfire_package_get_arch(package);
+ ASSERT_STRING_EQUALS(arch, "src");
+
+ // Check vendor
+ const char* vendor = pakfire_package_get_vendor(package);
+ ASSERT_STRING_EQUALS(vendor, pakfire_get_distro_vendor(t->pakfire));
+
+ // Check UUID
+ const char* uuid = pakfire_package_get_uuid(package);
+ ASSERT(uuid);
+
+ // Check groups
+ const char* groups = pakfire_package_get_groups(package);
+ ASSERT_STRING_EQUALS(groups, "Dummy");
+
+ // Check URL
+ const char* url = pakfire_package_get_url(package);
+ ASSERT_STRING_EQUALS(url, "https://www.example.org");
+
+ // Check license
+ const char* license = pakfire_package_get_license(package);
+ ASSERT_STRING_EQUALS(license, "GPLv2+");
+
+ // Check summary
+ const char* summary = pakfire_package_get_summary(package);
+ ASSERT_STRING_EQUALS(summary, "This is a dummy package");
+
+ // Check description
+ const char* description = pakfire_package_get_description(package);
+ ASSERT(description);
+
+ // Check size
+ size_t installed_size = pakfire_package_get_installsize(package);
+ ASSERT(installed_size == 0);
+
+ // Everything okay
+ r = EXIT_SUCCESS;
+
+FAIL:
+ if (archive)
+ pakfire_archive_unref(archive);
+ if (package)
+ pakfire_package_unref(package);
+
+ return r;
+}
+
int main(int argc, char** argv) {
testsuite_add_test(test_macros);
testsuite_add_test(test_parse);
testsuite_add_test(test_packages);
+ testsuite_add_test(test_dist_dummy);
return testsuite_run();
}