test/logging_tests.c

Thu, 17 Jan 2013 23:56:48 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 17 Jan 2013 23:56:48 +0100
changeset 77
51311a5685d3
parent 75
990734f548ef
child 80
0125e4089f88
permissions
-rw-r--r--

used more library friendly optimization level

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