]> git.ipfire.org Git - pakfire.git/commitdiff
testsuite: Log to stderr
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Nov 2017 22:46:04 +0000 (23:46 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Nov 2017 22:46:04 +0000 (23:46 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/logging.h
src/libpakfire/libpakfire.sym
tests/libpakfire/main.c
tests/testsuite.c
tests/testsuite.h

index ae0d45e5f6dfbd0294d09c586ccaa589752df3b0..96b93d9c2720a87bec6c1be98780d437ab3590c8 100644 (file)
@@ -35,6 +35,11 @@ void pakfire_log_set_function(pakfire_log_function_t func);
 int pakfire_log_get_priority();
 void pakfire_log_set_priority(int priority);
 
+void pakfire_log_stderr(int priority, const char* file,
+       int line, const char* fn, const char* format, va_list args);
+void pakfire_log_syslog(int priority, const char* file,
+       int line, const char* fn, const char* format, va_list args);
+
 #ifdef PAKFIRE_PRIVATE
 
 typedef struct pakfire_logging_config {
index 470818cf08180d25c85420f8c4512cd762f115ff..addb0a66bccdb5851bd90b994c05b9ef95fd430c 100644 (file)
@@ -104,6 +104,8 @@ global:
        pakfire_log_get_priority;
        pakfire_log_set_function;
        pakfire_log_set_priority;
+       pakfire_log_stderr;
+       pakfire_log_syslog;
 
        # package
        pakfire_package_add_conflicts;
index 4d6108e14c7f2f135616d427b95ddb7177e0c3ec..caebf741fd312842532268562a26a526a41af938 100644 (file)
@@ -37,6 +37,8 @@ static int test_init(const test_t* t) {
 }
 
 int main(int argc, char** argv) {
+       testsuite_init();
+
        testsuite_t* ts = testsuite_create(1);
 
        testsuite_add_test(ts, "test_init", test_init);
index ca99a1f211e11d2b86ccd62d50eba43fae9ed365..e77388178405ddc141034b87053fef0d534b847d 100644 (file)
 
 #include "testsuite.h"
 
+#include <pakfire/logging.h>
+#include <pakfire/pakfire.h>
+
+int testsuite_init() {
+       // Initialize the pakfire library
+       int r = pakfire_init();
+       if (r)
+               return r;
+
+       // Log to stderr
+       pakfire_log_set_function(pakfire_log_stderr);
+}
+
 int test_run(const test_t* t) {
        LOG("running %s\n", t->name);
 
index f99bd20c65744358002e6553d8fcfecc93ff8b49..406512dd69b5a4fbe05455c67825e5291d9f9414 100644 (file)
@@ -36,6 +36,7 @@ typedef struct testsuite {
        size_t left;
 } testsuite_t;
 
+int testsuite_init();
 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);