rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit a4a5b8fa69e2d6c789c0c4424b3138ffd8dc6d4e
parent 3b8aebd5bec050fd4e4cfe94f92fa92fd8a7a4df
Author: vaplv <vaplv@free.fr>
Date:   Tue, 23 Sep 2014 14:20:49 +0200

Add and test a logger

Diffstat:
Mcmake/CMakeLists.txt | 3+++
Asrc/logger.c | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/logger.h | 154+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/result.h | 1+
Msrc/test_binary_heap.c | 17+++--------------
Msrc/test_dynamic_array.c | 15+++------------
Msrc/test_free_list.c | 2--
Msrc/test_hash_table.c | 22++++------------------
Asrc/test_logger.c | 223+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/test_mutex.c | 298++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/test_str.c | 9++-------
Asrc/test_utils.h | 19+++++++++++++++++++
12 files changed, 631 insertions(+), 202 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -47,6 +47,7 @@ set(RSYS_FILES_SRC float44.c image.c library.c + logger.c mem_allocator.c pthread/pthread_condition.c pthread/pthread_mutex.c @@ -74,6 +75,7 @@ set(RSYS_FILES_INC image.h library.h list.h + logger.h math.h mem_allocator.h mutex.h @@ -123,6 +125,7 @@ new_test(test_free_list rsys) new_test(test_hash_table rsys) new_test(test_library rsys) new_test(test_list rsys) +new_test(test_logger rsys) new_test(test_mem_allocator rsys) new_test(test_binary_heap rsys) new_test(test_math m) diff --git a/src/logger.c b/src/logger.c @@ -0,0 +1,70 @@ +/* Copyright (C) 2013-2014 Vincent Forest (vaplv@free.fr) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#define _POSIX_C_SOURCE 200112L /* vsnprintf support */ +#include "logger.h" + +int +logger_print + (struct logger* logger, const enum log_type type, const char* log, ...) +{ + struct list_node* node = NULL; + va_list vargs_list; + int sz; + int err = 0; + ASSERT(logger && log && type < LOG_TYPES_COUNT__); + + if(logger == LOGGER_DEFAULT) { + va_start(vargs_list, log); + vfprintf(type == LOG_OUTPUT ? stdout : stderr, log, vargs_list); + va_end(vargs_list); + return 0; + } + + if(is_list_empty(logger->streams + type)) + return 0; + + va_start(vargs_list, log); + sz = vsnprintf + (darray_char_data_get(&logger->buffer), + darray_char_size_get(&logger->buffer), + log, vargs_list); + va_end(vargs_list); + ASSERT(sz > 0); + + /* If there is not sufficient space in the logger buffer, resize it */ + if((size_t)sz >= darray_char_size_get(&logger->buffer)) { + err = darray_char_resize(&logger->buffer, (size_t)sz + 1/*+1<=>'\0'*/); + if(err) + return err; + + va_start(vargs_list, log); + sz = vsnprintf + (darray_char_data_get(&logger->buffer), + darray_char_size_get(&logger->buffer), + log, vargs_list); + va_end(vargs_list); + ASSERT((size_t)sz < darray_char_size_get(&logger->buffer)); + } + + /* Broadcast the formatted string to the log streams */ + LIST_FOR_EACH(node, logger->streams + type) { + struct log_stream* stream = CONTAINER_OF + (node, struct log_stream, attachments[type]); + stream->writer(darray_char_cdata_get(&logger->buffer), stream->ctx); + } + return 0; +} + diff --git a/src/logger.h b/src/logger.h @@ -0,0 +1,154 @@ +/* Copyright (C) 2013-2014 Vincent Forest (vaplv@free.fr) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef LOGGER_H +#define LOGGER_H + +#include "dynamic_array_char.h" +#include "list.h" +#include "mem_allocator.h" + +#include <stdarg.h> + +#define LOGGER_DEFAULT (void*)0xC0DE + +enum log_type { + LOG_OUTPUT, + LOG_ERROR, + LOG_WARNING, + LOG_TYPES_COUNT__ +}; + +/******************************************************************************* + * Log stream that can be attached to a logger + ******************************************************************************/ +struct log_stream { + /* Internal data */ + struct list_node attachments[LOG_TYPES_COUNT__]; + void (*writer)(const char*msg, void* ctx); + void* ctx; /* User defined data */ +}; + +static INLINE void +log_stream_init(struct log_stream* stream) +{ + int i; + ASSERT(stream); + FOR_EACH(i, 0, LOG_TYPES_COUNT__) list_init(stream->attachments +i); + stream->writer = NULL; + stream->ctx = NULL; +} + +static INLINE void +log_stream_release(struct log_stream* stream) { (void)stream; } + +static INLINE void +log_stream_setup + (struct log_stream* stream, + void (*writer)(const char*, void*), + void* context) +{ + ASSERT(stream && writer); + stream->writer = writer; + stream->ctx = context; +} + +static INLINE void +log_stream_detach(struct log_stream* stream, const enum log_type type) +{ + ASSERT(stream && type < LOG_TYPES_COUNT__); + list_del(stream->attachments + type); +} + +static INLINE void +log_stream_clean(struct log_stream* stream) +{ + int i; + ASSERT(stream); + FOR_EACH(i, 0, LOG_TYPES_COUNT__) + log_stream_detach(stream, (enum log_type)i); +} + +/******************************************************************************* + * Logger + ******************************************************************************/ +struct logger { + /* Internal data */ + struct list_node streams[LOG_TYPES_COUNT__]; + struct mem_allocator* allocator; + struct darray_char buffer; +}; + +static INLINE int +logger_init + (struct mem_allocator* allocator, /* May be NULL <=> default allocator */ + struct logger* logger) +{ + int i; + ASSERT(logger); + logger->allocator = allocator ? allocator : &mem_default_allocator; + FOR_EACH(i, 0, LOG_TYPES_COUNT__) list_init(logger->streams + i); + darray_char_init(logger->allocator, &logger->buffer); + return darray_char_resize(&logger->buffer, 256); +} + +static INLINE void +logger_clear(struct logger* logger) +{ + int i; + ASSERT(logger); + FOR_EACH(i, 0, LOG_TYPES_COUNT__) { + struct list_node* node, *tmp; + LIST_FOR_EACH_SAFE(node, tmp, logger->streams + i) + list_del(node); + } +} + +static INLINE void +logger_release(struct logger* logger) +{ + ASSERT(logger); + logger_clear(logger); + darray_char_release(&logger->buffer); +} + +static INLINE void +logger_attach_stream + (struct logger* logger, + const enum log_type type, + struct log_stream* stream) +{ + ASSERT(logger && stream && is_list_empty(stream->attachments + type)); + ASSERT(type < LOG_TYPES_COUNT__); + list_add_tail(logger->streams + type, stream->attachments + type); +} + +BEGIN_DECLS + +RSYS_API int +logger_print + (struct logger* logger, + const enum log_type type, + const char* log, + ... ) +#ifdef COMPILER_GCC + __attribute((format(printf, 3, 4))) +#endif +; + +END_DECLS + +#endif /* LOGGER_H */ + diff --git a/src/result.h b/src/result.h @@ -0,0 +1 @@ + diff --git a/src/test_binary_heap.c b/src/test_binary_heap.c @@ -14,8 +14,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "binary_heap.h" -#include "mem_allocator.h" #include "str.h" +#include "test_utils.h" #define BHEAP_NAME u64 #define BHEAP_DATA uint64_t @@ -98,13 +98,7 @@ test_primitive_type(void) } bheap_u64_release(&heap); - - if(MEM_ALLOCATED_SIZE(&allocator_proxy)) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump)/sizeof(char)); - fprintf(stderr, "%s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } @@ -182,12 +176,7 @@ test_struct(void) str_release(&str); bheap_str_release(&heap); - if(MEM_ALLOCATED_SIZE(&allocator_proxy)) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump)/sizeof(char)); - fprintf(stderr, "%s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } diff --git a/src/test_dynamic_array.c b/src/test_dynamic_array.c @@ -14,6 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "dynamic_array.h" +#include "test_utils.h" #define DARRAY_NAME str #define DARRAY_DATA const char* @@ -91,12 +92,7 @@ test_primitive_type(void) CHECK(darray_str_size_get(&darray), 33); darray_str_release(&darray); - if(MEM_ALLOCATED_SIZE(&allocator_proxy)) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump)/sizeof(char)); - fprintf(stderr, "%s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } @@ -177,12 +173,7 @@ test_struct(void) darray_struct_str_release(&darray); - if(MEM_ALLOCATED_SIZE(&allocator_proxy)) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump)/sizeof(char)); - fprintf(stderr, "%s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } diff --git a/src/test_free_list.c b/src/test_free_list.c @@ -80,8 +80,6 @@ main(int argc, char** argv) } flist_object_release(&list); - CHECK(MEM_ALLOCATED_SIZE(&mem_default_allocator), 0); - return 0; } diff --git a/src/test_hash_table.c b/src/test_hash_table.c @@ -17,6 +17,7 @@ #include "hash.h" #include "hash_table.h" #include "str.h" +#include "test_utils.h" #include <string.h> #define HTABLE_KEY int @@ -66,12 +67,7 @@ test_htbl_int_float(void) } htable_int_float_release(&htbl); - if(MEM_ALLOCATED_SIZE(&allocator_proxy)) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump)/sizeof(char)); - fprintf(stderr, "%s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } @@ -266,12 +262,7 @@ test_htbl_str_int(void) str_release(&tmp); - if(MEM_ALLOCATED_SIZE(&allocator_proxy) ) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump) / sizeof(char)); - fprintf(stderr, "error: %s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } @@ -422,12 +413,7 @@ ANGVBA BS QRZBAF EHA NZBX VA BHE PVGVRF.", str_release(&tmp); darray_char_release(&darray); htable_str_darray_release(&htbl); - if(MEM_ALLOCATED_SIZE(&allocator_proxy) ) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump) / sizeof(char)); - fprintf(stderr, "error: %s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); } diff --git a/src/test_logger.c b/src/test_logger.c @@ -0,0 +1,223 @@ +/* Copyright (C) 2013-2014 Vincent Forest (vaplv@free.fr) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "logger.h" +#include "test_utils.h" + +static void +func_stream_out(const char* fmt, void* data) +{ + *(int*)data += 1; + CHECK(strcmp(fmt, "output"), 0); +} + +static void +func_stream_out_std(const char* fmt, void* data) +{ + (void)data; + printf("%s\n", fmt); +} + +static void +func_stream_out2(const char* fmt, void* data) +{ + *(int*)data += 1; + CHECK(strcmp(fmt, "output"), 0); +} + +static void +func_stream_err(const char* fmt, void* data) +{ + *(int*)data += 1; + CHECK(strcmp(fmt, "error"), 0); +} + +static void +func_stream_warn(const char* fmt, void* data) +{ + *(int*)data += 1; + CHECK(strcmp( fmt, "warning" ), 0); +} + +int +main(int argc, char** argv) +{ + int i = 0; + struct mem_allocator allocator_proxy; + struct log_stream stream_out; + struct log_stream stream_out2; + struct log_stream stream_err; + struct log_stream stream_warn; + struct logger logger; + int istream_out = 0; + int istream_err = 0; + int istream_warn = 0; + (void)argc, (void)argv; + + mem_init_proxy_allocator( &allocator_proxy, &mem_default_allocator ); + + FOR_EACH( i, 0, 10 ) { + logger_print(LOGGER_DEFAULT, LOG_OUTPUT, "Output: %d\n", i); + logger_print(LOGGER_DEFAULT, LOG_ERROR, "Error: %.10f\n", (float)i); + logger_print(LOGGER_DEFAULT, LOG_WARNING, "Warn: hop%c\n", (char)('a'+i)); + } + + log_stream_init(&stream_out); + log_stream_init(&stream_out2); + log_stream_init(&stream_err); + log_stream_init(&stream_warn); + + log_stream_setup(&stream_out, func_stream_out, &istream_out); + log_stream_setup(&stream_out2, func_stream_out2, &istream_out); + log_stream_setup(&stream_err, func_stream_err, &istream_err); + log_stream_setup(&stream_warn, func_stream_warn, &istream_warn); + + logger_init(&allocator_proxy, &logger); + logger_print(&logger, LOG_OUTPUT, "out%s", "put"); + CHECK(istream_out, 0); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + + logger_attach_stream(&logger, LOG_OUTPUT, &stream_out); + logger_print(&logger, LOG_OUTPUT, "output"); + CHECK(istream_out, 1); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + + logger_attach_stream(&logger, LOG_ERROR, &stream_err); + logger_attach_stream(&logger, LOG_WARNING, &stream_warn); + logger_print(&logger, LOG_OUTPUT, "output"); + CHECK(istream_out, 2); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + logger_print(&logger, LOG_ERROR, "error"); + CHECK(istream_out, 2); + CHECK(istream_err, 1); + CHECK(istream_warn, 0); + logger_print(&logger, LOG_WARNING, "war%c%s", 'n', "ing"); + CHECK(istream_out, 2); + CHECK(istream_err, 1); + CHECK(istream_warn, 1); + + logger_attach_stream(&logger, LOG_OUTPUT, &stream_out2); + logger_print(&logger, LOG_OUTPUT, "output"); + CHECK(istream_out, 4); + CHECK(istream_err, 1); + CHECK(istream_warn, 1); + + log_stream_detach(&stream_out, LOG_OUTPUT); + logger_print + ( &logger, LOG_OUTPUT, "%c%c%c%c%c%c", 'o', 'u' ,'t', 'p', 'u', 't' ); + CHECK(istream_out, 5); + CHECK(istream_err, 1); + CHECK(istream_warn, 1); + logger_print(&logger, LOG_ERROR, "error"); + CHECK(istream_out, 5); + CHECK(istream_err, 2); + CHECK(istream_warn, 1); + logger_print(&logger, LOG_WARNING, "warning"); + CHECK(istream_out, 5); + CHECK(istream_err, 2); + CHECK(istream_warn, 2); + log_stream_detach( &stream_err, LOG_ERROR ); + logger_print(&logger, LOG_ERROR, "error"); + CHECK(istream_out, 5); + CHECK(istream_err, 2); + CHECK(istream_warn, 2); + + logger_clear(&logger); + + istream_out = istream_err = istream_warn = 0; + logger_attach_stream(&logger, LOG_OUTPUT, &stream_out); + logger_attach_stream(&logger, LOG_ERROR, &stream_out); + logger_attach_stream(&logger, LOG_WARNING, &stream_out); + logger_print(&logger, LOG_OUTPUT, "output"); + CHECK(istream_out, 1); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + logger_print(&logger, LOG_ERROR, "output"); + CHECK(istream_out, 2); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + logger_print(&logger, LOG_WARNING, "output"); + CHECK(istream_out, 3); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + + log_stream_detach(&stream_out, LOG_WARNING); + logger_print(&logger, LOG_WARNING, "output"); + CHECK(istream_out, 3); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + logger_print(&logger, LOG_ERROR, "output"); + logger_print(&logger, LOG_OUTPUT, "output"); + CHECK(istream_out, 5); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + + log_stream_detach(&stream_out, LOG_OUTPUT); + log_stream_detach(&stream_out, LOG_OUTPUT); + logger_print(&logger, LOG_WARNING, "output"); + logger_print(&logger, LOG_OUTPUT, "output"); + CHECK(istream_out, 5); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + logger_print(&logger, LOG_ERROR, "output"); + CHECK(istream_out, 6); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + + logger_attach_stream(&logger, LOG_OUTPUT, &stream_out); + logger_attach_stream(&logger, LOG_WARNING, &stream_out); + logger_print(&logger, LOG_OUTPUT, "output"); + logger_print(&logger, LOG_ERROR, "output"); + logger_print(&logger, LOG_WARNING, "output"); + CHECK(istream_out, 9); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + log_stream_clean(&stream_out); + logger_print(&logger, LOG_OUTPUT, "output"); + logger_print(&logger, LOG_ERROR, "output"); + logger_print(&logger, LOG_WARNING, "output"); + CHECK(istream_out, 9); + CHECK(istream_err, 0); + CHECK(istream_warn, 0); + + log_stream_setup(&stream_out, func_stream_out_std, NULL); + logger_attach_stream(&logger, LOG_OUTPUT, &stream_out); + logger_print + (&logger, LOG_OUTPUT, "%s%s%s%s", +"Rcvfbqr 1, XARR-QRRC VA GUR QRNQ:\n\ +---------------------------------\n\n", +"BAPR LBH ORNG GUR OVT ONQNFFRF NAQ PYRNA BHG GUR ZBBA ONFR LBH'ER FHCCBFRQ GB\n\ +JVA, NERA'G LBH? NERA'G LBH? JURER'F LBHE SNG ERJNEQ NAQ GVPXRG UBZR? JUNG\n\ +GUR URYY VF GUVF? VG'F ABG FHCCBFRQ GB RAQ GUVF JNL!\n\n", +"VG FGVAXF YVXR EBGGRA ZRNG, OHG YBBXF YVXR GUR YBFG QRVZBF ONFR. YBBXF YVXR\n\ +LBH'ER FGHPX BA GUR FUBERF BS URYY. GUR BAYL JNL BHG VF GUEBHTU.\n\n", +"GB PBAGVAHR GUR QBBZ RKCREVRAPR, CYNL GUR FUBERF BS URYY NAQ VGF NZNMVAT\n\ +FRDHRY, VASREAB!\n"); + + log_stream_release(&stream_out); + log_stream_release(&stream_out2); + log_stream_release(&stream_err); + log_stream_release(&stream_warn); + logger_release(&logger); + + check_memory_allocator(&allocator_proxy); + mem_shutdown_proxy_allocator(&allocator_proxy); + CHECK(mem_allocated_size(), 0); + return 0; +} + diff --git a/src/test_mutex.c b/src/test_mutex.c @@ -20,149 +20,149 @@ #include <omp.h> static const char src_str[] = { - 'R', 'c', 'v', 'f', 'b', 'q', 'r', ' ', '1', ',', ' ', 'X', 'A', 'R', 'R', - '-', 'Q', 'R', 'R', 'C', ' ', 'V', 'A', ' ', 'G', 'U', 'R', ' ', 'Q', 'R', - 'N', 'Q', ':', '\n', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '-', '-', '-', '-', '-', '-', '-', '-', '\n', '\n', 'B', 'A', 'P', 'R', ' ', - 'L', 'B', 'H', ' ', 'O', 'R', 'N', 'G', ' ', 'G', 'U', 'R', ' ', 'O', 'V', - 'T', ' ', 'O', 'N', 'Q', 'N', 'F', 'F', 'R', 'F', ' ', 'N', 'A', 'Q', ' ', - 'P', 'Y', 'R', 'N', 'A', ' ', 'B', 'H', 'G', ' ', 'G', 'U', 'R', ' ', 'Z', - 'B', 'B', 'A', ' ', 'O', 'N', 'F', 'R', ' ', 'L', 'B', 'H', '\'', 'E', 'R', - ' ', 'F', 'H', 'C', 'C', 'B', 'F', 'R', 'Q', ' ', 'G', 'B', '\n', 'J', 'V', - 'A', ',', ' ', 'N', 'E', 'R', 'A', '\'', 'G', ' ', 'L', 'B', 'H', '?', ' ', - 'N', 'E', 'R', 'A', '\'', 'G', ' ', 'L', 'B', 'H', '?', ' ', 'J', 'U', 'R', - 'E', 'R', '\'', 'F', ' ', 'L', 'B', 'H', 'E', ' ', 'S', 'N', 'G', ' ', 'E', - 'R', 'J', 'N', 'E', 'Q', ' ', 'N', 'A', 'Q', ' ', 'G', 'V', 'P', 'X', 'R', - 'G', ' ', 'U', 'B', 'Z', 'R', '?', ' ', 'J', 'U', 'N', 'G', '\n', 'G', 'U', - 'R', ' ', 'U', 'R', 'Y', 'Y', ' ', 'V', 'F', ' ', 'G', 'U', 'V', 'F', '?', - ' ', 'V', 'G', '\'', 'F', ' ', 'A', 'B', 'G', ' ', 'F', 'H', 'C', 'C', 'B', - 'F', 'R', 'Q', ' ', 'G', 'B', ' ', 'R', 'A', 'Q', ' ', 'G', 'U', 'V', 'F', - ' ', 'J', 'N', 'L', '!', '\n', '\n', 'V', 'G', ' ', 'F', 'G', 'V', 'A', 'X', - 'F', ' ', 'Y', 'V', 'X', 'R', ' ', 'E', 'B', 'G', 'G', 'R', 'A', ' ', 'Z', - 'R', 'N', 'G', ',', ' ', 'O', 'H', 'G', ' ', 'Y', 'B', 'B', 'X', 'F', ' ', - 'Y', 'V', 'X', 'R', ' ', 'G', 'U', 'R', ' ', 'Y', 'B', 'F', 'G', ' ', 'Q', - 'R', 'V', 'Z', 'B', 'F', ' ', 'O', 'N', 'F', 'R', '.', ' ', 'Y', 'B', 'B', - 'X', 'F', ' ', 'Y', 'V', 'X', 'R', '\n', 'L', 'B', 'H', '\'', 'E', 'R', ' ', - 'F', 'G', 'H', 'P', 'X', ' ', 'B', 'A', ' ', 'G', 'U', 'R', ' ', 'F', 'U', - 'B', 'E', 'R', 'F', ' ', 'B', 'S', ' ', 'U', 'R', 'Y', 'Y', '.', ' ', 'G', - 'U', 'R', ' ', 'B', 'A', 'Y', 'L', ' ', 'J', 'N', 'L', ' ', 'B', 'H', 'G', - ' ', 'V', 'F', ' ', 'G', 'U', 'E', 'B', 'H', 'T', 'U', '.', '\n', '\n', 'G', - 'B', ' ', 'P', 'B', 'A', 'G', 'V', 'A', 'H', 'R', ' ', 'G', 'U', 'R', ' ', - 'Q', 'B', 'B', 'Z', ' ', 'R', 'K', 'C', 'R', 'E', 'V', 'R', 'A', 'P', 'R', - ',', ' ', 'C', 'Y', 'N', 'L', ' ', 'G', 'U', 'R', ' ', 'F', 'U', 'B', 'E', - 'R', 'F', ' ', 'B', 'S', ' ', 'U', 'R', 'Y', 'Y', ' ', 'N', 'A', 'Q', ' ', - 'V', 'G', 'F', ' ', 'N', 'Z', 'N', 'M', 'V', 'A', 'T', '\n', 'F', 'R', 'D', - 'H', 'R', 'Y', ',', ' ', 'V', 'A', 'S', 'R', 'E', 'A', 'B', '!', '\n', '\n', - 'R', 'c', 'v', 'f', 'b', 'q', 'r', ' ', '2', ',', ' ', 'G', 'U', 'R', ' ', - 'F', 'U', 'B', 'E', 'R', 'F', ' ', 'B', 'S', ' ', 'U', 'R', 'Y', 'Y', ':', - '\n', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '-', '\n', '\n', 'L', 'B', 'H', '\'', 'I', 'R', ' ', 'Q', 'B', 'A', 'R', ' ', - 'V', 'G', '!', ' ', 'G', 'U', 'R', ' ', 'U', 'V', 'Q', 'R', 'B', 'H', 'F', - ' ', 'P', 'L', 'O', 'R', 'E', '-', ' ', 'Q', 'R', 'Z', 'B', 'A', ' ', 'Y', - 'B', 'E', 'Q', ' ', 'G', 'U', 'N', 'G', ' ', 'E', 'H', 'Y', 'R', 'Q', ' ', - 'G', 'U', 'R', ' ', 'Y', 'B', 'F', 'G', ' ', 'Q', 'R', 'V', 'Z', 'B', 'F', - ' ', 'Z', 'B', 'B', 'A', '\n', 'O', 'N', 'F', 'R', ' ', 'U', 'N', 'F', ' ', - 'O', 'R', 'R', 'A', ' ', 'F', 'Y', 'N', 'V', 'A', ' ', 'N', 'A', 'Q', ' ', - 'L', 'B', 'H', ' ', 'N', 'E', 'R', ' ', 'G', 'E', 'V', 'H', 'Z', 'C', 'U', - 'N', 'A', 'G', '!', ' ', 'O', 'H', 'G', ' ', '.', '.', '.', ' ', 'J', 'U', - 'R', 'E', 'R', ' ', 'N', 'E', 'R', ' ', 'L', 'B', 'H', '?', ' ', 'L', 'B', - 'H', '\n', 'P', 'Y', 'N', 'Z', 'O', 'R', 'E', ' ', 'G', 'B', ' ', 'G', 'U', - 'R', ' ', 'R', 'Q', 'T', 'R', ' ', 'B', 'S', ' ', 'G', 'U', 'R', ' ', 'Z', - 'B', 'B', 'A', ' ', 'N', 'A', 'Q', ' ', 'Y', 'B', 'B', 'X', ' ', 'Q', 'B', - 'J', 'A', ' ', 'G', 'B', ' ', 'F', 'R', 'R', ' ', 'G', 'U', 'R', ' ', 'N', - 'J', 'S', 'H', 'Y', ' ', 'G', 'E', 'H', 'G', 'U', '.', '\n', '\n', 'Q', 'R', - 'V', 'Z', 'B', 'F', ' ', 'S', 'Y', 'B', 'N', 'G', 'F', ' ', 'N', 'O', 'B', - 'I', 'R', ' ', 'U', 'R', 'Y', 'Y', ' ', 'V', 'G', 'F', 'R', 'Y', 'S', '!', - ' ', ' ', 'L', 'B', 'H', '\'', 'I', 'R', ' ', 'A', 'R', 'I', 'R', 'E', ' ', - 'U', 'R', 'N', 'E', 'Q', ' ', 'B', 'S', ' ', 'N', 'A', 'L', 'B', 'A', 'R', - ' ', 'R', 'F', 'P', 'N', 'C', 'V', 'A', 'T', ' ', 'S', 'E', 'B', 'Z', '\n', - 'U', 'R', 'Y', 'Y', ',', ' ', 'O', 'H', 'G', ' ', 'L', 'B', 'H', '\'', 'Y', - 'Y', ' ', 'Z', 'N', 'X', 'R', ' ', 'G', 'U', 'R', ' ', 'O', 'N', 'F', 'G', - 'N', 'E', 'Q', 'F', ' ', 'F', 'B', 'E', 'E', 'L', ' ', 'G', 'U', 'R', 'L', - ' ', 'R', 'I', 'R', 'E', ' ', 'U', 'R', 'N', 'E', 'Q', ' ', 'B', 'S', ' ', - 'L', 'B', 'H', '!', ' ', 'D', 'H', 'V', 'P', 'X', 'Y', 'L', ',', ' ', 'L', - 'B', 'H', '\n', 'E', 'N', 'C', 'C', 'R', 'Y', ' ', 'Q', 'B', 'J', 'A', ' ', - 'G', 'B', ' ', 'G', 'U', 'R', ' ', 'F', 'H', 'E', 'S', 'N', 'P', 'R', ' ', - 'B', 'S', ' ', 'U', 'R', 'Y', 'Y', '.', '\n', '\n', 'A', 'B', 'J', ',', ' ', - 'V', 'G', '\'', 'F', ' ', 'B', 'A', ' ', 'G', 'B', ' ', 'G', 'U', 'R', ' ', - 'S', 'V', 'A', 'N', 'Y', ' ', 'P', 'U', 'N', 'C', 'G', 'R', 'E', ' ', 'B', - 'S', ' ', 'Q', 'B', 'B', 'Z', '!', ' ', '-', '-', ' ', 'V', 'A', 'S', 'R', - 'E', 'A', 'B', '.', '\n', '\n', 'R', 'c', 'v', 'f', 'b', 'q', 'r', ' ', '3', - ',', ' ', 'V', 'A', 'S', 'R', 'E', 'A', 'B', ':', '\n', '-', '-', '-', '-', - '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '\n', '\n', 'G', 'U', 'R', ' ', 'Y', 'B', 'N', 'G', 'U', 'F', 'B', 'Z', 'R', - ' ', 'F', 'C', 'V', 'Q', 'R', 'E', 'Q', 'R', 'Z', 'B', 'A', ' ', 'G', 'U', - 'N', 'G', ' ', 'Z', 'N', 'F', 'G', 'R', 'E', 'Z', 'V', 'A', 'Q', 'R', 'Q', - ' ', 'G', 'U', 'R', ' ', 'V', 'A', 'I', 'N', 'F', 'V', 'B', 'A', ' ', 'B', - 'S', ' ', 'G', 'U', 'R', ' ', 'Z', 'B', 'B', 'A', ' ', 'O', 'N', 'F', 'R', - 'F', '\n', 'N', 'A', 'Q', ' ', 'P', 'N', 'H', 'F', 'R', 'Q', ' ', 'F', 'B', - ' ', 'Z', 'H', 'P', 'U', ' ', 'Q', 'R', 'N', 'G', 'U', ' ', 'U', 'N', 'F', - ' ', 'U', 'N', 'Q', ' ', 'V', 'G', 'F', ' ', 'N', 'F', 'F', ' ', 'X', 'V', - 'P', 'X', 'R', 'Q', ' ', 'S', 'B', 'E', ' ', 'N', 'Y', 'Y', ' ', 'G', 'V', - 'Z', 'R', '.', '\n', '\n', 'N', ' ', 'U', 'V', 'Q', 'Q', 'R', 'A', ' ', 'Q', - 'B', 'B', 'E', 'J', 'N', 'L', ' ', 'B', 'C', 'R', 'A', 'F', ' ', 'N', 'A', - 'Q', ' ', 'L', 'B', 'H', ' ', 'R', 'A', 'G', 'R', 'E', '.', ' ', ' ', 'L', - 'B', 'H', '\'', 'I', 'R', ' ', 'C', 'E', 'B', 'I', 'R', 'A', ' ', 'G', 'B', - 'B', ' ', 'G', 'B', 'H', 'T', 'U', ' ', 'S', 'B', 'E', ' ', 'U', 'R', 'Y', - 'Y', ' ', 'G', 'B', '\n', 'P', 'B', 'A', 'G', 'N', 'V', 'A', ',', ' ', 'N', - 'A', 'Q', ' ', 'A', 'B', 'J', ' ', 'U', 'R', 'Y', 'Y', ' ', 'N', 'G', ' ', - 'Y', 'N', 'F', 'G', ' ', 'C', 'Y', 'N', 'L', 'F', ' ', 'S', 'N', 'V', 'E', - ' ', '-', '-', ' ', 'S', 'B', 'E', ' ', 'L', 'B', 'H', ' ', 'R', 'Z', 'R', - 'E', 'T', 'R', ' ', 'S', 'E', 'B', 'Z', ' ', 'G', 'U', 'R', ' ', 'Q', 'B', - 'B', 'E', ' ', 'G', 'B', '\n', 'F', 'R', 'R', ' ', 'G', 'U', 'R', ' ', 'T', - 'E', 'R', 'R', 'A', ' ', 'S', 'V', 'R', 'Y', 'Q', 'F', ' ', 'B', 'S', ' ', - 'R', 'N', 'E', 'G', 'U', '!', ' ', ' ', 'U', 'B', 'Z', 'R', ' ', 'N', 'G', - ' ', 'Y', 'N', 'F', 'G', '.', '\n', '\n', 'L', 'B', 'H', ' ', 'J', 'B', 'A', - 'Q', 'R', 'E', ' ', 'J', 'U', 'N', 'G', '\'', 'F', ' ', 'O', 'R', 'R', 'A', - ' ', 'U', 'N', 'C', 'C', 'R', 'A', 'V', 'A', 'T', ' ', 'B', 'A', ' ', 'R', - 'N', 'E', 'G', 'U', ' ', 'J', 'U', 'V', 'Y', 'R', ' ', 'L', 'B', 'H', ' ', - 'J', 'R', 'E', 'R', ' ', 'O', 'N', 'G', 'G', 'Y', 'V', 'A', 'T', ' ', 'R', - 'I', 'V', 'Y', '\n', 'H', 'A', 'Y', 'R', 'N', 'F', 'U', 'R', 'Q', '.', ' ', - 'V', 'G', '\'', 'F', ' ', 'T', 'B', 'B', 'Q', ' ', 'G', 'U', 'N', 'G', ' ', - 'A', 'B', ' ', 'U', 'R', 'Y', 'Y', '-', ' ', 'F', 'C', 'N', 'J', 'A', ' ', - 'P', 'B', 'H', 'Y', 'Q', ' ', 'U', 'N', 'I', 'R', ' ', 'P', 'B', 'Z', 'R', - ' ', 'G', 'U', 'E', 'B', 'H', 'T', 'U', ' ', 'G', 'U', 'N', 'G', ' ', 'Q', - 'B', 'B', 'E', '\n', 'J', 'V', 'G', 'U', ' ', 'L', 'B', 'H', ' ', '.', '.', - '.', '\n', '\n', 'R', 'c', 'v', 'f', 'b', 'q', 'r', ' ', '4', ',', ' ', 'G', - 'U', 'L', ' ', 'S', 'Y', 'R', 'F', 'U', ' ', 'P', 'B', 'A', 'F', 'H', 'Z', - 'R', 'Q', ':', '\n', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', - '-', '-', '-', '-', '\n', '\n', 'G', 'U', 'R', ' ', 'F', 'C', 'V', 'Q', 'R', - 'E', ' ', 'Z', 'N', 'F', 'G', 'R', 'E', 'Z', 'V', 'A', 'Q', ' ', 'Z', 'H', - 'F', 'G', ' ', 'U', 'N', 'I', 'R', ' ', 'F', 'R', 'A', 'G', ' ', 'S', 'B', - 'E', 'G', 'U', ' ', 'V', 'G', 'F', ' ', 'Y', 'R', 'T', 'V', 'B', 'A', 'F', - ' ', 'B', 'S', ' ', 'U', 'R', 'Y', 'Y', 'F', 'C', 'N', 'J', 'A', ' ', 'O', - 'R', 'S', 'B', 'E', 'R', '\n', 'L', 'B', 'H', 'E', ' ', 'S', 'V', 'A', 'N', - 'Y', ' ', 'P', 'B', 'A', 'S', 'E', 'B', 'A', 'G', 'N', 'G', 'V', 'B', 'A', - ' ', 'J', 'V', 'G', 'U', ' ', 'G', 'U', 'N', 'G', ' ', 'G', 'R', 'E', 'E', - 'V', 'O', 'Y', 'R', ' ', 'O', 'R', 'N', 'F', 'G', ' ', 'S', 'E', 'B', 'Z', - ' ', 'U', 'R', 'Y', 'Y', '.', ' ', 'O', 'H', 'G', ' ', 'L', 'B', 'H', ' ', - 'F', 'G', 'R', 'C', 'C', 'R', 'Q', '\n', 'S', 'B', 'E', 'J', 'N', 'E', 'Q', - ' ', 'N', 'A', 'Q', ' ', 'O', 'E', 'B', 'H', 'T', 'U', 'G', ' ', 'S', 'B', - 'E', 'G', 'U', ' ', 'R', 'G', 'R', 'E', 'A', 'N', 'Y', ' ', 'Q', 'N', 'Z', - 'A', 'N', 'G', 'V', 'B', 'A', ' ', 'N', 'A', 'Q', ' ', 'F', 'H', 'S', 'S', - 'R', 'E', 'V', 'A', 'T', ' ', 'H', 'C', 'B', 'A', ' ', 'G', 'U', 'R', ' ', - 'U', 'B', 'E', 'Q', 'R', ' ', 'N', 'F', ' ', 'N', '\n', 'G', 'E', 'H', 'R', - ' ', 'U', 'R', 'E', 'B', ' ', 'J', 'B', 'H', 'Y', 'Q', ' ', 'V', 'A', ' ', - 'G', 'U', 'R', ' ', 'S', 'N', 'P', 'R', ' ', 'B', 'S', ' ', 'F', 'B', 'Z', - 'R', 'G', 'U', 'V', 'A', 'T', ' ', 'F', 'B', ' ', 'R', 'I', 'V', 'Y', '.', - '\n', '\n', 'O', 'R', 'F', 'V', 'Q', 'R', 'F', ',', ' ', 'F', 'B', 'Z', 'R', - 'B', 'A', 'R', ' ', 'J', 'N', 'F', ' ', 'T', 'B', 'A', 'A', 'N', ' ', 'C', - 'N', 'L', ' ', 'S', 'B', 'E', ' ', 'J', 'U', 'N', 'G', ' ', 'U', 'N', 'C', - 'C', 'R', 'A', 'R', 'Q', ' ', 'G', 'B', ' ', 'Q', 'N', 'V', 'F', 'L', ',', - ' ', 'L', 'B', 'H', 'E', ' ', 'C', 'R', 'G', ' ', 'E', 'N', 'O', 'O', 'V', - 'G', '.', '\n', '\n', 'O', 'H', 'G', ' ', 'A', 'B', 'J', ',', ' ', 'L', 'B', - 'H', ' ', 'F', 'R', 'R', ' ', 'F', 'C', 'E', 'R', 'N', 'Q', ' ', 'O', 'R', - 'S', 'B', 'E', 'R', ' ', 'L', 'B', 'H', ' ', 'Z', 'B', 'E', 'R', ' ', 'C', - 'B', 'G', 'R', 'A', 'G', 'V', 'N', 'Y', ' ', 'C', 'N', 'V', 'A', ' ', 'N', - 'A', 'Q', ' ', 'T', 'V', 'O', 'O', 'V', 'G', 'H', 'Q', 'R', ' ', 'N', 'F', - ' ', 'N', '\n', 'A', 'N', 'G', 'V', 'B', 'A', ' ', 'B', 'S', ' ', 'Q', 'R', - 'Z', 'B', 'A', 'F', ' ', 'E', 'H', 'A', ' ', 'N', 'Z', 'B', 'X', ' ', 'V', - 'A', ' ', 'B', 'H', 'E', ' ', 'P', 'V', 'G', 'V', 'R', 'F', '.', '\n', '\n', - 'A', 'R', 'K', 'G', ' ', 'F', 'G', 'B', 'C', ',', ' ', 'U', 'R', 'Y', 'Y', - ' ', 'B', 'A', ' ', 'R', 'N', 'E', 'G', 'U', '!', '\n' + 'R','c','v','f','b','q','r',' ','1',',',' ','X','A','R','R', + '-','Q','R','R','C',' ','V','A',' ','G','U','R',' ','Q','R', + 'N','Q',':','\n','-','-','-','-','-','-','-','-','-','-','-', + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-', + '-','-','-','-','-','-','-','-','\n','\n','B','A','P','R',' ', + 'L','B','H',' ','O','R','N','G',' ','G','U','R',' ','O','V', + 'T',' ','O','N','Q','N','F','F','R','F',' ','N','A','Q',' ', + 'P','Y','R','N','A',' ','B','H','G',' ','G','U','R',' ','Z', + 'B','B','A',' ','O','N','F','R',' ','L','B','H','\'','E','R', + ' ','F','H','C','C','B','F','R','Q',' ','G','B','\n','J','V', + 'A',',',' ','N','E','R','A','\'','G',' ','L','B','H','?',' ', + 'N','E','R','A','\'','G',' ','L','B','H','?',' ','J','U','R', + 'E','R','\'','F',' ','L','B','H','E',' ','S','N','G',' ','E', + 'R','J','N','E','Q',' ','N','A','Q',' ','G','V','P','X','R', + 'G',' ','U','B','Z','R','?',' ','J','U','N','G','\n','G','U', + 'R',' ','U','R','Y','Y',' ','V','F',' ','G','U','V','F','?', + ' ','V','G','\'','F',' ','A','B','G',' ','F','H','C','C','B', + 'F','R','Q',' ','G','B',' ','R','A','Q',' ','G','U','V','F', + ' ','J','N','L','!','\n','\n','V','G',' ','F','G','V','A','X', + 'F',' ','Y','V','X','R',' ','E','B','G','G','R','A',' ','Z', + 'R','N','G',',',' ','O','H','G',' ','Y','B','B','X','F',' ', + 'Y','V','X','R',' ','G','U','R',' ','Y','B','F','G',' ','Q', + 'R','V','Z','B','F',' ','O','N','F','R','.',' ','Y','B','B', + 'X','F',' ','Y','V','X','R','\n','L','B','H','\'','E','R',' ', + 'F','G','H','P','X',' ','B','A',' ','G','U','R',' ','F','U', + 'B','E','R','F',' ','B','S',' ','U','R','Y','Y','.',' ','G', + 'U','R',' ','B','A','Y','L',' ','J','N','L',' ','B','H','G', + ' ','V','F',' ','G','U','E','B','H','T','U','.','\n','\n','G', + 'B',' ','P','B','A','G','V','A','H','R',' ','G','U','R',' ', + 'Q','B','B','Z',' ','R','K','C','R','E','V','R','A','P','R', + ',',' ','C','Y','N','L',' ','G','U','R',' ','F','U','B','E', + 'R','F',' ','B','S',' ','U','R','Y','Y',' ','N','A','Q',' ', + 'V','G','F',' ','N','Z','N','M','V','A','T','\n','F','R','D', + 'H','R','Y',',',' ','V','A','S','R','E','A','B','!','\n','\n', + 'R','c','v','f','b','q','r',' ','2',',',' ','G','U','R',' ', + 'F','U','B','E','R','F',' ','B','S',' ','U','R','Y','Y',':', + '\n','-','-','-','-','-','-','-','-','-','-','-','-','-','-', + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-', + '-','\n','\n','L','B','H','\'','I','R',' ','Q','B','A','R',' ', + 'V','G','!',' ','G','U','R',' ','U','V','Q','R','B','H','F', + ' ','P','L','O','R','E','-',' ','Q','R','Z','B','A',' ','Y', + 'B','E','Q',' ','G','U','N','G',' ','E','H','Y','R','Q',' ', + 'G','U','R',' ','Y','B','F','G',' ','Q','R','V','Z','B','F', + ' ','Z','B','B','A','\n','O','N','F','R',' ','U','N','F',' ', + 'O','R','R','A',' ','F','Y','N','V','A',' ','N','A','Q',' ', + 'L','B','H',' ','N','E','R',' ','G','E','V','H','Z','C','U', + 'N','A','G','!',' ','O','H','G',' ','.','.','.',' ','J','U', + 'R','E','R',' ','N','E','R',' ','L','B','H','?',' ','L','B', + 'H','\n','P','Y','N','Z','O','R','E',' ','G','B',' ','G','U', + 'R',' ','R','Q','T','R',' ','B','S',' ','G','U','R',' ','Z', + 'B','B','A',' ','N','A','Q',' ','Y','B','B','X',' ','Q','B', + 'J','A',' ','G','B',' ','F','R','R',' ','G','U','R',' ','N', + 'J','S','H','Y',' ','G','E','H','G','U','.','\n','\n','Q','R', + 'V','Z','B','F',' ','S','Y','B','N','G','F',' ','N','O','B', + 'I','R',' ','U','R','Y','Y',' ','V','G','F','R','Y','S','!', + ' ',' ','L','B','H','\'','I','R',' ','A','R','I','R','E',' ', + 'U','R','N','E','Q',' ','B','S',' ','N','A','L','B','A','R', + ' ','R','F','P','N','C','V','A','T',' ','S','E','B','Z','\n', + 'U','R','Y','Y',',',' ','O','H','G',' ','L','B','H','\'','Y', + 'Y',' ','Z','N','X','R',' ','G','U','R',' ','O','N','F','G', + 'N','E','Q','F',' ','F','B','E','E','L',' ','G','U','R','L', + ' ','R','I','R','E',' ','U','R','N','E','Q',' ','B','S',' ', + 'L','B','H','!',' ','D','H','V','P','X','Y','L',',',' ','L', + 'B','H','\n','E','N','C','C','R','Y',' ','Q','B','J','A',' ', + 'G','B',' ','G','U','R',' ','F','H','E','S','N','P','R',' ', + 'B','S',' ','U','R','Y','Y','.','\n','\n','A','B','J',',',' ', + 'V','G','\'','F',' ','B','A',' ','G','B',' ','G','U','R',' ', + 'S','V','A','N','Y',' ','P','U','N','C','G','R','E',' ','B', + 'S',' ','Q','B','B','Z','!',' ','-','-',' ','V','A','S','R', + 'E','A','B','.','\n','\n','R','c','v','f','b','q','r',' ','3', + ',',' ','V','A','S','R','E','A','B',':','\n','-','-','-','-', + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-', + '\n','\n','G','U','R',' ','Y','B','N','G','U','F','B','Z','R', + ' ','F','C','V','Q','R','E','Q','R','Z','B','A',' ','G','U', + 'N','G',' ','Z','N','F','G','R','E','Z','V','A','Q','R','Q', + ' ','G','U','R',' ','V','A','I','N','F','V','B','A',' ','B', + 'S',' ','G','U','R',' ','Z','B','B','A',' ','O','N','F','R', + 'F','\n','N','A','Q',' ','P','N','H','F','R','Q',' ','F','B', + ' ','Z','H','P','U',' ','Q','R','N','G','U',' ','U','N','F', + ' ','U','N','Q',' ','V','G','F',' ','N','F','F',' ','X','V', + 'P','X','R','Q',' ','S','B','E',' ','N','Y','Y',' ','G','V', + 'Z','R','.','\n','\n','N',' ','U','V','Q','Q','R','A',' ','Q', + 'B','B','E','J','N','L',' ','B','C','R','A','F',' ','N','A', + 'Q',' ','L','B','H',' ','R','A','G','R','E','.',' ',' ','L', + 'B','H','\'','I','R',' ','C','E','B','I','R','A',' ','G','B', + 'B',' ','G','B','H','T','U',' ','S','B','E',' ','U','R','Y', + 'Y',' ','G','B','\n','P','B','A','G','N','V','A',',',' ','N', + 'A','Q',' ','A','B','J',' ','U','R','Y','Y',' ','N','G',' ', + 'Y','N','F','G',' ','C','Y','N','L','F',' ','S','N','V','E', + ' ','-','-',' ','S','B','E',' ','L','B','H',' ','R','Z','R', + 'E','T','R',' ','S','E','B','Z',' ','G','U','R',' ','Q','B', + 'B','E',' ','G','B','\n','F','R','R',' ','G','U','R',' ','T', + 'E','R','R','A',' ','S','V','R','Y','Q','F',' ','B','S',' ', + 'R','N','E','G','U','!',' ',' ','U','B','Z','R',' ','N','G', + ' ','Y','N','F','G','.','\n','\n','L','B','H',' ','J','B','A', + 'Q','R','E',' ','J','U','N','G','\'','F',' ','O','R','R','A', + ' ','U','N','C','C','R','A','V','A','T',' ','B','A',' ','R', + 'N','E','G','U',' ','J','U','V','Y','R',' ','L','B','H',' ', + 'J','R','E','R',' ','O','N','G','G','Y','V','A','T',' ','R', + 'I','V','Y','\n','H','A','Y','R','N','F','U','R','Q','.',' ', + 'V','G','\'','F',' ','T','B','B','Q',' ','G','U','N','G',' ', + 'A','B',' ','U','R','Y','Y','-',' ','F','C','N','J','A',' ', + 'P','B','H','Y','Q',' ','U','N','I','R',' ','P','B','Z','R', + ' ','G','U','E','B','H','T','U',' ','G','U','N','G',' ','Q', + 'B','B','E','\n','J','V','G','U',' ','L','B','H',' ','.','.', + '.','\n','\n','R','c','v','f','b','q','r',' ','4',',',' ','G', + 'U','L',' ','S','Y','R','F','U',' ','P','B','A','F','H','Z', + 'R','Q',':','\n','-','-','-','-','-','-','-','-','-','-','-', + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-', + '-','-','-','-','\n','\n','G','U','R',' ','F','C','V','Q','R', + 'E',' ','Z','N','F','G','R','E','Z','V','A','Q',' ','Z','H', + 'F','G',' ','U','N','I','R',' ','F','R','A','G',' ','S','B', + 'E','G','U',' ','V','G','F',' ','Y','R','T','V','B','A','F', + ' ','B','S',' ','U','R','Y','Y','F','C','N','J','A',' ','O', + 'R','S','B','E','R','\n','L','B','H','E',' ','S','V','A','N', + 'Y',' ','P','B','A','S','E','B','A','G','N','G','V','B','A', + ' ','J','V','G','U',' ','G','U','N','G',' ','G','R','E','E', + 'V','O','Y','R',' ','O','R','N','F','G',' ','S','E','B','Z', + ' ','U','R','Y','Y','.',' ','O','H','G',' ','L','B','H',' ', + 'F','G','R','C','C','R','Q','\n','S','B','E','J','N','E','Q', + ' ','N','A','Q',' ','O','E','B','H','T','U','G',' ','S','B', + 'E','G','U',' ','R','G','R','E','A','N','Y',' ','Q','N','Z', + 'A','N','G','V','B','A',' ','N','A','Q',' ','F','H','S','S', + 'R','E','V','A','T',' ','H','C','B','A',' ','G','U','R',' ', + 'U','B','E','Q','R',' ','N','F',' ','N','\n','G','E','H','R', + ' ','U','R','E','B',' ','J','B','H','Y','Q',' ','V','A',' ', + 'G','U','R',' ','S','N','P','R',' ','B','S',' ','F','B','Z', + 'R','G','U','V','A','T',' ','F','B',' ','R','I','V','Y','.', + '\n','\n','O','R','F','V','Q','R','F',',',' ','F','B','Z','R', + 'B','A','R',' ','J','N','F',' ','T','B','A','A','N',' ','C', + 'N','L',' ','S','B','E',' ','J','U','N','G',' ','U','N','C', + 'C','R','A','R','Q',' ','G','B',' ','Q','N','V','F','L',',', + ' ','L','B','H','E',' ','C','R','G',' ','E','N','O','O','V', + 'G','.','\n','\n','O','H','G',' ','A','B','J',',',' ','L','B', + 'H',' ','F','R','R',' ','F','C','E','R','N','Q',' ','O','R', + 'S','B','E','R',' ','L','B','H',' ','Z','B','E','R',' ','C', + 'B','G','R','A','G','V','N','Y',' ','C','N','V','A',' ','N', + 'A','Q',' ','T','V','O','O','V','G','H','Q','R',' ','N','F', + ' ','N','\n','A','N','G','V','B','A',' ','B','S',' ','Q','R', + 'Z','B','A','F',' ','E','H','A',' ','N','Z','B','X',' ','V', + 'A',' ','B','H','E',' ','P','V','G','V','R','F','.','\n','\n', + 'A','R','K','G',' ','F','G','B','C',',',' ','U','R','Y','Y', + ' ','B','A',' ','R','N','E','G','U','!','\n' }; enum mutex_type { @@ -267,16 +267,16 @@ test_mutex(const enum mutex_type type) string.i = 0; switch(type) { - case MUTEX_COMMON: - string.mutex = mutex_create(); + case MUTEX_COMMON: + string.mutex = mutex_create(); NCHECK(string.mutex, NULL); break; - case MUTEX_SPIN: - string.mutex_spin = mutex_spin_create(); + case MUTEX_SPIN: + string.mutex_spin = mutex_spin_create(); NCHECK(string.mutex_spin, NULL); break; - case MUTEX_RW: - string.mutex_rw = mutex_rw_create(); + case MUTEX_RW: + string.mutex_rw = mutex_rw_create(); NCHECK(string.mutex_rw, NULL); break; default: ASSERT(0); break; diff --git a/src/test_str.c b/src/test_str.c @@ -13,8 +13,8 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "mem_allocator.h" #include "str.h" +#include "test_utils.h" #include <string.h> int @@ -127,12 +127,7 @@ main(int argc, char** argv) str_release(&str); - if(MEM_ALLOCATED_SIZE(&allocator_proxy)) { - char dump[512]; - MEM_DUMP(&allocator_proxy, dump, sizeof(dump) / sizeof(char)); - fprintf(stderr, "error: %s\n", dump); - FATAL("Memory leaks\n"); - } + check_memory_allocator(&allocator_proxy); mem_shutdown_proxy_allocator(&allocator_proxy); CHECK(mem_allocated_size(), 0); return 0; diff --git a/src/test_utils.h b/src/test_utils.h @@ -0,0 +1,19 @@ +#ifndef TEST_UTILS_H +#define TEST_UTILS_H + +#include "mem_allocator.h" +#include <stdio.h> + +static void +check_memory_allocator(struct mem_allocator* allocator) +{ + if(MEM_ALLOCATED_SIZE(allocator)) { + char dump[512]; + MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char)); + fprintf(stderr, "%s\n", dump); + FATAL("Memory leaks\n"); + } +} + +#endif /* TEST_UTILS_H */ +