Makefile 27.4 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

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

42 43 44
SRCS = $(sort $(wildcard *.c))
# To patch out upgrade tests, replace line above with line below
#SRCS = $(sort $(filter-out $(TRANSPARENT_UPGRADE_SRCS),$(wildcard *.c)))
45

46
#end
47

Yoni Fogel's avatar
Yoni Fogel committed
48 49 50 51 52
#Tests that don't compile in windows.  SHould
WINDOWS_NOT_PORTED_TESTS = \
        diskfull \
#\ ends prev line

53 54
#Tests that are irrelevant in windows.
WINDOWS_DONTRUN_TESTS = \
Yoni Fogel's avatar
Yoni Fogel committed
55
	$(WINDOWS_NOT_PORTED_TESTS) \
56 57 58 59 60
	helgrind1 \
	helgrind2 \
	helgrind3 \
#\ ends prev line

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

71 72 73 74 75 76

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

77
ifeq ($(OS_CHOICE),windows)
78
    TDB_BINS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(SRCS)))
79
    TDB_TESTS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(filter-out $(NONSTANDARD_SRCS),$(SRCS))))
80
else
81
    TDB_BINS = $(patsubst %.c,%.tdb$(BINSUF),$(SRCS))
82
    TDB_TESTS = $(patsubst %.c,%.tdb$(BINSUF),$(filter-out $(NONSTANDARD_SRCS),$(SRCS)))
83 84
endif

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

224 225 226 227
# 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)

228 229 230
BDB_TESTS_THAT_SHOULD_FAIL= \
#\ ends prev line
ifeq ($(OS_CHOICE),windows)
231 232
    #The following are nondeterministic test failures or hangs in windows.  Just get rid of them in BDB. (for now)
    WINDOWS_BDB_DONTRUN_TESTS += \
233
	test_archive2 \
234
	test_cursor_delete \
235
	test_cursor_stickyness \
236 237
	test_db_dbt_mem_behavior \
	test_dup_insert \
238
	test_dup_search \
239
	test_dupsort_get \
240 241 242
	test_dupsort_set \
	test_unused_memory_crash \
	test_dupsort_get_both_range \
243 244
	test_reverse_compare_fun \
	test-recover3 \
245 246 247
#\ ends prev line
endif

248

249 250 251 252
ifeq ($(OS_CHOICE),windows)
    BDB_DONTRUN_TESTS+=$(WINDOWS_BDB_DONTRUN_TESTS)
endif

253 254 255 256
ifeq ($(OS_CHOICE),windows)
BDB_TESTS=
BDB_BINS=
else
257
BDB_TESTS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DONTRUN_TESTS)),$(SRCS)))
258 259
BDB_BINS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DONTRUN_TESTS)),$(SRCS)))
endif
260 261 262

TDB_TESTS_THAT_SHOULD_FAIL= \
	test_truncate_txn_abort \
263
	test_db_no_env \
264
#\ ends prev line
265 266
#ifneq ($(OS_CHOICE),windows)
#    TDB_TESTS_THAT_SHOULD_FAIL+= \
267
#\ ends prev line
268
#endif
269

270
TDB_TESTS_THAT_SHOULD_FAIL_LIT= \
271 272 273
	test_log8.recover \
	test_log9.recover \
	test_log10.recover \
274 275
	recover-missing-dbfile.abortrecover \
	recover-missing-dbfile-2.abortrecover \
276 277
	recover-missing-dbfile-2.abortrecover \
	recover-dbopen-eclose.abortrecover \
278
	loader-tpch-load.loader \
279 280
#\ ends prev line

281 282
ifeq ($(OS_CHOICE),windows)
    #Tests that fail in windows but shouldn't.  TODO: Fix each one of these and remove from the list!
283
    WIN_IGNORE_TDB_TESTS_THAT_SHOULD_FAIL += \
284
#\ ends prev line
285
    WIN_IGNORE_TDB_TESTS_THAT_SHOULD_FAIL_LIT += \
286 287 288
#\ ends prev line
endif

289 290 291 292 293 294 295
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
296 297
endif

298
TLRECOVER = 2 3 4 5 6 7 8 9 10
299

300 301
EXTRA_TDB_TESTS = \
	$(patsubst %,test_log%.recover,$(TLRECOVER)) \
