Commit 4abb5ba3 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Use toku_assert instead of assert. Addresses #354.

git-svn-id: file:///svn/tokudb@2167 c7de825b-a66e-492c-adef-691d508d4ae1
parent 520eec42
......@@ -127,22 +127,24 @@ pma-test benchmark-test brt-test brt-serialize-test brtdump: LDFLAGS+=-lz
BRT_INTERNAL_H_INCLUDES = brt-internal.h cachetable.h fifo.h pma.h brt.h brttypes.h yerror.h ybt.h log.h ../include/db.h kv-pair.h memory.h crc.h
key.o: brttypes.h key.h
list-test: list-test.o toku_assert.o
pma-test.o: $(BRT_INTERNAL_H_INCLUDES) pma-internal.h pma.h list.h mempool.h
pma-test: pma.o memory.o key.o ybt.o log.o mempool.o fingerprint.o brt-serialize.o fifo.o primes.o toku_assert.o log_code.o roll.o brt.o cachetable.o brt-verify.o
pma.o: pma.h yerror.h pma-internal.h memory.h key.h ybt.h brttypes.h log.h ../include/db.h log_header.h
ybt.o: ybt.h brttypes.h ../include/db.h
ybt-test: ybt-test.o ybt.o memory.o
ybt-test: ybt-test.o ybt.o memory.o toku_assert.o
ybt-test.o: ybt.h ../include/db.h
cachetable.o: cachetable.h hashfun.h memory.h
brt-test: ybt.o brt.o fifo.o pma.o memory.o brt-serialize.o cachetable.o ybt.o key.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o
log.o: log_header.h log-internal.h log.h wbuf.h crc.h brttypes.h $(BRT_INTERNAL_H_INCLUDES)
logformat: logformat.o toku_assert.o
brt-test.o brt.o: brt.h ../include/db.h fifo.h pma.h brttypes.h cachetable.h memory.h
brt-serialize-test.o: $(BRT_INTERNAL_H_INCLUDES)
brt.o: $(BRT_INTERNAL_H_INCLUDES) key.h log_header.h
fifo.o: fifo.h brttypes.h
memory.o: memory.h
primes.o: primes.h toku_assert.h
fifo-test: fifo.o memory.o
fifo-test: fifo.o memory.o toku_assert.o
brt-serialize.o: $(BRT_INTERNAL_H_INCLUDES) key.h wbuf.h rbuf.h
brt-bigtest: memory.o ybt.o brt.o pma.o cachetable.o key.o fifo.o brt-serialize.o
brt-bigtest.o: brt.h ../include/db.h
......@@ -152,7 +154,7 @@ fingerprint.o: $(BRT_INTERNAL_H_INCLUDES)
toku_assert.o: toku_assert.h
brt-serialize-test: brt-serialize-test.o brt-serialize.o memory.o fifo.o pma.o key.o ybt.o brt.o cachetable.o primes.o toku_assert.o log.o mempool.o brt-verify.o fingerprint.o log_code.o roll.o
test_toku_malloc_plain_free: memory.o
test_toku_malloc_plain_free: memory.o toku_assert.o
cachetable-test.o: cachetable.h memory.h
......@@ -170,6 +172,9 @@ test-assert: test-assert.o toku_assert.o
brtdump: brtdump.o brt-serialize.o memory.o pma.o key.o fingerprint.o log.o log_code.o roll.o cachetable.o primes.o toku_assert.o brt.o ybt.o fifo.o mempool.o brt-verify.o
test_oexcl: test_oexcl.o toku_assert.o
checko2:
ifeq ($(OPTFLAGS),-O2)
@echo OPTFLAGS=$(OPTFLAGS) ok
......@@ -182,6 +187,7 @@ clean:
rm -rf test_oexcl.c.tmp *.brt
randdb4: LOADLIBES=-ldb
randdb4: randdb4.o toku_assert.o
randbrt: brt.o fifo.o cachetable.o memory.o brt-serialize.o
# After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences.
......
......@@ -5,7 +5,7 @@
#include "brt.h"
#include "key.h"
#include "memory.h"
#include <assert.h>
#include "toku_assert.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "assert.h"
#include "brt-internal.h"
#include <fcntl.h>
#include <assert.h>
#include <string.h>
#include <zlib.h>
#include <arpa/inet.h>
......
......@@ -4,12 +4,12 @@
#define _XOPEN_SOURCE 500
//#include "pma.h"
#include "toku_assert.h"
#include "brt-internal.h"
#include "key.h"
#include "rbuf.h"
#include "wbuf.h"
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <arpa/inet.h>
......
......@@ -5,9 +5,9 @@
#include "key.h"
#include "pma.h"
#include "brt-internal.h"
#include "memory.h"
#include <assert.h>
#include "toku_assert.h"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
......
......@@ -16,8 +16,7 @@
*/
#include "brt-internal.h"
#include <assert.h>
#include "toku_assert.h"
static void verify_local_fingerprint (BRTNODE node) {
u_int32_t fp=0;
......
......@@ -25,7 +25,6 @@
*/
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
......@@ -33,6 +32,7 @@
#include <string.h>
#include <unistd.h>
#include "toku_assert.h"
#include "brt-internal.h"
#include "key.h"
#include "log_header.h"
......
/* Tell me the diff between two brt files. */
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <inttypes.h>
#include "toku_assert.h"
#include "key.h"
#include "brt-internal.h"
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "toku_assert.h"
#include "memory.h"
#include "cachetable.h"
#include "test.h"
......
......@@ -3,8 +3,8 @@
#include "memory.h"
#include "cachetable.h"
#include "toku_assert.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......
......@@ -2,16 +2,17 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "cachetable.h"
#include "hashfun.h"
#include "memory.h"
#include "primes.h"
#include "toku_assert.h"
#include "yerror.h"
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include "hashfun.h"
#include "primes.h"
#include <sys/stat.h>
#include <unistd.h>
//#define TRACE_CACHETABLE
#ifdef TRACE_CACHETABLE
......
#include "fifo.h"
#include "memory.h"
#include "toku_assert.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "memory.h"
#include "fifo.h"
int verbose;
......
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include "toku_assert.h"
#include "memory.h"
#include "fifo.h"
......
......@@ -2,8 +2,8 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include <arpa/inet.h>
#include <assert.h>
#include "brt-internal.h"
#include "toku_assert.h"
// Calculate the fingerprint for a kvpair
static inline u_int32_t toku_calc_more_crc32_kvpair (u_int32_t crc, const void *key, int keylen, const void *val, int vallen) {
......@@ -35,6 +35,8 @@ u_int32_t toku_calccrc32_cmd (int type, TXNID xid, const void *key, int keylen,
u_int32_t toku_calccrc32_cmdstruct (BRT_CMD cmd) {
if (cmd->type <= BRT_DELETE_BOTH)
return toku_calccrc32_cmd (cmd->type, cmd->xid, cmd->u.id.key->data, cmd->u.id.key->size, cmd->u.id.val->data, cmd->u.id.val->size);
else
else {
assert(0); /* Should not have come here. */
return 0;
}
}
......@@ -2,7 +2,7 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "brt-internal.h"
#include <assert.h>
#include "toku_assert.h"
#include <string.h>
#if 0
......@@ -108,4 +108,5 @@ int toku_default_compare_fun (DB *db __attribute__((__unused__)), const DBT *a,
int toku_dont_call_this_compare_fun (DB *db __attribute__((__unused__)), const DBT *a __attribute__((__unused__)), const DBT*b __attribute__((__unused__))) {
assert(0);
return 0;
}
#include "list.h"
#include "toku_assert.h"
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <assert.h>
#include "list.h"
struct testlist {
struct list next;
......
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <assert.h>
#include "log.h"
#include "toku_assert.h"
#include "yerror.h"
#include <stdio.h>
#include <sys/types.h>
#include "yerror.h"
#include "log.h"
#define LOGGER_BUF_SIZE (1<<24)
struct tokulogger {
int is_open;
......
......@@ -2,11 +2,11 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "log-internal.h"
#include <sys/stat.h>
#include <sys/types.h>
#include "toku_assert.h"
#include <fcntl.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#define dname "log-test-dir"
......
......@@ -9,7 +9,7 @@
* The struct definitions.
* The Latex documentation.
*/
#include <assert.h>
#include "toku_assert.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
......
......@@ -2,7 +2,7 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "memory.h"
#include <assert.h>
#include "toku_assert.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include <stdio.h>
#include <assert.h>
#include "mempool.h"
#include "toku_assert.h"
#include <stdio.h>
void toku_mempool_init(struct mempool *mp, void *base, int size) {
// printf("mempool_init %p %p %d\n", mp, base, size);
......
......@@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "toku_assert.h"
#include "memory.h"
#include "mempool.h"
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "myassert.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef TESTER
void my_assert(int a, const char *f, int l) {
if (!a) { fprintf(stderr, "Assertion failed at %s:%d\n", f, l); abort(); }
}
#endif
#ifndef MYASSERT_H
#define MYASSERT_H
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#ifndef TESTER
#include <assert.h>
#else
extern void my_assert(int, const char *, int);
#define assert(x) my_assert(x, __FILE__, __LINE__)
#endif
#endif
......@@ -3,15 +3,15 @@
#include "brt-internal.h"
#include "key.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <arpa/inet.h>
#include "kv-pair.h"
#include "list.h"
#include "pma-internal.h"
#include "kv-pair.h"
#include "test.h"
#include "toku_assert.h"
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* we use pma cursors for testing the pma_search function. otherwise, there are no pma cursors */
#include "pma-cursor.h"
......
......@@ -8,7 +8,7 @@
#include "key.h"
#include "memory.h"
#include "myassert.h"
#include "toku_assert.h"
#include "../include/db.h"
#include <stdio.h>
#include <errno.h>
......
......@@ -26,16 +26,16 @@ int toku_get_prime (unsigned int idx) {
primes[i]=j;
}
}
toku_assert(idx<N_PRIMES);
assert(idx<N_PRIMES);
return primes[idx];
}
void toku_test_primes (void) {
toku_assert(toku_get_prime(0)==2);
toku_assert(toku_get_prime(1)==5);
toku_assert(toku_get_prime(2)==11);
toku_assert(toku_get_prime(3)==17);
toku_assert(toku_get_prime(4)==37);
toku_assert(toku_get_prime(5)==67);
toku_assert(toku_get_prime(6)==131);
assert(toku_get_prime(0)==2);
assert(toku_get_prime(1)==5);
assert(toku_get_prime(2)==11);
assert(toku_get_prime(3)==17);
assert(toku_get_prime(4)==37);
assert(toku_get_prime(5)==67);
assert(toku_get_prime(6)==131);
}
......@@ -2,7 +2,7 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
/* Test random insertions using db4 */
#include <assert.h>
#include "toku_assert.h"
#include <db.h>
#include <stdlib.h>
#include <sys/stat.h>
......
......@@ -7,15 +7,14 @@
// cd ../src/tests/tmpdir
// ../../../newbrt/recover ../dir.test_log2.c.tdb
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "log_header.h"
#include "log-internal.h"
#include "cachetable.h"
#include "key.h"
#include "log-internal.h"
#include "log_header.h"
#include "toku_assert.h"
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main (int argc, char *argv[]) {
const char *dir;
......
......@@ -2,8 +2,11 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
/* Dump the log from stdin to stdout. */
#include "brttypes.h"
#include "log-internal.h"
#include "log_header.h"
#include "toku_assert.h"
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdio.h>
......@@ -11,10 +14,6 @@
#include <sys/types.h>
#include <zlib.h>
#include "brttypes.h"
#include "log-internal.h"
#include "log_header.h"
#if 0
static u_int32_t crc=0;
static u_int32_t actual_len=0;
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#include "toku_assert.h"
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static void catch_abort (int sig __attribute__((__unused__))) {
exit(1);
}
int main (int argc, const char *argv[]) {
signal (SIGABRT, catch_abort);
if (argc!=2) { printf("argcount should be 2.\n"); exit(1); }
const char *str=argv[1];
toku_assert(strcmp(str,"ok")==0);
assert(strcmp(str,"ok")==0);
return 0;
}
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include <assert.h>
#include "toku_assert.h"
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
......
......@@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
void toku_do_assert(int expr,const char* expr_as_string,const char *function,const char*file,int line) {
void toku_do_assert(long expr,const char* expr_as_string,const char *function,const char*file,int line) {
if (expr==0) {
fprintf(stderr, "%s:%d %s: Assertion `%s' failed\n", file,line,function,expr_as_string);
abort();
......
#ifndef TOKU_ASSERT_H
#define TOKU_ASSERT_H
/* The problem with assert.h: If NDEBUG is set then it doesn't execute the function, if NDEBUG isn't set then we get a branch that isn't taken. */
/* This version will complain if NDEBUG is set. */
/* It evaluates the argument and then calls a function toku_do_assert() which takes all the hits for the branches not taken. */
......@@ -6,13 +8,11 @@
#error NDEBUG should not be set
#endif
void toku_do_assert(int,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/);
void toku_do_assert(long,const char*/*expr_as_string*/,const char */*fun*/,const char*/*file*/,int/*line*/);
#ifndef FAST_ASSERT
#define toku_assert(expr) toku_do_assert(expr, #expr, __FUNCTION__, __FILE__, __LINE__)
#define assert(expr) toku_do_assert((long)(expr), #expr, __FUNCTION__, __FILE__, __LINE__)
#else
#define toku_assert(expr) ({ int __assert_expr = expr; if (__assert_expr==0) toku_do_assert(0, #expr, __FUNCTION__, __FILE__, __LINE__); })
#define assert(expr) ({ long __assert_expr = (int)(expr); if (__assert_expr==0) toku_do_assert(0, #expr, __FUNCTION__, __FILE__, __LINE__); })
#endif
#endif
void dontuseassert (int) __attribute__((deprecated));
#define assert(barf) dontuseassert(barf)
......@@ -3,10 +3,10 @@
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <assert.h>
#include <string.h>
#include <errno.h>
#include "memory.h"
#include "toku_assert.h"
#include <errno.h>
#include <string.h>
//#define CRC_NO
#define CRC_INCR
......
......@@ -5,7 +5,7 @@
#include "ybt.h"
#include "memory.h"
#include <assert.h>
#include "toku_assert.h"
#include <string.h>
static void ybt_test0 (void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment