summaryrefslogtreecommitdiff
path: root/test/parse-auto.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2018-01-20 17:31:20 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2018-01-20 17:31:20 +0000
commit0dd48e83fbc246a881609b4c18ce10001ba1cc1a (patch)
tree7494cc81744799ab88f1503ac5ff044be2fcf4a5 /test/parse-auto.c
parente220b0fc2ede1dcbbe7e6e62c256e2ec297f26a3 (diff)
downloadlibcss-0dd48e83fbc246a881609b4c18ce10001ba1cc1a.tar.gz
libcss-0dd48e83fbc246a881609b4c18ce10001ba1cc1a.tar.bz2
Add support for logging via libnslog.
Release builds minumum compiled level is warning. Debug builds minimum compiled level is debug.
Diffstat (limited to 'test/parse-auto.c')
-rw-r--r--test/parse-auto.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/parse-auto.c b/test/parse-auto.c
index 58ccf9a..a298864 100644
--- a/test/parse-auto.c
+++ b/test/parse-auto.c
@@ -99,6 +99,20 @@ static void destroy_expected(line_ctx *ctx)
}
}
+static void test_logger(
+ void *_ctx, nslog_entry_context_t *ctx,
+ const char *fmt,
+ va_list args)
+{
+ UNUSED(_ctx);
+ fprintf(stderr, "%s: %s: %s:%i: ",
+ nslog_level_name(ctx->level),
+ ctx->category->description,
+ ctx->filename, ctx->lineno);
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+}
+
int main(int argc, char **argv)
{
line_ctx ctx;
@@ -108,6 +122,16 @@ int main(int argc, char **argv)
return 1;
}
+ if (nslog_set_render_callback(test_logger, NULL) != NSLOG_NO_ERROR) {
+ printf("Unable to set log render callback\n");
+ return 1;
+ }
+
+ if (nslog_uncork() != NSLOG_NO_ERROR) {
+ printf("Failed to uncork log.\n");
+ return 1;
+ }
+
ctx.buflen = css__parse_filesize(argv[1]);
if (ctx.buflen == 0)
return 1;
@@ -143,6 +167,8 @@ int main(int argc, char **argv)
assert(fail_because_lwc_leaked == false);
+ nslog_cleanup();
+
printf("PASS\n");
return 0;