[Libosinfo] [libosinfo PATCH 4/5] tests: Add basic tests for OsinfoMedia
Fabiano Fidêncio
fidencio at redhat.com
Fri Nov 23 14:09:59 UTC 2018
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
.gitignore | 1 +
tests/Makefile.am | 5 ++++
tests/test-media.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 tests/test-media.c
diff --git a/.gitignore b/.gitignore
index 951c8a4..68f4567 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,7 @@ tests/test-filter
tests/test-hypervisorlist
tests/test-install-script
tests/test-loader
+tests/test-media
tests/test-productfilter
tests/test-oslist
tests/test-os-resources
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 00dcc9c..3106ee8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@ check_PROGRAMS = \
test-devicelist \
test-devicelinklist \
test-filter \
+ test-media \
test-product \
test-os \
test-oslist \
@@ -74,6 +75,10 @@ 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_SOURCES = test-media.c
+
test_devicelist_LDADD = $(COMMON_LDADD)
test_devicelist_CFLAGS = $(COMMON_CFLAGS)
test_devicelist_SOURCES = test-devicelist.c
diff --git a/tests/test-media.c b/tests/test-media.c
new file mode 100644
index 0000000..062b751
--- /dev/null
+++ b/tests/test-media.c
@@ -0,0 +1,58 @@
+/*
+ * 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êncio <fidencio at redhat.com>
+ */
+
+#include <config.h>
+
+#include <osinfo/osinfo.h>
+
+
+
+static void
+test_basic(void)
+{
+ OsinfoMedia *media = osinfo_media_new("foo", "x86_64");
+
+ g_assert_true(OSINFO_IS_MEDIA(media));
+ g_assert_cmpstr((const char *)osinfo_entity_get_id(OSINFO_ENTITY(media)), ==, "foo");
+ g_assert_cmpstr((const char *)osinfo_media_get_architecture(media), ==, "x86_64");
+
+ g_object_unref(media);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/media/basic", test_basic);
+
+ /* Upfront so we don't confuse valgrind */
+ osinfo_media_get_type();
+
+ return g_test_run();
+}
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
--
2.19.1
More information about the Libosinfo
mailing list