[Libosinfo] [libosinfo PATCH v2 03/12] tests: Add basic test for OsinfoFeature
Fabiano Fidêncio
fidencio at redhat.com
Fri Jan 11 14:48:22 UTC 2019
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
.gitignore | 1 +
tests/Makefile.am | 5 ++++
tests/test-feature.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
create mode 100644 tests/test-feature.c
diff --git a/.gitignore b/.gitignore
index b888b50..524d9a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ tests/test-list
tests/test-db
tests/test-devicelist
tests/test-devicelinklist
+tests/test-feature
tests/test-filter
tests/test-hypervisorlist
tests/test-install-script
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 45703df..6f3cdb4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,6 +7,7 @@ check_PROGRAMS = \
test-list \
test-devicelist \
test-devicelinklist \
+ test-feature \
test-filter \
test-media \
test-product \
@@ -54,6 +55,10 @@ test_device_LDADD = $(COMMON_LDADD)
test_device_CFLAGS = $(COMMON_CFLAGS)
test_device_SOURCES = test-device.c
+test_feature_LDADD = $(COMMON_LDADD)
+test_feature_CFLAGS = $(COMMON_CFLAGS)
+test_feature_SOURCES = test-feature.c
+
test_filter_LDADD = $(COMMON_LDADD)
test_filter_CFLAGS = $(COMMON_CFLAGS)
test_filter_SOURCES = test-filter.c
diff --git a/tests/test-feature.c b/tests/test-feature.c
new file mode 100644
index 0000000..12a6944
--- /dev/null
+++ b/tests/test-feature.c
@@ -0,0 +1,62 @@
+/*
+ * 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>
+#include "osinfo/osinfo_feature_private.h"
+
+
+static void
+test_basic(void)
+{
+ OsinfoFeature *feature = osinfo_feature_new("foo");
+
+ g_assert_true(OSINFO_IS_FEATURE(feature));
+ g_assert_cmpstr(osinfo_entity_get_id(OSINFO_ENTITY(feature)), ==, "foo");
+ g_assert_cmpstr(osinfo_feature_get_name(feature), ==, "foo");
+ g_assert_true(osinfo_feature_get_supported(feature));
+
+ osinfo_feature_set_supported(feature, FALSE);
+ g_assert_false(osinfo_feature_get_supported(feature));
+
+ g_object_unref(feature);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/feature/basic", test_basic);
+
+ /* Upfront so we don't confuse valgrind */
+ osinfo_feature_get_type();
+
+ return g_test_run();
+}
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ */
--
2.19.2
More information about the Libosinfo
mailing list