$(o)/ucw/basecode.test: $(o)/ucw/basecode
$(addprefix $(o)/ucw/fb-,file.test grow.test pool.test socket.test atomic.test \
limfd.test temp.test mem.test buffer.test mmap.test): %.test: %-t
+$(o)/ucw/fb-atomic-tt.o: CFLAGS += -DFB_ATOMIC_TRACE
$(o)/ucw/url.test: $(o)/ucw/url-t
ifdef CONFIG_UCW_THREADS
* or -(expected maximum record length) for variable-sized ones.
*/
-#define LOCAL_DEBUG
-
#include "ucw/lib.h"
#include "ucw/fastbuf.h"
#include "ucw/lfs.h"
+#include "ucw/conf.h"
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+static uns trace;
+
+static struct cf_section fbatomic_config = {
+ CF_ITEMS {
+ CF_UNS("Trace", &trace)
+ }
+};
+
+static void CONSTRUCTOR fbatomic_init_config(void)
+{
+ cf_declare_section("FBAtomic", &fbatomic_config, 1);
+}
+
+#define TRACE(m...) do { if(trace) msg(L_DEBUG, "FB_ATOMIC: " m); } while(0)
+
struct fb_atomic_file {
int fd;
int use_count;
uns written = f->bptr - f->buffer;
uns size = f->bufend - f->buffer + F->slack_size;
F->slack_size *= 2;
- DBG("Reallocating buffer for atomic file %s with slack %d", f->name, F->slack_size);
+ TRACE("Reallocating buffer for atomic file %s with slack %d", f->name, F->slack_size);
f->buffer = xrealloc(f->buffer, size);
f->bufend = f->buffer + size;
f->bptr = f->buffer + written;
{
struct fastbuf *f, *g;
+ // Always trace in the test
+ trace = 1;
+
msg(L_INFO, "Testing block writes");
f = fbatomic_open("test", NULL, 16, 4);
for (u32 i=0; i<17; i++)
Run: ../obj/ucw/fb-atomic-t 2>&1 | sed -e 's/^\(.\) [^ ]* [^ ]* /\1 /'
Out: I Testing block writes
I Testing interleaved var-size writes
- D Reallocating buffer for atomic file test2 with slack 10
- D Reallocating buffer for atomic file test2 with slack 10
+ D FB_ATOMIC: Reallocating buffer for atomic file test2 with slack 10
+ D FB_ATOMIC: Reallocating buffer for atomic file test2 with slack 10