test/logging_tests.c

Fri, 30 Nov 2012 13:10:58 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 30 Nov 2012 13:10:58 +0100
changeset 76
655020a30e77
parent 75
990734f548ef
child 80
0125e4089f88
permissions
-rw-r--r--

fixed buffer

54
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 *
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 */
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 #include "logging_tests.h"
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 UCX_TEST_IMPLEMENT(test_ucx_logger_log) {
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 char buffer[100];
55
180bc6b18fec fixed map tests + used tmpfiles in tests
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
9 FILE *stream = tmpfile();
180bc6b18fec fixed map tests + used tmpfiles in tests
Mike Becker <universe@uap-core.de>
parents: 54
diff changeset
10
54
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 UcxLogger *logger = ucx_logger_new(stream, UCX_LOGGER_INFO);
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 UCX_TEST_BEGIN
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 ucx_logger_info(logger, ST("[INFO:] allright\n"));
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 ucx_logger_trace(logger, ST("[TRACE:] dont log this!\n"));
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 ucx_logger_error(logger, ST("[ERROR:] error!\n"));
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 fseek(stream, 0, SEEK_SET);
75
990734f548ef fixed some compiler warnings
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
18 int r = fread(buffer, 1, 100, stream);
54
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19
75
990734f548ef fixed some compiler warnings
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
20 UCX_TEST_ASSERT(r == 33 && strncmp(buffer,
54
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 "[INFO:] allright\n[ERROR:] error!\n", 33) == 0, "incorrect logs");
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 UCX_TEST_END
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 free(logger);
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 fclose(stream);
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 }

mercurial