302 303
	test_groupcommit_count_hgrind.tdbrun \
	test_groupcommit_count_vgrind.tdbrun \
304
#\ ends prev line
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
305

306 307 308 309 310 311
ifeq ($(OS_CHOICE),windows)
EXTRA_TDB_TESTS = \
	$(patsubst %,test_log%.recover,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(TLRECOVER))) \
#\ ends prev line
endif

312
RECOVER_TESTS = $(patsubst %.c,%.abortrecover,$(RECOVER_SRCS))
313
LOADER_TESTS= $(patsubst %.c,%.loader,$(LOADER_SRCS))
314 315
ifeq ($(OS_CHOICE),windows)
RECOVER_TESTS = $(patsubst %.c,%.abortrecover,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(RECOVER_SRCS)))
316
LOADER_TESTS = $(patsubst %.c,%.loader,$(filter-out $(patsubst %,%.c,$(WINDOWS_DONTRUN_TESTS)),$(LOADER_SRCS)))
317
endif
318

319 320

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

324
MORE_BDB_BINS = test1426.bdb$(BINSUF)
325

326 327
ALL_BINS = $(TDB_BINS) $(BDB_BINS) $(MORE_BDB_BINS)

328
.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
329

330
default all build: $(ALL_BINS)
331

332
ifndef TOKUDBONLY
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
333 334 335
MAYBE_CHECK_BDB = check.bdb
else
MAYBE_CHECK_BDB =
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
336
endif
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
337
check: check.tdb $(MAYBE_CHECK_BDB) ;
338

339
tests: tests.bdb tests.tdb ;
340
tests.bdb: $(BDB_BINS) ;
341
check.bdb: $(RUN_BDB_TESTS) ;
342
tests.tdb: $(TDB_BINS) ;
343
check.tdb: $(LIBTDB) $(PTHREAD_LOCAL) $(RUN_TDB_TESTS) ;
344 345
check.tdb.extra: $(EXTRA_TDB_TESTS) ;
check.abortrecover: $(RECOVER_TESTS) ;
346

347
foo:
348 349
	echo RUN_TDB_TESTS: $(RUN_TDB_TESTS)
	echo ALL_TESTS: $(ALL_TESTS)
350

351 352 353
#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))
354

355 356
.PHONY: %.bdbrun %.run %.tdbrun
# STUFF!!!!
357

358 359
%.run: %.bdbrun %.tdbrun

360 361
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))
362 363 364
# Any test that should fail, we invert the result by using MAYBEINVERTER
$(SHOULD_FAIL): MAYBEINVERTER=$(INVERTER)
$(SHOULD_FAIL): SUMMARIZE_CMD=$(SUMMARIZE_SHOULD_FAIL)
365 366 367
# 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
368

369 370
TDBVGRIND=$(VGRIND)

371 372
ifeq ($(OS_CHOICE),windows)
ifdef BDBDIR
373
%.bdb$(BINSUF): INCLUDEDIRS=-I$(BDBDIR)/include -I$(TOKUROOT)newbrt
374 375 376
%.bdb$(BINSUF): RPATH_DIRS=$(BDBDIR)/lib
endif
ifeq ($(DEBUG),0)
377
WINDOWS_BDB_LIB_NAME=libdb.$(SOEXT)
378
$(WINDOWS_BDB_LIB_NAME):
379
	cp $(BDBDIR)/lib/libdb[0-9][0-9].$(SOEXT) ./
380
else
381
WINDOWS_BDB_LIB_NAME=libdbd.$(SOEXT)
382
$(WINDOWS_BDB_LIB_NAME):
383
	cp $(BDBDIR)/lib/libdb[0-9][0-9]d.$(SOEXT) ./
