Makefile 2.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
.SILENT:

include TestList.mk

all: tests

setup:
	if [ ! -e po-hi-ada ]; then \
		echo "Checkout PolyORB-HI-Ada examples" ;\
		svn co http://eve.enst.fr/svn/polyorb-hi/trunk/examples po-hi-ada >/dev/null;\
	fi ;\
	if [ ! -e po-hi-c ]; then \
		echo "Checkout PolyORB-HI-C examples" ;\
		svn co http://eve.enst.fr/svn/polyorb_projects/design/po-hi-framework-c/examples po-hi-c >/dev/null;\
	fi

search: setup
	for v in $(SUBDIRS); do \
		if [ -f $$v/MANIFEST ]; then \
			grep Keywords: $$v/MANIFEST|grep $$key >/dev/null;\
			if [ $$? -eq 0 ]; then \
				echo $$v ;\
			fi \
		fi \
	done

tests: setup
	for v in $(SUBDIRS); do \
		$(MAKE) test name=$$v || exit 1;\
	done 

test: setup
	if [ -f $$name/MANIFEST ]; then \
		mypwd=`pwd`;\
		i=0 ;\
		nfiles=`ls -l $$name|wc -l` ;\
		while [ $$i -lt $$nfiles ]; do \
			mycmd=`grep Cmd$$i: $$name/MANIFEST|awk -F: '{print $$2}'` ;\
			if [ ! -z "$$mycmd" ]; then \
				tmp=`grep ^Output$$i: $$name/MANIFEST`;\
				if [ $$? -eq 0 ]; then \
					hasoutput=1 ;\
					myoutput=`echo $$tmp|awk -F: '{print $$2}'|sed -e 's/ //g'` ;\
					svn propget REV $$name/$$myoutput >/dev/null 2>&1 ;\
					if [ $$? -eq 0 ]; then \
						svn export $$name/$$myoutput $$name/$${myoutput}-export >/dev/null 2>&1 ;\
						myoutput=$${myoutput}-export ;\
					fi \
				else \
					hasoutput=0 ;\
				fi ;\
				tmp=`grep DiffSource$$i: $$name/MANIFEST`;\
				if [ $$? -eq 0 ]; then \
					hasdiffsource=1 ;\
					mydiffsource=`echo $$tmp|awk -F: '{print $$2}'` ;\
				else \
					hasdiffsource=0 ;\
				fi ;\
				grep "Success$$i: yes" $$name/MANIFEST >/dev/null 2>&1;\
				if [ $$? -eq 0 ]; then \
					mysuccess=1 ;\
				else \
					mysuccess=0 ;\
				fi ;\
				mycmd="$$mycmd" ;\
				cd $$name ; $$( exec $$mycmd >tmp.out 2>&1) ;\
				if [ $$? -eq 0 ]; then \
					if [ $$mysuccess -eq 0 ]; then \
						echo "FAILED TEST: $$name, command $$mycmd" && exit 1;\
					fi \
				else \
					if [ $$mysuccess -eq 1 ]; then \
						echo "FAILED TEST: $$name, command $$mycmd" && exit 1;\
					fi \
				fi ;\
				if [ $$hasoutput -eq 1 ]; then \
					if [ $$hasdiffsource -eq 1 ]; then \
						mytrace=$$mydiffsource ;\
					else \
						mytrace=tmp.out ;\
					fi ;\
					diff -urN $$myoutput $$mytrace 2>/dev/null 1>&2;\
					if [ $$? -ne 0 ]; then \
						echo "DIFF FAILED: $$name, command $$mycmd" && exit 1;\
					fi \
				fi ;\
				rm -f tmp.out ;\
				cd $$mypwd ;\
			fi ;\
			i=`expr $$i + 1`;\
		done \
	else \
		echo "$$name: This test does not exist" && exit 1;\
	fi

show: setup
	if [ -f $$name/MANIFEST ]; then \
		mydesc=`grep Description: $$name/MANIFEST |awk -F: '{print $$2}'` ;\
		mykeywords=`grep Keywords: $$name/MANIFEST|awk -F: '{print $$2}'` ;\
		echo "Test name: $$name" ;\
		echo "Description: $$mydesc" ;\
		echo "Keywords: $$mykeywords" ;\
	else \
		echo "$$name: This test does not exist" && exit 1;\
	fi