/src/scripts/quality-agent
/src/scripts/extract-debuginfo
/src/systemd/*.service
+/tests/libpakfire/main
/tmp
*.py[co]
/*.tar.bz2
AM_CFLAGS = $(OUR_CFLAGS)
AM_LDFLAGS = $(OUR_LDFLAGS)
-PAKFIRE_CFLAGS = -I$(top_srcdir)/src/libpakfire/include
-PAKFIRE_LIBS = libpakfire.la
+PAKFIRE_CPPFLAGS = -I$(top_srcdir)/src/libpakfire/include
+PAKFIRE_LIBS = libpakfire.la
+check_PROGRAMS =
lib_LTLIBRARIES =
libexec_PROGRAMS =
pkgpyexec_LTLIBRARIES =
src/_pakfire/util.c \
src/_pakfire/util.h
+_pakfire_la_CPPFLAGS = \
+ $(PAKFIRE_CPPFLAGS)
+
_pakfire_la_CFLAGS = \
$(AM_CFLAGS) \
$(PYTHON_DEVEL_CFLAGS) \
- $(PAKFIRE_CFLAGS) \
$(CAP_CFLAGS) \
$(SOLV_CFLAGS)
src/libpakfire/include/pakfire/util.h
libpakfire_la_CFLAGS = \
- $(AM_CFLAGS)
+ $(AM_CFLAGS) \
+ $(LIBGCRYPT_CFLAGS)
libpakfire_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
- $(LIBGCRYPT_CFLAGS) \
-I$(top_srcdir)/src/libpakfire/include \
-include $(top_builddir)/config.h \
-DPAKFIRE_PRIVATE
EXTRA_DIST += \
src/libpakfire/libpakfire.sym
+check_PROGRAMS += \
+ tests/libpakfire/main
+
+dist_tests_libpakfire_main_SOURCES = \
+ tests/libpakfire/main.c
+
+tests_libpakfire_main_CPPFLAGS = \
+ $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_main_LDADD = \
+ $(TESTSUITE_LDADD) \
+ $(PAKFIRE_LIBS)
+
# ------------------------------------------------------------------------------
lib_LTLIBRARIES += \
# - testsuite ------------------------------------------------------------------
+check_LTLIBRARIES = \
+ tests/libtestsuite.la
+
+tests_libtestsuite_la_SOURCES = \
+ tests/testsuite.c \
+ tests/testsuite.h
+
+TESTSUITE_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ $(PAKFIRE_CPPFLAGS)
+
+TESTSUITE_LDADD = \
+ tests/libtestsuite.la
+
TESTS_ENVIRONMENT = \
PYTHONPATH="$(top_srcdir)/.libs:$(top_srcdir)/src" \
topdir="$(shell pwd)"
-dist_check_SCRIPTS = \
- tests/module-load.py
+#dist_check_SCRIPTS = \
+# tests/module-load.py
TESTS = \
- $(dist_check_SCRTIPS)
+ $(check_PROGRAMS) \
+ $(dist_check_SCRIPTS)
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <pakfire/pakfire.h>
+
+#include "../testsuite.h"
+
+static int test_init(const test_t* t) {
+ Pakfire pakfire = pakfire_create("/", "x86_64");
+ if (!pakfire)
+ return EXIT_FAILURE;
+
+ LOG("Allocated at %p\n", pakfire);
+
+ pakfire_unref(pakfire);
+
+ return EXIT_SUCCESS;
+}
+
+int main(int argc, char** argv) {
+ testsuite_t* ts = testsuite_create(1);
+
+ testsuite_add_test(ts, "test_init", test_init);
+
+ return testsuite_run(ts);
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include "testsuite.h"
+
+int test_run(const test_t* t) {
+ LOG("running %s\n", t->name);
+
+ int r = t->func(t);
+
+ return r;
+}
+
+testsuite_t* testsuite_create(size_t n) {
+ testsuite_t* ts = calloc(1, sizeof(*ts));
+ if (!ts)
+ exit(EXIT_FAILURE);
+
+ // Make space for n tests
+ ts->tests = calloc(n + 1, sizeof(*ts->tests));
+ ts->left = n;
+
+ return ts;
+};
+
+int testsuite_add_test(testsuite_t* ts, const char* name, test_function_t* func) {
+ if (ts->left == 0)
+ exit(EXIT_FAILURE);
+
+ test_t** last = ts->tests;
+ while (*last)
+ last++;
+
+ test_t* test = *last = calloc(1, sizeof(**last));
+ if (test) {
+ test->name = name;
+ test->func = func;
+ }
+
+ ts->left--;
+
+ return 0;
+}
+
+int testsuite_run(testsuite_t* ts) {
+ for (test_t** t = ts->tests; *t; t++) {
+ int r = test_run(*t);
+ if (r)
+ exit(r);
+ }
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+// Forward declaration
+struct test;
+
+typedef int (*test_function_t)(const struct test* t);
+
+typedef struct test {
+ const char* name;
+ test_function_t func;
+} test_t;
+
+typedef struct testsuite {
+ test_t** tests;
+ size_t left;
+} testsuite_t;
+
+testsuite_t* testsuite_create(size_t n);
+int testsuite_add_test(testsuite_t* ts, const char* name, test_function_t* func);
+int testsuite_run(testsuite_t* ts);
+
+int test_run(const test_t* t);
+
+#define _LOG(prefix, fmt, ...) printf("TESTS: " prefix fmt, ## __VA_ARGS__);
+#define LOG(fmt, ...) _LOG("", fmt, ## __VA_ARGS__);
+#define LOG_WARN(fmt, ...) _LOG("WARN: ", fmt, ## __VA_ARGS__);
+#define LOG_ERROR(fmt, ...) _LOG("ERROR: ", fmt, ## __VA_ARGS__);
+
+#define assert_return(expr, r) \
+ do { \
+ if ((!(expr))) { \
+ ERR_("Failed assertion: " #expr " %s:%d %s\n", \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__); \
+ return r; \
+ } \
+ } while (0)