Makefile 36.7 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
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
27
LIBTDB=../../lib/lib$(LIBTOKUDB).$(SOEXT)
28 29
TLIBTDB=../libtokudbtrace.$(SOEXT)
%.tdb$(BINSUF):  DLINK_FILES+=$(LIBTDB)
30
%.tdb$(BINSUF):  RPATH_DIRS+=$(patsubst %/,%,$(dir $(LIBTDB)))
31
endif
32

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

40
FAIL3312C_SRCS = test3529.c
41 42 43 44

#SRCS = $(sort $(wildcard *.c))
# To patch out upgrade tests, replace line above with line below,
# and patch out loader-stress-test3 (see below)
45
#SRCS = $(sort $(filter-out $(TRANSPARENT_UPGRADE_SRCS),$(wildcard *.c)))
46
# To patch out tests failing on 3312c branch (including upgrade tests), use this:
47
SRCS = $(sort $(filter-out $(TRANSPARENT_UPGRADE_SRCS),$(filter-out $(FAIL3312C_SRCS),$(wildcard *.c))))
48

49

50
#end
51

Yoni Fogel's avatar
Yoni Fogel committed
52 53 54 55 56
#Tests that don't compile in windows.  SHould
WINDOWS_NOT_PORTED_TESTS = \
        diskfull \
#\ ends prev line

57 58
#Tests that are irrelevant in windows.
WINDOWS_DONTRUN_TESTS = \
Yoni Fogel's avatar
Yoni Fogel committed
59
	$(WINDOWS_NOT_PORTED_TESTS) \
60 61 62 63 64
	helgrind1 \
	helgrind2 \
	helgrind3 \
#\ ends prev line

65 66 67 68
#BDB Tests that are irrelevant in windows.
WINDOWS_BDB_DONTRUN_TESTS = \
	diskfull \
	test_groupcommit_count \
69
	test_set_func_malloc \
70 71 72
#\ 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
73
#test_set_func_malloc: windows bdb (some) are missing db_env_set_func_(malloc|realloc|free)
74

75 76 77 78 79 80

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

81 82 83 84 85
TDB_DONTRUN_SRCS = \
	$(wildcard bdb-simple-deadlock*.c) \

TDB_DONTRUN_TESTS = $(patsubst %.c,%,$(TDB_DONTRUN_SRCS))

86
ifeq ($(OS_CHOICE),windows)
87
    TDB_BINS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(SRCS)))
88
    TDB_TESTS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(filter-out $(NONSTANDARD_SRCS),$(SRCS))))
89
else
90 91
    TDB_BINS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(TDB_DONTRUN_SRCS),$(SRCS)))
    TDB_TESTS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(NONSTANDARD_SRCS),$(filter-out $(TDB_DONTRUN_SRCS),$(SRCS))))
92 93
endif

94
# For diskfull.bdb: db-4.6 seems OK, but db-4.3 segfaults
95
BDB_DONTRUN_TESTS = \
96
        backwards_10_each_le_and_msg \
97 98 99
	blocking-prelock-range \
	blocking-set-range-reverse-0 \
	blocking-table-lock \
100 101
        bug1381 \
        bug627 \
102
	cachetable-race \
103 104 105 106
        checkpoint_1 \
        checkpoint_callback \
        checkpoint_stress \
        checkpoint_truncate_1 \
107
	cursor-isolation \
108 109
	cursor-set-del-rmw \
	cursor-set-range-rmw \
110
	db-put-simple-deadlock \
111 112
	del-simple \
	del-multiple \
113
	del-multiple-huge-primary-row \
114
	del-multiple-srcdb \
115
	directory_lock \
116 117 118
        diskfull \
        env-put-multiple \
        env_startup \
119
	execute-updates \
120 121 122 123
        filesize \
        helgrind1 \
        helgrind2 \
        helgrind3 \
124 125 126 127 128 129
	hotindexer-bw \
	hotindexer-db-busy \
	hotindexer-error-callback \
	hotindexer-insert-committed-optimized \
	hotindexer-insert-committed \
	hotindexer-insert-provisional \
130
	hotindexer-lock-test \
131 132
	hotindexer-multiclient \
	hotindexer-nested-insert-committed \
133 134
	hotindexer-put-abort \
	hotindexer-put-commit \
135 136 137 138
	hotindexer-put-multiple \
	hotindexer-simple-abort \
	hotindexer-undo-do-test \
	hotindexer-with-queries \
Leif Walsh's avatar
Leif Walsh committed
139
        hot-optimize-table-tests \
140
	insert-dup-prelock \
141
        isolation \
142
        isolation-read-committed \
143
        keyrange \
Leif Walsh's avatar
Leif Walsh committed
144
	keyrange-merge \
145
	last-verify-time \
146
        loader-cleanup-test \
147 148
	loader-create-abort \
	loader-create-close \
149
	loader-db-busy \
150 151 152
        loader-dup-test \
        loader-no-puts \
        loader-reference-test \
153
	loader-stress-del \
154 155
        loader-stress-test \
        loader-tpch-load \
156
	lock-pressure \
157
        manyfiles \
158
        maxsize-for-loader \
Yoni Fogel's avatar
Yoni Fogel committed
159
	multiprocess \
160
	mvcc-create-table \
161
        mvcc-many-committed \
162 163 164 165
	prelock-read-read \
	prelock-read-write \
	prelock-write-read \
	prelock-write-write \
166
        powerfail \
167
	preload-db \