384 385
endif
%.bdb$(BINSUF): DLINK_FILES=$(BDBDIR)/lib/$(WINDOWS_BDB_LIB_NAME)
386
#empty
387 388 389 390 391 392 393 394 395 396 397
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
398
# Use -s on the command line to make things quiet.
399
# Use -s on the command line to make things quiet.
400
%.bdbrun: %.bdb$(BINSUF) $(DEPEND_COMPILE) $(DEPEND_LINK) $(WINDOWS_BDB_LIB_NAME)
401
	$(BDBVGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
402
%.tdbrun: %.tdb$(BINSUF) $(DEPEND_COMPILE) $(DEPEND_LINK) $(LIBTDB) $(PTHREAD_LOCAL)
403
	$(TDBVGRIND) ./$< $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
404

405 406 407 408 409 410 411
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
412
TDBRECOVER=$(TOKUROOT)newbrt/tdb-recover$(BINSUF)
413 414 415
TDBBRTDUMP=$(TOKUROOT)newbrt/brtdump$(BINSUF)

$(TDBBRTDUMP) $(TDBLOAD) $(TDBDUMP) $(TDBRECOVER):
416
	cd $(@D) && $(MAKE) $(@F)
417

418
%.recover: %.tdb$(BINSUF) $(PTHREAD_LOCAL) $(TDBRECOVER) $(TDBDUMP)
419
	echo doing ./$< &&\
420 421 422 423 424 425
	./$< --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/                   && \
426
	cp dir.$*.c.tdb/*.tokulog*         dir.$*.c.tdb.recover/                   && \
427
	echo doing recovery &&\
428
	$(VGRIND) $(TDBRECOVER) dir.$*.c.tdb.recover dir.$*.c.tdb.recover         && \
429
	echo dump and compare &&\
430 431
	$(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  && \
432
	diff -q dir.$*.c.tdb/foo.dump dir.$*.c.tdb.recover/foo.dump                                   \
433 434
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)

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

438
ABORTCODE=137
439
%.abortrecover: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
440
	{ ./$< --test ; } ; \
441
        if [ $$? -ne $(ABORTCODE) ] ; then \
442
		echo $* --test did not return $(ABORTCODE); \
443 444
		test 0 = 1; \
        else \
445
		$(VGRIND) ./$< --recover; \
446 447 448
	fi \
	$(MAYBEINVERTER) $(SUMMARIZE_CMD)

449
.PHONY: %.loader
450
# Generally these subtests cannot run in parallel unless they support an environment arg
451
%.loader: %.tdb$(BINSUF) $(PTHREAD_LOCAL)
452
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
453
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -p $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
454

455
.PHONY: %.recover
456
all.recover: $(patsubst %,test_log%.recover,$(TLRECOVER)) $(PTHREAD_LOCAL) ;
457 458 459 460

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

461 462 463
BDB_CFLAGS=
TDB_CFLAGS=
%.bdb$(BINSUF): BDB_CFLAGS= -DENVDIR=\"dir.$<.bdb\" -DUSE_BDB -DIS_TDB=0 -DTOKU_ALLOW_DEPRECATED
464 465

%.bdb$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK)
466
	$(CC) $< $(BDB_CFLAGS) $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
467 468

%.tdbt$(BINSUF): DLINK_FILES+=$(TLIBTDB)
Yoni Fogel's avatar
Yoni Fogel committed
469
%.tdbt$(BINSUF): RPATH_DIRS+=$(dir $(TLIBTDB))
470 471

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

Yoni Fogel's avatar
Yoni Fogel committed
476
%.tdb$(BINSUF) %.tdbt$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK) $(TDB_EXTRA_NEEDED)
477
	$(CC) $< $(TDB_CFLAGS) $(filter-out ../../lib/libtokuportability.a,$(BIN_FROM_C_FLAGS)) $(LINK_MUST_BE_LAST)
478 479 480 481 482 483 484 485

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
486

487
# Need these rule so that Make knows about all the file names
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
488
.PHONY: %.run
489 490
$(RUN_ALL_TESTS):
$(ALL_TESTS):
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
491

492
%.run: %.bdbrun %.tdbrun
493
	@ echo ok
494

495 496 497



498 499 500 501 502
INVERTER=;test $$? -ne 0

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

503 504
HERE = src/tests

505

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

508 509
# Don't run valgrind on the groupcommit performance tests
test_groupcommit_perf.bdbrun test_groupcommit_perf.tdbrun: VGRIND=
510
# Use helgrind on the group commit count test
511 512
# helgrind is too flakey, so I'm removing it from the tests. -Bradley
#test_groupcommit_count_helgrind.tdbrun: test_groupcommit_count_helgrind.tdb
513
#	$(HGRIND) ./$< $(VERBVERBOSE)
514 515


516 517
# Don't run valgrind on the diskfull test (since it aborts)
diskfull.tdbrun: VGRIND=
518
stress-gc.tdbrun: VGRIND=
519
insert-dup-prelock: VGRIND=
520

521

522
libs:
Yoni Fogel's avatar
Yoni Fogel committed
523
	cd ..;$(MAKE)
524

525

526

Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
527

528 529

loader-cleanup-test.tdb$(BINSUF) diskfull.tdb$(BINSUF): CPPFLAGS+=-DDONT_DEPRECATE_WRITES
530 531
test_db_curs4.tdb$(BINSUF): trace.h
test_db_curs4.bdb$(BINSUF): trace.h
532 533 534 535 536 537 538 539 540 541 542 543
# 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
544
	true $(SUMMARIZE_CMD) #State that this has passed.
545

546
tgbr_%_a.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
547
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -a $(MAYBEINVERTER) $(SUMMARIZE_CMD)
548
tgbr_%_b.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
549
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -b $(MAYBEINVERTER) $(SUMMARIZE_CMD)
550
tgbr_%_c.tdbrun: test_get_both_range.tdb$(BINSUF) $(PTHREAD_LOCAL)
551
	$(VGRIND) ./$< $(VERBVERBOSE) -i $* -c $(MAYBEINVERTER) $(SUMMARIZE_CMD)
552

553 554 555 556
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 > $@
557

558
else
559
dump.bdb.1426: test1426.bdb$(BINSUF) test1426.bdbdump/dump.bdb.1426
560 561 562 563 564
	./$< -q  && \
	 $(BDBDIR)/bin/db_dump -p -h dir.test1426.c.bdb main > $@
	diff -q $@ test1426.bdbdump/$@ #Assert output is correct.
endif

565
# test1426 is run by comparing the BDB output to the TDB output
566
# 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)
567
test1426.tdbrun: test1426.tdb$(BINSUF) dump.bdb.1426 $(PTHREAD_LOCAL) $(TDBDUMP)
568
	(./test1426.tdb$(BINSUF) -q && \
569
	 $(TDBDUMP) -x -p -h dir.test1426.c.tdb main > dump.tdb.1426 && \
570
	 diff -q -I db_pagesize=4096 dump.bdb.1426 dump.tdb.1426 ) \
571
	 $(MAYBEINVERTER) $(SUMMARIZE_CMD)
572

573
# STRESS RUNS is number of iterations, STRESS_SIZE is operations per iteration (must not change between iterations)
574 575 576
# 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
577 578
STRESS_RUNS=5
STRESS_SIZE=5001
579
checkpoint_stress.tdbrun: SHELL=/bin/bash
580
checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) $(PTHREAD_LOCAL)
581 582
	$(VGRIND) ./$< -C -n $(STRESS_SIZE) $(VERBVERBOSE) && \
	($(VGRIND) ./$< -C -i 0 -n $(STRESS_SIZE) $(VERBVERBOSE) && \
583
	 for (( i = 1; i < $(STRESS_RUNS); i++ )); do \
584 585
		$(if $(VERBOSE),date;) \
		{ ./$< -c -i $$i -n $(STRESS_SIZE) $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; } 2>/dev/null ; \
586 587 588
                if [ $$? -ne $(ABORTCODE) ] ; then \
                   exit 1 ; \
                fi ; \
589
		if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
590 591 592 593
	done && \
	test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
	) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

594 595 596 597 598 599
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 \
600
		{ ./$< -C $$i $(VERBVERBOSE) 2>/dev/null; } 2>/dev/null; \
601 602 603 604 605 606
		if [ $$? -ne $(DISKFULL_ABORTCODE) ] ; then \
		    echo "Diskfull (iteration $$i) did not abort" ; \
		    exit 1; \
		fi; \
	done; ) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

607 608 609 610 611
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 \
612 613
		$(if $(VERBOSE),date;) \
		{ ./$< -c -i $$i -n $(STRESS_SIZE) -l $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; } 2>/dev/null ; \
614 615 616
                if [ $$? -ne $(ABORTCODE) ] ; then \
                   exit 1 ; \
                fi ; \
617
		if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
618 619 620 621
	done && \
	test `grep -l 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.* |wc -l` = $$(($(STRESS_RUNS)-1)) \
	) $(MAYBEINVERTER) $(SUMMARIZE_CMD)

622 623 624 625
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
626
	$(MAYBEATSIGN)( \
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
        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 \
656 657 658 659 660 661 662 663
                                   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"; \
664
                                      { ./$< $(VERBVERBOSE) -c $$combination 2> $$errorfile ; } 2>/dev/null ;\
665 666 667
                                      if [ $$? -ne $(ABORTCODE) ] ; then \
                                         { cat dir.$@.errors/crash; echo Error: no crash in $$errorfile ; exit 1; }; \
                                      fi ; \
668 669 670 671
                                      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; \
672 673 674 675 676 677 678 679 680
                                done; \
                             done; \
                          done; \
                       done; \
                    done; \
                 done; \
              done; \
           done; \
        done; \
681
	(test -n "$(VERBOSE)" && echo $$count tests passed) || true; \
682 683
	) $(SUMMARIZE_CMD)

Yoni Fogel's avatar
Yoni Fogel committed
684
# helgrind1 is supposed to fail.
685
helgrind1.tdbrun: TDBVGRIND=$(HGRIND) --log-file=helgrind1.tdb.deleteme
Yoni Fogel's avatar
Yoni Fogel committed
686 687
helgrind1.tdbrun: MAYBEINVERTER=$(INVERTER)
helgrind2.bdbrun: BDBVGRIND=$(HGRIND)
688 689
helgrind2.tdbrun helgrind3.tdbrun: TDBVGRIND=$(HGRIND)
helgrind2.tdbrun helgrind3.tdbrun: HGRIND+=--suppressions=helgrind.suppressions
Yoni Fogel's avatar
Yoni Fogel committed
690 691
helgrind3.bdbrun: BDBVGRIND=$(HGRIND)

692

693 694 695 696 697 698
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)

699 700 701 702 703 704
# 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=

705 706 707
# filesize is too slow with vgrind.
filesize.tdbrun: VGRIND=

708 709 710
powerfail.tdbrun:
	@echo must run powerfail by hand $(SUMMARIZE_CMD)

711 712
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
713 714

# test on small stacks
715
test_thread_stack.%run: test_thread_stack.%$(BINSUF) $(PTHREAD_LOCAL)
716 717
	./$< -a -thread_stack 16384         && \
	./$< -a -thread_stack 16384 -resume $(SUMMARIZE_CMD)
718

719 720 721
preload-db-nested.tdbrun: VGRIND=
upgrade-test-4.tdbrun: VGRIND=

722

723 724

loader-stress-test.loader: $(patsubst %,loader-stress-test%.tdbrun, 0 1 2 3)
725 726 727
	true

loader-stress-test0.tdbrun: loader-stress-test.tdb$(BINSUF)
728
	$(TDBVGRIND) ./$< $(EXTRA_ARGS) -e 0 -c $(VERBVERBOSE) $(MAYBEINVERTER) $(SUMMARIZE_CMD)
729 730

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

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

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

739 740
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.
741 742 743

loader-dup-test0.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -e 0 $(SUMMARIZE_CMD)
744 745 746

loader-dup-test1.tdbrun: loader-dup-test.tdb$(BINSUF)
	$(VGRIND) ./loader-dup-test.tdb -d 1 -r 500000 -e 1 $(SUMMARIZE_CMD)
747 748 749 750 751 752 753 754 755 756 757 758 759

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)

760 761 762 763 764 765 766 767
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)
768

769 770 771 772 773 774 775 776 777 778
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, $@) 

779
LOADER_USE_DEFAULT_TESTS = create-abort create-close no-puts reference-test stress-test tpch-load
780

781 782
loader-tests: $(LOADER_TESTS)
	echo $(LOADER_TESTS)
783

784 785 786
HOTINDEXER_UNDO_TESTS = $(wildcard hotindexer-undo-do-tests/*.test)
CHECK_HOTINDEXER_UNDO_TESTS = $(patsubst %.test,%.run,$(HOTINDEXER_UNDO_TESTS))

787
hotindexer-undo-do-test.tdbrun: $(CHECK_HOTINDEXER_UNDO_TESTS)
788 789
	true

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

793
$(CHECK_HOTINDEXER_UNDO_TESTS): %.run: %.test hotindexer-undo-do-test.tdb$(BINSUF)
794 795
	./run-hotindexer-undo-do-tests.bash $< $(SUMMARIZE_CMD)

796 797 798 799 800
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