Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- .gitignore | 1 + tests/Makefile.am | 5 +++++ tests/test-firmware.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/test-firmware.c diff --git a/.gitignore b/.gitignore index 553e83d..d6300b3 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ tests/test-db tests/test-devicelist tests/test-devicelinklist tests/test-filter +tests/test-firmware tests/test-install-script tests/test-image tests/test-imagelist diff --git a/tests/Makefile.am b/tests/Makefile.am index bdd68d3..06be48d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,6 +8,7 @@ check_PROGRAMS = \ test-devicelist \ test-devicelinklist \ test-filter \ + test-firmware \ test-media \ test-product \ test-os \ @@ -50,6 +51,10 @@ test_filter_LDADD = $(COMMON_LDADD) test_filter_CFLAGS = $(COMMON_CFLAGS) test_filter_SOURCES = test-filter.c +test_firmware_LDADD = $(COMMON_LDADD) +test_firmware_CFLAGS = $(COMMON_CFLAGS) +test_firmware_SOURCES = test-firmware.c + test_product_LDADD = $(COMMON_LDADD) test_product_CFLAGS = $(COMMON_CFLAGS) test_product_SOURCES = test-product.c diff --git a/tests/test-firmware.c b/tests/test-firmware.c new file mode 100644 index 0000000..a78758a --- /dev/null +++ b/tests/test-firmware.c @@ -0,0 +1,48 @@ +/* + * 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> + +#define ID "foo:0" +#define ARCH "x86_64" +#define TYPE "efi" + +static void +test_basic(void) +{ + OsinfoFirmware *firmware = osinfo_firmware_new(ID, ARCH, TYPE); + + g_assert_true(OSINFO_IS_FIRMWARE(firmware)); + g_assert_cmpstr(osinfo_entity_get_id(OSINFO_ENTITY(firmware)), ==, ID); + g_assert_cmpstr(osinfo_firmware_get_architecture(firmware), ==, ARCH); + g_assert_cmpstr(osinfo_firmware_get_firmware_type(firmware), ==, TYPE); +} + +int +main(int argc, char *argv[]) +{ + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/firmware/basic", test_basic); + + /* Upfront so we don't confuse valgrind */ + osinfo_firmware_get_type(); + + return g_test_run(); +} -- 2.21.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo