From: Michael Tremer Date: Mon, 8 Aug 2022 15:24:27 +0000 (+0000) Subject: tests: Add simple create/free test for builds X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1066c7f711198d2d7d52f66644a267467d94ba8b;p=people%2Fstevee%2Fpakfire.git tests: Add simple create/free test for builds Signed-off-by: Michael Tremer --- diff --git a/.gitignore b/.gitignore index 7dfc5787..0945ff6a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ /tests/.root /tests/libpakfire/arch /tests/libpakfire/archive +/tests/libpakfire/build /tests/libpakfire/cgroup /tests/libpakfire/compress /tests/libpakfire/config diff --git a/Makefile.am b/Makefile.am index e3468150..bd953cbc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -368,6 +368,7 @@ check_PROGRAMS += \ tests/libpakfire/main \ tests/libpakfire/arch \ tests/libpakfire/archive \ + tests/libpakfire/build \ tests/libpakfire/cgroup \ tests/libpakfire/compress \ tests/libpakfire/config \ @@ -421,6 +422,18 @@ tests_libpakfire_archive_CFLAGS = \ tests_libpakfire_archive_LDADD = \ $(TESTSUITE_LDADD) +dist_tests_libpakfire_build_SOURCES = \ + tests/libpakfire/build.c + +tests_libpakfire_build_CPPFLAGS = \ + $(TESTSUITE_CPPFLAGS) + +tests_libpakfire_build_CFLAGS = \ + $(TESTSUITE_CFLAGS) + +tests_libpakfire_build_LDADD = \ + $(TESTSUITE_LDADD) + dist_tests_libpakfire_cgroup_SOURCES = \ tests/libpakfire/cgroup.c diff --git a/tests/libpakfire/build.c b/tests/libpakfire/build.c new file mode 100644 index 00000000..a1a44500 --- /dev/null +++ b/tests/libpakfire/build.c @@ -0,0 +1,49 @@ +/*############################################################################# +# # +# Pakfire - The IPFire package management system # +# Copyright (C) 2022 Pakfire development team # +# # +# 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 3 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 . # +# # +#############################################################################*/ + +#include + +#include + +#include "../testsuite.h" + +static int test_create_and_free(const struct test* t) { + struct pakfire_build* build = NULL; + + // Create a new build + ASSERT_SUCCESS(pakfire_build_create(&build, t->pakfire, NULL, 0)); + + // Check if build actually got allocated + ASSERT(build); + + // Free the build + ASSERT(pakfire_build_unref(build) == NULL); + + return EXIT_SUCCESS; + +FAIL: + return EXIT_FAILURE; +} + +int main(int argc, char** argv) { + testsuite_add_test(test_create_and_free); + + return testsuite_run(); +}