test/logging_tests.c

Tue, 09 Oct 2012 10:21:18 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 09 Oct 2012 10:21:18 +0200
changeset 55
180bc6b18fec
parent 54
f634f790661a
child 75
990734f548ef
permissions
-rw-r--r--

fixed map tests + used tmpfiles in tests

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);
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 fread(buffer, 1, 100, stream);
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19
f634f790661a added logging API
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 UCX_TEST_ASSERT(strncmp(buffer,
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