Makefile 26.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
# -*- Mode: Makefile -*-

.DEFAULT_GOAL= build
TOKUROOT=../../
INCLUDEDIRS=-I. -I../ -I$(TOKUROOT)newbrt -I../range_tree -I../lock_tree
DEPEND_COMPILE += \
	../*.h \
	../range_tree/*.h \
	../lock_tree/*.h \
	test.h \
#end
12 13
include $(TOKUROOT)toku_include/Makefile.include
CPPFLAGS+=-D_GNU_SOURCE
14 15 16 17

ifeq ($(CC),icc)
SKIP_WARNING += $(ICC_NOWARN)1418 #Non static functions do not need prototypes.
endif
Yoni Fogel's avatar
Yoni Fogel committed
18
BDBVGRIND=
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
19

20 21 22 23 24 25 26 27 28 29 30 31
TDB_EXTRA_NEEDED=
ifeq ($(OS_CHOICE),windows)
LIBTDB=$(WIN_YDB)
%.tdb$(BINSUF):  $(WIN_YDB)
%.tdb$(BINSUF):  LINK_FILES+=$(WIN_YDB)
TDB_EXTRA_NEEDED=$(WIN_YDB)
else
LIBTDB=../libtokudb.$(SOEXT)
TLIBTDB=../libtokudbtrace.$(SOEXT)
%.tdb$(BINSUF):  DLINK_FILES+=$(LIBTDB)
%.tdb$(BINSUF):  RPATH_DIRS+=$(dir $(LIBTDB))
endif
32

33
SRCS = $(sort $(wildcard *.c))
34
RECOVER_SRCS = $(wildcard recover-*.c)
35
LOADER_SRCS = $(wildcard loader-*.c)
36 37 38 39 40
TRANSPARENT_UPGRADE_SRCS = $(wildcard upgrade-*.c)
NONSTANDARD_SRCS= \
		  $(RECOVER_SRCS) \
		  $(LOADER_SRCS) \
#end
41

Yoni Fogel's avatar
Yoni Fogel committed
42 43 44 45 46
#Tests that don't compile in windows.  SHould
WINDOWS_NOT_PORTED_TESTS = \
        diskfull \
#\ ends prev line

47 48
#Tests that are irrelevant in windows.
WINDOWS_DONTRUN_TESTS = \
Yoni Fogel's avatar
Yoni Fogel committed
49
	$(WINDOWS_NOT_PORTED_TESTS) \
50 51 52 53 54
	helgrind1 \
	helgrind2 \
	helgrind3 \
#\ ends prev line

55 56 57 58
#BDB Tests that are irrelevant in windows.
WINDOWS_BDB_DONTRUN_TESTS = \
	diskfull \
	test_groupcommit_count \
59
	test_set_func_malloc \
60 61 62
#\ ends prev line
#diskfull: windows bdb is missing db_env_set_func_pwrite and db_env_set_func_write
#test_groupcommit_count: windows bdb is missing db_env_set_func_fsync
63
#test_set_func_malloc: windows bdb (some) are missing db_env_set_func_(malloc|realloc|free)
64

65 66 67 68 69 70

#These tests fail, but sometimes they hang! (in windows).  Just disable them.
WINDOWS_BDB_DONTRUN_TESTS += \
	test_error \
#\ ends prev line

71
ifeq ($(OS_CHOICE),windows)
72
    TDB_BINS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(SRCS)))
73
    TDB_TESTS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(filter-out $(NONSTANDARD_SRCS),$(SRCS))))
74
else
75
    TDB_BINS = $(patsubst %.c,%.tdb$(BINSUF),$(SRCS))
76
    TDB_TESTS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(NONSTANDARD_SRCS),$(SRCS)))
77 78
endif

79
# For diskfull.bdb: db-4.6 seems OK, but db-4.3 segfaults
80
BDB_DONTRUN_TESTS = \
81 82 83
        backwards_10_each_le_and_msg \
        bug1381 \
        bug627 \
84
	cachetable-race \
85 86 87 88
        checkpoint_1 \
        checkpoint_callback \
        checkpoint_stress \
        checkpoint_truncate_1 \
89
	cursor-isolation \
90 91
	del-simple \
	del-multiple \
92
	del-multiple-huge-primary-row \
93
	del-multiple-srcdb \
94
	directory_lock \
95 96 97 98 99 100 101
        diskfull \
        env-put-multiple \
        env_startup \
        filesize \
        helgrind1 \
        helgrind2 \
        helgrind3 \
102 103 104 105 106 107
	hotindexer-bw \
	hotindexer-db-busy \
	hotindexer-error-callback \
	hotindexer-insert-committed-optimized \
	hotindexer-insert-committed \
	hotindexer-insert-provisional \
108
	hotindexer-lock-test \
109 110 111 112 113 114
	hotindexer-multiclient \
	hotindexer-nested-insert-committed \
	hotindexer-put-multiple \
	hotindexer-simple-abort \
	hotindexer-undo-do-test \
	hotindexer-with-queries \
115
	insert-dup-prelock \
116
        isolation \
117
        isolation-read-committed \
118 119 120 121 122
        keyrange \
        keyrange-dupsort \
        keyrange-dupsort-unflat \
        keyrange-unflat \
        loader-cleanup-test \
123 124
	loader-create-abort \
	loader-create-close \
125
	loader-db-busy \
126 127 128 129 130
        loader-dup-test \
        loader-no-puts \
        loader-reference-test \
        loader-stress-test \
        loader-tpch-load \
131
	lock-pressure \
132
        manyfiles \
Yoni Fogel's avatar
Yoni Fogel committed
133
	multiprocess \
134
	mvcc-create-table \
135
        mvcc-many-committed \
136
        powerfail \
137
	preload-db \
138
	preload-db-nested \
139
	preload-3.1-db \
140
        progress \
141
	put-multiple \
142 143 144
        recover-2483 \
        recover-compare-db \
        recover-compare-db-descriptor \
145 146
	recover-del-multiple \
	recover-del-multiple-abort \
147 148 149 150 151
        recover-delboth-after-checkpoint \
        recover-delboth-checkpoint \
        recover-fclose-in-checkpoint \
        recover-loader-test \
        recover-lsn-filter-multiple \
152 153
	recover-put-multiple \
	recover-put-multiple-abort \
154 155 156 157
        recover-put-multiple-fdelete-all \
        recover-put-multiple-fdelete-some \
        recover-split-checkpoint \
        recover-tablelock \
158
	recover-test-logsuppress \
159
	recover-test-logsuppress-put \
160 161
	recover-upgrade-db-descriptor-multihandle \
	recover-upgrade-db-descriptor \
162 163
	recover-update-multiple \
	recover-update-multiple-abort \
164 165 166 167 168 169 170 171
        recovery_fileops_stress \
        recovery_fileops_unit \
        recovery_stress \
        redirect \
        root_fifo_2 \
        root_fifo_32 \
        root_fifo_41 \
        stat64 stat64_flatten \
172
	stress-gc \
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
        test1324 \
        test1426 \
        test1572 \
        test938c \
        test_abort1 \
        test_abort4 \
        test_abort5 \
        test_cursor_delete_2119 \
        test_db_descriptor \
        test_db_descriptor_named_db \
        test_dbremove_old \
        test_dupsort_get_both_range_reverse \
        test_dupsort_set_range_reverse \
        test_logflush \
        test_txn_abort6 \
        test_txn_abort8 \
        test_txn_abort9 \
        test_txn_close_open_commit \
        test_txn_commit8 \
        test_txn_nested1 \
        test_txn_nested2 \
        test_txn_nested3 \
        test_txn_nested4 \
        test_txn_nested5 \
197
	txn-ignore \
198
        transactional_fileops \
199
	update-multiple-data-diagonal \
200 201 202
	update-multiple-key0 \
	update-multiple-nochange \
	update-multiple-with-indexer \
203
        upgrade_simple \
204 205 206 207
	upgrade-test-1 \
	upgrade-test-2 \
	upgrade-test-3 \
	upgrade-test-4 \
208
	upgrade-test-5 \
209
        upgrade-test-6 \
210
        upgrade-test-7 \
211
        zombie_db \
212 213
#\ ends prev line

214 215 216 217
# checkpoint tests depend on this header file, 
checkpoint_1.tdb$(BINSUF) checkpoint_stress.tdb$(BINSUF): checkpoint_test.h
# dependency only, not a rule (do not insert a tab at this line)

218 219 220
BDB_TESTS_THAT_SHOULD_FAIL= \
#\ ends prev line
ifeq ($(OS_CHOICE),windows)
221 222
    #The following are nondeterministic test failures or hangs in windows.  Just get rid of them in BDB. (for now)
    WINDOWS_BDB_DONTRUN_TESTS += \
223
	test_archive2 \
224
	test_cursor_delete \
225
	test_cursor_stickyness \
226 227
	test_db_dbt_mem_behavior \
	test_dup_insert \
228
	test_dup_search \
229
	test_dupsort_get \
230 231 232
	test_dupsort_set \
	test_unused_memory_crash \
	test_dupsort_get_both_range \
233 234
	test_reverse_compare_fun \
	test-recover3 \
235 236 237
#\ ends prev line
endif

238

239 240 241 242
ifeq ($(OS_CHOICE),windows)
    BDB_DONTRUN_TESTS+=$(WINDOWS_BDB_DONTRUN_TESTS)
endif

243 244 245 246
ifeq ($(OS_CHOICE),windows)
BDB_TESTS=
BDB_BINS=
else
247
BDB_TESTS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DONTRUN_TESTS)),$(SRCS)))
248 249
BDB_BINS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DONTRUN_TESTS)),$(SRCS)))
endif
250 251 252

TDB_TESTS_THAT_SHOULD_FAIL= \
	test_truncate_txn_abort \
253
	test_db_no_env \
254
#\ ends prev line
255 256
#ifneq ($(OS_CHOICE),windows)
#    TDB_TESTS_THAT_SHOULD_FAIL+= \
257
#\ ends prev line
258
#endif
259

260
TDB_TESTS_THAT_SHOULD_FAIL_LIT= \
261 262 263
	test_log8.recover \
	test_log9.recover \
	test_log10.recover \
264 265
	recover-missing-dbfile.abortrecover \
	recover-missing-dbfile-2.abortrecover \
266 267
	recover-missing-dbfile-2.abortrecover \
	recover-dbopen-eclose.abortrecover \
268
	loader-tpch-load.loader \
269 270
#\ ends prev line

271 272
ifeq ($(OS_CHOICE),windows)
    #Tests that fail in windows but shouldn't.  TODO: Fix each one of these and remove from the list!
273
    WIN_IGNORE_TDB_TESTS_THAT_SHOULD_FAIL += \
274
#\ ends prev line
275
    WIN_IGNORE_TDB_TESTS_THAT_SHOULD_FAIL_LIT += \
276 277 278
#\ ends prev line
endif

279 280 281 282 283 284 285
ALL_TESTS  = $(TDB_TESTS)

#Skip all BDB tests for CYGWIN+ICC
ifeq ($(CYGWIN),)
ALL_TESTS += $(BDB_TESTS)
else ifneq ($(CC),icc)
ALL_TESTS += $(BDB_TESTS)
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
286 287
endif

288
TLRECOVER = 2 3 4 5 6 7 8 9 10
289

290 291
EXTRA_TDB_TESTS = \
	$(patsubst %,test_log%.recover,$(TLRECOVER)) \
292 293
	test_groupcommit_count_hgrind.tdbrun \
	test_groupcommit_count_vgrind.tdbrun \
294
#\ ends prev line
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
295

296 297 298 299 300 301
ifeq ($(OS_CHOICE),windows)
EXTRA_TDB_TESTS = \
	$(patsubst %,test_log%.recover,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(TLRECOVER))) \
#\ ends prev line
endif

302
RECOVER_TESTS = $(patsubst %.c,%.abortrecover,$(RECOVER_SRCS))
303
LOADER_TESTS= $(patsubst %.c,%.loader,$(LOADER_SRCS))
304 305
ifeq ($(OS_CHOICE),windows)
RECOVER_TESTS = $(patsubst %.c,%.abortrecover,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(RECOVER_SRCS)))
306
LOADER_TESTS = $(patsubst %.c,%.loader,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(LOADER_SRCS)))
307
endif
308

309 310

RUN_TDB_TESTS = $(patsubst %.tdb$(BINSUF),%.tdbrun,$(TDB_TESTS))  $(EXTRA_TDB_TESTS) $(RECOVER_TESTS) $(LOADER_TESTS)
311 312
RUN_BDB_TESTS  = $(patsubst %.bdb$(BINSUF),%.bdbrun,$(BDB_TESTS))
RUN_ALL_TESTS  = $(RUN_BDB_TESTS) $(RUN_TDB_TESTS)
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
313

314
MORE_BDB_BINS = test1426.bdb$(BINSUF)
315

316 317
ALL_BINS = $(TDB_BINS) $(BDB_BINS) $(MORE_BDB_BINS)

318
.PHONY: default all check tests check.lin check.tlog check.log tests.lin tests.log tests.tlog
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
319

320
default all build: $(ALL_BINS)
321

322
ifndef TOKUDBONLY
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
323 324 325
MAYBE_CHECK_BDB = check.bdb
else
MAYBE_CHECK_BDB =
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
326
endif
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
327
check: check.tdb $(MAYBE_CHECK_BDB) ;
328

329
tests: tests.bdb tests.tdb ;
330
tests.bdb: $(BDB_BINS) ;
331
check.bdb: $(RUN_BDB_TESTS) ;
332
tests.tdb: $(TDB_BINS) ;
333
check.tdb: $(LIBTDB) $(PTHREAD_LOCAL) $(RUN_TDB_TESTS) ;
334 335
check.tdb.extra: $(EXTRA_TDB_TESTS) ;
check.abortrecover: $(RECOVER_TESTS) ;
336

337
foo:
338 339
	echo RUN_TDB_TESTS: $(RUN_TDB_TESTS)
	echo ALL_TESTS: $(ALL_TESTS)
340

341 342 343
#TODO: What is this for? TODO: Port this if necessary.
#traces: test_env_open_flags.tdbt$(BINSUF)
traces: $(patsubst %.tdb$(BINSUF),%.tdbt$(BINSUF),$(TDB_TESTS))
344

345 346
.PHONY: %.bdbrun %.run %.tdbrun
# STUFF!!!!
347

348 349
%.run: %.bdbrun %.tdbrun

350 351
SHOULD_FAIL = $(TDB_TESTS_THAT_SHOULD_FAIL_LIT) $(patsubst %,%.tdbrun,$(TDB_TESTS_THAT_SHOULD_FAIL)) \
	      $(BDB_TESTS_THAT_SHOULD_FAIL_LIT) $(patsubst %,%.bdbrun,$(BDB_TESTS_THAT_SHOULD_FAIL))
352 353 354
# Any test that should fail, we invert the result by using MAYBEINVERTER
$(SHOULD_FAIL): MAYBEINVERTER=$(INVERTER)
$(SHOULD_FAIL): SUMMARIZE_CMD=$(SUMMARIZE_SHOULD_FAIL)
355 356 357
# I want the failing tests to send their stderr to /dev/null
$(SHOULD_FAIL): VGRIND+= --log-file=/dev/null
# $(SHOULD_FAIL): INVERTER= 2> /dev/null ;test $$? -ne 0
358

359 360
TDBVGRIND=$(VGRIND)

361 362
ifeq ($(OS_CHOICE),windows)
ifdef BDBDIR
363
%.bdb$(BINSUF): INCLUDEDIRS=-I$(BDBDIR)/include -I$(TOKUROOT)newbrt
364 365 366
%.bdb$(BINSUF): RPATH_DIRS=$(BDBDIR)/lib
endif
ifeq ($(DEBUG),0)
367
WINDOWS_BDB_LIB_NAME=libdb.$(SOEXT)
368
$(WINDOWS_BDB_LIB_NAME):
369
	cp $(BDBDIR)/lib/libdb[0-9][0-9].$(SOEXT) ./
370
else
371
WINDOWS_BDB_LIB_NAME=libdbd.$(SOEXT)
372
$(WINDOWS_BDB_LIB_NAME):
373
	cp $(BDBDIR)/lib/libdb[0-9][0-9]d.$(SOEXT) ./
374 375
endif
%.bdb$(BINSUF): DLINK_FILES=$(BDBDIR)/lib/$(WINDOWS_BDB_LIB_NAME)
376
#empty
377 378 379 380 381 382 383 384 385 386 387
else
WINDOWS_BDB_LIB_NAME=
#linux
ifdef BDBDIR
%.bdb$(BINSUF): INCLUDEDIRS=-I$(BDBDIR)/include
%.bdb$(BINSUF): RPATH_DIRS=$(BDBDIR)/lib
endif
%.bdb$(BINSUF): DLINK_FILES=db.$(SOEXT)
endif
#empty on purpose

Yoni Fogel's avatar
Yoni Fogel committed
388
# Use -s on the command line to make things quiet.
389
# Use -s on the command line to make things quiet.
390
%.bdbrun: %.bdb$(BINSUF) $(DEPEND_COMPILE) $(DEPEND_LINK) $(WINDOWS_BDB_LIB_NAME)
391
	$(BDBVGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
392
%.tdbrun: %.tdb$(BINSUF) $(DEPEND_COMPILE) $(DEPEND_LINK) $(LIBTDB) $(PTHREAD_LOCAL)
393
	$(TDBVGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
394

395 396 397 398 399 400 401
ifeq ($(OS_CHOICE),windows)
    TDBDUMP=$(TOKUROOT)utils/tokudb_dump$(BINSUF)
    TDBLOAD=$(TOKUROOT)utils/tokudb_load$(BINSUF)
else
    TDBDUMP=$(TOKUROOT)utils/tokudb_dump_static$(BINSUF)
    TDBLOAD=$(TOKUROOT)utils/tokudb_load_static$(BINSUF)
endif
402
TDBRECOVER=$(TOKUROOT)newbrt/tdb-recover$(BINSUF)
403 404 405
TDBBRTDUMP=$(TOKUROOT)newbrt/brtdump$(BINSUF)

$(TDBBRTDUMP) $(TDBLOAD) $(TDBDUMP) $(TDBRECOVER):
406
	cd $(@D) && $(MAKE) $(@F)
407

408
%.recover: %.tdb$(BINSUF) $(PTHREAD_LOCAL) $(TDBRECOVER) $(TDBDUMP)
409
	echo doing ./$< &&\
410 411 412 413 414 415
	./$< --no-shutdown                                                         && \
	rm -rf dir.$*.c.tdb.recover                                                && \
	mkdir dir.$*.c.tdb.recover                                                 && \
	cp dir.$*.c.tdb/tokudb.directory   dir.$*.c.tdb.recover/                   && \
	cp dir.$*.c.tdb/tokudb.environment dir.$*.c.tdb.recover/                   && \
	cp dir.$*.c.tdb/tokudb.rollback    dir.$*.c.tdb.recover/                   && \
416
	cp dir.$*.c.tdb/*.tokulog*         dir.$*.c.tdb.recover/                   && \
417
	echo doing recovery &&\
418
	$(VGRIND) $(TDBRECOVER) dir.$*.c.tdb.recover dir.$*.c.tdb.recover         && \
419
	echo dump and compare &&\
420 421
	$(TDBDUMP) -h dir.$*.c.tdb         foo.db > dir.$*.c.tdb/foo.dump          && \
	$(TDBDUMP) -h dir.$*.c.tdb.recover foo.db > dir.$*.c.tdb.recover/foo.dump  && \
422
	diff -q dir.$*.c.tdb/foo.dump dir.$*.c.tdb.recover/foo.dump                                   \
423 424
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)

425
%.recoverwc: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
426
	 (cd dir.$*.c.tdb;pwd;cat log*| ../../../newbrt/tdb_logprint |wc -c)
427

428
ABORTCODE=137
429
%.abortrecover: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
430
	{ ./$< --test ; } ; \
431
        if [ $$? -ne $(ABORTCODE) ] ; then \
432
		echo $* --test did not return $(ABORTCODE); \
433 434
		test 0 = 1; \
        else \
435
		$(VGRIND) ./$< --recover; \
436 437 438
	fi \
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)

439
.PHONY: %.loader
440
# Generally these subtests cannot run in parallel unless they support an environment arg
441
%.loader: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
442
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
443
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -p $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
444

445
.PHONY: %.recover
446
all.recover: $(patsubst %,test_log%.recover,$(TLRECOVER)) $(PTHREAD_LOCAL) ;
447 448 449 450

#DISABLE standard tdbrun for recover tests.
$(patsubst %,test_log%.tdbrun,$(TLRECOVER)): ;

451 452 453
BDB_CFLAGS=
TDB_CFLAGS=
%.bdb$(BINSUF): BDB_CFLAGS= -DENVDIR=\"dir.$<.bdb\" -DUSE_BDB -DIS_TDB=0 -DTOKU_ALLOW_DEPRECATED
454 455

%.bdb$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK)
456
	$(CC) $< $(BDB_CFLAGS) $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
457 458

%.tdbt$(BINSUF): DLINK_FILES+=$(TLIBTDB)
Yoni Fogel's avatar
Yoni Fogel committed
459
%.tdbt$(BINSUF): RPATH_DIRS+=$(dir $(TLIBTDB))
460 461

%.tdb$(BINSUF) %.tdbt$(BINSUF): TDB_CFLAGS= -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1
462
%.tdb$(BINSUF) %.tdbt$(BINSUF): CPPFLAGS+=-I$(TOKUROOT)include
463 464
loader-stress-test: CPPFLAGS+=-I$(TOKUROOT)include -DENVDIR=\"dir.$<\"
loader-stress-test: LOADLIBES+=-L.. -ltokudb -Wl,-rpath,..
465

Yoni Fogel's avatar
Yoni Fogel committed
466
%.tdb$(BINSUF) %.tdbt$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK) $(TDB_EXTRA_NEEDED)
467
	$(CC) $< $(TDB_CFLAGS) $(filter-out ../../lib/libtokuportability.a,$(BIN_FROM_C_FLAGS)) $(LINK_MUST_BE_LAST)
468 469 470 471 472 473 474 475

ifeq ($(VGRIND),)
  BDB_SUPPRESSIONS =
else
  BDB_SUPPRESSIONS = --suppressions=bdb.supressions --gen-suppressions=all
endif

# VERBOSE=true
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
476

477
# Need these rule so that Make knows about all the file names
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
478
.PHONY: %.run
479 480
$(RUN_ALL_TESTS):
$(ALL_TESTS):
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
481

482
%.run: %.bdbrun %.tdbrun
483
	@ echo ok
484

485 486 487



488 489 490 491 492
INVERTER=;test $$? -ne 0

# Any test that should fail, we invert the result by using MAYBEINVERTER
$(SHOULD_FAIL): MAYBEINVERTER=$(INVERTER)

493 494
HERE = src/tests

495

496
# Don't include log2 log3 log4 log5 etc since they are covered by all.recover
497

498 499
# Don't run valgrind on the groupcommit performance tests
test_groupcommit_perf.bdbrun test_groupcommit_perf.tdbrun: VGRIND=
500
# Use helgrind on the group commit count test
501 502
# helgrind is too flakey, so I'm removing it from the tests. -Bradley
#test_groupcommit_count_helgrind.tdbrun: test_groupcommit_count_helgrind.tdb
503
#	$(HGRIND) ./$< $(VERBVERBOSE)
504 505


506 507
# Don't run valgrind on the diskfull test (since it aborts)
diskfull.tdbrun: VGRIND=
508
stress-gc.tdbrun: VGRIND=
509
insert-dup-prelock: VGRIND=
510

511

512
libs:
Yoni Fogel's avatar
Yoni Fogel committed
513
	cd ..;$(MAKE)
514

515

516

Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
517

518 519

loader-cleanup-test.tdb$(BINSUF) diskfull.tdb$(BINSUF): CPPFLAGS+=-DDONT_DEPRECATE_WRITES
520 521
test_db_curs4.tdb$(BINSUF): trace.h
test_db_curs4.bdb$(BINSUF): trace.h
522 523 524 525 526 527 528 529 530 531 532 533
# a bunch of little tests designed to run in parallel
test_get_both_range.tdbrun: \
 tgbr_256_a.tdbrun tgbr_256_b.tdbrun tgbr_256_c.tdbrun \
 tgbr_128_a.tdbrun tgbr_128_b.tdbrun tgbr_128_c.tdbrun \
 tgbr_64_a.tdbrun  tgbr_64_b.tdbrun  tgbr_64_c.tdbrun \
 tgbr_32_a.tdbrun  tgbr_32_b.tdbrun  tgbr_32_c.tdbrun \
 tgbr_16_a.tdbrun  tgbr_16_b.tdbrun  tgbr_16_c.tdbrun \
 tgbr_8_a.tdbrun   tgbr_8_b.tdbrun   tgbr_8_c.tdbrun \
 tgbr_4_a.tdbrun   tgbr_4_b.tdbrun   tgbr_4_c.tdbrun \
 tgbr_2_a.tdbrun   tgbr_2_b.tdbrun   tgbr_2_c.tdbrun \
 tgbr_1_a.tdbrun   tgbr_1_b.tdbrun   tgbr_1_c.tdbrun \
 # intentionally blank line
534
	true $(SUMMARIZE_CMD) #State that this has passed.
535

536
tgbr_%_a.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
537
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -a $(MAYBEINVERTER) $(SUMMARIZE_CMD)
538
tgbr_%_b.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
539
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -b $(MAYBEINVERTER) $(SUMMARIZE_CMD)
540
tgbr_%_c.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
541
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -c $(MAYBEINVERTER) $(SUMMARIZE_CMD)
542

543 544 545 546
ifeq ($(OS_CHOICE),windows)
    #Windows BDB cannot run 1426.  Save output from linux and compare.
dump.bdb.1426: test1426.bdbdump/dump.bdb.1426
	cat $< | unix2dos --u2d > $@
547

548
else
549
dump.bdb.1426: test1426.bdb$(BINSUF) test1426.bdbdump/dump.bdb.1426
550 551 552 553 554
	./$< -q  && \
	 $(BDBDIR)/bin/db_dump -p -h dir.test1426.c.bdb main > $@
	diff -q $@ test1426.bdbdump/$@ #Assert output is correct.
endif

555
# test1426 is run by comparing the BDB output to the TDB output
556
# we use the -x flag (no transactions or recovery) in the dump program.  (-x is not in the BDB version of dump, but it's in ours)
557
test1426.tdbrun: test1426.tdb$(BINSUF) dump.bdb.1426 $(PTHREAD_LOCAL) $(TDBDUMP)
558
	(./test1426.tdb$(BINSUF) -q && \
559
	 $(TDBDUMP) -x -p -h dir.test1426.c.tdb main > dump.tdb.1426 && \
560
	 diff -q -I db_pagesize=4096 dump.bdb.1426 dump.tdb.1426 ) \
561
	 $(MAYBEINVERTER) $(SUMMARIZE_CMD)
562

563
# STRESS RUNS is number of iterations, STRESS_SIZE is operations per iteration (must not change between iterations)
564 565 566
# Note the magic with the brackets is there to suppress the printout of "/bin/bash: line 11: 1234 Killed ...."
# See http://stackoverflow.com/questions/714855/bash-suppress-notice-of-forked-command-being-killed
# also we only print the date if VERBOSE is set to non-null
567 568
STRESS_RUNS=5
STRESS_SIZE=5001
569
checkpoint_stress.tdbrun: SHELL=/bin/bash
570
checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL)
571 572
	$(VGRIND) ./$< -C -n $(STRESS_SIZE) $(VERBVERBOSE) && \
	($(VGRIND) ./$< -C -i 0 -n $(STRESS_SIZE) $(VERBVERBOSE) && \
573
	 for (( i = 1; i < $(STRESS_RUNS); i++ )); do \
574 575
		$(if $(VERBOSE),date;) \
		{ ./$< -c -i $$i -n $(STRESS_SIZE) $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; } 2>/dev/null ; \
576 577 578
                if [ $$? -ne $(ABORTCODE) ] ; then \
                   exit 1 ; \
                fi ; \
579
		if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
580 581 582 583
	done && \
	test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
	) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

584 585 586 587 588 589
DISKFULL_ABORTCODE=134

diskfull.tdbrun: SHELL=/bin/bash
diskfull.tdbrun: diskfull.tdb$(BINSUF) $(PTHREAD_LOCAL)
	NUM_WRITES=$$($(VGRIND) ./$< -q) && \
	(for (( i = 0; i < $$NUM_WRITES; i++ )); do \
590
		{ ./$< -C $$i $(VERBVERBOSE) 2>/dev/null; } 2>/dev/null; \
591 592 593 594 595 596
		if [ $$? -ne $(DISKFULL_ABORTCODE) ] ; then \
		    echo "Diskfull (iteration $$i) did not abort" ; \
		    exit 1; \
		fi; \
	done; ) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

597 598 599 600 601
recover_stress.tdbrun: SHELL=/bin/bash
recover_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL)
	$(VGRIND) ./$< -C -n $(STRESS_SIZE) -l $(VERBVERBOSE) && \
	($(VGRIND) ./$< -C -i 0 -n $(STRESS_SIZE) -l $(VERBVERBOSE) && \
	 for (( i = 1; i < $(STRESS_RUNS); i++ )); do \
602 603
		$(if $(VERBOSE),date;) \
		{ ./$< -c -i $$i -n $(STRESS_SIZE) -l $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; } 2>/dev/null ; \
604 605 606
                if [ $$? -ne $(ABORTCODE) ] ; then \
                   exit 1 ; \
                fi ; \
607
		if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
608 609 610 611
	done && \
	test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
	) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

612 613 614 615
recovery_fileops_unit.tdbrun: SHELL=/bin/bash
recovery_fileops_unit.tdbrun: recovery_fileops_unit.tdb$(BINSUF) $(PTHREAD_LOCAL)
	rm -rf dir.$@.errors
	mkdir dir.$@.errors
616
	$(MAYBEATSIGN)( \
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
        Oset="c d r"; \
        aset="0 1"; \
        bset="0 1"; \
        cset="0 1 2"; \
        fset="0 1"; \
        count=0; \
        for O in $$Oset; do \
           if test $$O = c ; then \
              gset="0"; \
              hset="0"; \
           else \
              gset="0 1 2 3 4 5"; \
              hset="0 1"; \
           fi; \
           for a in $$aset; do \
              for b in $$bset; do \
                 if test $$b -eq 0 ; then \
                    dset="0"; \
                    eset="0"; \
                 else \
                    dset="0 1"; \
                    eset="0 1"; \
                 fi; \
                 for c in $$cset; do \
                    for d in $$dset; do \
                       for e in $$eset; do \
                          for f in $$fset; do \
                             for g in $$gset; do \
                                for h in $$hset; do \
646 647 648 649 650 651 652 653
                                   if test \( $$O != c \) -a \( $$c -eq 0 \) -a \( \( $$b -eq 0 \) -o \( $$e -eq 0 \) -o  \( $$d -eq 1 \)  \) ; then \
                                      iset="0 1"; \
                                   else \
                                      iset="0"; \
                                   fi; \
                                   for i in $$iset; do \
                                      errorfile=dir.$@.errors/crash.$$O.$$a.$$b.$$c.$$d.$$e.$$f.$$g.$$h.$$i; \
                                      combination="-O $$O -A $$a -B $$b -C $$c -D $$d -E $$e -F $$f -G $$g -H $$h -I $$i"; \
654
                                      { ./$< $(VERBVERBOSE) -c $$combination 2> $$errorfile ; } 2>/dev/null ;\
655 656 657
                                      if [ $$? -ne $(ABORTCODE) ] ; then \
                                         { cat dir.$@.errors/crash; echo Error: no crash in $$errorfile ; exit 1; }; \
                                      fi ; \
658 659 660 661
                                      grep 'HAPPY CRASH' $$errorfile >/dev/null || { cat $$errorfile; echo Error: incorrect crash in $$errorfile ; exit 1; }; \
                                      ./$< $(VERBVERBOSE) -r $$combination 2>> $$errorfile || { cat $$errorfile ; echo Error: during recovery in $$errorfile ; exit 1; }; \
                                      count=$$(($$count + 1)); \
                                   done; \
662 663 664 665 666 667 668 669 670
                                done; \
                             done; \
                          done; \
                       done; \
                    done; \
                 done; \
              done; \
           done; \
        done; \
671
	(test -n "$(VERBOSE)" && echo $$count tests passed) || true; \
672 673
	) $(SUMMARIZE_CMD)

Yoni Fogel's avatar
Yoni Fogel committed
674
# helgrind1 is supposed to fail.
675
helgrind1.tdbrun: TDBVGRIND=$(HGRIND) --log-file=helgrind1.tdb.deleteme
Yoni Fogel's avatar
Yoni Fogel committed
676
helgrind1.tdbrun: MAYBEINVERTER=$(INVERTER)
677
helgrind2.tdbrun: TDBVGRIND=$(HGRIND)
Yoni Fogel's avatar
Yoni Fogel committed
678
helgrind2.bdbrun: BDBVGRIND=$(HGRIND)
679
helgrind3.tdbrun: TDBVGRIND=$(HGRIND)
Yoni Fogel's avatar
Yoni Fogel committed
680 681
helgrind3.bdbrun: BDBVGRIND=$(HGRIND)

682 683 684 685 686 687
test_groupcommit_count_hgrind.tdbrun: HGRIND+=--suppressions=helgrind.suppressions
test_groupcommit_count_hgrind.tdbrun: test_groupcommit_count.tdb$(BINSUF)
	$(HGRIND) ./test_groupcommit_count.tdb$(BINSUF) $(VERBVERBOSE) -n 1 -p hgrind $(SUMMARIZE_CMD)
test_groupcommit_count_vgrind.tdbrun: test_groupcommit_count.tdb$(BINSUF)
	$(VGRIND) ./test_groupcommit_count.tdb$(BINSUF) $(VERBVERBOSE) -n 1 -p vgrind $(SUMMARIZE_CMD)

688 689 690 691 692 693
# we deliberately don't close the env, so recovery runs
# lets avoid all of the valgrind errors
test-recover1.tdbrun: VGRIND=
test-recover2.tdbrun: VGRIND=
test-recover3.tdbrun: VGRIND=

694 695 696
# filesize is too slow with vgrind.
filesize.tdbrun: VGRIND=

697 698 699
powerfail.tdbrun:
	@echo must run powerfail by hand $(SUMMARIZE_CMD)

700 701
dumpit: $(TDBBRTDUMP)
	$(TDBBRTDUMP)  dir.test_log5.c.tdb.recover/foo.db > dump.r && $(TDBBRTDUMP) dir.test_log5.c.tdb/foo.db > dump.o && diff -q dump.o dump.r
702 703

# test on small stacks
704
test_thread_stack.%run: test_thread_stack.%$(BINSUF) $(PTHREAD_LOCAL)
705 706
	./$< -a -thread_stack 16384         && \
	./$< -a -thread_stack 16384 -resume $(SUMMARIZE_CMD)
707

708
loader-stress-test.loader: $(patsubst %,loader-stress-test%.tdbrun, 0 1 2 3)
709 710 711
	true

loader-stress-test0.tdbrun: loader-stress-test.tdb$(BINSUF)
712
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -e 0 -c $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
713 714

loader-stress-test1.tdbrun: loader-stress-test.tdb$(BINSUF)
715
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -e 1 -c -p $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
716 717

loader-stress-test2.tdbrun: loader-stress-test.tdb$(BINSUF) 
718
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -e 2 -r 5000 -s $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD) # to manifest #2717.
719

720 721 722
loader-stress-test3.tdbrun: loader-stress-test.tdb$(BINSUF)
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -e 3 -u -c $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

723 724
loader-dup-test.loader loader-dup-test.tdbrun: $(patsubst %,loader-dup-test%.tdbrun, 0 1 2 3 4 5)
	true $(SUMMARIZE_CMD) #State that this has passed.  Override the default rule.
725 726 727

loader-dup-test0.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -e 0 $(SUMMARIZE_CMD)
728 729 730

loader-dup-test1.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -d 1 -r 500000 -e 1 $(SUMMARIZE_CMD)
731 732 733 734 735 736 737 738 739 740 741 742 743

loader-dup-test2.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -d 1 -r 1000000 -e 2 $(SUMMARIZE_CMD)

loader-dup-test3.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 100 -e 3 $(SUMMARIZE_CMD)

loader-dup-test4.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 1000 -e 4 $(SUMMARIZE_CMD)

loader-dup-test5.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 1000 -E -e 5 $(SUMMARIZE_CMD)

744 745 746 747 748 749 750 751
loader-cleanup-test.loader: $(patsubst %,loader-cleanup-test%.tdbrun, 0 1)
	true

loader-cleanup-test0.tdbrun: loader-cleanup-test.tdb$(BINSUF)
	$(VGRIND) ./$< -s -r 8000 -e 0 $(SUMMARIZE_CMD)

loader-cleanup-test1.tdbrun: loader-cleanup-test.tdb$(BINSUF)
	$(VGRIND) ./$< -s -r 8000 -p -e 1 $(SUMMARIZE_CMD)
752

753 754 755 756 757 758 759 760 761 762
ROOT_FIFO_41_RUNS = $(foreach num, $(shell seq 1 100), root_fifo_41_$(num)_populate.tdbrun root_fifo_41_$(num)_nopopulate.tdbrun)
root_fifo_41.tdbrun: $(ROOT_FIFO_41_RUNS)
	@echo -n
root_fifo_41_%_populate.tdbrun: root_fifo_41.tdb
	$(VGRIND) ./$< -n $(patsubst root_fifo_41_%_populate.tdbrun, %, $@)   -h $(patsubst %.tdbrun, %.tdbdir, $@) -populate $(SUMMARIZE_CMD)
	@rm -rf $(patsubst %.tdbrun, %.dir, $@) 
root_fifo_41_%_nopopulate.tdbrun: root_fifo_41.tdb
	$(VGRIND) ./$< -n $(patsubst root_fifo_41_%_nopopulate.tdbrun, %, $@) -h $(patsubst %.tdbrun, %.tdbdir, $@)           $(SUMMARIZE_CMD)
	@rm -rf $(patsubst %.tdbrun, %.dir, $@) 

763
LOADER_USE_DEFAULT_TESTS = create-abort create-close no-puts reference-test stress-test tpch-load
764

765 766
loader-tests: $(LOADER_TESTS)
	echo $(LOADER_TESTS)
767

768 769 770
HOTINDEXER_UNDO_TESTS = $(wildcard hotindexer-undo-do-tests/*.test)
CHECK_HOTINDEXER_UNDO_TESTS = $(patsubst %.test,%.run,$(HOTINDEXER_UNDO_TESTS))

771
hotindexer-undo-do-test.tdbrun: $(CHECK_HOTINDEXER_UNDO_TESTS)
772 773
	true

774
$(CHECK_HOTINDEXER_UNDO_TESTS): %.run: %.test hotindexer-undo-do-test.tdb$(BINSUF)
775 776
	./run-hotindexer-undo-do-tests.bash $< $(SUMMARIZE_CMD)

777 778 779 780 781
clean:
	rm -f $(ALL_BINS)
	rm -rf dir.* *.check.output *.check.valgrind
	rm -f dump.bdb.1426 dump.tdb.1426 test1426.bdb
	rm -f *.bdb *.tdb