[libosinfo PATCH v3 07/10] tests: Add test-image

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

 



test-image tests the basic functionally of OsImage APIs.

https://gitlab.com/libosinfo/osinfo-db/issues/10

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 tests/Makefile.am  |  5 ++++
 tests/test-image.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)
 create mode 100644 tests/test-image.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 06f81bf..410f373 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,6 +18,7 @@ check_PROGRAMS = \
 	test-isodetect \
 	test-install-script \
 	test-os-resources \
+	test-image \
         $(NULL)
 
 if HAVE_CURL
@@ -116,6 +117,10 @@ test_os_resources_LDADD = $(COMMON_LDADD)
 test_os_resources_CFLAGS = $(COMMON_CFLAGS)
 test_os_resources_SOURCES = test-os-resources.c
 
+test_image_LDADD = $(COMMON_LDADD)
+test_image_CFLAGS = $(COMMON_CFLAGS)
+test_image_SOURCES = test-image.c
+
 TESTS = $(check_PROGRAMS) \
 	$(NULL)
 
diff --git a/tests/test-image.c b/tests/test-image.c
new file mode 100644
index 0000000..053e041
--- /dev/null
+++ b/tests/test-image.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2018 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:
+ *   Fabiano Fidênciog <fidencio@xxxxxxxxxx>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+
+#define ID "foo"
+#define ARCH "x86_64"
+#define FORMAT "qcow2"
+#define URL "https://foo.bar/foobar.img";
+
+static void
+test_basic(void)
+{
+    OsinfoImage *image = osinfo_image_new(ID, ARCH, FORMAT);
+    osinfo_entity_set_param(OSINFO_ENTITY(image),
+                            OSINFO_IMAGE_PROP_URL,
+                            URL);
+
+    g_assert_true(OSINFO_IS_IMAGE(image));
+    g_assert_cmpstr(osinfo_entity_get_id(OSINFO_ENTITY(image)), ==, ID);
+    g_assert_cmpstr(osinfo_image_get_architecture(image), ==, ARCH);
+    g_assert_cmpstr(osinfo_image_get_format(image), ==, FORMAT);
+    g_assert_cmpstr(osinfo_image_get_url(image), ==, URL);
+
+    g_object_unref(image);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+    g_test_init(&argc, &argv, NULL);
+
+    g_test_add_func("/image/basic", test_basic);
+
+    /* Upfront so we don't confuse valgrind */
+    osinfo_image_get_type();
+
+    return g_test_run();
+}
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ */
-- 
2.19.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