From 551cf378a93588d42732983ec30716e14afef945 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 10 Jun 2017 18:11:25 +0100 Subject: Initial version --- test/Makefile | 3 +++ test/basic.c | 33 +++++++++++++++++++++++++++++++++ test/runtest.sh | 12 ++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 test/Makefile create mode 100644 test/basic.c create mode 100755 test/runtest.sh (limited to 'test') diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..0cebdaa --- /dev/null +++ b/test/Makefile @@ -0,0 +1,3 @@ +DIR_TEST_ITEMS := basic:basic.c + +include $(NSBUILD)/Makefile.subdir diff --git a/test/basic.c b/test/basic.c new file mode 100644 index 0000000..fd40633 --- /dev/null +++ b/test/basic.c @@ -0,0 +1,33 @@ +/* + * Copyright 2017 Daniel Silverstone + * + * This file is part of libnslog. + * + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#include "nslog/nslog.h" + +#include + +NSLOG_DEFINE_CATEGORY(test, "Test category"); + +static void test_render_function(void *ctx, nslog_entry_t *log) +{ + (void)ctx; + fprintf(stderr, "%s %s:%d [%s] %s() %s\n", + nslog_level_name(log->level), + log->filename, log->lineno, + log->category->name, + log->funcname, + log->message); +} + +int main(int argc, char **argv) +{ + nslog_set_render_callback(test_render_function, NULL); + nslog_uncork(); + NSLOG(test, WARN, "argc=%d", argc); + return 0; +} diff --git a/test/runtest.sh b/test/runtest.sh new file mode 100755 index 0000000..1b67a97 --- /dev/null +++ b/test/runtest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +TEST_PATH=$1 +TEST_PFX=$4 + +for TEST in basic; do + ${TEST_PATH}/${TEST_PFX}${TEST} +done + +exit 0 -- cgit v1.2.3