[libosinfo PATCH 1/5] tests: Remove test-*.uris

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Those tests are now part of osinfo-db.

With this change we can get rid of the curl dependency we have.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 README                   |   1 -
 configure.ac             |   8 ---
 libosinfo.spec.in        |   1 -
 tests/Makefile.am        |  26 +---------
 tests/test-imageuris.c   |  83 -----------------------------
 tests/test-mediauris.c   |  89 --------------------------------
 tests/test-treeuris.c    |  87 -------------------------------
 tests/test-uris-common.c | 109 ---------------------------------------
 tests/test-uris-common.h |  26 ----------
 9 files changed, 2 insertions(+), 428 deletions(-)
 delete mode 100644 tests/test-imageuris.c
 delete mode 100644 tests/test-mediauris.c
 delete mode 100644 tests/test-treeuris.c
 delete mode 100644 tests/test-uris-common.c
 delete mode 100644 tests/test-uris-common.h

diff --git a/README b/README
index e3d528c..7f73e74 100644
--- a/README
+++ b/README
@@ -26,7 +26,6 @@ Dependencies
 
 - Optional:
   - gobject-introspection
-  - libcurl (for tests only)
   - Vala (build-time only)
 
 Patch submissions
diff --git a/configure.ac b/configure.ac
index f4b4b71..4b0fd40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,14 +55,6 @@ AC_ARG_ENABLE([tests],
         AS_HELP_STRING([--enable-tests], [enable test suite]),
         [], [enable_tests=yes])
 
-if test "x$enable_tests" != "xno" ; then
-  have_curl=no
-  PKG_CHECK_MODULES([CURL], [libcurl], [have_curl=yes], [:])
-  AC_SUBST(CURL_CFLAGS)
-  AC_SUBST(CURL_LIBS)
-fi
-AM_CONDITIONAL([HAVE_CURL],[test "x$have_curl" = "xyes"])
-
 AM_CONDITIONAL([ENABLE_TESTS],[test "x$enable_tests" = "xyes"])
 
 LIBOSINFO_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
diff --git a/libosinfo.spec.in b/libosinfo.spec.in
index 8c0cc03..79b58dd 100644
--- a/libosinfo.spec.in
+++ b/libosinfo.spec.in
@@ -14,7 +14,6 @@ BuildRequires: glib2-devel
 BuildRequires: libxml2-devel >= 2.6.0
 BuildRequires: libxslt-devel >= 1.0.0
 BuildRequires: vala
-BuildRequires: libcurl-devel
 BuildRequires: /usr/bin/pod2man
 BuildRequires: hwdata
 BuildRequires: gobject-introspection-devel
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a822af2..27b0f8d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,14 +23,6 @@ check_PROGRAMS = \
 	test-imagelist \
         $(NULL)
 
-if HAVE_CURL
-check_PROGRAMS += \
-	test-mediauris \
-	test-treeuris \
-	test-imageuris \
-	$(NULL)
-endif
-
 COMMON_LDADD = \
 	$(COVERAGE_LDFLAGS) \
 	$(GLIB_LIBS) \
@@ -78,8 +70,8 @@ test_list_LDADD = $(COMMON_LDADD)
 test_list_CFLAGS = $(COMMON_CFLAGS)
 test_list_SOURCES = test-list.c
 
-test_media_LDADD = $(COMMON_LDADD) $(CURL_LIBS)
-test_media_CFLAGS = $(COMMON_CFLAGS) $(CURL_CFLAGS)
+test_media_LDADD = $(COMMON_LDADD)
+test_media_CFLAGS = $(COMMON_CFLAGS)
 test_media_SOURCES = test-media.c
 
 test_devicelist_LDADD = $(COMMON_LDADD)
@@ -110,20 +102,6 @@ test_isodetect_LDADD = $(COMMON_LDADD)
 test_isodetect_CFLAGS = $(COMMON_CFLAGS)
 test_isodetect_SOURCES = test-isodetect.c
 
