default: diag

TEST = param
TODELETE = $(TEST).export $(TEST).comm $(TEST).distr $(TEST).pre.include $(TEST).resu \
           pyobj cmdline pytest poursuite test_param.py \
           poursuite.export poursuite.comm poursuite.resu

include ../Makefile.inc

$(TEST).comm:
	@echo 'DEBUT()'   > $(TEST).tmp
	@echo 'P1 = 12.' >> $(TEST).tmp
	@echo 'print "Parameter P1 = %s" % P1' >> $(TEST).tmp
	@echo 'FIN()'    >> $(TEST).tmp
	@mv -f $(TEST).tmp $@

poursuite.comm:
	@echo 'POURSUITE()'   > $(TEST).tmp
	@echo 'FIN()'    >> $(TEST).tmp
	@mv -f $(TEST).tmp $@

$(TEST).distr:
	@echo 'VALE=('                    > $(TEST).tmp
	@echo '   _F(P1=1., P2=0.3),'    >> $(TEST).tmp
	@echo '   _F(P1=22., P2=0.4),'   >> $(TEST).tmp
	@echo '   _F(P1=333., P2=0.4),)' >> $(TEST).tmp
	@echo 'UNITE_PRE_CALCUL = 38'    >> $(TEST).tmp
	@mv -f $(TEST).tmp $@

$(TEST).pre.include:
	@echo 'print "Fichier inlus par INCLUDE après DEBUT."' >> $(TEST).tmp
	@mv -f $(TEST).tmp $@

cmdline: $(TEST).export $(TEST).comm $(TEST).distr $(TEST).pre.include
	$(as_run) $< > output.1.$@ 2> error.1.$@
	@grep EXIT_CODE output.1.$@ > $@

poursuite: poursuite.export poursuite.comm $(TEST).distr cmdline
	$(as_run) $< > output.3.$@ 2> error.3.$@
	@grep EXIT_CODE output.3.$@ > $@

pyobj: test_param.py
	$(PYTHONEXECUTABLE) test_param.py > output.2.$@ 2> error.2.$@
	@grep EXIT_CODE output.2.$@ > $@

unittest: cmdline pyobj poursuite
	@echo "EXIT_CODE=0" > exit_code.tmp
	@if  [ `grep -c EXIT_CODE=0 cmdline`  -ne 1 ] || \
	     [ `grep -c EXIT_CODE=0 poursuite` -ne 1 ] || \
	     [ `grep -c EXIT_CODE=0 pyobj` -ne 1 ]; then \
	   echo "EXIT_CODE=104" > exit_code.tmp; \
	fi
	@if  [ `egrep -c '^calc_.*<A>_COPY_REPE' output.1.cmdline`  -ne 6 ] || \
	     [ `egrep -c '^calc_.*<A>_COPY_REPE' output.2.pyobj` -ne 2 ]; then \
	   echo "EXIT_CODE=108" > exit_code.tmp; \
	fi
	@mv -f exit_code.tmp $@

