#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
# OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
#
# Permission is hereby granted to use or copy this program
# for any purpose,  provided the above notices are retained on all copies.
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.

# Common libs to _LDADD for all tests.
test_ldadd = $(top_builddir)/libgc.la $(EXTRA_TEST_LIBS)

TESTS += gctest$(EXEEXT)
check_PROGRAMS += gctest
gctest_SOURCES = tests/test.c
gctest_LDADD = $(test_ldadd)
if THREADS
gctest_LDADD += $(THREADDLLIBS)
endif
gctest_DEPENDENCIES = $(top_builddir)/libgc.la

TESTS += leaktest$(EXEEXT)
check_PROGRAMS += leaktest
leaktest_SOURCES = tests/leak_test.c
leaktest_LDADD = $(test_ldadd)

TESTS += middletest$(EXEEXT)
check_PROGRAMS += middletest
middletest_SOURCES = tests/middle.c
middletest_LDADD = $(test_ldadd)

TESTS += smashtest$(EXEEXT)
check_PROGRAMS += smashtest
smashtest_SOURCES = tests/smash_test.c
smashtest_LDADD = $(test_ldadd)

TESTS += hugetest$(EXEEXT)
check_PROGRAMS += hugetest
hugetest_SOURCES = tests/huge_test.c
hugetest_LDADD = $(test_ldadd)

TESTS += realloc_test$(EXEEXT)
check_PROGRAMS += realloc_test
realloc_test_SOURCES = tests/realloc_test.c
realloc_test_LDADD = $(test_ldadd)

TESTS += staticrootstest$(EXEEXT)
check_PROGRAMS += staticrootstest
staticrootstest_SOURCES = tests/staticrootstest.c
staticrootstest_CFLAGS = -DSTATICROOTSLIB2
staticrootstest_LDADD = $(test_ldadd) libstaticrootslib_test.la \
                        libstaticrootslib2_test.la
check_LTLIBRARIES += libstaticrootslib_test.la libstaticrootslib2_test.la
libstaticrootslib_test_la_SOURCES = tests/staticrootslib.c
libstaticrootslib_test_la_LIBADD = $(test_ldadd)
libstaticrootslib_test_la_LDFLAGS = -version-info 1:3:0 -no-undefined \
                                    -rpath /nowhere
libstaticrootslib_test_la_DEPENDENCIES = $(top_builddir)/libgc.la
libstaticrootslib2_test_la_SOURCES = tests/staticrootslib.c
libstaticrootslib2_test_la_LIBADD = $(test_ldadd)
libstaticrootslib2_test_la_CFLAGS = -DSTATICROOTSLIB2
libstaticrootslib2_test_la_LDFLAGS = -version-info 1:3:0 -no-undefined \
                                     -rpath /nowhere

if KEEP_BACK_PTRS
TESTS += tracetest$(EXEEXT)
check_PROGRAMS += tracetest
tracetest_SOURCES = tests/trace_test.c
tracetest_LDADD = $(test_ldadd)
endif

if THREADS
TESTS += threadleaktest$(EXEEXT)
check_PROGRAMS += threadleaktest
threadleaktest_SOURCES = tests/thread_leak_test.c
threadleaktest_LDADD = $(test_ldadd) $(THREADDLLIBS)

TESTS += threadkey_test$(EXEEXT)
check_PROGRAMS += threadkey_test
threadkey_test_SOURCES = tests/threadkey_test.c
threadkey_test_LDADD = $(test_ldadd) $(THREADDLLIBS)

TESTS += subthreadcreate_test$(EXEEXT)
check_PROGRAMS += subthreadcreate_test
subthreadcreate_test_SOURCES = tests/subthread_create.c
subthreadcreate_test_LDADD = $(test_ldadd) $(THREADDLLIBS)

TESTS += initsecondarythread_test$(EXEEXT)
check_PROGRAMS += initsecondarythread_test
initsecondarythread_test_SOURCES = tests/initsecondarythread.c
initsecondarythread_test_LDADD = $(test_ldadd) $(THREADDLLIBS)
endif

if CPLUSPLUS
TESTS += test_cpp$(EXEEXT)
check_PROGRAMS += test_cpp
test_cpp_SOURCES = tests/test_cpp.cc
if AVOID_CPP_LIB
test_cpp_LDADD = gc_cpp.o $(test_ldadd) $(CXXLIBS)
else
test_cpp_LDADD = libgccpp.la $(test_ldadd) $(CXXLIBS)
endif
endif

if ENABLE_DISCLAIM
TESTS += disclaim_test
check_PROGRAMS += disclaim_test
disclaim_test_SOURCES = tests/disclaim_test.c
disclaim_test_LDADD = $(test_ldadd)
if THREADS
disclaim_test_LDADD += $(THREADDLLIBS)
endif

TESTS += disclaim_bench
check_PROGRAMS += disclaim_bench
disclaim_bench_SOURCES = tests/disclaim_bench.c
disclaim_bench_LDADD = $(test_ldadd)
endif