168
	preload-db-nested \
169
        progress \
170
	put-multiple \
171
	queries_with_deletes \
172
        recover-2483 \
173
        recover-3113 \
174 175
        recover-compare-db \
        recover-compare-db-descriptor \
176 177
	recover-del-multiple \
	recover-del-multiple-abort \
178
        recover-del-multiple-srcdb-fdelete-all \
179 180
        recover-delboth-after-checkpoint \
        recover-delboth-checkpoint \
181 182 183
        recover-descriptor \
        recover-descriptor2 \
        recover-descriptor3 \
184 185 186 187 188 189 190
        recover-descriptor4 \
        recover-descriptor5 \
        recover-descriptor6 \
        recover-descriptor7 \
        recover-descriptor8 \
        recover-descriptor9 \
        recover-descriptor10 \
191 192
        recover-descriptor11 \
        recover-descriptor12 \
193
        recover-fclose-in-checkpoint \
194
        recover-fcreate-basementnodesize \
195 196 197 198 199 200 201 202
	recover-ft1 \
	recover-ft2 \
	recover-ft3 \
	recover-ft4 \
	recover-ft5 \
	recover-ft6 \
	recover-ft7 \
	recover-ft8 \
203 204
	recover-ft9 \
	recover-ft10 \
205 206
        recover-loader-test \
        recover-lsn-filter-multiple \
207 208
	recover-put-multiple \
	recover-put-multiple-abort \
209 210
        recover-put-multiple-fdelete-all \
        recover-put-multiple-fdelete-some \
211
        recover-put-multiple-srcdb-fdelete-all \
212 213
        recover-split-checkpoint \
        recover-tablelock \
214
	recover-test-logsuppress \
215
	recover-test-logsuppress-put \
216 217
	recover-test_stress1 \
	recover-test_stress2 \
218 219
	recover-upgrade-db-descriptor-multihandle \
	recover-upgrade-db-descriptor \
220 221
	recover-update-multiple \
	recover-update-multiple-abort \
222 223 224 225 226 227 228
	recover-update_aborts \
	recover-update_aborts_before_checkpoint \
	recover-update_aborts_before_close \
	recover-update_changes_values \
	recover-update_changes_values_before_checkpoint \
	recover-update_changes_values_before_close \
	recover-update_broadcast_aborts \
229 230
	recover-update_broadcast_aborts2 \
	recover-update_broadcast_aborts3 \
231 232 233
	recover-update_broadcast_aborts_before_checkpoint \
	recover-update_broadcast_aborts_before_close \
	recover-update_broadcast_changes_values \
234 235
	recover-update_broadcast_changes_values2 \
	recover-update_broadcast_changes_values3 \
236 237 238
	recover-update_broadcast_changes_values_before_checkpoint \
	recover-update_broadcast_changes_values_before_close \
	recover-update_changes_values_before_close \
239 240 241 242
        recovery_fileops_stress \
        recovery_fileops_unit \
        recovery_stress \
        redirect \
243
	replace-into-write-lock \
244 245 246
        root_fifo_2 \
        root_fifo_32 \
        root_fifo_41 \
247
	shutdown-3344 \
248
        stat64 stat64-create-modify-times stat64_flatten stat64-null-txn stat64-root-changes \
249
	stress-gc \
250 251 252
        test1324 \
        test1426 \
        test1572 \
253
	test3219 \
254
	test3522 \
255
	test3522b \
256
	test4356 \
257
        test938c \
Zardosht Kasheff's avatar
Zardosht Kasheff committed
258
        test_3645 \
259 260
	test_3529_insert_2 \
	test_3529_table_lock \
261
        test_3755 \
262
	test_4015 \
263
	test_4368 \
264 265 266
        test_abort1 \
        test_abort4 \
        test_abort5 \
267
	test_blobs_leaf_split \
Zardosht Kasheff's avatar
Zardosht Kasheff committed
268
	test_bulk_fetch \
269 270 271
        test_cursor_delete_2119 \
        test_db_descriptor \
        test_db_descriptor_named_db \
272
	test_db_txn_locks_read_uncommitted \
273 274 275
        test_dbremove_old \
        test_dupsort_get_both_range_reverse \
        test_dupsort_set_range_reverse \
276
	test_large_update_broadcast_small_cachetable \
277
        test_logflush \
278
        test_multiple_checkpoints_block_commit \
279
	test_query \
280
	test_rand_insert_mult_db \
Zardosht Kasheff's avatar
Zardosht Kasheff committed
281
	test_redirect_func \
282 283 284 285 286 287
	test_stress1 \
	test_stress2 \
	test_stress3 \
	test_stress4 \
	test_stress5 \
	test_stress6 \
Leif Walsh's avatar
Leif Walsh committed
288
	test_stress7 \
289
	test_stress_with_verify \
290
        test_transactional_descriptor \
291 292 293 294
        test_trans_desc_during_chkpt \
        test_trans_desc_during_chkpt2 \
        test_trans_desc_during_chkpt3 \
        test_trans_desc_during_chkpt4 \
295 296 297 298 299 300 301 302 303 304
        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 \
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
	test_update_abort_works \
	test_update_calls_back \
	test_update_can_delete_elements \
	test_update_changes_values \
	test_update_nonexistent_keys \
	test_update_previously_deleted \
	test_update_stress \
	test_update_txn_snapshot_works_concurrently \
	test_update_txn_snapshot_works_correctly_with_deletes \
	test_update_broadcast_abort_works \
	test_update_broadcast_calls_back \
	test_update_broadcast_can_delete_elements \
	test_update_broadcast_changes_values \
	test_update_broadcast_previously_deleted \
	test_update_broadcast_stress \
	test_update_broadcast_update_fun_has_choices \
	test_update_broadcast_with_empty_table \
        test_update_broadcast_indexer \
	test_update_broadcast_loader \
	test_update_broadcast_nested_updates \
	test_update_nested_updates \
	test_update_with_empty_table \
327
	txn-ignore \
328
        transactional_fileops \
329
	update-multiple-data-diagonal \
330 331 332
	update-multiple-key0 \
	update-multiple-nochange \
	update-multiple-with-indexer \
333
	update \
334
        upgrade_simple \
335 336 337 338
	upgrade-test-1 \
	upgrade-test-2 \
	upgrade-test-3 \
	upgrade-test-4 \
339
	upgrade-test-5 \
340
        upgrade-test-6 \
341
        upgrade-test-7 \
342
        zombie_db \
343 344
#\ ends prev line

345 346 347 348
# 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)

349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
DEPENDS_ON_STRESS_HELPERS = \
 recover-ft1 \
 recover-ft2 \
 recover-ft3 \
 recover-ft4 \
 recover-ft5 \
 recover-ft6 \
 recover-ft7 \
 recover-ft8 \
 recover-test_stress1 \
 recover-test_stress2 \
 test_stress1 \
 test_stress2 \
 test_stress3 \
 test_stress4 \
 test_stress5 \
 test_stress6 \
Leif Walsh's avatar
Leif Walsh committed
366
 test_stress7 \
367 368 369 370
 #blank
$(patsubst %,%.tdb,$(DEPENDS_ON_STRESS_HELPERS)): threaded_stress_test_helpers.h


371 372 373
BDB_TESTS_THAT_SHOULD_FAIL= \
#\ ends prev line
ifeq ($(OS_CHOICE),windows)
374 375
    #The following are nondeterministic test failures or hangs in windows.  Just get rid of them in BDB. (for now)
    WINDOWS_BDB_DONTRUN_TESTS += \
376
	test_archive2 \
377
	test_cursor_delete \
378
	test_cursor_stickyness \
379 380
	test_db_dbt_mem_behavior \
	test_dup_insert \
381
	test_dup_search \
382
	test_dupsort_get \
383 384 385
	test_dupsort_set \
	test_unused_memory_crash \
	test_dupsort_get_both_range \
386 387
	test_reverse_compare_fun \
	test-recover3 \
388 389 390
#\ ends prev line
endif

391

392 393 394 395
ifeq ($(OS_CHOICE),windows)
    BDB_DONTRUN_TESTS+=$(WINDOWS_BDB_DONTRUN_TESTS)
endif

396 397 398 399
ifeq ($(OS_CHOICE),windows)
BDB_TESTS=
BDB_BINS=
else
400
BDB_TESTS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DONTRUN_TESTS)),$(SRCS)))
401 402
BDB_BINS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DONTRUN_TESTS)),$(SRCS)))
endif
403 404 405

TDB_TESTS_THAT_SHOULD_FAIL= \
	test_truncate_txn_abort \
406
	test_db_no_env \
407
#\ ends prev line
408 409
#ifneq ($(OS_CHOICE),windows)
#    TDB_TESTS_THAT_SHOULD_FAIL+= \
410
#\ ends prev line
411
#endif
412

413
TDB_TESTS_THAT_SHOULD_FAIL_LIT= \
414 415 416
	test_log8.recover \
	test_log9.recover \
	test_log10.recover \
417 418
	recover-missing-dbfile.abortrecover \
	recover-missing-dbfile-2.abortrecover \
419 420
	recover-missing-dbfile-2.abortrecover \
	recover-dbopen-eclose.abortrecover \
421
	loader-tpch-load.loader \
422 423
#\ ends prev line

424 425
ifeq ($(OS_CHOICE),windows)
    #Tests that fail in windows but shouldn't.  TODO: Fix each one of these and remove from the list!
426
    WIN_IGNORE_TDB_TESTS_THAT_SHOULD_FAIL += \
427
#\ ends prev line
428
    WIN_IGNORE_TDB_TESTS_THAT_SHOULD_FAIL_LIT += \
429 430 431
#\ ends prev line
endif

432 433 434 435 436 437 438
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
439 440
endif

441
TLRECOVER = 2 3 4 5 6 7 8 9 10
442

443 444
EXTRA_TDB_TESTS = \
	$(patsubst %,test_log%.recover,$(TLRECOVER)) \
445 446
	test_groupcommit_count_hgrind.tdbrun \
	test_groupcommit_count_vgrind.tdbrun \
447
	test_4015.drdrun \
448
#\ ends prev line
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
449

450 451 452 453 454 455
ifeq ($(OS_CHOICE),windows)
EXTRA_TDB_TESTS = \
	$(patsubst %,test_log%.recover,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(TLRECOVER))) \
#\ ends prev line
endif

456
RECOVER_TESTS = $(patsubst %.c,%.abortrecover,$(RECOVER_SRCS))
457
LOADER_TESTS = $(patsubst %.c,%.loader,$(LOADER_SRCS))
458 459
ifeq ($(OS_CHOICE),windows)
RECOVER_TESTS = $(patsubst %.c,%.abortrecover,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(RECOVER_SRCS)))
460
LOADER_TESTS = $(patsubst %.c,%.loader,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(LOADER_SRCS)))
461
endif
462

463 464

RUN_TDB_TESTS = $(patsubst %.tdb$(BINSUF),%.tdbrun,$(TDB_TESTS))  $(EXTRA_TDB_TESTS) $(RECOVER_TESTS) $(LOADER_TESTS)
465 466
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
467

468
MORE_BDB_BINS = test1426.bdb$(BINSUF)
469

470 471
ALL_BINS = $(TDB_BINS) $(BDB_BINS) $(MORE_BDB_BINS)

472
.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
473

474
default all build: $(ALL_BINS)
475

476
ifndef TOKUDBONLY
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
477 478 479
MAYBE_CHECK_BDB = check.bdb
else
MAYBE_CHECK_BDB =
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
480
endif
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
481
check: check.tdb $(MAYBE_CHECK_BDB) ;
482

483
tests: tests.bdb tests.tdb ;
484
tests.bdb: $(BDB_BINS) ;
485
check.bdb: $(RUN_BDB_TESTS) ;
486
tests.tdb: $(TDB_BINS) ;
487
check.tdb: $(LIBTDB) $(PTHREAD_LOCAL) $(RUN_TDB_TESTS) ;
488 489
check.tdb.extra: $(EXTRA_TDB_TESTS) ;
check.abortrecover: $(RECOVER_TESTS) ;
490

491 492 493 494
.PHONY: fastcheck.tdb fastcheckonlyfail.tdb
fastcheck.tdb: $(patsubst %,%.fast,$(RUN_TDB_TESTS))
fastcheckonlyfail.tdb: $(patsubst %,%.fastonlyfail,$(RUN_TDB_TESTS))

495
foo:
496 497
	echo RUN_TDB_TESTS: $(RUN_TDB_TESTS)
	echo ALL_TESTS: $(ALL_TESTS)
498

499 500 501
#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))
502

503 504
.PHONY: %.bdbrun %.run %.tdbrun
# STUFF!!!!
505

506 507
%.run: %.bdbrun %.tdbrun

508 509
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))
510 511 512
# Any test that should fail, we invert the result by using MAYBEINVERTER
$(SHOULD_FAIL): MAYBEINVERTER=$(INVERTER)
$(SHOULD_FAIL): SUMMARIZE_CMD=$(SUMMARIZE_SHOULD_FAIL)
513 514 515
# 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
516

517 518
TDBVGRIND=$(VGRIND)

519 520
ifeq ($(OS_CHOICE),windows)
ifdef BDBDIR
521
%.bdb$(BINSUF): INCLUDEDIRS=-I$(BDBDIR)/include -I$(TOKUROOT)newbrt
522 523 524
%.bdb$(BINSUF): RPATH_DIRS=$(BDBDIR)/lib
endif
ifeq ($(DEBUG),0)
525
WINDOWS_BDB_LIB_NAME=libdb.$(SOEXT)
526
$(WINDOWS_BDB_LIB_NAME):
527
	cp $(BDBDIR)/lib/libdb[0-9][0-9].$(SOEXT) ./
528
else
529
WINDOWS_BDB_LIB_NAME=libdbd.$(SOEXT)
530
$(WINDOWS_BDB_LIB_NAME):
531
	cp $(BDBDIR)/lib/libdb[0-9][0-9]d.$(SOEXT) ./
