# Copyright (C) 2010, 2011  Red Hat, Inc.
#
# This file is part of ABRT.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

CFLAGS=-g

TESTS=\
 testDivideByZero\
 testReadNull\
 testStackRecursion\
 testReadRandom\
 testSignalAbort\
 testSignalIll\
 testWriteRandom\
 testExecuteInvalid\
 testStackBufferOverflow\
 testFloatingPointException\

all: $(TESTS)

clean:
	rm -f $(TESTS)

testlive: all
	for t in $(TESTS); do \
	    echo "====="; \
	    echo "Test: $$t"; \
	    gdb --batch \
		-ex 'python execfile("../../src/plugins/abrt-gdb-exploitable")' \
		-ex 'run' \
		-ex 'disas $$pc-16,$$pc+16' \
		-ex 'abrt-exploitable' \
		-ex 'cont' \
		-ex 'quit' \
		./$$t; \
	done 2>&1 | tee testlive.log

testcore: all
	rm ./core* 2>/dev/null; \
	ulimit -c unlimited; \
	for t in $(TESTS); do \
	    echo "====="; \
	    echo "Test: $$t"; \
	    ./$$t && { echo "No crash???"; continue; }; \
	    mv core* core || { echo "No corefile???"; continue; }; \
	    gdb --batch \
		-ex 'python execfile("../../src/plugins/abrt-gdb-exploitable")' \
		-ex 'core ./core' \
		-ex 'disas $$pc-16,$$pc+16' \
		-ex 'abrt-exploitable' \
		-ex 'quit' \
		; \
	    rm core; \
	done 2>&1 | tee testcore.log
