struct pakfire* p = NULL;
int r;
+ // Always require a configuration
+ if (!config)
+ return -EINVAL;
+
// Default to the native architecture
if (!arch)
arch = pakfire_arch_native();
p->flags = flags;
// Store a reference to the configuration
- if (config) {
- p->config = pakfire_config_ref(config);
- } else {
- r = pakfire_config_create(&p->config);
- if (r < 0)
- goto ERROR;
- }
+ p->config = pakfire_config_ref(config);
// Store the nominal architecture
r = pakfire_string_set(p->arches.nominal, arch);
}
static int test_fail(const struct test* t) {
+ struct pakfire_config* config = NULL;
struct pakfire* pakfire = NULL;
+ int r = EXIT_FAILURE;
+
+ // Create a configuration
+ ASSERT_SUCCESS(pakfire_config_create(&config));
// Init without anything
- ASSERT(pakfire_create(&pakfire, t->ctx, NULL, NULL, NULL, 0) == -EINVAL);
+ ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, NULL, NULL, NULL, 0), EINVAL);
// Invalid architecture
- ASSERT(pakfire_create(&pakfire, t->ctx, NULL, NULL, "arch", 0) == -ENOTSUP);
+ ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, config, NULL, "arch", 0), ENOTSUP);
// Invalid path (must be absolute)
- ASSERT(pakfire_create(&pakfire, t->ctx, NULL, "path", NULL, 0) == -EINVAL);
+ ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, config, "path", NULL, 0), EINVAL);
// Cannot use snapshots with a path
- ASSERT(pakfire_create(&pakfire, t->ctx, NULL, PAKFIRE_TMP_DIR "/test",
- NULL, PAKFIRE_USE_SNAPSHOT) == -EINVAL);
+ ASSERT_ERROR(pakfire_create(&pakfire, t->ctx, NULL, PAKFIRE_TMP_DIR "/test",
+ NULL, PAKFIRE_USE_SNAPSHOT), EINVAL);
- return EXIT_SUCCESS;
+ r = EXIT_SUCCESS;
FAIL:
- return EXIT_FAILURE;
+ if (config)
+ pakfire_config_unref(config);
+
+ return r;
}
int main(int argc, const char* argv[]) {