-if HAVE_CURL
-test_mediauris_LDADD = $(COMMON_LDADD) $(CURL_LIBS)
-test_mediauris_CFLAGS = $(COMMON_CFLAGS) $(CURL_CFLAGS)
-test_mediauris_SOURCES = test-mediauris.c test-uris-common.c test-uris-common.h
-
-test_treeuris_LDADD = $(COMMON_LDADD) $(CURL_LIBS)
-test_treeuris_CFLAGS = $(COMMON_CFLAGS) $(CURL_CFLAGS)
-test_treeuris_SOURCES = test-treeuris.c test-uris-common.c test-uris-common.h
-
-test_imageuris_LDADD = $(COMMON_LDADD) $(CURL_LIBS)
-test_imageuris_CFLAGS = $(COMMON_CFLAGS) $(CURL_CFLAGS)
-test_imageuris_SOURCES = test-imageuris.c test-uris-common.c test-uris-common.h
-endif
-
 test_install_script_LDADD = $(COMMON_LDADD)
 test_install_script_CFLAGS = $(COMMON_CFLAGS)
 test_install_script_SOURCES = test-install-script.c
diff --git a/tests/test-imageuris.c b/tests/test-imageuris.c
deleted file mode 100644
index 5a1128c..0000000
--- a/tests/test-imageuris.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2108 Red Hat, Inc.
- *
- * 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 2 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/>
- *
- * Authors:
- *   Daniel P. Berrange <berrange@xxxxxxxxxx>
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <osinfo/osinfo.h>
-#include <curl/curl.h>
-
-#include "test-uris-common.h"
-
-static void
-test_imageuris(gconstpointer data)
-{
-    OsinfoOs *os = OSINFO_OS(data);
-    GError *error = NULL;
-
-    OsinfoImageList *imagelist = osinfo_os_get_image_list(os);
-
-    test_uri(OSINFO_LIST(imagelist), (GetURLFunc) osinfo_image_get_url, &error);
-
-    g_assert_no_error(error);
-
-    g_object_unref(imagelist);
-}
-
-int
-main(int argc, char *argv[])
-{
-    int ret;
-    OsinfoLoader *loader = osinfo_loader_new();
-    OsinfoDb *db = osinfo_loader_get_db(loader);
-    OsinfoOsList *oslist = NULL;
-    GError *error = NULL;
-
-    g_test_init(&argc, &argv, NULL);
-    g_test_set_nonfatal_assertions();
-
-    if (!g_getenv("LIBOSINFO_NETWORK_TESTS"))
-        return 77; /* Skip */
-
-    /* Upfront so we don't confuse valgrind */
-    curl_global_init(CURL_GLOBAL_ALL);
-    osinfo_db_get_type();
-    osinfo_os_get_type();
-    osinfo_list_get_type();
-    osinfo_oslist_get_type();
-    osinfo_filter_get_type();
-
-    osinfo_loader_process_default_path(loader, &error);
-    g_assert_no_error(error);
-
-    oslist = osinfo_db_get_os_list(db);
-    test_uris(oslist, "/imageuris/uris", test_imageuris);
-
-    ret = g_test_run();
-
-    if (oslist)
-        g_object_unref(oslist);
-
-    g_object_unref(loader);
-
-    curl_global_cleanup();
-
-    return ret;
-}
diff --git a/tests/test-mediauris.c b/tests/test-mediauris.c
deleted file mode 100644
index 004c5bb..0000000
--- a/tests/test-mediauris.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2009-2012, 2014 Red Hat, Inc.
- *
- * 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 2 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/>
- *
- * Authors:
- *   Daniel P. Berrange <berrange@xxxxxxxxxx>
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <osinfo/osinfo.h>
-#include <curl/curl.h>
-
-#include "test-uris-common.h"
-
-static void
-test_mediauris(gconstpointer data)
-{
-    OsinfoOs *os = OSINFO_OS(data);
-    GError *error = NULL;
-
-    OsinfoMediaList *medialist = osinfo_os_get_media_list(os);
-
-    test_uri(OSINFO_LIST(medialist), (GetURLFunc) osinfo_media_get_url, &error);
-
-    g_assert_no_error(error);
-
-    g_object_unref(medialist);
-}
-
-int
-main(int argc, char *argv[])
-{
-    int ret;
-    OsinfoLoader *loader = osinfo_loader_new();
-    OsinfoDb *db = osinfo_loader_get_db(loader);
-    OsinfoOsList *oslist = NULL;
-    GError *error = NULL;
-
-    g_test_init(&argc, &argv, NULL);
-    g_test_set_nonfatal_assertions();
-
-    if (!g_getenv("LIBOSINFO_NETWORK_TESTS"))
-        return 77; /* Skip */
-
-    /* Upfront so we don't confuse valgrind */
-    curl_global_init(CURL_GLOBAL_ALL);
-    osinfo_entity_get_type();
-    osinfo_db_get_type();
-    osinfo_device_get_type();
-    osinfo_platform_get_type();
-    osinfo_os_get_type();
-    osinfo_list_get_type();
-    osinfo_devicelist_get_type();
-    osinfo_platformlist_get_type();
-    osinfo_oslist_get_type();
-    osinfo_filter_get_type();
-
-
-    osinfo_loader_process_default_path(loader, &error);
-    g_assert_no_error(error);
-
-    oslist = osinfo_db_get_os_list(db);
-    test_uris(oslist, "/mediauris/uris", test_mediauris);
-
-    ret = g_test_run();
-
-    if (oslist)
-        g_object_unref(oslist);
-
-    g_object_unref(loader);
-
-    curl_global_cleanup();
-
-    return ret;
-}
diff --git a/tests/test-treeuris.c b/tests/test-treeuris.c
deleted file mode 100644
index 50bb8ce..0000000
--- a/tests/test-treeuris.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2009-2012, 2014 Red Hat, Inc.
- *
- * 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 2 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/>
- *
- * Authors:
- *   Daniel P. Berrange <berrange@xxxxxxxxxx>
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <osinfo/osinfo.h>
-#include <curl/curl.h>
-
-#include "test-uris-common.h"
-
-static void
-test_treeuris(gconstpointer data)
-{
-    OsinfoOs *os = OSINFO_OS(data);
-    GError *error = NULL;
-    OsinfoTreeList *treelist = osinfo_os_get_tree_list(os);
-
-    test_uri(OSINFO_LIST(treelist), (GetURLFunc) osinfo_tree_get_url, &error);
-
-    g_assert_no_error(error);
-
-    g_object_unref(treelist);
-}
-
-int
-main(int argc, char *argv[])
-{
-    int ret;
-    OsinfoLoader *loader = osinfo_loader_new();
-    OsinfoDb *db = osinfo_loader_get_db(loader);
-    OsinfoOsList *oslist = NULL;
-    GError *error = NULL;
-
-    g_test_init(&argc, &argv, NULL);
-    g_test_set_nonfatal_assertions();
-
-    if (!g_getenv("LIBOSINFO_NETWORK_TESTS"))
-        return 77; /* Skip */
-
-    /* Upfront so we don't confuse valgrind */
-    curl_global_init(CURL_GLOBAL_ALL);
-    osinfo_entity_get_type();
-    osinfo_db_get_type();
-    osinfo_device_get_type();
-    osinfo_platform_get_type();
-    osinfo_os_get_type();
-    osinfo_list_get_type();
-    osinfo_devicelist_get_type();
-    osinfo_platformlist_get_type();
-    osinfo_oslist_get_type();
-    osinfo_filter_get_type();
-
-    osinfo_loader_process_default_path(loader, &error);
-    g_assert_no_error(error);
-
-    oslist = osinfo_db_get_os_list(db);
-    test_uris(oslist, "/treeuris/uris", test_treeuris);
-
-    ret = g_test_run();
-
-    if (oslist)
-        g_object_unref(oslist);
-
-    g_object_unref(loader);
-
-    curl_global_cleanup();
-
-    return ret;
-}
diff --git a/tests/test-uris-common.c b/tests/test-uris-common.c
deleted file mode 100644
index 8ebe4ea..0000000
--- a/tests/test-uris-common.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2019 Red Hat, Inc.
- *
- * 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 2 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 <config.h>
-
-#include <stdlib.h>
-#include <osinfo/osinfo.h>
-#include <curl/curl.h>
-
-#include "test-uris-common.h"
-
-static size_t write_callback(char *ptr,
-                             size_t size,
-                             size_t nmemb,
-                             void *userdata)
-{
-    abort();
-}
-
-void test_uri(OsinfoList *list, GetURLFunc get_url_func, GError **error)
-{
-    GList *el = NULL, *tmp;
-
-    tmp = el = osinfo_list_get_elements(list);
-    while (tmp) {
-        const gchar *url = get_url_func(tmp->data);
-        const gchar *debugstr;
-        CURL *curl;
-        CURLcode res;
-        long response_code;
-
-        if (url == NULL || g_str_equal(url, "")) {
-            tmp = tmp->next;
-            continue;
-        }
-
-        curl = curl_easy_init();
-        curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
-        curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60L);
-        curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
-        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
-        curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
-        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
-
-        if ((debugstr = g_getenv("LIBOSINFO_TEST_DEBUG"))) {
-            int debug_level = atoi(debugstr);
-
-            curl_easy_setopt(curl, CURLOPT_VERBOSE, debug_level > 0 ? 1L : 0L);
-        }
-
-        g_test_message("%s", url);
-        curl_easy_setopt(curl, CURLOPT_URL, url);
-        res = curl_easy_perform(curl);
-        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
-
-        g_test_message("res=%d, %s; code=%ld", res, curl_easy_strerror(res), response_code);
-
-        if (res == CURLE_OPERATION_TIMEDOUT) {
-            g_printerr("Ignoring network timeout failure for %s\n", url);
-        } else {
-            if (res != CURLE_OK) {
-                g_printerr("Failed URI %s res=%d (%s) code=%ld\n",
-                           url, res, curl_easy_strerror(res), response_code);
-            }
-            g_assert_cmpint(res, ==, CURLE_OK);
-        }
-
-        tmp = tmp->next;
-        curl_easy_cleanup(curl);
-    }
-
-    g_list_free(el);
-}
-
-
-void test_uris(OsinfoOsList *oslist, const gchar *prefix, TestURLFunc test_func)
-{
-    GList *osel = NULL, *tmp;
-
-    tmp = osel = osinfo_list_get_elements(OSINFO_LIST(oslist));
-
-    while (tmp) {
-        OsinfoOs *os = tmp->data;
-        gchar *name = g_strdup_printf("%s/%s",
-                                      prefix,
-                                      osinfo_product_get_short_id(OSINFO_PRODUCT(os)));
-
-        g_test_add_data_func(name, os, test_func);
-        g_free(name);
-
-        tmp = tmp->next;
-    }
-
-    g_list_free(osel);
-}
diff --git a/tests/test-uris-common.h b/tests/test-uris-common.h
deleted file mode 100644
index 34cc242..0000000
--- a/tests/test-uris-common.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2019 Red Hat, Inc.
- *
- * 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 2 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 <config.h>
-
-#include <osinfo/osinfo.h>
-
-typedef const gchar *(*GetURLFunc)(gpointer p);
-typedef void (*TestURLFunc)(gconstpointer p);
-
-void test_uri(OsinfoList *list, GetURLFunc get_url_func, GError **error);
-void test_uris(OsinfoOsList *oslist, const gchar *prefix, TestURLFunc test_func);
-- 
2.20.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux