[Libosinfo] [libosinfo PATCH 15/31] tests: Add basic test for DeviceLink
Fabiano Fidêncio
fidencio at redhat.com
Fri Nov 23 10:15:04 UTC 2018
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
.gitignore | 1 +
tests/Makefile.am | 5 +++
tests/test-devicelink.c | 71 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 tests/test-devicelink.c
diff --git a/.gitignore b/.gitignore
index 0f36a99..076cca1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,6 +53,7 @@ tests/test-hypervisor
tests/test-link
tests/test-list
tests/test-db
+tests/test-devicelink
tests/test-devicelist
tests/test-devicelinklist
tests/test-feature
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b603b02..1ba0a60 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,7 @@ check_PROGRAMS = \
test-device \
test-link \
test-list \
+ test-devicelink \
test-devicelist \
test-devicelinklist \
test-feature \
@@ -54,6 +55,10 @@ test_device_LDADD = $(COMMON_LDADD)
test_device_CFLAGS = $(COMMON_CFLAGS)
test_device_SOURCES = test-device.c
+test_devicelink_LDADD = $(COMMON_LDADD)
+test_devicelink_CFLAGS = $(COMMON_CFLAGS)
+test_devicelink_SOURCES = test-devicelink.c
+
test_feature_LDADD = $(COMMON_LDADD)
test_feature_CFLAGS = $(COMMON_CFLAGS)
test_feature_SOURCES = test-feature.c
diff --git a/tests/test-devicelink.c b/tests/test-devicelink.c
new file mode 100644
index 0000000..70ab19a
--- /dev/null
+++ b/tests/test-devicelink.c
@@ -0,0 +1,71 @@
+/*
+ * 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_devicelink_basic(void)
+{
+ OsinfoDeviceLink *devicelink;
+ OsinfoDevice *device;
+ OsinfoEntity *entity;
+
+ device = osinfo_device_new("foo");
+
+ devicelink = osinfo_devicelink_new(device);
+ g_assert_true(OSINFO_IS_DEVICELINK(devicelink));
+ g_assert_true(OSINFO_IS_LINK(devicelink));
+
+ entity = osinfo_link_get_target(OSINFO_LINK(devicelink));
+ g_assert_true(OSINFO_IS_DEVICE(entity));
+ g_assert_true(OSINFO_IS_ENTITY(entity));
+
+ g_assert_true(device == OSINFO_DEVICE(entity));
+
+ g_object_unref(device);
+ g_object_unref(devicelink);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/devicelink/basic", test_devicelink_basic);
+
+ /* Upfront so we don't confuse valgrind */
+ osinfo_device_get_type();
+ osinfo_devicelink_get_type();
+ osinfo_entity_get_type();
+ osinfo_link_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