summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Jarosch <tomj@simonv.com>2015-01-03 16:47:27 +0100
committerThomas Jarosch <tomj@simonv.com>2015-01-03 18:17:11 +0100
commite7d94323bcb481d4fb1e1e77fdd26b23916aca1d (patch)
tree863e37924202d9c7414753927cf98ece026112c2
parente13801625634809a3b16bc41911d180b9497336d (diff)
downloadrockbox-e7d9432.tar.gz
rockbox-e7d9432.zip
Enable printing of buflib allocations
Change-Id: Ie446177931032d585f69e0651f05ff88ebc6e8ba
-rw-r--r--firmware/test/buflib/Makefile6
-rw-r--r--firmware/test/buflib/test_main.c11
-rw-r--r--firmware/test/buflib/util.c28
-rw-r--r--firmware/test/buflib/util.h27
4 files changed, 65 insertions, 7 deletions
diff --git a/firmware/test/buflib/Makefile b/firmware/test/buflib/Makefile
index 7c0d36a8ca..f4eed2843a 100644
--- a/firmware/test/buflib/Makefile
+++ b/firmware/test/buflib/Makefile
@@ -1,7 +1,7 @@
FIRMWARE=../..
CC ?= gcc
-CFLAGS += -g -O2 -DDEBUG -D__PCTOOL__ -std=gnu99 -I$(FIRMWARE)/include -I$(FIRMWARE)/export -I.
+CFLAGS += -g -O2 -DDEBUG -D__PCTOOL__ -DBUFLIB_DEBUG_BLOCKS -std=gnu99 -I$(FIRMWARE)/include -I$(FIRMWARE)/export -I.
LDFLAGS += -L. -lpthread
.PHONY: clean all
@@ -11,7 +11,9 @@ TARGETS = $(TARGETS_OBJ:.o=)
LIB_OBJ = buflib.o \
crc32.o \
- strlcpy.o
+ strlcpy.o \
+ util.o
+
LIB_FILE = libbuflib.a
LIB = buflib
diff --git a/firmware/test/buflib/test_main.c b/firmware/test/buflib/test_main.c
index 050deca006..83b95e4341 100644
--- a/firmware/test/buflib/test_main.c
+++ b/firmware/test/buflib/test_main.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "buflib.h"
+#include "util.h"
#define BUFLIB_BUFFER_SIZE (12<<10)
static char buflib_buffer[BUFLIB_BUFFER_SIZE];
@@ -59,16 +60,16 @@ int main(int argc, char **argv)
strncpy(buflib_get_data(&ctx, id3), STR, sizeof STR);
if (id > 0)
{
-// buflib_print_allocs(&ctx);
+ buflib_print_allocs(&ctx, &print_handle);
buflib_free(&ctx, id);
-// buflib_print_allocs(&ctx);
+ buflib_print_allocs(&ctx, &print_handle);
buflib_free(&ctx, id2);
-// buflib_print_allocs(&ctx);
+ buflib_print_allocs(&ctx, &print_handle);
id = buflib_alloc_ex(&ctx, 3<<10, "should compact", &ops);
if (id <= 0) printf("compacting alloc failed\n");
-// buflib_print_allocs(&ctx);
+ buflib_print_allocs(&ctx, &print_handle);
printf("id I: %p\n", buflib_get_data(&ctx, id3));
id2 = buflib_alloc_ex(&ctx, 3<<10, "should fail", &ops);
@@ -80,7 +81,7 @@ int main(int argc, char **argv)
buflib_free(&ctx, id);
printf("Check string: \"%s\"\n", buflib_get_data(&ctx, id3));
-// buflib_print_allocs(&ctx);
+ buflib_print_allocs(&ctx, &print_handle);
}
return 0;
diff --git a/firmware/test/buflib/util.c b/firmware/test/buflib/util.c
new file mode 100644
index 0000000000..934a8be763
--- /dev/null
+++ b/firmware/test/buflib/util.c
@@ -0,0 +1,28 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2015 Thomas Jarosch
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+#include "util.h"
+#include "stdio.h"
+
+void print_handle(int handle_num, const char *str)
+{
+ (void)handle_num;
+ printf("%s\n", str);
+}
diff --git a/firmware/test/buflib/util.h b/firmware/test/buflib/util.h
new file mode 100644
index 0000000000..f25f106172
--- /dev/null
+++ b/firmware/test/buflib/util.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+* __________ __ ___.
+* Open \______ \ ____ ____ | | _\_ |__ _______ ___
+* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+* \/ \/ \/ \/ \/
+* $Id$
+*
+* Copyright (C) 2015 Thomas Jarosch
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+* KIND, either express or implied.
+*
+****************************************************************************/
+
+#ifndef _TEST_UTIL_H
+#define _TEST_UTIL_H
+
+void print_handle(int handle_num, const char *string);
+
+#endif