532 533
endif
%.bdb$(BINSUF): DLINK_FILES=$(BDBDIR)/lib/$(WINDOWS_BDB_LIB_NAME)
534
#empty
535 536 537 538 539 540 541 542 543 544 545
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
546
# Use -s on the command line to make things quiet.
547
# Use -s on the command line to make things quiet.
548
%.bdbrun: %.bdb$(BINSUF) $(DEPEND_COMPILE) $(DEPEND_LINK) $(WINDOWS_BDB_LIB_NAME)
549
	$(BDBVGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
550
%.tdbrun: %.tdb$(BINSUF) $(DEPEND_COMPILE) $(DEPEND_LINK) $(LIBTDB) $(PTHREAD_LOCAL)
551
	$(TDBVGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
552

553 554 555 556 557 558 559
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
560
TDBRECOVER=$(TOKUROOT)newbrt/tdb-recover$(BINSUF)
561 562 563
TDBBRTDUMP=$(TOKUROOT)newbrt/brtdump$(BINSUF)

$(TDBBRTDUMP) $(TDBLOAD) $(TDBDUMP) $(TDBRECOVER):
564
	cd $(@D) && $(MAKE) $(@F)
565

566
%.recover: %.tdb$(BINSUF) $(PTHREAD_LOCAL) $(TDBRECOVER) $(TDBDUMP)
567
	echo doing ./$< &&\
568 569 570 571 572 573
	./$< --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/                   && \
574
	cp dir.$*.c.tdb/*.tokulog*         dir.$*.c.tdb.recover/                   && \
575
	echo doing recovery &&\
576
	$(VGRIND) $(TDBRECOVER) dir.$*.c.tdb.recover dir.$*.c.tdb.recover         && \
577
	echo dump and compare &&\
578 579
	$(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  && \
580
	diff -q dir.$*.c.tdb/foo.dump dir.$*.c.tdb.recover/foo.dump                                   \
581 582
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)

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

586
ABORTCODE=137
587
%.abortrecover: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
588
	{ ./$< --test ; } ; \
589
        if [ $$? -ne $(ABORTCODE) ] ; then \
590
		echo $* --test did not return $(ABORTCODE); \
591 592
		test 0 = 1; \
        else \
593
		$(VGRIND) ./$< --recover; \
594 595 596
	fi \
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)

597
.PHONY: %.recover
598
all.recover: $(patsubst %,test_log%.recover,$(TLRECOVER)) $(PTHREAD_LOCAL) ;
599 600 601 602

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

603 604
.PHONY: %.fast %.fastonlyfail
%.fast: $(DEPEND_COMPILE) $(DEPEND_LINK) $(LIBTDB) $(PTHREAD_LOCAL)
605
	@(perl -e 'alarm ($(FASTCHECKTIMEOUT) * 60) ; exec @ARGV' $(MAKE) VGRIND= SUMMARIZE=0 $*) &>$*.fastlog ; \
606 607 608 609 610 611 612 613
		if test $$? != 0 ; then \
			printf "%-60s FAIL\nexamine %s\n" $* $*.fastlog; \
			exit 2 ; \
		else \
			printf "%-60s PASS\n" $* ; \
			$(RM) $*.fastlog ; \
		fi
%.fastonlyfail: $(DEPEND_COMPILE) $(DEPEND_LINK) $(LIBTDB) $(PTHREAD_LOCAL)
614
	@(perl -e 'alarm ($(FASTCHECKTIMEOUT) * 60) ; exec @ARGV' $(MAKE) VGRIND= SUMMARIZE=0 $*) &>$*.fastlog ; \
615 616 617 618 619 620 621
		if test $$? != 0 ; then \
			printf "%-60s FAIL\nexamine %s\n" $* $*.fastlog; \
			exit 2 ; \
		else \
			$(RM) $*.fastlog ; \
		fi

622 623 624
BDB_CFLAGS=
TDB_CFLAGS=
%.bdb$(BINSUF): BDB_CFLAGS= -DENVDIR=\"dir.$<.bdb\" -DUSE_BDB -DIS_TDB=0 -DTOKU_ALLOW_DEPRECATED
625 626

%.bdb$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK)
627
	$(CC) $< $(BDB_CFLAGS) $(BIN_FROM_C_FLAGS) -L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib -l$(LIBTOKUPORTABILITY) $(LINK_MUST_BE_LAST)
628 629

%.tdbt$(BINSUF): DLINK_FILES+=$(TLIBTDB)
Yoni Fogel's avatar
Yoni Fogel committed
630
%.tdbt$(BINSUF): RPATH_DIRS+=$(dir $(TLIBTDB))
631 632

%.tdb$(BINSUF) %.tdbt$(BINSUF): TDB_CFLAGS= -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1
633
%.tdb$(BINSUF) %.tdbt$(BINSUF): CPPFLAGS+=-I$(TOKUROOT)include
634
%.tdb$(BINSUF) %.tdbt$(BINSUF): LDFLAGS+=-l$(LIBTOKUPORTABILITY)
635
loader-stress-test: CPPFLAGS+=-I$(TOKUROOT)include -DENVDIR=\"dir.$<\"
636
loader-stress-test: LOADLIBES+=-L../lib -ltokudb -Wl,-rpath,..
637

Yoni Fogel's avatar
Yoni Fogel committed
638
%.tdb$(BINSUF) %.tdbt$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK) $(TDB_EXTRA_NEEDED)
639
	$(CC) $< $(TDB_CFLAGS) $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
640 641 642 643 644 645 646 647

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
648

649
# Need these rule so that Make knows about all the file names
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
650
.PHONY: %.run
651 652
$(RUN_ALL_TESTS):
$(ALL_TESTS):
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
653

654
%.run: %.bdbrun %.tdbrun
655
	@ echo ok
656

657 658 659



660 661 662 663 664
INVERTER=;test $$? -ne 0

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

665 666
HERE = src/tests

667

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

670 671
# Don't run valgrind on the groupcommit performance tests
test_groupcommit_perf.bdbrun test_groupcommit_perf.tdbrun: VGRIND=
672
# Use helgrind on the group commit count test
673 674
# helgrind is too flakey, so I'm removing it from the tests. -Bradley
#test_groupcommit_count_helgrind.tdbrun: test_groupcommit_count_helgrind.tdb
675
#	$(HGRIND) ./$< $(VERBVERBOSE)
676 677


678 679
# Don't run valgrind on the diskfull test (since it aborts)
diskfull.tdbrun: VGRIND=
680
stress-gc.tdbrun: VGRIND=
681
insert-dup-prelock: VGRIND=
Zardosht Kasheff's avatar
Zardosht Kasheff committed
682
test_3645: VGRIND=
683
test_large_update_broadcast_small_cachetable.tdbrun: VGRIND=
684 685
test_update_broadcast_stress.tdbrun: VGRIND=
test_update_stress.tdbrun: VGRIND=
686 687
stress-test.tdbrun: VGRIND=
stress-test.bdbrun: VGRIND=
Leif Walsh's avatar
Leif Walsh committed
688
hot-optimize-table-tests.tdbrun: VGRIND=
689

690

691
libs:
Yoni Fogel's avatar
Yoni Fogel committed
692
	cd ..;$(MAKE)
693

694

695

Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
696

697 698

loader-cleanup-test.tdb$(BINSUF) diskfull.tdb$(BINSUF): CPPFLAGS+=-DDONT_DEPRECATE_WRITES
699 700
test_db_curs4.tdb$(BINSUF): trace.h
test_db_curs4.bdb$(BINSUF): trace.h
701 702 703 704 705 706 707 708 709 710 711 712
# 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
713
	true $(SUMMARIZE_CMD) #State that this has passed.
714

715
tgbr_%_a.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
716
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -a $(MAYBEINVERTER) $(SUMMARIZE_CMD)
717
tgbr_%_b.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
718
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -b $(MAYBEINVERTER) $(SUMMARIZE_CMD)
719
tgbr_%_c.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
720
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -c $(MAYBEINVERTER) $(SUMMARIZE_CMD)
721

722 723 724 725
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 > $@
726

727
else
728
dump.bdb.1426: test1426.bdb$(BINSUF) test1426.bdbdump/dump.bdb.1426
729 730 731 732 733
	./$< -q  && \
	 $(BDBDIR)/bin/db_dump -p -h dir.test1426.c.bdb main > $@
	diff -q $@ test1426.bdbdump/$@ #Assert output is correct.
endif

734
# test1426 is run by comparing the BDB output to the TDB output
735
# 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)
736
test1426.tdbrun: test1426.tdb$(BINSUF) dump.bdb.1426 $(PTHREAD_LOCAL) $(TDBDUMP)
737
	(./test1426.tdb$(BINSUF) -q && \
738
	 $(TDBDUMP) -x -p -h dir.test1426.c.tdb main > dump.tdb.1426 && \
739
	 diff -q -I db_pagesize=4096 dump.bdb.1426 dump.tdb.1426 ) \
740
	 $(MAYBEINVERTER) $(SUMMARIZE_CMD)
741

742
# STRESS RUNS is number of iterations, STRESS_SIZE is operations per iteration (must not change between iterations)
743 744 745
# 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
746 747
STRESS_RUNS=5
STRESS_SIZE=5001
748
checkpoint_stress.tdbrun: SHELL=/bin/bash
749
checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL)
750 751
	$(VGRIND) ./$< -C -n $(STRESS_SIZE) $(VERBVERBOSE) && \
	($(VGRIND) ./$< -C -i 0 -n $(STRESS_SIZE) $(VERBVERBOSE) && \
752
	 for (( i = 1; i < $(STRESS_RUNS); i++ )); do \
753 754
		$(if $(VERBOSE),date;) \
		{ ./$< -c -i $$i -n $(STRESS_SIZE) $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; } 2>/dev/null ; \
755 756 757
                if [ $$? -ne $(ABORTCODE) ] ; then \
                   exit 1 ; \
                fi ; \
758
		if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
759 760 761 762
	done && \
	test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
	) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

763 764 765 766 767 768
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 \
769
		{ ./$< -C $$i $(VERBVERBOSE) 2>/dev/null; } 2>/dev/null; \
770 771 772 773 774 775
		if [ $$? -ne $(DISKFULL_ABORTCODE) ] ; then \
		    echo "Diskfull (iteration $$i) did not abort" ; \
		    exit 1; \
		fi; \
	done; ) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

776 777 778 779 780
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 \
781 782
		$(if $(VERBOSE),date;) \
		{ ./$< -c -i $$i -n $(STRESS_SIZE) -l $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; } 2>/dev/null ; \
783 784 785
                if [ $$? -ne $(ABORTCODE) ] ; then \
                   exit 1 ; \
                fi ; \
786
		if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
787 788 789 790
	done && \
	test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
	) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

791 792 793 794
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
795
	$(MAYBEATSIGN)( \
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
        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 \
825 826 827 828 829 830 831 832
                                   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"; \
833
                                      { ./$< $(VERBVERBOSE) -c $$combination 2> $$errorfile ; } 2>/dev/null ;\
834 835 836
                                      if [ $$? -ne $(ABORTCODE) ] ; then \
                                         { cat dir.$@.errors/crash; echo Error: no crash in $$errorfile ; exit 1; }; \
                                      fi ; \
837 838 839 840
                                      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; \
841 842 843 844 845 846 847 848 849
                                done; \
                             done; \
                          done; \
                       done; \
                    done; \
                 done; \
              done; \
           done; \
        done; \
850
	(test -n "$(VERBOSE)" && echo $$count tests passed) || true; \
851 852
	) $(SUMMARIZE_CMD)

Yoni Fogel's avatar
Yoni Fogel committed
853
# helgrind1 is supposed to fail.
854
helgrind1.tdbrun: TDBVGRIND=$(HGRIND) --log-file=helgrind1.tdb.deleteme
Yoni Fogel's avatar
Yoni Fogel committed
855 856
helgrind1.tdbrun: MAYBEINVERTER=$(INVERTER)
helgrind2.bdbrun: BDBVGRIND=$(HGRIND)
857 858
helgrind2.tdbrun helgrind3.tdbrun: TDBVGRIND=$(HGRIND)
helgrind2.tdbrun helgrind3.tdbrun: HGRIND+=--suppressions=helgrind.suppressions
Yoni Fogel's avatar
Yoni Fogel committed
859 860
helgrind3.bdbrun: BDBVGRIND=$(HGRIND)

861

862 863 864 865 866 867
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)

868 869 870 871 872 873
# 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=

874 875 876
# filesize is too slow with vgrind.
filesize.tdbrun: VGRIND=

877 878 879
powerfail.tdbrun:
	@echo must run powerfail by hand $(SUMMARIZE_CMD)

880 881
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
882 883

# test on small stacks
884
test_thread_stack.%run: test_thread_stack.%$(BINSUF) $(PTHREAD_LOCAL)
885 886
	./$< -a -thread_stack 16384         && \
	./$< -a -thread_stack 16384 -resume $(SUMMARIZE_CMD)
887

888 889 890
preload-db-nested.tdbrun: VGRIND=
upgrade-test-4.tdbrun: VGRIND=

891 892 893 894 895 896 897 898 899 900 901 902 903 904
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, $@) 

test3039.tdbrun: test3039.tdb
	( ($(VGRIND) ./$< -v -n 1000 ) && ./$< -v ) $(SUMMARIZE_CMD)

# loader tests
905 906 907 908 909 910 911 912
.PHONY: %.loader
%.loader: %.nop.loader %.p.loader
	true
%.nop.loader: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -e dir.$@ $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
%.p.loader: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -p -e dir.$@ $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

913 914 915
# re-enable loader-stress-test3 when upgrade is complete
#loader-stress-test.loader: $(patsubst %,loader-stress-test%.tdbrun, 0 1 2 3)
loader-stress-test.loader: $(patsubst %,loader-stress-test%.tdbrun, 0 1 2)
916
	true 
917
loader-stress-test0.tdbrun: loader-stress-test.tdb$(BINSUF)
918
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -c -e dir.$@ $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
919
loader-stress-test1.tdbrun: loader-stress-test.tdb$(BINSUF)
920
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -c -p -e dir.$@ $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
921
loader-stress-test2.tdbrun: loader-stress-test.tdb$(BINSUF) 
922
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -r 5000 -s -e dir.$@ $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD) # to manifest #2717.
923
loader-stress-test3.tdbrun: loader-stress-test.tdb$(BINSUF)
924
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -u -c -e dir.$@ $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
925

926 927
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.
928
loader-dup-test0.tdbrun: loader-dup-test.tdb$(BINSUF)
929
	$(VGRIND) ./loader-dup-test.tdb -e dir.$@ $(SUMMARIZE_CMD)
930
loader-dup-test1.tdbrun: loader-dup-test.tdb$(BINSUF)
931
	$(VGRIND) ./loader-dup-test.tdb -d 1 -r 500000 -e dir.$@ $(SUMMARIZE_CMD)
932
loader-dup-test2.tdbrun: loader-dup-test.tdb$(BINSUF)
933
	$(VGRIND) ./loader-dup-test.tdb -d 1 -r 1000000 -e dir.$@ $(SUMMARIZE_CMD)
934
loader-dup-test3.tdbrun: loader-dup-test.tdb$(BINSUF)
935
	$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 100 -e dir.$@ $(SUMMARIZE_CMD)
936
loader-dup-test4.tdbrun: loader-dup-test.tdb$(BINSUF)
937
	$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 1000 -e dir.$@ $(SUMMARIZE_CMD)
938
loader-dup-test5.tdbrun: loader-dup-test.tdb$(BINSUF)
939
	$(VGRIND) ./loader-dup-test.tdb -d 1 -s -r 1000 -E -e dir.$@ $(SUMMARIZE_CMD)
940

941 942 943
loader-cleanup-test.loader: $(patsubst %,loader-cleanup-test%.tdbrun, 0 1)
	true
loader-cleanup-test0.tdbrun: loader-cleanup-test.tdb$(BINSUF)
944
	$(VGRIND) ./$< -s -r 8000 -e dir.$@ $(SUMMARIZE_CMD)
945
loader-cleanup-test1.tdbrun: loader-cleanup-test.tdb$(BINSUF)
946
	$(VGRIND) ./$< -s -r 8000 -p -e dir.$@ $(SUMMARIZE_CMD)
947

948 949
loader-tests: $(LOADER_TESTS)
	echo $(LOADER_TESTS)
950

951
# hot indexer tests
952 953 954
HOTINDEXER_UNDO_TESTS = $(wildcard hotindexer-undo-do-tests/*.test)
CHECK_HOTINDEXER_UNDO_TESTS = $(patsubst %.test,%.run,$(HOTINDEXER_UNDO_TESTS))

955
hotindexer-undo-do-test.tdbrun: $(CHECK_HOTINDEXER_UNDO_TESTS)
956
	true
957 958
$(CHECK_HOTINDEXER_UNDO_TESTS): %.run: %.test hotindexer-undo-do-test.tdb$(BINSUF) 
	./run-hotindexer-undo-do-tests.bash $< $(SUMMARIZE_CMD)
959

960
# blocking lock tree tests
961
BLOCKING_SRCS = $(wildcard blocking-*.c db-put-*.c)
962 963 964
BLOCKING_TDB_TESTS = $(patsubst %.c,%.tdbrun,$(BLOCKING_SRCS))
BLOCKING_BDB_TESTS = $(patsubst %.c,%.bdbrun,$(BLOCKING_SRCS))

965
check_blocking.tdbrun: $(BLOCKING_TDB_TESTS)
966

967
check_blocking.bdbrun: $(BLOCKING_BDB_TESTS)
968

969 970
STRESS_TEST_SRCS = $(wildcard test_stress*.c)
STRESS_TESTS = $(patsubst %.c,%,$(STRESS_TEST_SRCS))
971 972 973 974 975 976 977 978 979 980

stress_tests.tdbrun: $(patsubst %,%.stressrun,$(STRESS_TESTS))
	true

%.stressrun: %.tdb
	./$< --only_create --envdir dir.$@ && \
	$(VGRIND) ./$< $(VERBVERBOSE) --only_stress --num_seconds 1000 --envdir dir.$@ \
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)	

# stress tests with drd
981 982 983 984 985
TINY_STRESS_TESTS = $(patsubst %,tiny_%.drdrun,$(STRESS_TESTS))
MID_STRESS_TESTS = $(patsubst %,mid_%.drdrun,$(STRESS_TESTS))
LARGE_STRESS_TESTS = $(patsubst %,large_%.drdrun,$(STRESS_TESTS))

stress_tests.drdrun: $(TINY_STRESS_TESTS) \
986 987 988
	$(MID_STRESS_TESTS) \
	large_test_stress1.drdrun large_test_stress3.drdrun \
	test_4015.drdrun
989
	true
990 991
tiny_stress_tests.drdrun: $(TINY_STRESS_TESTS)
	true
992 993
mid_stress_tests.drdrun: $(MID_STRESS_TESTS)
	true
994 995
large_stress_tests.drdrun: $(LARGE_STRESS_TESTS)
	true
996 997
tiny_%.drdrun: %.tdb
	$(VALGRIND) --tool=drd --quiet --suppressions=drd.suppressions --error-exitcode=1 ./$< $(VERBVERBOSE) --num_seconds 5 --num_elements 150 --envdir dir.$@ \
998
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)
999 1000 1001
mid_%.drdrun: %.tdb
	./$< --only_create --envdir dir.$@ --num_elements 10000 && \
	$(VALGRIND) --tool=drd --quiet --suppressions=drd.suppressions --error-exitcode=1 ./$< $(VERBVERBOSE) --only_stress --num_seconds 100 --envdir dir.$@ --num_elements 10000 \
1002
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)
1003 1004 1005
large_%.drdrun: %.tdb
	./$< --only_create --envdir dir.$@ && \
	$(VALGRIND) --tool=drd --quiet --suppressions=drd.suppressions --error-exitcode=1 ./$< $(VERBVERBOSE) --only_stress --num_seconds 1000 --envdir dir.$@ \
1006
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)
1007
test_4015.drdrun: test_4015.tdb
1008 1009
	$(VALGRIND) --tool=drd --quiet --suppressions=drd.suppressions --error-exitcode=1 ./$< --envdir dir.tdb.$@ \
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)
1010

1011
# upgrade tests
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
UPGRADE_TEST_SRCS = $(wildcard upgrade-test-*.c)
UPGRADE_TESTS = $(patsubst %.c,%,$(UPGRADE_TEST_SRCS))
UPGRADE_TESTS_VALGRIND = $(patsubst upgrade-test-%,upgrade-test-%.valgrind,$(UPGRADE_TESTS))

upgrade-tests.tdbrun: $(UPGRADE_TESTS_VALGRIND)
	echo $(UPGRADE_TESTS_VALGRIND)
	true
upgrade-test-%.valgrind: upgrade-test-%.tdb
	$(VGRIND) ./$< $(VERBVERBOSE) $(SUMMARIZE_CMD)

1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
# keyrange tests
keyrange.tdbrun: keyrange-get0.tdbrun keyrange-get1.tdbrun \
	keyrange-random-get0.tdbrun keyrange-random-get1.tdbrun \
	keyrange-loader-get0.tdbrun keyrange-loader-get1.tdbrun
	true
keyrange-get0.tdbrun: keyrange.tdb
	$(TDBVGRIND) ./$< $(VERBVERBOSE) --get 0 --envdir dir.$@ $(MAYBEINVERTER) $(SUMMARIZE_CMD)
keyrange-get1.tdbrun: keyrange.tdb
	$(TDBVGRIND) ./$< $(VERBVERBOSE) --get 1 --envdir dir.$@ $(MAYBEINVERTER) $(SUMMARIZE_CMD)
keyrange-random-get0.tdbrun: keyrange.tdb
	$(TDBVGRIND) ./$< $(VERBVERBOSE) --get 0 --random_keys 1 --envdir dir.$@ $(MAYBEINVERTER) $(SUMMARIZE_CMD)
keyrange-random-get1.tdbrun: keyrange.tdb
	$(TDBVGRIND) ./$< $(VERBVERBOSE) --get 1 --random_keys 1 --envdir dir.$@ $(MAYBEINVERTER) $(SUMMARIZE_CMD)
keyrange-loader-get0.tdbrun: keyrange.tdb
	$(TDBVGRIND) ./$< $(VERBVERBOSE) --get 0 --loader 1 --envdir dir.$@ $(MAYBEINVERTER) $(SUMMARIZE_CMD)
keyrange-loader-get1.tdbrun: keyrange.tdb
	$(TDBVGRIND) ./$< $(VERBVERBOSE) --get 1 --loader 1 --envdir dir.$@ $(MAYBEINVERTER) $(SUMMARIZE_CMD)

1040 1041 1042 1043 1044 1045
maxsize-for-loader.tdbrun: maxsize-for-loader-A.tdbrun maxsize-for-loader-B.tdbrun 
	@echo -n
maxsize-for-loader-A.tdbrun: maxsize-for-loader.tdb
	$(TDBVGRIND) ./$< -e $@  -f 2> /dev/null $(SUMMARIZE_CMD)
maxsize-for-loader-B.tdbrun: maxsize-for-loader.tdb
	./$< -e $@                  2> /dev/null $(SUMMARIZE_CMD)
1046 1047 1048 1049 1050 1051
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
	rm -f *.fastlog
1052
	rm -rf rundir.* recover-test_stress*.dir