return EXIT_SUCCESS;
}
+static int test_retrieve_with_mirrors(const struct test* t) {
+ struct pakfire_downloader* d;
+ struct pakfire_mirrorlist* m;
+
+ // Create downloader
+ int r = pakfire_downloader_create(&d, t->pakfire);
+ ASSERT(r == 0);
+
+ // Create mirrorlist
+ ASSERT_SUCCESS(pakfire_mirrorlist_create(&m, t->pakfire));
+
+ // Add a couple of mirrors
+ ASSERT_SUCCESS(pakfire_mirrorlist_add_mirror(m, "file://" ABS_TOP_SRCDIR "/tests/data/mirror-1"));
+ ASSERT_SUCCESS(pakfire_mirrorlist_add_mirror(m, "file://" ABS_TOP_SRCDIR "/tests/data/mirror-2"));
+ ASSERT_SUCCESS(pakfire_mirrorlist_add_mirror(m, "file://" ABS_TOP_SRCDIR "/tests/data/mirror-3"));
+ ASSERT_SUCCESS(pakfire_mirrorlist_add_mirror(m, "file://" ABS_TOP_SRCDIR "/tests/data"));
+
+ // Retrieve a file which doesn't exist
+ //ASSERT_FAILURE(pakfire_downloader_retrieve(d, m, "doesnt-exist.pfm", DOWNLOAD_PATH));
+
+ // Retrieve a file which exists
+ ASSERT_SUCCESS(pakfire_downloader_retrieve(d, m, "beep-1.3-2.ip3.x86_64.pfm", DOWNLOAD_PATH));
+
+ // Cleanup
+ ASSERT_NULL(pakfire_mirrorlist_unref(m));
+ ASSERT_NULL(pakfire_downloader_unref(d));
+
+ return 0;
+}
+
int main(int argc, char** argv) {
testsuite_add_test(test_simple);
testsuite_add_test(test_retrieve_with_pending_transfers);
+ testsuite_add_test(test_retrieve_with_mirrors);
return testsuite_run();
}
} \
} while (0)
+#define ASSERT_FAILURE(expr) \
+ do { \
+ if ((expr) > 0) { \
+ LOG_ERROR("Failed assertion: " #expr " unexpectedly didn't fail in %s:%d %s\n", \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+ return EXIT_FAILURE; \
+ } \
+ } while (0)
+
#define ASSERT_ERRNO(expr, e) \
do { \
if (!(expr)) { \